// packageD/directSeeding/liveDividend/liveDividend.js let app = getApp(); Page({ /** * 页面的初始数据 */ data: { language: "", current: 0, status: "", isLoadMore: true, page: 1, total_page: 0, dividendData: "", dividenList: [], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getDividend(""); }, getDividend(type) { let that = this; let urlStr = app.getNetAddresss("plugin.room.frontend.anchor.dividend"); app._postNetWork({ url: urlStr, showToastIn: false, data: { status: type, page: 1, }, success: function (resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ dividendData: res.data.data, dividenList: res.data.data.bonus, total_page: res.data.last_page, }); } else { wx.showToast({ icon: "none", title: res.msg, duration: 1500, }); } }, fail: function (res) { console.log(res.msg); }, }); }, getMoreData() { let that = this; let urlStr = app.getNetAddresss("plugin.room.frontend.anchor.dividend"); if (this.data.page == this.data.total_page) { return; } if (this.data.page >= this.data.total_page) { this.setData({ isLoadMore: false, }); return; } else { this.setData({ page: this.data.page + 1, }); app._getNetWork({ url: urlStr, data: { status: this.data.status, page: this.data.page, }, success: function (resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ cupconList: that.data.dividenList.concat(res.data.data.bonus), }); } else { that.setData({ page: that.data.page - 1, isLoadMore: false, }); } }, fail: function (res) { console.log(res); }, }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { let language = wx.getStorageSync("langIndex"); this.setData({ language: language.en }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, swichTabTItem(e) { let index = e.detail.index; this.setData({ current: index, }); if (index == 0) { this.setData({ status: "", }); } else if (index == 1) { this.setData({ status: 0, }); } else if (index == 2) { this.setData({ status: 1, }); } else if (index == 3) { this.setData({ status: -1, }); } this.setData({ isLoadMore: true, page: 1, total_page: 0, }); this.getDividend(this.data.status); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.isLoadMore) { this.getMoreData(); } else { console.log("没有更多数据"); } }, });