liukangdong
2024-08-05 00bf17838b496e6fcfed2e521f9c27f8f0e3e3c7
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,8 @@
  data: {
    category: [],
    secondCategory: [],
    showCate: true,
    animationData: {},
    catalogCode: '',
    tagCode: '',
@@ -15,14 +18,19 @@
    total: 0,
    pageNum: 1,
    pageSize: 10,
    scrollTop: 0
    // height: 0,
    // top: 0,
  },
  onLoad(options) {
    this.getCate()
    this.animation = wx.createAnimation({
      duration: 500,
      timingFunction: 'ease',
    });
  },
  onReachBottom() {
  bindscrolltolower() {
    console.log('触底事件');
    const { total, dataList, pageNum } = this.data
    if(total > dataList.length){
@@ -58,6 +66,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',
@@ -112,10 +127,39 @@
  onReady() {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  bindscrolltoupper() {
    this.setData({ showCate: true })
    this.fadeIn();
  },
  touchstart(e){
    touchDot = e.detail.scrollTop;
  },
  touchmove(e) {
    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) 
  },