From b7fd27a4a7ac72eef5fc142cae9bb63fe69ef233 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 22 七月 2024 15:34:47 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 wechat_jiaxuan/pages/consult/consult.js |  103 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 73 insertions(+), 30 deletions(-)

diff --git a/wechat_jiaxuan/pages/consult/consult.js b/wechat_jiaxuan/pages/consult/consult.js
index 52fb869..5e74e3b 100644
--- a/wechat_jiaxuan/pages/consult/consult.js
+++ b/wechat_jiaxuan/pages/consult/consult.js
@@ -1,4 +1,4 @@
-import { getZhongTaiProductNewsPage, getCatalogList } from '../../api/index'
+import { getZhongTaiProductNewsPage, getCatalogList,actionDo } from '../../api/index'
 Page({
 
   /**
@@ -6,50 +6,108 @@
    */
   data: {
     category: [],
-    secondCategory: ['绾у垎绫�','绾у垎绫�','绾у垎绫�','绾у垎绫�','绾у垎绫�','绾у垎绫�'],
-    activeCate: '',
-    seActiveCate: '',
+    secondCategory: [],
 
+    catalogCode: '',
+    tagCode: '',
+    query: '',
     dataList: [],
     total: 0,
     pageNum: 1,
     pageSize: 10,
+
+    // height: 0,
+    // top: 0,
   },
   onLoad(options) {
     this.getCate()
-    this.getList()
+  },
+  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 => {
       this.setData({ category: res.data })
+      if(res.data && res.data.length > 0){
+        this.setData({catalogCode: res.data[0].code})
+        this.gettag()
+        this.getList()
+      }
+    })
+  },
+  gettag() {
+    const { catalogCode } = this.data
+    getCatalogList({
+      catalogCode
+    }).then(res => {
+      if(res.data && res.data.length > 0){
+        this.setData({ secondCategory: res.data })
+      }
     })
   },
   itemClick(e) {
-    const { id } = e.currentTarget.dataset
-    wx.navigateTo({
-      url: '/pages/consult/detail?id='+id,
-    })
+    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,
+        success: function(res) {
+          // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+          res.eventChannel.emit('acceptDataFromOpenerPage', { link: item.openContent, title: item.title })
+        }
+      })
+    }else{
+      wx.navigateTo({
+        url: '/pages/consult/detail?id='+item.id,
+      })
+    }    
   },
   getList() {
-    const { pageNum, pageSize, activeCate } = this.data
+    const { pageNum, pageSize, catalogCode, tagCode, query } = this.data
     getZhongTaiProductNewsPage({
-      pageNum, pageSize, catalogCode: activeCate
+      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
+        })
       }
       
     })
   },
   cateClick(e) {
     const { code } = e.currentTarget.dataset
-    this.setData({ activeCate: code })
+    this.setData({ catalogCode: code,secondCategory: [], tagCode: ''  })
+    this.gettag()
     this.getList()
+    this.setData({ dataList: [], pageNum: 1 })
   },
   seCateClick(e) {
-    const { index } = e.currentTarget.dataset
-    console.log(index);
+    const { code } = e.currentTarget.dataset
+    if(this.data.tagCode == code){
+      this.setData({ tagCode: '' })
+    }else{
+      this.setData({ tagCode: code })
+    }
+    this.setData({ dataList: [], pageNum: 1 })
+    this.getList()
   },
+  priviewFull(e){
+      const item = e.currentTarget.dataset.item
+      console.log('item', item);
+      
+    },
   onReady() {
 
   },
@@ -74,21 +132,6 @@
   onUnload() {
 
   },
-
-  /**
-   * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
-   */
-  onPullDownRefresh() {
-
-  },
-
-  /**
-   * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
-   */
-  onReachBottom() {
-
-  },
-
   /**
    * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
    */

--
Gitblit v1.9.3