// subpages/liverecord/liverecord.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { planId: '', liveUrl: app.liveUrl, liveImgUrl: app.liveImgUrl, liveList: [], page: 1, rows: 5, hasMore: true, isLoading: true }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ planId: options.id }) this.getList(); }, getList() { var _self = this; app.restAjax.get(app.restAjax.path(_self.data.liveUrl + '/app/liverecord/listpageliverecordrelease/' + _self.data.planId, []), { page: _self.data.page, rows: _self.data.rows }, null, function (code, data) { _self.data.liveList = _self.data.liveList.concat(data.rows) _self.setData({ liveList: _self.data.liveList, isLoading: false, hasMore: _self.data.liveList.length < data.total }) wx.stopPullDownRefresh() }, function (code, err) { app.dialog.msg('网络错误') wx.stopPullDownRefresh() _self.setData({ isLoading: false }) }, ) }, onReachBottom() { var _self = this; if (_self.data.hasMore) { _self.setData({ page: _self.data.page + 1 }) _self.getList() } else { app.dialog.msg('暂无更多数据了') } }, onPullDownRefresh() { this.setData({ liveList: [], page: 1, hasMore: true }) this.getList() } })