From 2c08a98f7e85ec7c9376f27a7933e75e44d672f7 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 27 八月 2024 15:52:59 +0800
Subject: [PATCH] ll

---
 wechat_jiaxuan/pages/productVideo/index.js |  179 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 156 insertions(+), 23 deletions(-)

diff --git a/wechat_jiaxuan/pages/productVideo/index.js b/wechat_jiaxuan/pages/productVideo/index.js
index 22a8ed7..084b2f1 100644
--- a/wechat_jiaxuan/pages/productVideo/index.js
+++ b/wechat_jiaxuan/pages/productVideo/index.js
@@ -1,34 +1,162 @@
-// pages/consult/consult.js
+import { getZhongTaiVideoPage, actionDo, getCataLogTagList } from '../../api/index'
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    category: ['鏂板搧涓婂競', '涓撳埄璇佷功', '澶х墝鎺堟潈','鏂板搧涓婂競', '涓撳埄璇佷功', '澶х墝鎺堟潈'],
-    secondCategory: ['绾у垎绫�','绾у垎绫�','绾у垎绫�','绾у垎绫�','绾у垎绫�','绾у垎绫�'],
-    activeCate: '',
-    seActiveCate: '',
-    dataList: []
-  },
+    acVid: '',
+    viewIdList: [],
+    
+    activeIndex: -1,
+    activeParam: [],
+    tagCodes: [],
 
-  itemClick(e) {
-    const { id } = e.target.dataset
-    console.log(e.target.dataset);
-    wx.navigateTo({
-      url: '/pages/consult/detail',
+    videoContext:null,
+    category: [],
+    videoUrl: '',
+    showVideo: false,
+    isShow:false,
+    curVideoSrc:'',
+    dataList: [],
+    total: 0,
+    pageSize: 10,
+    pageNum: 1,
+
+  },
+  changeShowParams(e) {
+    const { category } = this.data
+    const activeIndex = e.currentTarget.dataset.index
+    if (activeIndex === this.data.activeIndex) {
+      this.setData({ activeIndex: -1, activeParam: [] })
+    } else {
+      this.setData({
+        activeIndex,
+        activeParam: category[activeIndex].valueVos
+      })
+    }
+  },
+  cancelParam() {
+    const { category } = this.data
+    category.forEach(item => { 
+      item.tempParamIndex = item.paramIndex
+      item.tempParamName =   item.paramName
+      item.tempParamCode =  item.paramCode 
+    })
+    this.setData({ activeParam: [],activeIndex: -1 ,category}) 
+  },
+  subParam() {
+    const { category } = this.data
+    var codes = []
+    category.forEach(item => {
+      item.paramIndex =  item.tempParamIndex 
+      item.paramName = item.tempParamName  
+      item.paramCode = item.tempParamCode
+      if( item.paramIndex>-1 && item.tempParamCode){
+        codes.push( item.tempParamCode) 
+      } 
+    })  
+    this.setData({tagCodes:codes}) 
+    this.setData({ pageNum: 1, activeParam: [] ,activeIndex: -1, dataList: [], total: 0 })
+    this.getList()
+  },
+  tagClick(e) {
+    const code = e.currentTarget.dataset.code
+    const paramIndex = e.currentTarget.dataset.index
+    const { category, tagCodes, activeParam, activeIndex } = this.data
+    const index = tagCodes.indexOf(code)
+    if ( category[activeIndex].tempParamIndex==null || category[activeIndex].tempParamIndex != paramIndex) {
+      category[activeIndex].tempParamIndex = paramIndex
+      category[activeIndex].tempParamCode = code
+      category[activeIndex].tempParamName = activeParam[paramIndex].labelValueName
+    } else {
+      category[activeIndex].tempParamIndex = -1
+      category[activeIndex].tempParamCode = ''
+      category[activeIndex].tempParamName = ''
+    }
+    this.setData({ category })
+  },
+  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, tagCodes } = this.data
+    getZhongTaiVideoPage({
+      pageSize,pageNum, tagCodes
+    }).then(res => {
+      if(res.data && res.data.records){
+        this.setData({
+          dataList: [...this.data.dataList, ...res.data.records],
+          total: res.data.total
+        })
+      }
     })
   },
+  getTagList() {
+    getCataLogTagList({
+      catalogCode: 'video_rec'
+    }).then(res => {
+      if(res.data){
+        this.setData({ category: [...res.data] })
+      }
+      
+    })
+  },
+  itemClick(e) {
+    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, index } = e.target.dataset
+    if(this.data.activeIndex === index){
+      this.setData({ tagCodes: [], activeIndex: -1 })
+    }else{
+      this.setData({ tagCodes: [code], activeIndex: index })
+    }
+    this.setData({ total: 0, dataList: [], pageNum: 1 })
+    this.getList()
   },
   seCateClick(e) {
     const { index } = e.target.dataset
     console.log(index);
   },
   onLoad(options) {
-
+    this.getTagList()
+    this.getList() 
+    this.videoContext = wx.createVideoContext('myVideo') 
   },
 
   /**
@@ -65,18 +193,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