const {getLotteries} = require('../../utils/API.js') let cur_page = 1 Page({ data: { has_more: true, loading: false, lotteries: [], // 抽奖列表 recommend: {} // 推荐的抽奖 }, loadMore(){ if(this.data.has_more) { cur_page++ this.setData({loading: true}) getLotteries(cur_page) .then(data => { data.data.rows.length === 0 && this.setData({has_more: false}) this.setData({ lotteries: this.data.lotteries.concat(data.data.rows), loading: false }) }) } }, onLoad: function () { wx.showLoading({title: '加载中', mask: true}) getLotteries(cur_page).then(data => { this.setData({ lotteries: data.data.rows, recommend: data.data.recommend_lottery }) wx.hideLoading() }) }, onPullDownRefresh(){ cur_page = 1 getLotteries(cur_page).then(data => { this.setData({ lotteries: data.data.rows, recommend: data.data.recommend_lottery }) wx.stopPullDownRefresh() }) }, onReachBottom(){ this.loadMore() }, onShareAppMessage() { return { path: '/pages/index/index' } } })