''
liukangdong
2024-08-02 1cee3a660c5f8e5f4290ae894c2898c4966a834d
wechat_staff/pages/consult/consult.js
@@ -1,4 +1,5 @@
import { getZhongTaiProductNewsPage, getCatalogList,actionDo,refreshEnjoy } from '../../api/index'
let touchDot = 0
Page({
  /**
@@ -7,6 +8,7 @@
  data: {
    category: [],
    secondCategory: [],
    showCate: true,
    catalogCode: '',
    tagCode: '',
@@ -15,6 +17,7 @@
    total: 0,
    pageNum: 1,
    pageSize: 10,
    scrollTop: 0
    // height: 0,
    // top: 0,
@@ -22,17 +25,12 @@
  onLoad(options) {
    this.getCate()
  },
  onPullDownRefresh: function () {
    console.log('下拉刷新');
    this.setData({ dataList: [], pageNum: 1, total: 0 })
    this.getList()
  },
  onReachBottom() {
  bindscrolltolower() {
    console.log('触底事件');
    const { total, dataList, pageNum } = this.data
    if(total > dataList.length){
      this.setData({ pageNum: pageNum + 1 })
      this.getList()
      this.getList(false)
    }else{
      wx.showToast({
        title: '暂无更多数据',
@@ -63,6 +61,13 @@
  itemClick(e) {
    const item = e.currentTarget.dataset.item
    actionDo({actionType: 'view',id: item.id})
    const { dataList } = this.data
    dataList.forEach(ite => {
      if(item.id === ite.id){
        ite.viewCount += 1
      }
    })
    this.setData({ dataList })
    if(item.contentType == 'link'){
      wx.navigateTo({
        url: '/pages/webView/index',
@@ -78,7 +83,7 @@
      })
    }    
  },
  getList() {
  getList(showCate = true) {
    const { pageNum, pageSize, catalogCode, tagCode, query } = this.data
    getZhongTaiProductNewsPage({
      pageNum, pageSize, query, catalogCode: tagCode || catalogCode
@@ -86,7 +91,8 @@
      if(res.data){
        this.setData({ 
          dataList: [ ...this.data.dataList, ...res.data.records ],
          total: res.data.total
          total: res.data.total,
          showCate
        })
      }
      
@@ -117,10 +123,20 @@
  onReady() {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  touchstart(e){
    // touchDot = e.touches[0].pageY;
    console.log('开始', e);
  },
  touchmove(e) {
    // var touchMove = e.touches[0].pageY;
    console.log('touchMove', e);
    // if(touchDot - touchMove > 60){
    //   this.setData({ showCate: false })
    // }
    // if(touchMove - touchDot > 60){
    //   this.setData({ showCate: true })
    // }
  },
  onShow() {
    refreshEnjoy(this) 
  },