liukangdong
2024-08-05 00bf17838b496e6fcfed2e521f9c27f8f0e3e3c7
wechat_staff/pages/productVideo/index.js
@@ -1,4 +1,4 @@
import { getZhongTaiVideoPage, getCataLogTagList ,refreshEnjoy} from '../../api/index'
import { getZhongTaiVideoPage,  actionDo, getCataLogTagList ,refreshEnjoy} from '../../api/index'
Page({
  /**
@@ -7,6 +7,8 @@
  data: {
    category: [],
    tagCodes: '',
    acVid:'',
    viewIdList: [],
    dataList: [],
    total: 0,
@@ -46,14 +48,31 @@
    })
  },
  itemClick(e) {
    const { videourl } = e.currentTarget.dataset
    let videoPlay = this.selectComponent('.videoPlay');
    if(videoPlay){
      videoPlay.startPlayVideo(videourl,this );
    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()
    }
    // wx.previewMedia({
    //   sources: [{ url: videourl, type: 'video' }]
    // })
    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