// packageA/member/order/cpsCoupon/cpsCoupon.js const app = getApp(); Page({ data: { isCoupon: true, page: 1, finished: false, orderList: [], }, onShow: function () { this.getData(); }, getData () { if (this.data.finished) return; let baseUrl = app.getNetAddresss("plugin.aggregation-cps.api.equity.order-list"); app._getNetWork({ url: baseUrl, data: { page: this.data.page }, success: (respone) => { if (respone.data.result !== 1) { wx.showToast({ title: respone.data.msg, }); return false; } let res = respone.data.data; let finished = false; let orderList = []; if (this.data.page >= res.last_page || (!res.data) || res.data.length < res.per_page) { finished = true; } if (this.data.page > 1) { orderList = this.data.orderList.concat(res.data); } else { orderList = res.data; } this.setData({ finished, orderList, page: ++this.data.page }); } }); }, initGetData () { this.setData({ page: 1, finished: false, }); }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.initGetData(); this.getData(); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.getData(); }, });