import { getZhongTaiProductNewsPage, getCatalogList, getCataLogTagList } from '../../api/index' Page({ /** * 页面的初始数据 */ data: { category: [], secondCategory: [], catalogCode: '', tagCode: '', search: '', dataList: [], total: 0, pageNum: 1, pageSize: 10, }, onLoad(options) { this.getCate() }, getCate() { getCatalogList({catalogCode: 'product_info'}).then(res => { this.setData({ category: res.data }) if(res.data && res.data.length > 0){ this.setData({catalogCode: res.data[0].code}) this.gettag() this.getList() } }) }, gettag() { const { catalogCode } = this.data getCatalogList({ catalogCode }).then(res => { if(res.data && res.data.length > 0){ this.setData({ secondCategory: res.data }) } }) }, itemClick(e) { const item = e.currentTarget.dataset.item if(item.contentType == 'link'){ wx.navigateTo({ url: '/pages/webView/index?link=' + item.content, success: function(res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('acceptDataFromOpenerPage', { link: item.openContent, title: item.title }) } }) }else{ wx.navigateTo({ url: '/pages/consult/detail?id='+item.id, }) } }, getList() { const { pageNum, pageSize, catalogCode, tagCode, search } = this.data getZhongTaiProductNewsPage({ pageNum, pageSize, search, catalogCode: tagCode || catalogCode }).then(res => { if(res.data){ this.setData({ dataList: res.data.records,total: res.data.records.total }) } }) }, cateClick(e) { const { code } = e.currentTarget.dataset this.setData({ catalogCode: code,secondCategory: [], tagCode: '' }) this.gettag() this.getList() console.log('e', e.currentTarget.dataset); console.log('catalogCode', this.data.catalogCode); }, seCateClick(e) { const { code } = e.currentTarget.dataset if(this.data.tagCode == code){ this.setData({ tagCode: '' }) }else{ this.setData({ tagCode: code }) } this.getList() }, priviewFull(e){ const item = e.currentTarget.dataset.item console.log('item', item); }, onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })