lll
liukangdong
2024-08-01 e6e0218a1abd7395d00ade401c6ea6a02e7c3ece
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',