mui.init({ pullRefresh: { container: '#pullrefresh_chanpin_list', down: {}, up: { contentrefresh: '正在加载...', callback: pullupRefresh } } }); var pageNumber = 0, pagesize = 10, proType = "1"; function pullupRefresh() { pageNumber += 1; $.ajax(base_path + '/product/productIndex?dates=' + new Date().getTime(), { data: { "pageSize": pagesize, "pageNO": pageNumber, "productType": proType }, dataType: 'json', type: 'post', timeout: 15000, xhrFields: { withCredentials: true }, crossDomain: true, success: function(dt) { if (dt.isRedirect) { location.href = dt.redirectURL; } else { if(dt.status) { var chanpin_data = []; chanpin_data = dt.data.productList; mui('#pullrefresh_chanpin_list').pullRefresh().endPullupToRefresh(chanpin_data.length < pagesize); var table = document.body.querySelector('.my-tab-view-pull'); mui(chanpin_data).each(function(index) { var pro_color = this.productColor; var li = document.createElement('li'); var yuanjia = '原价:¥' + accDiv(this.productPrice, 100) + ''; if(marquee != '' && this.productDiscount == '328000') { yuanjia = '购买即赠3年滤芯' } var img=''; img=this.colorImg; if($(".box-list-card .iconfont").hasClass("icon-list")) { li.className = 'mui-table-view-cell mui-media'; li.innerHTML = '
' + this.productName + '
' + this.productColorDes + '
' + marquee + '¥' + accDiv(this.productDiscount, 100) + '' + yuanjia + '
">'; } else { li.className = 'mui-table-view-cell mui-media mui-col-xs-6'; li.innerHTML = '
' + this.productName + '
' + this.productColorDes + '
' + marquee + '¥' + accDiv(this.productDiscount, 100) + '' + yuanjia + '
'; } table.appendChild(li) mui('#pullrefresh_chanpin_list').pullRefresh().disablePullupToRefresh(); }); if(chanpin_data.length==0){ mui('#pullrefresh_chanpin_list').pullRefresh().disablePullupToRefresh(); var li = document.createElement('li'); li.className = 'mui-table-view-cell mui-media mui-col-xs-12 mui-text-center'; li.innerHTML='
暂无产品信息,逛逛别的产品吧!
'; table.appendChild(li); } } else { mui('#pullrefresh_chanpin_list').pullRefresh().endPullupToRefresh(true) } } }, error: function(xhr, type, errorThrown) { console.log(xhr) } }) }; function search_pullrefresh(str) { if(str != null && str != '') { if(!checkParameter(str)) { mui.alert('您输入的格式有误,请重新输入!') } else { pageNumber = 0; $('.my-tab-view-pull').empty(); search_str = str; mui('#pullrefresh_chanpin_list').pullRefresh().refresh(true); mui('#pullrefresh_chanpin_list').pullRefresh().pullupLoading() } } else { pageNumber = 0; $('.my-tab-view-pull').empty(); search_str = str; mui('#pullrefresh_chanpin_list').pullRefresh().refresh(true); mui('#pullrefresh_chanpin_list').pullRefresh().pullupLoading() } }; //mui.os.ios ? listener_ipt() : keyup_fn(); // //function keyup_fn() { // $('body').on('keyup', '#chanpin-search', function(e) { // var currKey = 0, // e = e || event; // currKey = e.keyCode || e.which || e.charCode; // var keyName = String.fromCharCode(currKey); // if(currKey == "13") { // var str = $.trim($('#chanpin-search').val()); // search_pullrefresh(str) // } // }) //}; //document.getElementById('chanpin-search').addEventListener('input', function(e) { // var value = e.target.value //}); //function listener_ipt() { // document.getElementById('chanpin-search').onblur = function() { // var str = $.trim($('#chanpin-search').val()); // search_pullrefresh(str) // } //}; mui.ready(function() { proType = getParam("proType"); proType == null ? proType = "1" : proType; //springFestivalPop(); marquee_Show(); if(proType != 1) { $(".tab-with-chanpin-list .mui-control-item:first-child").removeClass('mui-active'); $(".tab-with-chanpin-list .mui-control-item:last-child").addClass('mui-active'); } mui('#pullrefresh_chanpin_list').pullRefresh().pullupLoading(); getCartNum(); document.querySelector('.loading-bg').style.display = 'none' }); function checkParameter(remark) { if(!/^[\u4e00-\u9fa5_a-zA-Z0-9-]+$/.test(remark)) { return false } return true }; $(document).on('tap', '.box-list-card', function() { var listcard = $(this).children().first(); if(listcard.hasClass("icon-list")) { listcard.removeClass("icon-list").addClass("icon-list-card"); $(".my-tab-view-pull").removeClass("mui-table-view-chevron").addClass("mui-grid-view"); $(".mui-media-object").removeClass("mui-pull-left wh-100"); $(".my-tab-view-pull .mui-table-view-cell").addClass("mui-col-xs-6") } else { listcard.removeClass("icon-list-card").addClass("icon-list"); $(".my-tab-view-pull").removeClass("mui-grid-view").addClass("mui-table-view-chevron"); $(".mui-media-object").addClass("mui-pull-left wh-100"); $(".my-tab-view-pull .mui-table-view-cell").removeClass("mui-col-xs-6") } }); mui.each(document.querySelectorAll('.tab-with-chanpin-list .mui-control-item'), function(index, el) { el.addEventListener('tap', function() { pageNumber = 0; switch(index) { case 0: proType = 1; break; case 1: proType = 16; break; default: proType = 1; break } var href=location.href; if(href.indexOf("proType")>0){ history.pushState("", "产品列表",'//'+location.host+ html_path +'/chanpin_list.html?proType='+proType); } $('.my-tab-view-pull').empty(); mui('#pullrefresh_chanpin_list').pullRefresh().refresh(true); mui('#pullrefresh_chanpin_list').pullRefresh().pullupLoading() }, false) });