From 7b950f425d01b74febcebb9a6506e1607c3a2a0f Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 06 八月 2024 09:44:21 +0800
Subject: [PATCH] ''

---
 wechat_jiaxuan/pages/productVideo/index.js |   48 +++++++++++++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/wechat_jiaxuan/pages/productVideo/index.js b/wechat_jiaxuan/pages/productVideo/index.js
index 61ab302..00bbf85 100644
--- a/wechat_jiaxuan/pages/productVideo/index.js
+++ b/wechat_jiaxuan/pages/productVideo/index.js
@@ -5,9 +5,14 @@
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
+    acVid: '',
+    viewIdList: [],
+    
+    activeIndex: -1,
+    activeParam: [],
+    tagCodes: [],
     videoContext:null,
     category: [],
-    tagCodes: '',
     videoUrl: '',
     showVideo: false,
     isShow:false,
@@ -34,7 +39,7 @@
   getList() {
     const { pageSize, pageNum, tagCodes } = this.data
     getZhongTaiVideoPage({
-      pageSize,pageNum, tagCodes: tagCodes ? [tagCodes] : null
+      pageSize,pageNum, tagCodes
     }).then(res => {
       this.setData({
         dataList: [...this.data.dataList, ...res.data.records],
@@ -50,30 +55,35 @@
     })
   },
   itemClick(e) {
-    const { videourl ,id} = e.currentTarget.dataset 
-    const { dataList } = this.data
+    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){
+      if(id === ite.id && index === -1){
         ite.viewCount += 1
+        viewIdList.push(id)
+        actionDo({
+          actionType: 'view',
+          id: id
+        })
+        this.setData({ viewIdList })
       }
     })
     this.setData({ dataList })
-    actionDo({
-      actionType: 'view',
-      id: id
-    })
-    let videoPlay = this.selectComponent('.videoPlay'); 
-    if(videoPlay){ 
-      videoPlay.startPlayVideo(videourl,this );
-    }
-    // this.startPlayVideo(videourl) 
-    // wx.previewMedia({
-    //   sources: [{ url: videourl, type: 'video' }]
-    // })
   },
   cateClick(e) {
-    const { code } = e.target.dataset
-    this.setData({ tagCodes: code })
+    const { code, index } = e.target.dataset
+    this.setData({ tagCodes: [code], activeIndex: index })
     this.setData({ total: 0, dataList: [], pageNum: 1 })
     this.getList()
   },

--
Gitblit v1.9.3