$(function(){ $(".find_nav_list li").on('click', function(){ nav_w=$(this).width(); $(this).addClass("find_nav_cur").siblings().removeClass("find_nav_cur"); $(this).find("a").addClass("on"); $(this).siblings().find("a").removeClass("on"); var fn_w = ($(".find_nav").width() - nav_w) / 2; var fnl_l; var fnl_x = parseInt($(this).position().left); if (fnl_x <= fn_w) { fnl_l = 0; } else if (fn_w - fnl_x <= flb_w - fl_w) { fnl_l = flb_w - fl_w; } else { fnl_l = fn_w - fnl_x; } $(".find_nav_list").animate({ "left" : fnl_l }, 300); sessionStorage.left=fnl_l; var c_nav=$(this).find("a").text(); }); var Yleft = $('.find_nav_list ul li a.on').position().left; var Yleftlast = $('.find_nav_list ul li').last().position().left; var Ylefteq2 = $('.find_nav_list ul li').eq(-2).position().left; var Ylefteq3 = $('.find_nav_list ul li').eq(-3).position().left; if (Yleft < 150) { $(".find_nav_list").css("left","0px"); }else if(Yleft>Yleftlast){ $(".find_nav_list").css("left",'-'+(Yleft-$(window).width()+95)+"px"); }else if(Yleft>Ylefteq2){ $(".find_nav_list").css("left",'-'+(Yleft-($(window).width()/2)-15)+"px"); }else if(Yleft>Ylefteq3){ $(".find_nav_list").css("left",'-'+(Yleft-($(window).width()/2)+90)+"px"); }else{ $(".find_nav_list").css("left",'-'+(Yleft-90)+"px"); }; var fl_w=$(".find_nav_list").width(); var flb_w=$(".find_nav_left").width(); $(".find_nav_list").on('touchstart', function (e) { var touch1 = e.originalEvent.targetTouches[0]; x1 = touch1.pageX; y1 = touch1.pageY; ty_left = parseInt($(this).css("left")); }); $(".find_nav_list").on('touchmove', function (e) { var touch2 = e.originalEvent.targetTouches[0]; var x2 = touch2.pageX; var y2 = touch2.pageY; if(ty_left + x2 - x1>=0){ $(this).css("left", 0); }else if(ty_left + x2 - x1<=flb_w-fl_w){ $(this).css("left", flb_w-fl_w); }else{ $(this).css("left", ty_left + x2 - x1+20); // console.log(ty_left + x2 - x1+20) } if(Math.abs(y2-y1)>0){ e.preventDefault(); } }); // 轮播图 var mySwiper1 = new Swiper('.newslist_slide_main',{ autoplay:5500, //自动切换 loop : true, //循环 pagination: '.swiper-pagination', // 如果需要分页器 }) var mySwiper2 = new Swiper('.newslist_type', { slidesPerView : 4, slidesPerGroup : 1, }) /*----------------定义页面全局变量-----------------------*/ // 页数 var page = 0; // 每页展示5个 var size = 10; //资讯ID var lid=0; //资讯区域ID var cityid=0; var url = window.location.href; var params = getUrlParams(url); //获取get请求的参数 if(!$.isEmptyObject(params)){ $.each(params,function(key,val){ switch (key){ case 'lid': lid = val; break; case 'cityid': cityid = val; break; } }) // urlParams = urlParams.substring(0,urlParams.length - 1); // searchParams = '&'+ urlParams; } // 选择各个模块 function ModuleWay(conditions){ var _html=""; $.each(conditions.data,function (key,val) { // if (val.thumb != null && val.thumb != "" && val.thumb.length == 1 && val.thumb_size == 1) { _html +='
'; _html +=''+val.subject+''; _html +=''+val.open_time+''; _html +='
'; _html +=''; _html +=''; _html +=''; _html +=''+val.subject+''; _html +=''+val.open_time+''; _html +='
'; _html +=''; _html +=''; _html +=''; _html +=''+val.subject+''; _html +=''+val.open_time+''; _html +='
'; _html +=''; for (k in val.thumb) { _html +=''; }; _html +='
'; _html +=''; _html +='