k94314517
2024-07-25 a75b18a4157ab486e0b51c438ac165ab3a08e3e0
wechat_jiaxuan/pages/homeId/index.js
@@ -1,39 +1,97 @@
// pages/consult/consult.js
import { getCataLogTagList, pageZSZXContentList, actionDo } from '../../api/index'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    category: ['新品上市', '专利证书', '大牌授权','新品上市', '专利证书', '大牌授权'],
    secondCategory: ['级分类','级分类','级分类','级分类','级分类','级分类'],
    tagList: [],
    activeCate: '',
    seActiveCate: '',
    dataList: []
  },
    dataList: [],
    total: 0,
    pageNum: 1,
    pageSize: 10,
  itemClick(e) {
    const { id } = e.target.dataset
    console.log(e.target.dataset);
    wx.navigateTo({
      url: '/pages/consult/detail',
    })
  },
  cateClick(e) {
    const { index } = e.target.dataset
    console.log(index);
  },
  seCateClick(e) {
    const { index } = e.target.dataset
    console.log(index);
    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() {
  },
@@ -69,9 +127,6 @@
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  /**
   * 用户点击右上角分享