From c3086cda662e2b908cf96b6b3ff599713eb924d6 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期一, 02 九月 2024 16:59:16 +0800
Subject: [PATCH] gongneng

---
 pages/digitalCourses/index.js |   99 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 67 insertions(+), 32 deletions(-)

diff --git a/pages/digitalCourses/index.js b/pages/digitalCourses/index.js
index 0f69f19..9175e6e 100644
--- a/pages/digitalCourses/index.js
+++ b/pages/digitalCourses/index.js
@@ -17,9 +17,35 @@
     tabList: [],
     courseList: [],
     searchValue: '',
+    active: 0,
     activeItem: null,
     loading: false,
-    shoppingCartGetId: []
+    shoppingCartGetId: [],
+    sorter: {
+      value: "*",
+      options: [{
+          value: "*",
+          label: "榛樿鎺掑簭",
+        },
+        {
+          value: "nameAsc",
+          label: "鐐瑰嚮閲忔搴�",
+        },
+        {
+          value: "nameDesc",
+          label: "鐐瑰嚮閲忓�掑簭",
+        },
+        {
+          value: "timeAsc",
+          label: "鍒涘缓鏃堕棿姝e簭",
+        },
+        {
+          value: "timeDesc",
+          label: "鍒涘缓鏃堕棿鍊掑簭",
+        },
+      ],
+    },
+    sortActive: ''
   },
 
   /**
@@ -34,6 +60,11 @@
       barHeight: systInfo.statusBarHeight,
       navBarHeight: navBarHeight,
     });
+    if (options.courseTypeActive) {
+      this.setData({
+        active: JSON.parse(options.courseTypeActive),
+      });
+    }
     this.getCourseTypeListList()
     this.getShoppingCartList()
   },
@@ -96,7 +127,6 @@
     wx.navigateBack();
   },
   getCourseTypeListList() {
-
     this.setData({
       loading: true
     })
@@ -119,21 +149,25 @@
     app.MG.store.getStoreChannelList(data).then((res) => {
       // 鍘婚櫎鏁扮粍鏈�鍚庝竴涓厓绱�
       const newData = res.datas.slice(0, res.datas.length - 1)
-
-
-
       this.setData({
         tabList: newData,
-        activeItem: newData[0],
         loading: false
       })
-      this.getCourseList(newData[0])
+      if (this.data.active) {
+        this.getCourseList(newData[this.data.active])
+      } else {
+        this.setData({
+          activeItem: newData[0],
+        })
+        this.getCourseList(newData[0])
+      }
+
     })
   },
 
   getCourseList(item) {
     let searchObj = {}
-    // let sort = {}
+    let sort = {}
     // // 鎼滅储妗�
     if (this.data.searchValue) {
       searchObj = {
@@ -142,23 +176,24 @@
       }
     }
 
-    // if (timeSort.value) {
-    //     sort = {
-    //         CreateDate: timeSort.value || 'Desc'
-
-    //     }
-    // } else {
-    //     sort = {
-    //         ViewCount: nameSort.value || 'Desc'
-    //     }
+    if (this.data.sortActive == 'nameAsc') {
+      sort = {
+        ViewCount: 'Asc'
+      }
+    } else if (this.data.sortActive == 'nameDesc') {
+      sort = {
+        ViewCount: 'Desc'
+      }
+    } else if (this.data.sortActive == 'timeAsc') {
+      sort = {
+        CreateDate: 'Asc'
+      }
+    } else if (this.data.sortActive == 'timeDesc') {
+      sort = {
+        CreateDate: 'Desc'
+      }
+    }
     //     // 缁勫悎鐨勫啓娉� 瑕佹煡璇㈢殑瀛楁:鍗囧簭鍜岄檷搴�
-
-    //     // Name: "Desc"
-    //     //涓�鑸殑鎺掑簭浼犳硶
-    //     // type: "Asc",
-    //     // field: "CreateDate",
-    // }
-    // courseList.value = [];
     const obj = {
       storeInfo: app.config.goodsStore,
       path: item.pathList + '\\' + item.id,
@@ -173,7 +208,7 @@
         value: 'Normal',
         field: 'state'
       }],
-      // sort: sort,
+      sort: sort,
       fields: {
         courseLeader: [],
         affiliatedUnit: [],
@@ -184,7 +219,6 @@
       }
     }
     app.MG.store.getProductList(obj).then((res) => {
-      console.log(res, '7895')
       res.datas.forEach(item => {
         item.price = item.price.toFixed(2)
       })
@@ -193,21 +227,22 @@
         courseList: res.datas
       })
 
-      console.log(this.data.courseList);
-
     })
   },
   searchBook() {
-    console.log(this.data.searchValue);
     this.getCourseList(this.data.activeItem)
   },
+  onSort(e) {
+    this.setData({
+      "sortActive": e.detail.value,
+    });
+    console.log(e)
+    this.getCourseList(this.data.activeItem);
+  },
   courseDetail(e) {
-    console.log(e);
     const item = e.currentTarget.dataset.item
-
     setNewView('productId', item.id)
     this.getCourseTypeListList()
-
     wx.navigateTo({
       url: '/pages/digitalCourses/digitalCoursesDetails/index?id=' + item.id,
     })

--
Gitblit v1.9.1