liukangdong
2024-07-18 5b219a9694c8d69db42e746a654c779cc6a61bf6
wechat_jiaxuan/pages/consult/consult.js
@@ -1,39 +1,55 @@
// pages/consult/consult.js
import { getZhongTaiProductNewsPage, getCatalogList } from '../../api/index'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    category: ['新品上市', '专利证书', '大牌授权','新品上市', '专利证书', '大牌授权'],
    category: [],
    secondCategory: ['级分类','级分类','级分类','级分类','级分类','级分类'],
    activeCate: '',
    seActiveCate: '',
    dataList: []
  },
    dataList: [],
    total: 0,
    pageNum: 1,
    pageSize: 10,
  },
  onLoad(options) {
    this.getCate()
    this.getList()
  },
  getCate() {
    getCatalogList({catalogCode: 'product_info'}).then(res => {
      this.setData({ category: res.data })
    })
  },
  itemClick(e) {
    const { id } = e.target.dataset
    console.log(e.target.dataset);
    const { id } = e.currentTarget.dataset
    wx.navigateTo({
      url: '/pages/consult/detail',
      url: '/pages/consult/detail?id='+id,
    })
  },
  getList() {
    const { pageNum, pageSize, activeCate } = this.data
    getZhongTaiProductNewsPage({
      pageNum, pageSize, catalogCode: activeCate
    }).then(res => {
      if(res.data){
        this.setData({ dataList: res.data.records,total: res.data.records.total })
      }
    })
  },
  cateClick(e) {
    const { index } = e.target.dataset
    console.log(index);
    const { code } = e.currentTarget.dataset
    this.setData({ activeCate: code })
    this.getList()
  },
  seCateClick(e) {
    const { index } = e.target.dataset
    const { index } = e.currentTarget.dataset
    console.log(index);
  },
  onLoad(options) {
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  },