// pages/billboards/park/index.js import { BillboardModel } from '../../../../models/billboard.js' let billboard = new BillboardModel() Page({ /** * 页面的初始数据 */ data: { loading: true, list: [], curCode: '', curPage:1, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { const {code} = options console.log(code) this.setData({ curCode: code }) this.fetchList() }, clickCardItem (e) { console.log(e.detail) const { id } = e.detail wx.navigateTo({ url: `/pages/article/index?id=${id}`, }) }, fetchList () { const {curCode} = this.data const page = this.data.curPage billboard.fetchBailList(curCode, page, res => { this.setData({ loading:false, }) console.log(res) const list = res.list if (page == 1) { this.setData({ list: list }) } else { if (list.length > 0) { const list = [...this.data.list, ...list] this.setData({ list: list }) } else { const page = this.data.currPage - 1 this.setData({ currPage: page }) wx.showToast({ title: '已加载全部', icon: 'none' }) } } }) wx.stopPullDownRefresh() }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.setData({ curPage: 1, }) this.fetchList() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { const page = this.data.curPage + 1 this.setData({ curPage: page }) this.fetchList() }, })