From e6e0218a1abd7395d00ade401c6ea6a02e7c3ece Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期四, 01 八月 2024 18:20:28 +0800
Subject: [PATCH] lll

---
 wechat_staff/pages/index/index.js |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/wechat_staff/pages/index/index.js b/wechat_staff/pages/index/index.js
index 39f047c..571385e 100644
--- a/wechat_staff/pages/index/index.js
+++ b/wechat_staff/pages/index/index.js
@@ -19,6 +19,10 @@
     serviceHeight: 0,
     serviceList: [],
 
+    videoTop: 0,
+    windowHeight: 0,
+    videoPlay: true,
+
     bannerSwiperOption: {
       indicatorDots: true,
       vertical: false,
@@ -36,6 +40,20 @@
   },
   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() {
     // 姣忔棩涓婃柊
@@ -102,6 +120,21 @@
       })
     })
   },
+  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',

--
Gitblit v1.9.3