From d41f1f707dc643b726a42b9d2a63b186dd9e4f28 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 06 八月 2024 16:12:38 +0800
Subject: [PATCH] ll

---
 wechat_jiaxuan/pages/productVideo/index.js |   74 ++++++++++++++++++++++++++++++++++---
 1 files changed, 68 insertions(+), 6 deletions(-)

diff --git a/wechat_jiaxuan/pages/productVideo/index.js b/wechat_jiaxuan/pages/productVideo/index.js
index 00bbf85..084b2f1 100644
--- a/wechat_jiaxuan/pages/productVideo/index.js
+++ b/wechat_jiaxuan/pages/productVideo/index.js
@@ -11,6 +11,7 @@
     activeIndex: -1,
     activeParam: [],
     tagCodes: [],
+
     videoContext:null,
     category: [],
     videoUrl: '',
@@ -22,6 +23,58 @@
     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('瑙﹀簳浜嬩欢');
@@ -41,17 +94,22 @@
     getZhongTaiVideoPage({
       pageSize,pageNum, tagCodes
     }).then(res => {
-      this.setData({
-        dataList: [...this.data.dataList, ...res.data.records],
-        total: res.data.total
-      })
+      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 => {
-      this.setData({ category: res.data })
+      if(res.data){
+        this.setData({ category: [...res.data] })
+      }
+      
     })
   },
   itemClick(e) {
@@ -83,7 +141,11 @@
   },
   cateClick(e) {
     const { code, index } = e.target.dataset
-    this.setData({ tagCodes: [code], activeIndex: index })
+    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()
   },

--
Gitblit v1.9.3