| | |
| | | serviceHeight: 0, |
| | | serviceList: [], |
| | | |
| | | videoTop: 0, |
| | | windowHeight: 0, |
| | | videoPlay: true, |
| | | |
| | | bannerSwiperOption: { |
| | | indicatorDots: true, |
| | | vertical: false, |
| | |
| | | }, |
| | | 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() { |
| | | // 每日上新 |
| | |
| | | }) |
| | | }) |
| | | }, |
| | | 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', |