From 04b4bddaac0a222760113899568d20b45af701f4 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 27 九月 2024 19:04:14 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 wechat_jiaxuan/pages/index/index.js |  444 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 408 insertions(+), 36 deletions(-)

diff --git a/wechat_jiaxuan/pages/index/index.js b/wechat_jiaxuan/pages/index/index.js
index ea13e96..d590a95 100644
--- a/wechat_jiaxuan/pages/index/index.js
+++ b/wechat_jiaxuan/pages/index/index.js
@@ -1,4 +1,18 @@
-import { getDictData, getMemberInfo } from '../../api/index'
+import {
+  getDictData,
+  getMemberInfo,
+  getZSZXCatalogs,
+  getCustomizedNewsList,
+  getHomeBanner,
+  actionDo,
+  getZhongTaiVideoPage,
+  getZhongTaiProductNewsPage
+} from '../../api/index'
+import {
+  eventBus
+} from '../../utils/eventBus'
+const app = getApp()
+var touchDot = 0; //瑙︽懜鏃剁殑鍘熺偣 
 Page({
 
   /**
@@ -7,17 +21,26 @@
   data: {
     // 椤堕儴nav
     topHeadStyle: 1,
-    showWhiteHead: true,
+    top: 0,
+    open: false,
+    desc: true,
+    font_color: '#ffffff',
+    ZSZXCata: {},
+
+    showWhiteHead: false,
     topHeadBorder: false,
     member: {},
-    
-    bannerList: [
-      {imgurl: ''},
-      {imgurl: 'adsa.png'},
-      {imgurl: 'adsa.png'},
-      {imgurl: 'adsa.png'},
-    ],
 
+    bannerList: [],
+    bannerImgHeight: 0,
+    consultList: [],
+    consultImgHeight: 0,
+
+    videoTop: 0,
+    windowHeight: 0,
+    videoPlay: true,
+
+    productVideo: {},
     bannerSwiperOption: {
       indicatorDots: true,
       vertical: false,
@@ -25,34 +48,75 @@
       interval: 3000,
       duration: 500
     },
+    serviceList: [],
+    testUrl: '',
     HOME_CLASS_A: '',
     HOME_CLASS_B: '',
     HOME_CLASS_B2: '',
     HOME_CLASS_C: '',
   },
-
-  toSearch() {},
+  onLoadLogin(options) {
+    // 宸茬粡鐧诲綍锛屽彲浠ヨ蛋渚濊禆token鐨勯�昏緫浜�
+    console.log('棣栭〉鐨刼nLoadLogin', options, `{"token":"${app.globalData.token}"}`);
+    this.initData()
+    const member = wx.getStorageSync('member')
+    this.setData({
+      member
+    })
+  },
+  onReady() {
+    const windowInfo = wx.getWindowInfo()
+    setTimeout(() => {
+      const query = wx.createSelectorQuery()
+      query.select('.product_video').boundingClientRect(function (rect) {
+        rect.top // 鑺傜偣鐨勪笂杈圭晫鍧愭爣
+        rect.bottom // 鑺傜偣鐨勪笅杈圭晫鍧愭爣
+      }).exec(res => {
+        console.log(windowInfo.windowHeight)
+        this.setData({
+          videoTop: res[0].top,
+          windowHeight: windowInfo.windowHeight
+        })
+      })
+    }, 3000)
+  },
   onShow() {
-    getMemberInfo().then(res => {
-      this.setData({member: res.data})
+    const member = wx.getStorageSync('member')
+    this.setData({
+      member
+    })
+    eventBus.once("reloadHome", () => {
+      console.log('reloadHome');
+      this.onLoad()
+      this.initData()
     })
   },
   onLoad(options) {
-    this.initData()
+    this.initDictData()
+    // this.initData()
   },
   changePath(e) {
     let index = e.currentTarget.dataset.type
-    console.log(index);
+    const member = this.data.member
+    let that = this
     switch (index) {
       case '0':
-        wx.navigateTo({
-          url: '/pages/webView/index',
-          success: function (res) {
-            // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
-            res.eventChannel.emit('acceptDataFromOpenerPage', { link: 'https://m.zbom.com/mobile/styleTest.html?type=1' })
-            // saveBehavior({ type: 1 })
-          }
-        })
+        if (member && member.phone) {
+          wx.navigateTo({
+            url: '/pages/webView/index',
+            success: function (res) {
+              // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+              res.eventChannel.emit('acceptDataFromOpenerPage', {
+                link: that.data.testUrl
+              })
+            }
+          })
+        } else {
+          wx.setStorageSync('tempPath', '/pages/webView/index')
+          wx.navigateTo({
+            url: '/pages/auth/auth',
+          })
+        }
         break;
 
       case '1':
@@ -60,11 +124,18 @@
           url: '/pages/calculator/index'
         })
         break;
-
       case '2':
-        wx.navigateTo({
-          url: '/pages/design/design'
-        })
+        if (member && member.phone) {
+          wx.navigateTo({
+            url: '/pages/design/design'
+          })
+        } else {
+          wx.setStorageSync('tempPath', '/pages/design/design')
+          wx.navigateTo({
+            url: '/pages/auth/auth',
+          })
+        }
+
         // wx.navigateTo({
         //   url: '/pages/wonderful_activity/index',
         //   success: function(res) {
@@ -79,30 +150,99 @@
         break;
     }
   },
+  changeStrategy(e) {
+    let item = e.currentTarget.dataset.item
+    wx.navigateTo({
+      url: `/pages/homeId/index?code=${item.code}&name=${item.name}`,
+    })
+  },
   initData() {
+    // 杞挱
+    getHomeBanner().then(res => {
+      if (res.data) {
+        this.setData({
+          bannerList: res.data
+        })
+      }
+    })
+    // 浜у搧瑙嗛
+    getZhongTaiVideoPage({
+      pageSize: 1,
+      pageNum: 1
+    }).then(res => {
+      if (res.data && res.data.records && res.data.records.length > 0) {
+        this.setData({
+          productVideo: res.data.records
+        })
+      }
+    })
+    getZSZXCatalogs().then(res => { //蹇楄瑁呬慨
+      this.setData({
+        ZSZXCata: res.data || {}
+      })
+    })
+    // 璧勮
+    getZhongTaiProductNewsPage({
+      catalogCode: 'product_info',
+      pageSize: 6,
+      pageNum: 1
+    }).then(res => {
+      if (res.data && res.data.records) {
+        this.setData({
+          consultList: res.data.records
+        })
+      }
+    })
+    getCustomizedNewsList().then(res => { // 瀹氬埗鏈嶅姟
+      this.setData({
+        serviceList: res.data || []
+      })
+    })
+  },
+  initDictData() {
+    // 椋庢牸娴嬭瘯
+    getDictData({
+      code: 'WX_MINI_CONFIG',
+      label: 'ZBOM_STYLE_TEST_URL'
+    }).then(res => {
+      if (res.data) {
+        this.setData({
+          testUrl: res.data.code
+        })
+        wx.setStorageSync('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() {
@@ -110,10 +250,130 @@
       url: '/pages/productVideo/index',
     })
   },
-  jumpProKefu() {
-    wx.navigateTo({
-      url: '/pages/kefu/index',
+  videoClick(e) {
+    const {
+      videourl,
+      id
+    } = e.currentTarget.dataset
+    actionDo({
+      actionType: 'view',
+      id
     })
+    let videoPlay = this.selectComponent('.videoPlay');
+    if (videoPlay) {
+      videoPlay.startPlayVideo(videourl, this);
+    }
+    // wx.previewMedia({
+    //   sources: [{
+    //     url: videourl,
+    //     type: 'video'
+    //   }]
+    // })
+  },
+  goserHeight: function (e) {
+    const serviceHeight = e.detail.height
+    this.setData({
+      serviceHeight: serviceHeight
+    })
+  },
+  bannerbindload(e) {
+    const {
+      height,
+      width
+    } = e.detail
+    let activeHeight = height * 670 / width
+    this.setData({
+      bannerImgHeight: activeHeight
+    })
+  },
+  consultbindload(e) {
+    const {
+      height,
+      width
+    } = e.detail
+    let activeHeight = height * 670 / width
+    this.setData({
+      consultImgHeight: activeHeight + 100
+    })
+  },
+  consultClick(e) {
+    const item = e.currentTarget.dataset.id
+    actionDo({
+      actionType: 'view',
+      id: item.id
+    })
+    if (item.contentType == 'link') {
+      wx.navigateTo({
+        url: '/pages/webView/index',
+        success: function (res) {
+          // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+          res.eventChannel.emit('acceptDataFromOpenerPage', {
+            link: item.content,
+            title: item.title
+          })
+        }
+      })
+    } else {
+      wx.navigateTo({
+        url: '/pages/consult/detail?id=' + item.id,
+      })
+    }
+    // wx.navigateTo({
+    //   url: '/pages/consult/detail?id=' + id
+    // })
+  },
+  bannerClick(e) {
+    const {
+      id
+    } = e.currentTarget.dataset
+    const item = e.currentTarget.dataset.item
+    console.log('item', item);
+    if (item.openType) {
+      actionDo({
+        actionType: 'view',
+        id: item.id
+      })
+    }
+    if (item.openType == 'video') {
+      wx.previewMedia({
+        sources: [{
+          url: item.openContent,
+          type: 'video'
+        }]
+      })
+    }
+    if (item.openType == 'link') {
+      wx.navigateTo({
+        url: '/pages/webView/index',
+        success: function (res) {
+          res.eventChannel.emit('acceptDataFromOpenerPage', {
+            link: item.openContent || item.content
+          });
+        }
+      })
+    }
+    if (item.openType == 'page') {
+      getApp().globalData.catalogCode = item.openContent
+      wx.switchTab({
+        url: '/pages/discover/discover'
+      })
+    }
+    // getHomeBannerDetail({id})
+  },
+  seriveClick(e) {
+    const {
+      id,
+      title
+    } = e.currentTarget.dataset
+    if (title === '涓撳睘瀹㈡湇') {
+      wx.navigateTo({
+        url: `/pages/kefu/index?title=${title}&id=${id}`,
+      })
+    } else {
+      wx.navigateTo({
+        url: `/pages/kefu/service?title=${title}&id=${id}`,
+      })
+    }
   },
   jumpProConsult() {
     wx.switchTab({
@@ -123,10 +383,122 @@
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
-  onReady() {
-
+  bindVideoPlay() {
+    const {
+      id
+    } = this.data.productVideo[0]
+    actionDo({
+      actionType: 'view',
+      id
+    })
   },
+  hdBtn() {
+    this.setData({
+      showWhiteHead: true,
+      open: true,
+      font_color: "#000000",
+      sty: '',
+      topHeadStyle: 1,
+      desc: false
+    })
+  },
+  touchStart: function (e) {
+    touchDot = e.touches[0].pageY;
+  },
+  touchMove: function (e) {
+    var touchMove = e.touches[0].pageY;
+    if (touchMove - touchDot <= 0 && this.data.top <= 1 && this.data.desc) {
+      this.setData({
+        showWhiteHead: true,
+        open: false,
+        desc: false
+      })
+      setTimeout(() => {
+        this.setData({
+          open: true,
+          sty: ''
+        })
+      }, 1000)
+    }
+    if (touchMove - touchDot >= 50 && this.data.top <= 1 && !this.data.desc) {
+      this.setData({
+        showWhiteHead: false,
+        open: false,
+        desc: true,
+        sty: 'overflow: hidden;'
+      })
+    }
+  },
+  onPageScroll(e) {
+    const {
+      videoTop,
+      windowHeight,
+      videoPlay
+    } = this.data
+    if (e.scrollTop + 100 > videoTop - (windowHeight / 2) && videoPlay) {
+      this.setData({
+        videoPlay: false
+      })
+      let videoplay = wx.createVideoContext('myvideo', this)
+      videoplay.play();
+    }
 
+    let scrollTop = e.scrollTop / 100
+    if (scrollTop <= 0.1) {
+      this.setData({
+        font_color: '#ffffff'
+      })
+    } else if (scrollTop >= 0.1 && scrollTop < 0.2) {
+      this.setData({
+        font_color: '#d0d0d0'
+      })
+    } else if (scrollTop >= 0.2 && scrollTop < 0.3) {
+      this.setData({
+        font_color: '#bdbdbd'
+      })
+    } else if (scrollTop >= 0.3 && scrollTop < 0.4) {
+      this.setData({
+        font_color: '#a1a1a1'
+      })
+    } else if (scrollTop >= 0.4 && scrollTop < 0.5) {
+      this.setData({
+        font_color: '#878787'
+      })
+    } else if (scrollTop >= 0.5 && scrollTop < 0.6) {
+      this.setData({
+        font_color: '#6d6d6d'
+      })
+    } else if (scrollTop >= 0.6 && scrollTop < 0.7) {
+      this.setData({
+        font_color: '#535353'
+      })
+    } else if (scrollTop >= 0.7 && scrollTop < 0.8) {
+      this.setData({
+        font_color: '#3b3b3b'
+      })
+    } else if (scrollTop >= 0.8 && scrollTop < 0.9) {
+      this.setData({
+        font_color: '#282828'
+      })
+    } else if (scrollTop >= 0.9) {
+      this.setData({
+        font_color: '#000000'
+      })
+    }
+    if (scrollTop > 0) {
+      this.setData({
+        showWhiteHead: true
+      })
+    } else {
+      this.setData({
+        showWhiteHead: false
+      })
+    }
+    this.setData({
+      topHeadStyle: scrollTop,
+      top: scrollTop
+    })
+  },
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */

--
Gitblit v1.9.3