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_staff/pages/index/index.js |   72 +++++++++++++++++++++++++++++++-----
 1 files changed, 62 insertions(+), 10 deletions(-)

diff --git a/wechat_staff/pages/index/index.js b/wechat_staff/pages/index/index.js
index 3952d1c..571385e 100644
--- a/wechat_staff/pages/index/index.js
+++ b/wechat_staff/pages/index/index.js
@@ -6,6 +6,8 @@
   getCustomizedNewsList,
   newsPage
 } from '../../api/index'
+const { HYEventBus } = require('hy-event-store')
+const eventBus = new HYEventBus()
 Page({
   data: {
     searchValue: '',
@@ -16,6 +18,10 @@
     everydayTop: ['../../static/ic_top1@2x.png', '../../static/ic_top2@2x.png', '../../static/ic_top3@2x.png'],
     serviceHeight: 0,
     serviceList: [],
+
+    videoTop: 0,
+    windowHeight: 0,
+    videoPlay: true,
 
     bannerSwiperOption: {
       indicatorDots: true,
@@ -28,13 +34,26 @@
   onLoad() {
     const res = wx.getMenuButtonBoundingClientRect()
     this.setData({
-      clientHeight: res.height
-    })
-    this.setData({
+      clientHeight: res.height,
       clientTop: res.top
     })
-
+  },
+  onShow() {
     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('res', res);
+        console.log(windowInfo.windowHeight)
+        this.setData({ videoTop: res[0].top,windowHeight: windowInfo.windowHeight})
+      })
+    }, 2000)
   },
   initData() {
     // 姣忔棩涓婃柊
@@ -101,10 +120,39 @@
       })
     })
   },
+  bindVideoPlay() {
+    const { id } = this.data.productVideo[0]
+    actionDo({
+      actionType: 'view',
+      id
+    })
+  },
+  onPageScroll(e) {
+    const { videoTop, windowHeight, videoPlay } = this.data
+    if(e.scrollTop > videoTop - (windowHeight / 2) && videoPlay ){
+      this.setData({ videoPlay: false })
+      let videoplay = wx.createVideoContext('myvideo', this)
+      videoplay.play();
+    }
+  },
   promotionClick() {
     wx.navigateTo({
       url: '/pages/promotion/index',
     })
+  },
+  funClick(e){
+    const i = e.currentTarget.dataset.i
+    let map = ['product_intro', 'whole_case', 'real_case'] 
+    if(i == 3){
+      wx.navigateTo({
+        url: '/pages/consult/consult',
+      })
+    }else{
+      wx.setStorageSync('discoverKey', map[i])
+      wx.switchTab({
+        url: '/pages/discover/discover',
+      })
+    }
   },
   jumpProVideo() {
     wx.navigateTo({
@@ -115,12 +163,16 @@
     const {
       videourl
     } = e.currentTarget.dataset
-    wx.previewMedia({
-      sources: [{
-        url: videourl,
-        type: 'video'
-      }]
-    })
+    let videoPlay = this.selectComponent('.videoPlay'); 
+    if(videoPlay){ 
+      videoPlay.startPlayVideo(videourl,this );
+    }
+    // wx.previewMedia({
+    //   sources: [{
+    //     url: videourl,
+    //     type: 'video'
+    //   }]
+    // })
   },
   seriveClick(e) {
     const {

--
Gitblit v1.9.3