From 1efd950a5b40ef3bf37a8afd738ff574f68cea35 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 09 四月 2024 10:39:47 +0800
Subject: [PATCH] 详情页底部按钮显示调整

---
 packageBookService/pages/bookServices/detail/components/tree/index.js |   60 +++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index 7aba5ed..d946ea5 100644
--- a/packageBookService/pages/bookServices/detail/components/tree/index.js
+++ b/packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -41,6 +41,9 @@
       type: Boolean,
       value: false,
     },
+    checkAllState: {
+      type: Boolean,
+    },
   },
   data: {
     sonPurchaseSaleMethodId: "",
@@ -52,10 +55,7 @@
     shoppingCart: true,
     stop: false,
   },
-  ready() {
-    this.setData({});
-    console.log("鍑嗗");
-  },
+  ready() {},
 
   onLoad() {
     this.setData({
@@ -67,14 +67,15 @@
     );
   },
   observers: {
-    openIds: function (newValue) {
-      // var myEventDetail = {
-      // }
-      // var myEventOption = {
-      //   bubbles: true,
-      //   composed: true
-      // }
-      // this.triggerEvent('handleTree', myEventDetail, myEventOption)
+    treeList: function (newValue) {
+      const list = [];
+      let checked = "";
+      this.properties.treeList.forEach((item) => {
+        if (item.children && item.children.length > 0) {
+          list.push(...this.flattenTree([item]));
+        }
+      });
+      const flag = list.findIndex((item) => item.checked == true);
     },
   },
 
@@ -163,7 +164,10 @@
         ) {
           return wx.showToast({
             icon: "error",
-            title: "璇峰厛璐拱璇ヨ祫婧�",
+            title:
+              item.saleMethod[0].Price > 0
+                ? "璇峰厛璐拱璇ヨ祫婧�"
+                : "璇峰厛鐐瑰嚮棰嗗彇鏌ョ湅鎸夐挳",
           });
         }
         wx.navigateTo({
@@ -305,16 +309,9 @@
         ids.push(item.id);
         checked = item.checked;
       });
-      const flag =
-        list.findIndex((item) => item.checked == false) > -1 ? true : false;
-        var myEventDetail = {
-          value:flag,
-        }; // detail瀵硅薄锛屾彁渚涚粰浜嬩欢鐩戝惉鍑芥暟
-        var myEventOption = {
-          bubbles: true,
-          composed: true,
-        }; // 瑙﹀彂浜嬩欢鐨勯�夐」
-        this.triggerEvent('changeCheckAll',myEventDetail,myEventOption)
+      // const flag =
+      //   list.findIndex((item) => item.checked == false) > -1 ? true : false;
+      const flag = this.properties.checkAllState;
       const updataList = this.findAndUpdateItemsByIds(
         this.properties.treeList,
         ids,
@@ -329,12 +326,19 @@
       this.setData({
         treeList: updataList,
       });
+      var myEventDetail = {
+        value: !flag,
+      }; // detail瀵硅薄锛屾彁渚涚粰浜嬩欢鐩戝惉鍑芥暟
+      var myEventOption = {
+        bubbles: true,
+        composed: true,
+      }; // 瑙﹀彂浜嬩欢鐨勯�夐」
+      this.triggerEvent("changeCheckAll", myEventDetail, myEventOption);
     },
 
     // 绔犺妭鍕鹃��
     checkResourceTitle(e) {
       const flag = e.detail.checked;
-      debugger;
       // 杩欎釜鏃跺�檆hecked鐨勫�兼槸fals
       let checkResourceTitleList = [];
       const item = e.currentTarget.dataset.item;
@@ -344,7 +348,6 @@
       list.forEach((item) => {
         ids.push(item.id);
       });
-      // console.log(list, 'list789');
       const updatedTreeList = this.findAndUpdateItemsByIds(
         this.properties.treeList,
         ids,
@@ -422,6 +425,8 @@
       });
       if (shoppingCartGetId.includes(saleMethodId)) {
         console.log(111);
+        // this.data.updateShoppingCartHidden();
+        // this.data.updateCloudLearning();
 
         wx.showToast({
           icon: "error",
@@ -448,6 +453,11 @@
         });
       }
     },
+    sadd() {
+      this.triggerEvent("updateShoppingCartHidden");
+      this.triggerEvent("updateCloudLearning");
+      console.log(789);
+    },
   },
 
   catchtap() {},

--
Gitblit v1.9.1