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 |   95 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 73 insertions(+), 22 deletions(-)

diff --git a/wechat_jiaxuan/pages/productVideo/index.js b/wechat_jiaxuan/pages/productVideo/index.js
index 640bda1..53f848c 100644
--- a/wechat_jiaxuan/pages/productVideo/index.js
+++ b/wechat_jiaxuan/pages/productVideo/index.js
@@ -1,44 +1,89 @@
-import { getZhongTaiVideoPage, getCataLogTagList } from '../../api/index'
+import { getZhongTaiVideoPage, actionDo, getCataLogTagList } from '../../api/index'
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    category: [],
-    activeCate: '',
-    seActiveCate: '',
+    acVid: '',
+    viewIdList: [],
 
+    videoContext:null,
+    category: [],
+    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 { 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 { 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 +91,8 @@
   },
   onLoad(options) {
     this.getTagList()
-    this.getList()
+    this.getList() 
+    this.videoContext = wx.createVideoContext('myVideo') 
   },
 
   /**
@@ -83,18 +129,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() 
+    }
   }
 })
\ No newline at end of file

--
Gitblit v1.9.3