From 00bf17838b496e6fcfed2e521f9c27f8f0e3e3c7 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期一, 05 八月 2024 18:38:20 +0800
Subject: [PATCH] ‘’

---
 wechat_jiaxuan/pages/consult/consult.js |  112 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 86 insertions(+), 26 deletions(-)

diff --git a/wechat_jiaxuan/pages/consult/consult.js b/wechat_jiaxuan/pages/consult/consult.js
index 4b2b005..161b04e 100644
--- a/wechat_jiaxuan/pages/consult/consult.js
+++ b/wechat_jiaxuan/pages/consult/consult.js
@@ -1,4 +1,5 @@
-import { getZhongTaiProductNewsPage, getCatalogList, getCataLogTagList } from '../../api/index'
+import { getZhongTaiProductNewsPage, getCatalogList,actionDo } from '../../api/index'
+let touchDot = 0
 Page({
 
   /**
@@ -7,17 +8,39 @@
   data: {
     category: [],
     secondCategory: [],
+    showCate: true,
+    animationData: {},
 
     catalogCode: '',
     tagCode: '',
-    search: '',
+    query: '',
     dataList: [],
     total: 0,
     pageNum: 1,
     pageSize: 10,
+
+    // height: 0,
+    // top: 0,
   },
   onLoad(options) {
     this.getCate()
+    this.animation = wx.createAnimation({
+      duration: 500,
+      timingFunction: 'ease',
+    });
+  },
+  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,12 +64,20 @@
   },
   itemClick(e) {
     const item = e.currentTarget.dataset.item
+    const { dataList } = this.data
+    dataList.forEach(ite => {
+      if(item.id === ite.id){
+        ite.viewCount += 1
+      }
+    })
+    this.setData({ dataList })
+    actionDo({actionType: 'view',id: item.id})
     if(item.contentType == 'link'){
       wx.navigateTo({
-        url: '/pages/webView/index?link=' + item.content,
+        url: '/pages/webView/index',
         success: function(res) {
           // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
-          res.eventChannel.emit('acceptDataFromOpenerPage', { link: item.openContent, title: item.title })
+          res.eventChannel.emit('acceptDataFromOpenerPage', { link: item.content, title: item.title })
         }
       })
     }else{
@@ -55,13 +86,20 @@
       })
     }    
   },
+  searchList() {
+    this.setData({ dataList: [], total: 0, pageNum: 1 })
+    this.getList()
+  },
   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 +109,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 +118,7 @@
     }else{
       this.setData({ tagCode: code })
     }
+    this.setData({ dataList: [], pageNum: 1 })
     this.getList()
   },
   priviewFull(e){
@@ -91,7 +129,38 @@
   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.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); // 鍔ㄧ敾鎸佺画鏃堕棿
+  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
@@ -112,25 +181,16 @@
   onUnload() {
 
   },
-
-  /**
-   * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
-   */
-  onReachBottom() {
-
-  },
-
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */
   onShareAppMessage() {
-
+    let { info } = this.data
+    console.log('鐐瑰嚮浜嗗垎浜�')
+    if(info.users && info.users.userId){
+      return {
+        path: '/pages/detailDis/product?id=' + info.id + '&userId=' + info.users.id
+      }
+    }
   }
 })
\ No newline at end of file

--
Gitblit v1.9.3