lll
liukangdong
2024-08-05 2da083225417ef7007842b84e7276242faeb0e35
wechat_staff/pages/consult/consult.js
@@ -9,6 +9,7 @@
    category: [],
    secondCategory: [],
    showCate: true,
    animationData: {},
    catalogCode: '',
    tagCode: '',
@@ -24,13 +25,17 @@
  },
  onLoad(options) {
    this.getCate()
    this.animation = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease',
    });
  },
  bindscrolltolower() {
    console.log('触底事件');
    const { total, dataList, pageNum } = this.data
    if(total > dataList.length){
      this.setData({ pageNum: pageNum + 1 })
      this.getList(false)
      this.getList()
    }else{
      wx.showToast({
        title: '暂无更多数据',
@@ -83,7 +88,7 @@
      })
    }    
  },
  getList(showCate = true) {
  getList() {
    const { pageNum, pageSize, catalogCode, tagCode, query } = this.data
    getZhongTaiProductNewsPage({
      pageNum, pageSize, query, catalogCode: tagCode || catalogCode
@@ -91,8 +96,7 @@
      if(res.data){
        this.setData({ 
          dataList: [ ...this.data.dataList, ...res.data.records ],
          total: res.data.total,
          showCate
          total: res.data.total
        })
      }
      
@@ -123,19 +127,38 @@
  onReady() {
  },
  bindscrolltoupper() {
    this.setData({ showCate: true })
    this.fadeIn();
  },
  touchstart(e){
    // touchDot = e.touches[0].pageY;
    console.log('开始', e);
    touchDot = e.detail.scrollTop;
  },
  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 })
    // }
    var touchMove = e.detail.scrollTop;
    if(touchMove - touchDot > 60){
      // this.setData({ showCate: false })
      this.fadeOut();
    }
    if(touchDot - touchMove > 60){
      this.fadeIn();
      this.setData({ showCate: true })
    }
  },
  fadeIn: function () {
    this.animation.opacity(1).step();
    this.setData({
      animationData: this.animation.export()
    });
  },
  fadeOut: function () {
    this.animation.opacity(0).step();
    this.setData({
      animationData: this.animation.export()
    });
    setTimeout(() => {
      this.setData({ showCate: false });
    }, 500); // 动画持续时间
  },
  onShow() {
    refreshEnjoy(this)