jiangping
2024-09-27 04b4bddaac0a222760113899568d20b45af701f4
wechat_jiaxuan/pages/index/index.js
@@ -12,6 +12,7 @@
  eventBus
} from '../../utils/eventBus'
const app = getApp()
var touchDot = 0; //触摸时的原点
Page({
  /**
@@ -21,6 +22,8 @@
    // 顶部nav
    topHeadStyle: 1,
    top: 0,
    open: false,
    desc: true,
    font_color: '#ffffff',
    ZSZXCata: {},
@@ -56,6 +59,10 @@
    // 已经登录,可以走依赖token的逻辑了
    console.log('首页的onLoadLogin', options, `{"token":"${app.globalData.token}"}`);
    this.initData()
    const member = wx.getStorageSync('member')
    this.setData({
      member
    })
  },
  onReady() {
    const windowInfo = wx.getWindowInfo()
@@ -66,16 +73,18 @@
        rect.bottom // 节点的下边界坐标
      }).exec(res => {
        console.log(windowInfo.windowHeight)
        this.setData({ videoTop: res[0].top,windowHeight: windowInfo.windowHeight})
        this.setData({
          videoTop: res[0].top,
          windowHeight: windowInfo.windowHeight
        })
      })
    }, 2000)
    }, 3000)
  },
  onShow() {
    const member = wx.getStorageSync('member')
    this.setData({
      member
    })
    eventBus.once("reloadHome", () => {
      console.log('reloadHome');
      this.onLoad()
@@ -84,7 +93,7 @@
  },
  onLoad(options) {
    this.initDictData()
    this.initData()
    // this.initData()
  },
  changePath(e) {
    let index = e.currentTarget.dataset.type
@@ -103,6 +112,7 @@
            }
          })
        } else {
          wx.setStorageSync('tempPath', '/pages/webView/index')
          wx.navigateTo({
            url: '/pages/auth/auth',
          })
@@ -120,6 +130,7 @@
            url: '/pages/design/design'
          })
        } else {
          wx.setStorageSync('tempPath', '/pages/design/design')
          wx.navigateTo({
            url: '/pages/auth/auth',
          })
@@ -148,16 +159,18 @@
  initData() {
    // 轮播
    getHomeBanner().then(res => {
      this.setData({
        bannerList: res.data
      })
      if (res.data) {
        this.setData({
          bannerList: res.data
        })
      }
    })
    // 产品视频
    getZhongTaiVideoPage({
      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
        })
@@ -174,7 +187,7 @@
      pageSize: 6,
      pageNum: 1
    }).then(res => {
      if (res.data) {
      if (res.data && res.data.records) {
        this.setData({
          consultList: res.data.records
        })
@@ -192,9 +205,12 @@
      code: 'WX_MINI_CONFIG',
      label: 'ZBOM_STYLE_TEST_URL'
    }).then(res => {
      this.setData({
        testUrl: res.data.code
      })
      if (res.data) {
        this.setData({
          testUrl: res.data.code
        })
        wx.setStorageSync('testUrl', res.data.code)
      }
    })
    getDictData({
      code: 'WEIXIN_DEFAULT_IMGS',
@@ -368,19 +384,65 @@
   * 生命周期函数--监听页面初次渲染完成
   */
  bindVideoPlay() {
    const { id } = this.data.productVideo[0]
    const {
      id
    } = this.data.productVideo[0]
    actionDo({
      actionType: 'view',
      id
    })
  },
  hdBtn() {
    this.setData({
      showWhiteHead: true,
      open: true,
      font_color: "#000000",
      sty: '',
      topHeadStyle: 1,
      desc: false
    })
  },
  touchStart: function (e) {
    touchDot = e.touches[0].pageY;
  },
  touchMove: function (e) {
    var touchMove = e.touches[0].pageY;
    if (touchMove - touchDot <= 0 && this.data.top <= 1 && this.data.desc) {
      this.setData({
        showWhiteHead: true,
        open: false,
        desc: false
      })
      setTimeout(() => {
        this.setData({
          open: true,
          sty: ''
        })
      }, 1000)
    }
    if (touchMove - touchDot >= 50 && this.data.top <= 1 && !this.data.desc) {
      this.setData({
        showWhiteHead: false,
        open: false,
        desc: true,
        sty: 'overflow: hidden;'
      })
    }
  },
  onPageScroll(e) {
    const { videoTop, windowHeight, videoPlay } = this.data
    if(e.scrollTop - 100 > videoTop - (windowHeight / 2) && videoPlay ){
      this.setData({ videoPlay: false })
    const {
      videoTop,
      windowHeight,
      videoPlay
    } = this.data
    if (e.scrollTop + 100 > videoTop - (windowHeight / 2) && videoPlay) {
      this.setData({
        videoPlay: false
      })
      let videoplay = wx.createVideoContext('myvideo', this)
      videoplay.play();
    }
    let scrollTop = e.scrollTop / 100
    if (scrollTop <= 0.1) {
      this.setData({