// packageH/stock/agencyDividend/agencyDividend.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { active: 0, accumulate_reward: "--", member: {}, recordsList: [], //more isLoadMore: true, page: 1, total_page: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getData(); }, getData() { let urlStr = app.getNetAddresss("plugin.salesman-dividend.frontend.reward-log.get-reward-list"); app._postNetWork({ url: urlStr, success: (resdata) => { let res = resdata.data; if (res.result == 1) { this.setData({ member: res.data.memberInfo, accumulate_reward: res.data.accumulate_reward, total_page: res.data.list.last_page, recordsList: res.data.list.data, isLoadMore: true }); } else { wx.showToast({ icon: "none", title: res.msg, duration: 1000, }); } }, fail: (res) => { console.log(res); }, }); }, //获取更多数据 getMoreData() { let urlStr = app.getNetAddresss("plugin.salesman-dividend.frontend.reward-log.get-reward-list"); // 防止多次请求分页数据 this.data.isLoadMore = false; if (this.data.page >= this.data.total_page) { return; } else { this.data.page++; let json = { page: this.data.page }; app._getNetWork({ url: urlStr, data: json, success: (resdata) => { var res = resdata.data; if (res.result == 1) { this.data.isLoadMore = true; var myData = res.data.list.data; this.setData({ recordsList: this.data.recordsList.concat(myData) }); } else { this.data.isLoadMore = false; this.data.page--; } } }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.isLoadMore) { this.getMoreData(); } else { console.log("没有更多数据"); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } });