// subpages/understandJs/pages/sclerotia/sclerotia.js const api = require('../../../../utils/understandJs') Page({ /** * 页面的初始数据 */ data: { pageIndex: 1, pageSize: 10, sclerotialist: [], nodata: false, loadMoreType: 'none', loadMoreVisible: false, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getSclerotiaList() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.setData({ loadMoreVisible: true }) if (this.data.loadMoreType === 'loading') { this.setData({ pageIndex: this.data.pageIndex + 1, pageSize: this.data.pageSize, }) this.getSclerotiaList() } }, getSclerotiaList: function() { let that = this let para = { pageIndex: this.data.pageIndex, pageSize: this.data.pageSize, noticeCategory: 'notice_yh' } api.noticelist(para).then(function(res) { that.setData({ sclerotialist: that.data.sclerotialist.concat(res.data), loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none', }) if (that.data.sclerotialist.length == 0) { that.setData({ nodata: true, loadMoreType: 'none', loadMoreVisible: false }) } }).catch(() => { that.setData({ nodata: true, loadMoreType: 'none', loadMoreVisible: false, sclerotialist: [] }) }) }, toDetail (e) { wx.navigateTo({ url: '../noticeDetail/noticeDetail?modulecode=notice_yh&id=' + e.currentTarget.dataset.id }) } })