fix: 小商城的订单列表支持分页
This commit is contained in:
@@ -4,7 +4,10 @@ var api = require('../../../config/api.js');
|
||||
Page({
|
||||
data: {
|
||||
orderList: [],
|
||||
showType: 0
|
||||
showType: 0,
|
||||
page: 1,
|
||||
size: 10,
|
||||
totalPages: 1
|
||||
},
|
||||
onLoad: function(options) {
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
@@ -28,20 +31,42 @@ Page({
|
||||
|
||||
let that = this;
|
||||
util.request(api.OrderList, {
|
||||
showType: that.data.showType
|
||||
showType: that.data.showType,
|
||||
page: that.data.page,
|
||||
size: that.data.size
|
||||
}).then(function(res) {
|
||||
if (res.errno === 0) {
|
||||
that.setData({
|
||||
orderList: res.data.data
|
||||
orderList: that.data.orderList.concat(res.data.data),
|
||||
totalPages: res.data.totalPages
|
||||
});
|
||||
wx.hideLoading();
|
||||
}
|
||||
});
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.data.totalPages > this.data.page) {
|
||||
this.setData({
|
||||
page: this.data.page + 1
|
||||
});
|
||||
this.getOrderList();
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '没有更多订单了',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
},
|
||||
switchTab: function(event) {
|
||||
let showType = event.currentTarget.dataset.index;
|
||||
this.setData({
|
||||
showType: showType
|
||||
orderList: [],
|
||||
showType: showType,
|
||||
page: 1,
|
||||
size: 10,
|
||||
totalPages: 1
|
||||
});
|
||||
this.getOrderList();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user