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 |  239 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 184 insertions(+), 55 deletions(-)

diff --git a/wechat_jiaxuan/pages/index/index.js b/wechat_jiaxuan/pages/index/index.js
index 003f46a..d590a95 100644
--- a/wechat_jiaxuan/pages/index/index.js
+++ b/wechat_jiaxuan/pages/index/index.js
@@ -8,10 +8,11 @@
   getZhongTaiVideoPage,
   getZhongTaiProductNewsPage
 } from '../../api/index'
-const {
-  HYEventBus
-} = require('hy-event-store')
-const eventBus = new HYEventBus()
+import {
+  eventBus
+} from '../../utils/eventBus'
+const app = getApp()
+var touchDot = 0; //瑙︽懜鏃剁殑鍘熺偣 
 Page({
 
   /**
@@ -21,6 +22,8 @@
     // 椤堕儴nav
     topHeadStyle: 1,
     top: 0,
+    open: false,
+    desc: true,
     font_color: '#ffffff',
     ZSZXCata: {},
 
@@ -32,6 +35,10 @@
     bannerImgHeight: 0,
     consultList: [],
     consultImgHeight: 0,
+
+    videoTop: 0,
+    windowHeight: 0,
+    videoPlay: true,
 
     productVideo: {},
     bannerSwiperOption: {
@@ -48,46 +55,68 @@
     HOME_CLASS_B2: '',
     HOME_CLASS_C: '',
   },
-  onShow() {
-    let that = this
+  onLoadLogin(options) {
+    // 宸茬粡鐧诲綍锛屽彲浠ヨ蛋渚濊禆token鐨勯�昏緫浜�
+    console.log('棣栭〉鐨刼nLoadLogin', options, `{"token":"${app.globalData.token}"}`);
+    this.initData()
     const member = wx.getStorageSync('member')
-    if (member && (member.authStatus == '1' || member.authStatus == '2')) {
-      getMemberInfo().then(res => {
+    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({
-          member: res.data
+          videoTop: res[0].top,
+          windowHeight: windowInfo.windowHeight
         })
       })
-    } else {
-      this.setData({
-        member
-      })
-    }
-    eventBus.on("reloadHome", () => {
+    }, 3000)
+  },
+  onShow() {
+    const member = wx.getStorageSync('member')
+    this.setData({
+      member
+    })
+    eventBus.once("reloadHome", () => {
       console.log('reloadHome');
       this.onLoad()
+      this.initData()
     })
   },
   onLoad(options) {
-    const member = wx.getStorageSync('member')
     this.initDictData()
-    setTimeout(() => {
-      this.initData()
-    }, 1200)
+    // this.initData()
   },
   changePath(e) {
     let index = e.currentTarget.dataset.type
+    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: that.data.testUrl
-            })
-          }
-        })
+        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':
@@ -96,9 +125,17 @@
         })
         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) {
@@ -122,16 +159,18 @@
   initData() {
     // 杞挱
     getHomeBanner().then(res => {
-      this.setData({
-        bannerList: res.data
-      })
+      if (res.data) {
+        this.setData({
+          bannerList: res.data
+        })
+      }
     })
     // 浜у搧瑙嗛
     getZhongTaiVideoPage({
       pageSize: 1,
       pageNum: 1
     }).then(res => {
-      if (res.data.records && res.data.records.length > 0) {
+      if (res.data && res.data.records && res.data.records.length > 0) {
         this.setData({
           productVideo: res.data.records
         })
@@ -148,7 +187,7 @@
       pageSize: 6,
       pageNum: 1
     }).then(res => {
-      if (res.data) {
+      if (res.data && res.data.records) {
         this.setData({
           consultList: res.data.records
         })
@@ -166,9 +205,12 @@
       code: 'WX_MINI_CONFIG',
       label: 'ZBOM_STYLE_TEST_URL'
     }).then(res => {
-      this.setData({
-        testUrl: res.data.code
-      })
+      if (res.data) {
+        this.setData({
+          testUrl: res.data.code
+        })
+        wx.setStorageSync('testUrl', res.data.code)
+      }
     })
     getDictData({
       code: 'WEIXIN_DEFAULT_IMGS',
@@ -210,14 +252,23 @@
   },
   videoClick(e) {
     const {
-      videourl
+      videourl,
+      id
     } = e.currentTarget.dataset
-    wx.previewMedia({
-      sources: [{
-        url: videourl,
-        type: 'video'
-      }]
+    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
@@ -226,9 +277,13 @@
     })
   },
   bannerbindload(e) {
-    const height = e.detail.height
+    const {
+      height,
+      width
+    } = e.detail
+    let activeHeight = height * 670 / width
     this.setData({
-      bannerImgHeight: height
+      bannerImgHeight: activeHeight
     })
   },
   consultbindload(e) {
@@ -238,18 +293,34 @@
     } = e.detail
     let activeHeight = height * 670 / width
     this.setData({
-      consultImgHeight: activeHeight
+      consultImgHeight: activeHeight + 100
     })
   },
   consultClick(e) {
-    const id = e.currentTarget.dataset.id
+    const item = e.currentTarget.dataset.id
     actionDo({
       actionType: 'view',
-      id: id
+      id: item.id
     })
-    wx.navigateTo({
-      url: '/pages/consult/detail?id=' + 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 {
@@ -275,7 +346,7 @@
       wx.navigateTo({
         url: '/pages/webView/index',
         success: function (res) {
-          res.eventChannel.emit('data', {
+          res.eventChannel.emit('acceptDataFromOpenerPage', {
             link: item.openContent || item.content
           });
         }
@@ -312,8 +383,66 @@
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
-
+  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({

--
Gitblit v1.9.3