import { getCataLogTagList, pageZSZXContentList, actionDo } from '../../api/index' Page({ /** * 页面的初始数据 */ data: { tagList: [], activeCate: '', dataList: [], total: 0, pageNum: 1, pageSize: 10, code: '', tagCodes: '' }, onLoad(options) { wx.setNavigationBarTitle({ title: options.name }) this.setData({ code: options.code}) this.getTabList() 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' }) } }, getList(){ const { code, tagCodes, pageSize, pageNum } = this.data pageZSZXContentList({ catalogCode: code, tagCodes: tagCodes ? [tagCodes] : [], pageSize, pageNum }).then(res => { this.setData({ total: res.data.total, dataList: [ ...this.data.dataList, ...res.data.records ] }) }) }, itemClick(e) { const item = e.currentTarget.dataset.item console.log('item', item); actionDo({actionType: 'view',id: item.id}) if(item.contentType == 'video'){ wx.previewMedia({ sources: [{ url: item.content, type: 'video' }] }) } if(item.contentType == 'link'){ wx.navigateTo({ url: '/pages/webView/index?link=' + item.content, }) } if(item.contentType == 'page'){ getApp().globalData.catalogCode=item.content wx.switchTab({ url: '/pages/discover/discover' }) } }, cateClick(e) { const { code } = e.target.dataset this.setData({ tagCodes: code, pageNum: 1, dataList: [] }) this.getList() }, getTabList() { getCataLogTagList({ catalogCode: this.data.code }).then(res => { if(res && res.data && res.data.length > 0){ this.setData({ tagList: res.data[0].valueVos }) } }) }, onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ /** * 用户点击右上角分享 */ onShareAppMessage() { } })