liukangdong
2024-09-29 b2d360d9113b6955287108ca9e90d76a1f3c1419
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,24 @@
  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 => {
        this.setData({ videoTop: res[0].top,windowHeight: windowInfo.windowHeight})
      })
    }, 2000)
  },
  initData() {
    // 每日上新
@@ -42,7 +59,7 @@
      fileType: '0'
    }).then(res => {
      this.setData({
        DailyUpdates: res.data
        DailyUpdates: res.data || {}
      })
    })
    // 产品视频
@@ -50,7 +67,7 @@
      pageSize: 1,
      pageNum: 1
    }).then(res => {
      if (res.data.records && res.data.records.length > 0) {
      if (res.data && res.data.records && res.data.records.length > 0) {
        this.setData({
          productVideo: res.data.records
        })
@@ -101,10 +118,39 @@
      })
    })
  },
  bindVideoPlay() {
    const { id } = this.data.productVideo[0]
    actionDo({
      actionType: 'view',
      id
    })
  },
  onPageScroll(e) {
    const { videoTop, windowHeight, videoPlay } = this.data
    if(e.scrollTop + 60 > 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 +161,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 {