liukangdong
2024-08-05 00bf17838b496e6fcfed2e521f9c27f8f0e3e3c7
wechat_jiaxuan/pages/productVideo/index.js
@@ -1,15 +1,20 @@
import { getZhongTaiVideoPage, getCataLogTagList } from '../../api/index'
import { getZhongTaiVideoPage, actionDo, getCataLogTagList } from '../../api/index'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    acVid: '',
    viewIdList: [],
    videoContext:null,
    category: [],
    tagCodes: '',
    videoUrl: '',
    showVideo: false,
    isShow:false,
    curVideoSrc:'',
    dataList: [],
    total: 0,
    pageSize: 10,
@@ -48,10 +53,31 @@
    })
  },
  itemClick(e) {
    const { videourl } = e.currentTarget.dataset
    wx.previewMedia({
      sources: [{ url: videourl, type: 'video' }]
    const { id } = e.currentTarget.dataset.item
    const { dataList, acVid, viewIdList } = this.data
    const index = viewIdList.findIndex(i => i === id)
    if(acVid){
      if(id != acVid){
        wx.createVideoContext(acVid).pause()
        wx.createVideoContext(id).play()
        this.setData({ acVid: id })
      }
    }else{
      this.setData({ acVid: id })
      wx.createVideoContext(id).play()
    }
    dataList.forEach(ite => {
      if(id === ite.id && index === -1){
        ite.viewCount += 1
        viewIdList.push(id)
        actionDo({
          actionType: 'view',
          id: id
        })
        this.setData({ viewIdList })
      }
    })
    this.setData({ dataList })
  },
  cateClick(e) {
    const { code } = e.target.dataset
@@ -65,7 +91,8 @@
  },
  onLoad(options) {
    this.getTagList()
    this.getList()
    this.getList()
    this.videoContext = wx.createVideoContext('myVideo')
  },
  /**
@@ -107,5 +134,18 @@
   */
  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()
    }
  }
})