From 7a2084c90ed29a4ec9d4267deb2b78f0d49c904d Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 23 七月 2024 09:56:34 +0800
Subject: [PATCH] ‘’

---
 wechat_jiaxuan/pages/index/index.js |  200 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 147 insertions(+), 53 deletions(-)

diff --git a/wechat_jiaxuan/pages/index/index.js b/wechat_jiaxuan/pages/index/index.js
index 3828fd4..a4274e7 100644
--- a/wechat_jiaxuan/pages/index/index.js
+++ b/wechat_jiaxuan/pages/index/index.js
@@ -23,7 +23,7 @@
     showWhiteHead: false,
     topHeadBorder: false,
     member: {},
-    
+
     bannerList: [],
     bannerImgHeight: 0,
     consultList: [],
@@ -46,16 +46,28 @@
   },
   onShow() {
     const member = wx.getStorageSync('member')
-    if(member && (member.authStatus == '1' || member.authStatus == '2')){
+    if (member && (member.authStatus == '1' || member.authStatus == '2')) {
       getMemberInfo().then(res => {
-        this.setData({member: res.data})
+        this.setData({
+          member: res.data
+        })
       })
-    }else{
-      this.setData({member})
+    } else {
+      this.setData({
+        member
+      })
     }
   },
   onLoad(options) {
-    this.initData()
+    const member = wx.getStorageSync('member')
+    this.initDictData()
+    if (member && member.token) {
+      this.initData()
+    } else {
+      setTimeout(() => {
+        this.initData()
+      }, 1200)
+    }
   },
   changePath(e) {
     let index = e.currentTarget.dataset.type
@@ -66,7 +78,9 @@
           url: '/pages/webView/index',
           success: function (res) {
             // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
-            res.eventChannel.emit('acceptDataFromOpenerPage', { link: that.data.testUrl })
+            res.eventChannel.emit('acceptDataFromOpenerPage', {
+              link: that.data.testUrl
+            })
           }
         })
         break;
@@ -98,18 +112,25 @@
   changeStrategy(e) {
     let item = e.currentTarget.dataset.item
     wx.navigateTo({
-      url: `/pages/homeId/index?code=${item.code}&name=${item.name}` ,
+      url: `/pages/homeId/index?code=${item.code}&name=${item.name}`,
     })
   },
   initData() {
     // 杞挱
     getHomeBanner().then(res => {
-      this.setData({ bannerList: res.data })
+      this.setData({
+        bannerList: res.data
+      })
     })
     // 浜у搧瑙嗛
-    getZhongTaiVideoPage({ pageSize: 1, pageNum: 1 }).then(res => {
-      if(res.data.records && res.data.records.length > 0){
-        this.setData({ productVideo: res.data.records })
+    getZhongTaiVideoPage({
+      pageSize: 1,
+      pageNum: 1
+    }).then(res => {
+      if (res.data.records && res.data.records.length > 0) {
+        this.setData({
+          productVideo: res.data.records
+        })
       }
     })
     getZSZXCatalogs().then(res => { //蹇楄瑁呬慨
@@ -120,45 +141,62 @@
     // 璧勮
     getZhongTaiProductNewsPage({
       catalogCode: 'product_info',
-      pageSize: 6, pageNum: 1
+      pageSize: 6,
+      pageNum: 1
     }).then(res => {
-      if(res.data){
-        this.setData({ consultList: res.data.records })
+      if (res.data) {
+        this.setData({
+          consultList: res.data.records
+        })
       }
     })
     getCustomizedNewsList().then(res => { // 瀹氬埗鏈嶅姟
-      this.setData({serviceList: res.data || []})
+      this.setData({
+        serviceList: res.data || []
+      })
     })
+  },
+  initDictData() {
     // 椋庢牸娴嬭瘯
     getDictData({
       code: 'WX_MINI_CONFIG',
       label: 'ZBOM_STYLE_TEST_URL'
     }).then(res => {
-      this.setData({ testUrl: res.data.code })
+      this.setData({
+        testUrl: res.data.code
+      })
     })
     getDictData({
       code: 'WEIXIN_DEFAULT_IMGS',
       label: 'HOME_CLASS_A'
     }).then(res => {
-      this.setData({ HOME_CLASS_A: res.data.code })
+      this.setData({
+        HOME_CLASS_A: res.data.code
+      })
     })
     getDictData({
       code: 'WEIXIN_DEFAULT_IMGS',
       label: 'HOME_CLASS_B'
     }).then(res => {
-      this.setData({ HOME_CLASS_B: res.data.code })
+      this.setData({
+        HOME_CLASS_B: res.data.code
+      })
     })
     getDictData({
       code: 'WEIXIN_DEFAULT_IMGS',
       label: 'HOME_CLASS_B2'
     }).then(res => {
-      this.setData({ HOME_CLASS_B2: res.data.code })
+      this.setData({
+        HOME_CLASS_B2: res.data.code
+      })
     })
     getDictData({
       code: 'WEIXIN_DEFAULT_IMGS',
       label: 'HOME_CLASS_C'
     }).then(res => {
-      this.setData({ HOME_CLASS_C: res.data.code })
+      this.setData({
+        HOME_CLASS_C: res.data.code
+      })
     })
   },
   jumpProVideo() {
@@ -167,12 +205,17 @@
     })
   },
   videoClick(e) {
-    const { videourl } = e.currentTarget.dataset
+    const {
+      videourl
+    } = e.currentTarget.dataset
     wx.previewMedia({
-      sources: [{ url: videourl, type: 'video' }]
+      sources: [{
+        url: videourl,
+        type: 'video'
+      }]
     })
   },
-  goserHeight:function (e) {
+  goserHeight: function (e) {
     const serviceHeight = e.detail.height
     this.setData({
       serviceHeight: serviceHeight
@@ -185,29 +228,52 @@
     })
   },
   consultbindload(e) {
-    const { height, width } = e.detail
+    const {
+      height,
+      width
+    } = e.detail
     let activeHeight = height * 670 / width
     this.setData({
       consultImgHeight: activeHeight
     })
   },
+  consultClick(e) {
+    const id = e.currentTarget.dataset.id
+    actionDo({
+      actionType: 'view',
+      id: id
+    })
+    wx.navigateTo({
+      url: '/pages/consult/detail?id=' + id
+    })
+  },
   bannerClick(e) {
-    const { id } = e.currentTarget.dataset
+    const {
+      id
+    } = e.currentTarget.dataset
     const item = e.currentTarget.dataset.item
     console.log('item', item);
-    actionDo({actionType: 'view',id: item.id})
-    if(item.openType == 'video'){
-      wx.previewMedia({
-        sources: [{ url: item.openContent, type: 'video' }]
+    if(item.openType){
+      actionDo({
+        actionType: 'view',
+        id: item.id
       })
     }
-    if(item.openType == 'link'){
+    if (item.openType == 'video') {
+      wx.previewMedia({
+        sources: [{
+          url: item.openContent,
+          type: 'video'
+        }]
+      })
+    }
+    if (item.openType == 'link') {
       wx.navigateTo({
         url: '/pages/webView/index?link=' + item.openContent,
       })
     }
-    if(item.openType == 'page'){
-      getApp().globalData.catalogCode=item.openContent
+    if (item.openType == 'page') {
+      getApp().globalData.catalogCode = item.openContent
       wx.switchTab({
         url: '/pages/discover/discover'
       })
@@ -215,17 +281,20 @@
     // getHomeBannerDetail({id})
   },
   seriveClick(e) {
-    const { id, title } = e.currentTarget.dataset
-    if(title === '涓撳睘瀹㈡湇'){
+    const {
+      id,
+      title
+    } = e.currentTarget.dataset
+    if (title === '涓撳睘瀹㈡湇') {
       wx.navigateTo({
         url: `/pages/kefu/index?title=${title}&id=${id}`,
       })
-    }else{
+    } else {
       wx.navigateTo({
         url: `/pages/kefu/service?title=${title}&id=${id}`,
       })
     }
-    
+
   },
   jumpProConsult() {
     wx.switchTab({
@@ -235,38 +304,63 @@
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
-  onReady() {
 
-  },
   onPageScroll(e) {
     let scrollTop = e.scrollTop / 100
     if (scrollTop <= 0.1) {
-      this.setData({ font_color: '#ffffff' })
+      this.setData({
+        font_color: '#ffffff'
+      })
     } else if (scrollTop >= 0.1 && scrollTop < 0.2) {
-      this.setData({ font_color: '#d0d0d0' })
+      this.setData({
+        font_color: '#d0d0d0'
+      })
     } else if (scrollTop >= 0.2 && scrollTop < 0.3) {
-      this.setData({ font_color: '#bdbdbd' })
+      this.setData({
+        font_color: '#bdbdbd'
+      })
     } else if (scrollTop >= 0.3 && scrollTop < 0.4) {
-      this.setData({ font_color: '#a1a1a1' })
+      this.setData({
+        font_color: '#a1a1a1'
+      })
     } else if (scrollTop >= 0.4 && scrollTop < 0.5) {
-      this.setData({ font_color: '#878787' })
+      this.setData({
+        font_color: '#878787'
+      })
     } else if (scrollTop >= 0.5 && scrollTop < 0.6) {
-      this.setData({ font_color: '#6d6d6d' })
+      this.setData({
+        font_color: '#6d6d6d'
+      })
     } else if (scrollTop >= 0.6 && scrollTop < 0.7) {
-      this.setData({ font_color: '#535353' })
+      this.setData({
+        font_color: '#535353'
+      })
     } else if (scrollTop >= 0.7 && scrollTop < 0.8) {
-      this.setData({ font_color: '#3b3b3b' })
+      this.setData({
+        font_color: '#3b3b3b'
+      })
     } else if (scrollTop >= 0.8 && scrollTop < 0.9) {
-      this.setData({ font_color: '#282828' })
+      this.setData({
+        font_color: '#282828'
+      })
     } else if (scrollTop >= 0.9) {
-      this.setData({ font_color: '#000000' })
+      this.setData({
+        font_color: '#000000'
+      })
     }
     if (scrollTop > 0) {
-      this.setData({ showWhiteHead: true })
-    } else{
-      this.setData({ showWhiteHead: false })
+      this.setData({
+        showWhiteHead: true
+      })
+    } else {
+      this.setData({
+        showWhiteHead: false
+      })
     }
-    this.setData({ topHeadStyle: scrollTop, top: scrollTop })
+    this.setData({
+      topHeadStyle: scrollTop,
+      top: scrollTop
+    })
   },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌

--
Gitblit v1.9.3