var tabindex = 0, pageNumber = 0, pagesize = 10; mui.init({ pullRefresh: { container: '#pullrefresh_yhq_list', down: {}, up: {contentrefresh: '正在加载...', callback: pullupRefresh} } }); function pullupRefresh() { pageNumber += 1; var btnArray = ['否', '是']; $.ajax(base_path + '/coupon/couponItemList', { data: { "pageSize": pagesize, "useStatus": tabindex, "pageNO": pageNumber }, 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 coupon_data = []; coupon_data = dt.data.itemList; mui('#pullrefresh_yhq_list').pullRefresh().endPullupToRefresh(coupon_data.length < pagesize); var table = document.body.querySelector('.my-yhq-list'); mui(coupon_data).each(function (index) { var li = document.createElement('li'); li.className = 'my-yhq-cell'; var ptrice; if (this.couponType == 1) { ptrice = accDiv(this.couponReduce, 100) + '元' } else { ptrice = "-" + (100 - this.couponReduce) + "%" } if (this.couponUseStatus == 1 && tabindex <= 1 && this.couponItemRemark == "normal") { li.innerHTML = '
' + this.couponName + '

有效期至' + this.couponUseEndDate + '

满' + accDiv(this.couponConsumeEnough, 100) + '元可使用
' + ptrice + '
立即使用

有效期至' + this.couponUseEndDate + '

满' + accDiv(this.couponConsumeEnough, 100) + '元可使用
' + ptrice + '
立即领取
' } table.appendChild(li) }) } else { mui.confirm(dt.message + '是否重新加载页面?', '爱贝源-提示', btnArray, function (e) { if (e.index == 1) { } }) } } }, error: function (xhr, type, errorThrown) { console.log(xhr) } }) };mui.ready(function () { mui('#pullrefresh_yhq_list').pullRefresh().pullupLoading(); getCartNum(); document.querySelector('.loading-bg').style.display = 'none' }); mui.each(document.querySelectorAll('.tab-yhq-list .mui-control-item'), function (index, el) { el.addEventListener('tap', function () { pageNumber = 0; switch (index) { case 0: tabindex = 0; break; case 1: tabindex = 1; break; case 2: tabindex = 2; break; default: tabindex = 3; break } $('.my-yhq-list').empty(); mui('#pullrefresh_yhq_list').pullRefresh().refresh(true); mui('#pullrefresh_yhq_list').pullRefresh().pullupLoading() }, false) });