| | |
| | | // pages/consult/consult.js |
| | | import { getZhongTaiProductNewsPage, getCatalogList,actionDo } from '../../api/index' |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | category: ['新品上市', '专利证书', '大牌授权','新品上市', '专利证书', '大牌授权'], |
| | | secondCategory: ['级分类','级分类','级分类','级分类','级分类','级分类'], |
| | | activeCate: '', |
| | | seActiveCate: '', |
| | | dataList: [] |
| | | }, |
| | | category: [], |
| | | secondCategory: [], |
| | | |
| | | catalogCode: '', |
| | | tagCode: '', |
| | | query: '', |
| | | dataList: [], |
| | | total: 0, |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | |
| | | // height: 0, |
| | | // top: 0, |
| | | }, |
| | | onLoad(options) { |
| | | this.getCate() |
| | | }, |
| | | 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' |
| | | }) |
| | | } |
| | | }, |
| | | 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 { id } = e.target.dataset |
| | | console.log(e.target.dataset); |
| | | const item = e.currentTarget.dataset.item |
| | | actionDo({actionType: 'view',id: item.id}) |
| | | if(item.contentType == 'link'){ |
| | | wx.navigateTo({ |
| | | url: '/pages/consult/detail', |
| | | 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, query } = this.data |
| | | getZhongTaiProductNewsPage({ |
| | | pageNum, pageSize, query, catalogCode: tagCode || catalogCode |
| | | }).then(res => { |
| | | if(res.data){ |
| | | this.setData({ |
| | | dataList: [ ...this.data.dataList, ...res.data.records ], |
| | | total: res.data.total |
| | | }) |
| | | } |
| | | |
| | | }) |
| | | }, |
| | | cateClick(e) { |
| | | const { index } = e.target.dataset |
| | | console.log(index); |
| | | const { code } = e.currentTarget.dataset |
| | | this.setData({ catalogCode: code,secondCategory: [], tagCode: '' }) |
| | | this.gettag() |
| | | this.getList() |
| | | this.setData({ dataList: [], pageNum: 1 }) |
| | | }, |
| | | seCateClick(e) { |
| | | const { index } = e.target.dataset |
| | | console.log(index); |
| | | const { code } = e.currentTarget.dataset |
| | | if(this.data.tagCode == code){ |
| | | this.setData({ tagCode: '' }) |
| | | }else{ |
| | | this.setData({ tagCode: code }) |
| | | } |
| | | this.setData({ dataList: [], pageNum: 1 }) |
| | | this.getList() |
| | | }, |
| | | onLoad(options) { |
| | | priviewFull(e){ |
| | | const item = e.currentTarget.dataset.item |
| | | console.log('item', item); |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | |
| | | onUnload() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |