From 8f1835f66ef83bbd752e080178afb98632a6970d Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期四, 28 三月 2024 14:09:44 +0800 Subject: [PATCH] 云学习购买 --- packageBookService/pages/bookServices/detail/components/tree/index.js | 66 ++++++++++++++++----------------- 1 files changed, 32 insertions(+), 34 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index 1486ac7..675c529 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.js +++ b/packageBookService/pages/bookServices/detail/components/tree/index.js @@ -1,4 +1,3 @@ - import Message from 'tdesign-miniprogram/message/message'; const util = require('./components/util') // 寮曞叆灏佽杩囩殑鍔犺浇鎻愮ず const app = getApp() @@ -29,8 +28,7 @@ openIds: { type: Array, value: [], - } - , + }, isShowCheck: { type: Boolean, value: false, @@ -49,7 +47,8 @@ superiorPurchaseSaleMethodId: [], activeValues: [1, 2], webpageSrc: '', - cloudShoppingCart: [] + cloudShoppingCart: [], + selectAll: [] }, ready() { this.setData({ @@ -57,16 +56,12 @@ }) console.log('鍑嗗'); }, - onShow() { - debugger - this.setData({ - sonPurchaseSaleMethodId: '' - }) - }, + onLoad() { this.setData({ - sonPurchaseSaleMethodId: '' + sonPurchaseSaleMethodId: [] }) + console.log(this.data.sonPurchaseSaleMethodId, 'sonPurchaseSaleMethodId789'); }, observers: { 'openIds': function (newValue) { @@ -201,6 +196,7 @@ // 鎷垮埌鎵�鏈夐」 getAllChildren(id) { let result = []; + function findChildren(item) { if (item.id === id) { if (item.children && item.children.length > 0) { @@ -228,6 +224,7 @@ // 鎷垮埌褰撳墠椤瑰瓙椤� flattenTree(tree) { let result = []; + function flatten(node) { result.push(node); if (node.children && node.children.length > 0) { @@ -249,7 +246,7 @@ function findAndUpdate(node) { if (ids.includes(node.id)) { // console.log(node, 'node'); - node.checked = !node.checked // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true + node.checked = !node.checked // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true } if (node.children && node.children.length > 0) { for (let child of node.children) { @@ -273,9 +270,8 @@ const element = node.children[index]; findAndUpdate(element) } - } - else if (id == node.id && node.sysType == "CmsItem") { - node.checked = !node.checked // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true + } else if (id == node.id && node.sysType == "CmsItem") { + node.checked = !node.checked // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true } } for (let node of tree) { @@ -287,6 +283,7 @@ checkAll() { const ids = [] const list = [] + let checked = '' this.properties.treeList.forEach(item => { if (item.children && item.children.length > 0) { list.push(...this.flattenTree([item])) @@ -294,8 +291,21 @@ }) list.forEach(item => { ids.push(item.id) + + checked = item.checked }) + + const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); + + console.log(checked, 'list'); + if (!checked) { + this.setData({ + selectAll: list + }) + + } + this.setData({ treeList: updataList }) @@ -315,23 +325,16 @@ // console.log(list, 'list789'); const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); this.setData({ - treeList: updatedTreeList // 鏇存柊 treeList 鏁版嵁 + treeList: updatedTreeList // 鏇存柊 treeList 鏁版嵁 }); - + console.log(list, 'list.checked'); if (!list.checked) { - if (this.properties.superior) { - console.log(852); - this.properties.superior = false - this.setData({ - superiorPurchaseSaleMethodId: [] - }) - } - if (!this.properties.superior) { - this.setData({ - superiorPurchaseSaleMethodId: list - }) - } + + this.setData({ + superiorPurchaseSaleMethodId: list + }) + } // console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId'); @@ -363,20 +366,15 @@ if (!this.properties.paymentPage) { sonPurchaseSaleMethodId.push(citem.saleMethod[0].Id) } - - this.setData({ sonPurchaseSaleMethodId: sonPurchaseSaleMethodId }) console.log(this.data.sonPurchaseSaleMethodId); } else { // 鍙栨秷閫変腑鐨勬椂鍊欏垹闄d - } - this.setData({ treeList: updataList, - }) }, // 鍔犲叆璐墿杞� -- Gitblit v1.9.1