// packageE/ranking_2/index/index.js import DPagination from "../DPagination"; const IncomePagination = new DPagination("incomeList"); const App = getApp(); Page({ /** * 页面的初始数据 */ data: { incomeList: {}, earningsThisMonth: 0, //* 本月收益 remainingBonus: 0, //* 待分配奖金 personalRanking: "暂未上榜", //* 个人排名 platformReward: 0, //* 平台收益 customSettings: { rankingName: "排行榜", expectedEarningText: 0, //*本月预计收益自定义名称 }, memberInfo: null, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { IncomePagination.bind(this); IncomePagination.clean(); this.loadIncomeData(); }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { IncomePagination.clean(); this.loadIncomeData(); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.loadIncomeData(); }, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, onShareTimeline() {}, loadIncomeData() { if (IncomePagination.loading || IncomePagination.finished) { return; } wx.showLoading({ title: "加载中", mask: true, }); IncomePagination.loading = true; let url = App.getNetAddresss( "plugin.commission-ranking.api.get-commission-ranking.index" ); App._getNetWork({ url, data: { page: IncomePagination.loadPage, }, success: ({ data: { result, msg, data: response } }) => { if (result == 0) { wx.showToast({ title: msg, icon: "none", }); return; } if (response.data.length < IncomePagination.limit) { IncomePagination.finished = true; } if (IncomePagination.limit != response.per_page) { IncomePagination.limit = response.per_page; } IncomePagination.push(response.data); if (response.plugin_name != this.data.customSettings.pageTitle) { wx.setNavigationBarTitle({ title: response.plugin_name, }); } const setData = { earningsThisMonth: response.my_profit, remainingBonus: response.allocated, customSettings: { rankingName: response.profit_name || "排行榜", expectedEarningText: response.estimate_profit_name || "本月预计收益", //*本月预计收益自定义名称 pageTitle: response.plugin_name || "排行榜", //* 插件自定义名称 }, }; if (response.personal_ranking) { response.personal_ranking = parseInt(response.personal_ranking); if (response.personal_ranking) { setData["personalRanking"] = "第" + response.personal_ranking + "名"; } } if(this.data.memberInfo===null){ setData['memberInfo']=response.member; } this.setData(setData); IncomePagination.loading = false; wx.hideLoading(); wx.stopPullDownRefresh(); }, }); }, });