From 5d70c2d38f12437afedc1c978269d29689ff0c2e Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期四, 28 三月 2024 19:54:52 +0800 Subject: [PATCH] 微信支付 --- packageBookService/pages/bookServices/detail/components/tree/index.js | 152 +++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 131 insertions(+), 21 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index 85c10dc..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,30 +28,71 @@ openIds: { type: Array, value: [], - } - , + }, isShowCheck: { + type: Boolean, + value: false, + }, + paymentPage: { + type: Boolean, + value: false, + }, + superior: { type: Boolean, value: false, } }, data: { + sonPurchaseSaleMethodId: '', + superiorPurchaseSaleMethodId: [], activeValues: [1, 2], webpageSrc: '', - cloudShoppingCart: [] + cloudShoppingCart: [], + selectAll: [] }, - onShow() { + ready() { + this.setData({ + + }) + console.log('鍑嗗'); }, + onLoad() { + this.setData({ + sonPurchaseSaleMethodId: [] + }) + console.log(this.data.sonPurchaseSaleMethodId, 'sonPurchaseSaleMethodId789'); + }, + observers: { + 'openIds': function (newValue) { + // var myEventDetail = { + // } + // var myEventOption = { + // bubbles: true, + // composed: true + // } + // this.triggerEvent('handleTree', myEventDetail, myEventOption) + } + }, methods: { + + handleList(tree) { + for (let index = 0; index < tree.length; index++) { + const item = tree[index]; + if (item.sysType == 'CmsItem' && !item.checked) { + + } + if (item.children && item.children.length > 0) { + this.handleList(item.children) + } + } + }, // 鑺傜偣灞曞紑 handleChange(e) { - // console.log(this.properties.treeList, 'this.properties.treeList'); this.setData({ - activeValues: e.detail.value, + openIds: e.detail.value, }); - // console.log('浼犻��', this.properties.buyIds); }, handleCheck(data) { for (let index = 0; index < data.length; index++) { @@ -156,6 +196,7 @@ // 鎷垮埌鎵�鏈夐」 getAllChildren(id) { let result = []; + function findChildren(item) { if (item.id === id) { if (item.children && item.children.length > 0) { @@ -182,15 +223,11 @@ }, // 鎷垮埌褰撳墠椤瑰瓙椤� flattenTree(tree) { - let result = []; function flatten(node) { - result.push(node); - if (node.children && node.children.length > 0) { - node.children.forEach(child => { flatten(child); }); @@ -209,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) { @@ -233,10 +270,8 @@ const element = node.children[index]; findAndUpdate(element) } - } - else if (id == node.id && node.sysType == "CmsItem") { - debugger - 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) { @@ -245,20 +280,64 @@ return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍 }, + checkAll() { + const ids = [] + const list = [] + let checked = '' + this.properties.treeList.forEach(item => { + if (item.children && item.children.length > 0) { + list.push(...this.flattenTree([item])) + } + }) + 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 + }) + }, + // 绔犺妭鍕鹃�� checkResourceTitle(e) { // 杩欎釜鏃跺�檆hecked鐨勫�兼槸fals + let checkResourceTitleList = [] const item = e.currentTarget.dataset.item + // let list = this.flattenTree([item]) let ids = [] list.forEach(item => { ids.push(item.id) }) + // console.log(list, 'list789'); const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); this.setData({ - treeList: updatedTreeList // 鏇存柊 treeList 鏁版嵁 + treeList: updatedTreeList // 鏇存柊 treeList 鏁版嵁 }); - console.log(list, 'list'); + console.log(list, 'list.checked'); + if (!list.checked) { + + + this.setData({ + superiorPurchaseSaleMethodId: list + }) + + } + + // console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId'); list.forEach(items => { console.log(items.checked, 'itesasd'); if (!items.checked) { @@ -267,12 +346,36 @@ }) } }) - this.onCloudShoppingCart() + // this.onCloudShoppingCart() }, // 瀛愰」鍕鹃�� checkResource(e) { const citem = e.currentTarget.dataset.item - this.checkResoucrceInfo(this.properties.treeList, citem.id) + console.log(citem, '5648'); + const updataList = this.checkResoucrceInfo(this.properties.treeList, citem.id) + console.log(citem.checked, 'citem.checked'); + 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 + } + 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, + }) }, // 鍔犲叆璐墿杞� async onCloudShoppingCart() { @@ -305,4 +408,11 @@ // } }, }, + onCheckAllChange(e) { + // debugger + // console.log('checkbox', e.detail.value); + // this.setData({ + // checkAllValues: event.detail, + // }); + } }) \ No newline at end of file -- Gitblit v1.9.1