import { collectLikePage } from '../../api/index' Page({ /** * 页面的初始数据 */ data: { activeTabs: 'product_intro', dataList: [], total: 0, pageNum: 1, pageSize: 10, }, onLoad(options) { }, onPullDownRefresh: function () { console.log('下拉刷新') this.setData({ dataList: [], pageNum: 1, total: 0 }) wx.stopPullDownRefresh() this.getList() }, onReachBottom() { console.log('触底事件') const { total, dataList, pageNum } = this.data if (total > dataList.length) { this.setData({ pageNum: pageNum + 1 }) this.getList() } else { wx.showToast({ title: '暂无更多数据', icon: 'none' }) } }, tabsChange(e) { const activeTabs = e.currentTarget.dataset.val this.setData({ activeTabs, dataList: [], total: 0, pageNum: 1 }) this.getList() }, handleDetail(e) { const id = e.currentTarget.dataset.id const { activeTabs } = this.data let url = '' if (activeTabs == 'product_intro') { url = '/pages/detailDis/product' } else if (activeTabs == 'whole_case') { url = '/pages/detailDis/case' } else { url = '/pages/detailDis/realpic' } wx.navigateTo({ url: `${url}?id=${id}`, }) }, getList() { const { pageSize, pageNum, activeTabs } = this.data collectLikePage({ businessCategory: 'collect', businessType: activeTabs, pageSize, pageNum }).then(res => { if (res.data) { // res.data.pageNum = res.data.pageNum <=0?1: res.data.pageNum // if(pageNum == res.data.pageNum){ // if(pageNum == 1){ // this.setData({dataList:[],total:0}) // } this.setData({ dataList: [...this.data.dataList, ...res.data.records || []], total: res.data.total }) // } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.setData({ pageNum: 1 }) this.getList() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ /** * 用户点击右上角分享 */ onShareAppMessage() { } })