From 7dc29ed74ebaa8a0e66f68264d9a13f95dc3af21 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 02 八月 2024 11:09:06 +0800
Subject: [PATCH] aa

---
 wechat_jiaxuan/pages/index/index.js |  176 ++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 126 insertions(+), 50 deletions(-)

diff --git a/wechat_jiaxuan/pages/index/index.js b/wechat_jiaxuan/pages/index/index.js
index a4274e7..710f6ed 100644
--- a/wechat_jiaxuan/pages/index/index.js
+++ b/wechat_jiaxuan/pages/index/index.js
@@ -8,6 +8,10 @@
   getZhongTaiVideoPage,
   getZhongTaiProductNewsPage
 } from '../../api/index'
+import {
+  eventBus
+} from '../../utils/eventBus'
+const app = getApp()
 Page({
 
   /**
@@ -29,6 +33,10 @@
     consultList: [],
     consultImgHeight: 0,
 
+    videoTop: 0,
+    windowHeight: 0,
+    videoPlay: true,
+
     productVideo: {},
     bannerSwiperOption: {
       indicatorDots: true,
@@ -44,45 +52,62 @@
     HOME_CLASS_B2: '',
     HOME_CLASS_C: '',
   },
+  onLoadLogin(options) {
+    // 宸茬粡鐧诲綍锛屽彲浠ヨ蛋渚濊禆token鐨勯�昏緫浜�
+    console.log('棣栭〉鐨刼nLoadLogin', options, `{"token":"${app.globalData.token}"}`);
+    this.initData()
+  },
+  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})
+      })
+    }, 2000)
+  },
   onShow() {
     const member = wx.getStorageSync('member')
-    if (member && (member.authStatus == '1' || member.authStatus == '2')) {
-      getMemberInfo().then(res => {
-        this.setData({
-          member: res.data
-        })
-      })
-    } else {
-      this.setData({
-        member
-      })
-    }
+    this.setData({
+      member
+    })
+
+    eventBus.once("reloadHome", () => {
+      console.log('reloadHome');
+      this.onLoad()
+      this.initData()
+    })
   },
   onLoad(options) {
-    const member = wx.getStorageSync('member')
+    console.log(options)
     this.initDictData()
-    if (member && member.token) {
-      this.initData()
-    } else {
-      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.navigateTo({
+            url: '/pages/auth/auth',
+          })
+        }
         break;
 
       case '1':
@@ -90,11 +115,17 @@
           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.navigateTo({
+            url: '/pages/auth/auth',
+          })
+        }
+
         // wx.navigateTo({
         //   url: '/pages/wonderful_activity/index',
         //   success: function(res) {
@@ -206,14 +237,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
@@ -222,9 +262,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) {
@@ -234,18 +278,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 {
@@ -253,7 +313,7 @@
     } = e.currentTarget.dataset
     const item = e.currentTarget.dataset.item
     console.log('item', item);
-    if(item.openType){
+    if (item.openType) {
       actionDo({
         actionType: 'view',
         id: item.id
@@ -269,7 +329,12 @@
     }
     if (item.openType == 'link') {
       wx.navigateTo({
-        url: '/pages/webView/index?link=' + item.openContent,
+        url: '/pages/webView/index',
+        success: function (res) {
+          res.eventChannel.emit('acceptDataFromOpenerPage', {
+            link: item.openContent || item.content
+          });
+        }
       })
     }
     if (item.openType == 'page') {
@@ -294,7 +359,6 @@
         url: `/pages/kefu/service?title=${title}&id=${id}`,
       })
     }
-
   },
   jumpProConsult() {
     wx.switchTab({
@@ -304,8 +368,20 @@
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
    */
-
+  bindVideoPlay() {
+    const { id } = this.data.productVideo[0]
+    actionDo({
+      actionType: 'view',
+      id
+    })
+  },
   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