jiangping
2024-07-29 d9a89d83c2048a964f16ca179feb2b7f21b9d33a
wechat_jiaxuan/pages/productVideo/index.js
@@ -5,40 +5,68 @@
   * 页面的初始数据
   */
  data: {
    videoContext:null,
    category: [],
    activeCate: '',
    seActiveCate: '',
    tagCodes: '',
    videoUrl: '',
    showVideo: false,
    isShow:false,
    curVideoSrc:'',
    dataList: [],
    total: 0,
    pageSize: 10,
    pageNum: 1,
  },
  onReachBottom() {
    console.log('触底事件');
    const { total, dataList, pageNum } = this.data
    if(total > dataList.length){
      this.setData({ pageNum: pageNum + 1 })
      this.getList()
    }else{
      wx.showToast({
        title: '暂无更多数据',
        icon: 'none'
      })
    }
  },
  getList() {
    const { pageSize, pageNum } = this.data
    const { pageSize, pageNum, tagCodes } = this.data
    getZhongTaiVideoPage({
      pageSize,pageNum
      pageSize,pageNum, tagCodes: tagCodes ? [tagCodes] : null
    }).then(res => {
      this.setData({ dataList: res.data.records })
      this.setData({
        dataList: [...this.data.dataList, ...res.data.records],
        total: res.data.total
      })
    })
  },
  getTagList() {
    getCataLogTagList({
      catalogCode: 'video_rec'
    }).then(res => {
      this.setData({ category: res.data.valueVos })
      this.setData({ category: res.data })
    })
  },
  itemClick(e) {
    const { videourl } = e.currentTarget.dataset
    wx.previewMedia({
      sources: [{ url: videourl, type: 'video' }]
    })
    const { videourl } = e.currentTarget.dataset
    let videoPlay = this.selectComponent('.videoPlay');
    if(videoPlay){
      videoPlay.startPlayVideo(videourl,this );
    }
    // this.startPlayVideo(videourl)
    // wx.previewMedia({
    //   sources: [{ url: videourl, type: 'video' }]
    // })
  },
  cateClick(e) {
    const { index } = e.target.dataset
    console.log(index);
    const { code } = e.target.dataset
    this.setData({ tagCodes: code })
    this.setData({ total: 0, dataList: [], pageNum: 1 })
    this.getList()
  },
  seCateClick(e) {
    const { index } = e.target.dataset
@@ -46,7 +74,8 @@
  },
  onLoad(options) {
    this.getTagList()
    this.getList()
    this.getList()
    this.videoContext = wx.createVideoContext('myVideo')
  },
  /**
@@ -83,18 +112,23 @@
  onPullDownRefresh() {
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
  },
  startPlayVideo(videourl){
    this.setData({isShow:true, curVideoSrc:videourl})
    console.log(videourl)
    this.videoContext.requestFullScreen({
      // direction: 0
    });
  },
  onClose(){
    this.setData({isShow:false})
    if(this.videoContext){
      this.videoContext.exitFullScreen()
    }
  }
})