const util = require('../../utils/util.js'); const app = getApp(); Page({ data: { pageIndex: 1, pageSize:10, activeData: [],//活动列表 bottom: false, vid:'' }, onLoad: function (options) { this.setData({ vid: options.vid }); this.getHotActivity(0); }, getHotActivity(status) { let that = this; util.ajax({ func: "v2/voucher/articles", data: { "vid": that.data.vid, "pageSize": that.data.pageSize, "pageIndex": that.data.pageIndex} }, function (res) { if (res.code == 0) { let datas = res.data.list, activeData = that.data.activeData, bottom = false; if (datas.length < 10 && that.data.pageIndex>1) bottom = true; if (that.data.pageIndex == 1) { activeData = datas; } else { activeData = [...activeData, ...datas]; } that.setData({ activeData, bottom }) } else { util.showTips(res.reason); } if (status == '0') {//onshow } else if (status == '1') {//onReachBottom wx.hideNavigationBarLoading(); } else if (status == '2') {//onPullDownRefresh wx.stopPullDownRefresh(); wx.hideNavigationBarLoading(); } }); }, onReachBottom: function () { if (this.data.bottom) return false this.setData({ pageIndex: this.data.pageIndex+1}) this.getHotActivity(1); }, onPullDownRefresh: function () { let that = this; if (!util.isObjEmpty(app.globalData.city)) { wx.showNavigationBarLoading(); that.setData({ pageIndex: 1}); setTimeout(function () { that.getHotActivity(2); }, 1000); } else { wx.stopPullDownRefresh(); } } })