mui.init(); mui('.mui-scroll-wrapper').scroll(); var pageNumber = 1; var pageSize=10; var sort=""; var category=""; var map; var pointA; /** *初始化、添加监听 */ mui.ready(function(){ wx.ready(function(){ var l = layer.open({type: 3,shadeClose:false,content: '定位中...'}); wx.getLocation({ type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' success: function (res) { $.ajax({ url:'http://api.map.baidu.com/geoconv/v1/?coords='+res.longitude+','+res.latitude+'&from=1&to=5&ak=3Q4laSROftZI4chFMPVUno90', dataType:'jsonp', processData: false, type:'get', success:function(json){ layer.close(l); if (json.status=='0'){ var latitude=json.result[0].y; var longitude=json.result[0].x; map = new BMap.Map("allmap"); pointA = new BMap.Point(longitude,latitude); } getMerchant(); }, error:function(XMLHttpRequest, textStatus, errorThrown) { layer.close(l); getMerchant(); layer.msg('坐标转换失败'); } }); }, cancel:function(json){ layer.close(l); getMerchant(); } }); }); getCategory(); $('.mui-bar-tab').on('tap', 'a', function(e) { location.href=$(this).attr("href"); }); $("#tab1").on("tap",function(){ if($(this).hasClass("active")){ $(this).removeClass("active"); }else{ $(this).addClass("active"); $(this).siblings().removeClass("active"); } mui('#topPopover').popover('toggle'); }); $("#tab2").on("tap",function(){ if($(this).hasClass("active")){ $(this).removeClass("active"); }else{ $(this).addClass("active"); $(this).siblings().removeClass("active"); } mui('#middlePopover').popover('toggle'); }); $("#tab3").on("tap",function(){ if($(this).hasClass("active")){ $(this).removeClass("active"); }else{ $(this).addClass("active"); $(this).siblings().removeClass("active"); } mui('#bottomPopover').popover('toggle'); }); $("body").on("tap",".mui-backdrop",function(e){ e.stopPropagation(); $(".mui-table-cell").removeClass("active"); }); $("#topPopover").on("tap","li",function(){ if($(this).attr("data")=="10"&&!pointA){ layer.open({content:'定位失败,无法按距离排序',time:3}); return; } $("#tab1 span:eq(0)").html($(this).find("a").html()); mui('#topPopover').popover('toggle'); $('#tab1').removeClass("active"); sort=$(this).attr("data"); pageNumber=1; $("#merchantList").empty(); $(".dropload-down").remove(); getMerchant(); }); $("#middlePopover").on("tap","li",function(){ $("#tab2 span:eq(0)").html($(this).find("a").html()); mui('#middlePopover').popover('toggle'); $('#tab2').removeClass("active"); category=$(this).attr("data"); pageNumber=1; $("#merchantList").empty(); $(".dropload-down").remove(); getMerchant(); }); $("#bottomPopover").on("tap","li",function(){ $("#tab3 span:eq(0)").html($(this).find("a").html()); mui('#bottomPopover').popover('toggle'); $('#tab3').removeClass("active"); }); $("#merchantList").on("tap","ul",function(){ location.href=base+'/mobile/merchantDetail.jsp?id='+$(this).attr("data-id"); }); }); function getCategory(){ mobile.ajaxPost(base+'/productCategory/getList',{},function(json){ $.each(json.data,function(id,item){ $("#middlePopover ul").append('
'); html.push(''+item.visit_num+'人关注