mui.init(); mui('.mui-scroll-wrapper').scroll(); var type=mobile.getUrlVars("type"); if (!type){ type = ""; } var pageNumber = 1; var pageSize=10; var droploader; /** *初始化、添加监听 */ mui.ready(function(){ getCategory(); getProduct(type); $('.mui-bar-tab').on('tap', 'a', function(e) { location.href=$(this).attr("href"); }); $(".mui-segmented-control").on("tap",".mui-control-item",function(e){ pageNumber=1; $(".section-list").empty(); $(".dropload-down").remove(); getProduct($(this).attr("data-id")); }); //跳转 $(".product").on('tap','li',function(){ location.href=base+'/mobile/productDetail.jsp?id='+$(this).attr('data-id'); }); //推广 $(".tuiguang").on('tap',function(){ if(user.is_share=='1'){ $("#share").show(); }else{ location.href=base+'/mobile/userInfo.jsp?flag=1'; } }); //分享 $(".share-bg").on('tap',function(){ $("#share").hide(); }); //分享 $(".share-img").on('tap',function(){ $("#share").hide(); }); }); function getCategory() { mobile.ajaxPost(base+'/productCategory/getList',{"navShow":"1"},function(json){ if(json.data&&json.data.length>0){ if (type){ $(".mui-segmented-control .mui-scroll").append('全部'); }else{ $(".mui-segmented-control .mui-scroll").append('全部'); } $.each(json.data,function (id,item) { if (item.id==type){ $(".mui-segmented-control .mui-scroll").append(''+item.cat_name+''); }else{ $(".mui-segmented-control .mui-scroll").append(''+item.cat_name+''); } }); } }); } /** *获取导航 */ function getProduct(type){ if (droploader){ droploader.lock(); droploader.noData(); droploader.resetload(); } if(!type){ type=""; } droploader = $('.product-content').dropload({ scrollArea : window, loadDownFn : function(me){ mobile.ajaxPost(base+'/product/getList',{ type: type, pageSize: pageSize, pageNumber: pageNumber },function(json){ if(json.list&&json.list.length>0){ if(pageNumber==json.totalPage){ me.lock(); me.noData(); }else{ pageNumber++; } var html=[]; jQuery.each(json.list,function(id,item){ html.push(''); html.push('
'); html.push(''); if (item.time_status=='1'){ html.push('
'); }else if (item.time_status=='2'||item.time_status=='3'){ html.push('
'); } html.push('
'); html.push('
'); html.push('
'+item.product_name+'
'); html.push('
'); html.push('
¥'+item.product_price+''+item.product_old_price+'元
') html.push('
'+item.visit_num+'人关注
') html.push('
'); html.push('
'); }); $(".section-list").append(html.join("")); droploader.resetload(); $("img.product-lazy").lazyload({ threshold : 200, effect: "fadeIn", placeholder: base+'/static/mobile/image/100.gif', skip_invisible : false }); }else{ droploader.lock(); droploader.noData(); droploader.resetload(); } }); } }); } function checkTime(i){ //将0-9的数字前面加上0,例1变为01 if(i<10) { i = "0" + i; } return i; }