// packageE/TeamPerformanceAward/TeamPerformanceAward.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { member: {}, recordsList: [], isLoadMore: true, page: 1, total_page: 0, progressNum: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getMember(); this.getData(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.isLoadMore) { this._getMoreData(); } else { console.log("没有更多数据"); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, getMember() { let urlStr = app.getNetAddresss( "plugin.performance.frontend.bonus.getMemberInfo" ); app._getNetWork({ url: urlStr, success: (resdata) => { var res = resdata.data; if (res.result == 1) { let progressNum = Number(res.data.rest)>0?parseInt((1 - Number(res.data.rest) / Number(res.data.rest_all)) * 100):100; this.setData({ member: res.data, progressNum: progressNum }); wx.setNavigationBarTitle({ title: res.data.plugin_name, }); } }, }); }, getData() { let urlStr = app.getNetAddresss( "plugin.performance.frontend.bonus.getList" ); app._postNetWork({ url: urlStr, success: (resdata) => { var res = resdata.data; if (res.result == 1) { this.data.isLoadMore = true; this.data.total_page = res.data.list.last_page; if (!this.data.total_page) { this.data.total_page = 0; } this.setData({ recordsList: res.data.list.data, }); } else { wx.showToast({ title: res.msg, }); } }, }); }, //获取更多数据 _getMoreData() { this.data.isLoadMore = false; // 防止多次请求分页数据 if (this.data.page >= this.data.total_page) { return; } else { this.data.page = this.data.page + 1; let urlStr = app.getNetAddresss( "plugin.performance.frontend.bonus.getList" ); app._getNetWork({ url: urlStr, data: { page: this.data.page }, success: (resdata) => { var res = resdata.data; this.data.isLoadMore = true; if (res.result == 1) { let myData = res.data.list.data; this.setData({ recordsList: this.data.recordsList.concat(myData), }); } else { this.data.page = this.data.page - 1; this.data.isLoadMore = false; wx.showToast({ title: res.msg, }); } }, }); } }, });