k94314517
2024-07-25 a75b18a4157ab486e0b51c438ac165ab3a08e3e0
wechat_jiaxuan/pages/consult/consult.js
@@ -1,4 +1,4 @@
import { getZhongTaiProductNewsPage, getCatalogList, getCataLogTagList } from '../../api/index'
import { getZhongTaiProductNewsPage, getCatalogList,actionDo } from '../../api/index'
Page({
  /**
@@ -10,14 +10,30 @@
    catalogCode: '',
    tagCode: '',
    search: '',
    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 => {
@@ -41,6 +57,7 @@
  },
  itemClick(e) {
    const item = e.currentTarget.dataset.item
    actionDo({actionType: 'view',id: item.id})
    if(item.contentType == 'link'){
      wx.navigateTo({
        url: '/pages/webView/index?link=' + item.content,
@@ -56,12 +73,15 @@
    }    
  },
  getList() {
    const { pageNum, pageSize, catalogCode, tagCode, search } = this.data
    const { pageNum, pageSize, catalogCode, tagCode, query } = this.data
    getZhongTaiProductNewsPage({
      pageNum, pageSize, search, catalogCode: tagCode || catalogCode
      pageNum, pageSize, query, catalogCode: tagCode || catalogCode
    }).then(res => {
      if(res.data){
        this.setData({ dataList: res.data.records,total: res.data.records.total })
        this.setData({
          dataList: [ ...this.data.dataList, ...res.data.records ],
          total: res.data.total
        })
      }
      
    })
@@ -71,8 +91,7 @@
    this.setData({ catalogCode: code,secondCategory: [], tagCode: ''  })
    this.gettag()
    this.getList()
    console.log('e', e.currentTarget.dataset);
    console.log('catalogCode', this.data.catalogCode);
    this.setData({ dataList: [], pageNum: 1 })
  },
  seCateClick(e) {
    const { code } = e.currentTarget.dataset
@@ -81,6 +100,7 @@
    }else{
      this.setData({ tagCode: code })
    }
    this.setData({ dataList: [], pageNum: 1 })
    this.getList()
  },
  priviewFull(e){
@@ -112,21 +132,6 @@
  onUnload() {
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  /**
   * 用户点击右上角分享
   */