// pages/find/find.js import api from '../../utils/api.js' const app = getApp() Page({ /** * 页面的初始数据 */ data: { params: { page: 1, offset: 10 }, Rplist: [], RpCount: 0, mpType: app.globalData.mpType }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { }, onShow: function() { let timer = setInterval(() => { if (app.globalData.PageCallback) { this.getRpGameList() clearInterval(timer) } }, 200) }, getPrize: function(e) { api.getGameIncome().then(res => { if (res.code === 200) { wx.showModal({ title: '试玩奖励', content: `恭喜获得${res.data.gain_integral}积分!`, showCancel: false, success: (e) => { this.data.Rplist.list[e.currentTarget.dataset.index].status = 3 } }) } }) }, getRpGameList(hdld) { api.getRpGameList(hdld ? { ...this.data.params, HideLoading: true} : this.data.params).then(res => { this.setData({ Rplist: this.data.params.page > 1 ? this.data.Rplist.concat(res.data.list) : res.data.list, RpCount: res.data.count }) }) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { if (this.data.Rplist.length >= this.data.RpCount) { return false } this.data.params.page++ this.setData({ params: this.data.params }) this.getRpGameList() }, // 页面相关事件处理函数--监听用户下拉动作 onPullDownRefresh: function () { this.setData({ params: { page: 1, offset: 10 } }) this.getRpGameList(true) wx.stopPullDownRefresh() }, openGame: function (e) { let id = e.currentTarget.dataset.id api.openGame({ game_id: id }).then(res => { this.getRpGameList(true) }, err => { console.log(err) }) }, showPop: function (e) { wx.previewImage({ urls: [e.currentTarget.dataset.entrance] }) } })