From 3b22db15cfc9f3704c4654df9d694ebfc16875bf Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 09 四月 2024 18:46:28 +0800
Subject: [PATCH] 图书详情,答题器修改

---
 packageBookService/pages/bookServices/detail/components/tree/index.js |   57 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js
index 186a9e1..c4f9ab8 100644
--- a/packageBookService/pages/bookServices/detail/components/tree/index.js
+++ b/packageBookService/pages/bookServices/detail/components/tree/index.js
@@ -43,6 +43,9 @@
       type: Boolean,
       value: false,
     },
+    checkAllState: {
+      type: Boolean,
+    },
   },
   data: {
     sonPurchaseSaleMethodId: "",
@@ -54,10 +57,7 @@
     shoppingCart: true,
     stop: false,
   },
-  ready() {
-    this.setData({});
-    console.log("鍑嗗");
-  },
+  ready() {},
 
   onLoad() {
     this.setData({
@@ -72,7 +72,6 @@
     treeList: function (newValue) {
       const list = [];
       let checked = "";
-      console.log("鏂板��", this.properties.treeList);
       this.properties.treeList.forEach((item) => {
         if (item.children && item.children.length > 0) {
           list.push(...this.flattenTree([item]));
@@ -166,7 +165,8 @@
         ) {
           return wx.showToast({
             icon: "error",
-            title: "璇峰厛璐拱璇ヨ祫婧�",
+            title: item.saleMethod[0].Price > 0 ?
+              "璇峰厛璐拱璇ヨ祫婧�" : "璇峰厛鐐瑰嚮棰嗗彇鏌ョ湅鎸夐挳",
           });
         }
         wx.navigateTo({
@@ -308,16 +308,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,
@@ -332,6 +325,14 @@
       this.setData({
         treeList: updataList,
       });
+      var myEventDetail = {
+        value: !flag,
+      }; // detail瀵硅薄锛屾彁渚涚粰浜嬩欢鐩戝惉鍑芥暟
+      var myEventOption = {
+        bubbles: true,
+        composed: true,
+      }; // 瑙﹀彂浜嬩欢鐨勯�夐」
+      this.triggerEvent("changeCheckAll", myEventDetail, myEventOption);
     },
 
     // 绔犺妭鍕鹃��
@@ -376,18 +377,24 @@
     // 瀛愰」鍕鹃��
     checkResource(e) {
       const citem = e.currentTarget.dataset.item;
-      console.log(citem, "5648");
+      const parent = e.currentTarget.dataset.parent
+      const childrenList = parent.children.filter(item => item.id !== citem.id)
+      const flag = childrenList.findIndex(item => item.checked == false)
       const updataList = this.checkResoucrceInfo(
         this.properties.treeList,
         citem.id
       );
-      console.log(citem.checked, "citem.checked");
+      if (flag == -1) {
+        if (citem.checked == false) {
+          this.findAndUpdateItemsByIds(this.properties.treeList, [parent.id], true)
+        } else {
+          this.findAndUpdateItemsByIds(this.properties.treeList, [parent.id], false)
+        }
+      }
       if (!citem.checked) {
         //閫変腑鐨勬椂鍊欐坊鍔爄d
         let sonPurchaseSaleMethodId = this.data.sonPurchaseSaleMethodId || [];
-        console.log(this.properties.paymentPage, "this.properties.paymentPage");
         if (this.properties.paymentPage) {
-          console.log(789987);
           sonPurchaseSaleMethodId = [];
           this.properties.paymentPage = false;
         }
@@ -450,13 +457,11 @@
       }
     },
     sadd() {
-      this.triggerEvent('updateShoppingCartHidden');
-      this.triggerEvent('updateCloudLearning');
+      this.triggerEvent("updateShoppingCartHidden");
+      this.triggerEvent("updateCloudLearning");
       console.log(789);
     },
-
   },
 
-
-  catchtap() {}
-})
\ No newline at end of file
+  catchtap() {},
+});
\ No newline at end of file

--
Gitblit v1.9.1