From 00bf17838b496e6fcfed2e521f9c27f8f0e3e3c7 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期一, 05 八月 2024 18:38:20 +0800
Subject: [PATCH] ‘’

---
 wechat_jiaxuan/pages/productVideo/index.js |   40 +++++++++++++++++++++++++++++++---------
 1 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/wechat_jiaxuan/pages/productVideo/index.js b/wechat_jiaxuan/pages/productVideo/index.js
index 3915e21..53f848c 100644
--- a/wechat_jiaxuan/pages/productVideo/index.js
+++ b/wechat_jiaxuan/pages/productVideo/index.js
@@ -1,10 +1,13 @@
-import { getZhongTaiVideoPage, getCataLogTagList } from '../../api/index'
+import { getZhongTaiVideoPage, actionDo, getCataLogTagList } from '../../api/index'
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
+    acVid: '',
+    viewIdList: [],
+
     videoContext:null,
     category: [],
     tagCodes: '',
@@ -50,12 +53,31 @@
     })
   },
   itemClick(e) {
-    const { videourl } = e.currentTarget.dataset 
-    this.startPlayVideo(videourl)
-
-    // 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
@@ -69,8 +91,8 @@
   },
   onLoad(options) {
     this.getTagList()
-    this.getList()
-    this.videoContext = wx.createVideoContext('myVideo')
+    this.getList() 
+    this.videoContext = wx.createVideoContext('myVideo') 
   },
 
   /**

--
Gitblit v1.9.3