From d44f1c3412aeb61709e58c737279ac2b2f60e018 Mon Sep 17 00:00:00 2001 From: litian <C21AF165> Date: 星期三, 03 四月 2024 09:30:52 +0800 Subject: [PATCH] 样式修改 --- packageBookService/pages/bookServices/detail/components/tree/index.js | 115 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 61 insertions(+), 54 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index 715f67e..0ea1d2e 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.js +++ b/packageBookService/pages/bookServices/detail/components/tree/index.js @@ -50,7 +50,9 @@ activeValues: [1, 2], webpageSrc: '', cloudShoppingCart: [], - selectAll: [] + selectAll: [], + shoppingCart: true, + stop: false, }, ready() { this.setData({ @@ -78,7 +80,6 @@ }, methods: { - handleList(tree) { for (let index = 0; index < tree.length; index++) { const item = tree[index]; @@ -141,10 +142,15 @@ } }) } else { - if (this.properties.isShowCheck) return true const item = e.currentTarget.dataset.item const parent = e.currentTarget.dataset.parent let url + if (this.properties.isShowCheck && this.resourceIsBuy(item)) { + return wx.showToast({ + icon: 'error', + title: "璇峰厛璐拱璧勬簮" + }) + } if (item.selectType == 'video' || item.learnSelectType == 'video') { url = '/packageDomain/pages/resourceDetails/myVideo/index' } else if (item.selectType == 'audio' || item.learnSelectType == 'audio') { @@ -240,7 +246,6 @@ } } tree.forEach(node => { - flatten(node); }); // console.log(result, 'result'); @@ -248,11 +253,11 @@ }, // 鍙樹负true - findAndUpdateItemsByIds(tree, ids) { + findAndUpdateItemsByIds(tree, ids, state) { function findAndUpdate(node) { if (ids.includes(node.id)) { // console.log(node, 'node'); - node.checked = !node.checked // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true + node.checked = state // 灏嗙洰鏍囬」鐨� check 灞炴�ц缃负 true } if (node.children && node.children.length > 0) { for (let child of node.children) { @@ -260,9 +265,7 @@ } } } - for (let node of tree) { - findAndUpdate(node); // 瀵规瘡涓《灞傝妭鐐规墽琛屾煡鎵惧拰鏇存柊鎿嶄綔 } // console.log(tree, 'tree345'); @@ -285,7 +288,7 @@ } return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍 }, - + // 鍏ㄩ�� checkAll() { const ids = [] const list = [] @@ -297,21 +300,16 @@ }) list.forEach(item => { ids.push(item.id) - checked = item.checked }) - - - const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); - + const flag = list.findIndex(item => item.checked == false) > -1 ? true : false + const updataList = this.findAndUpdateItemsByIds(this.properties.treeList, ids, flag); console.log(checked, 'list'); if (!checked) { this.setData({ selectAll: list }) - } - this.setData({ treeList: updataList }) @@ -319,6 +317,8 @@ // 绔犺妭鍕鹃�� checkResourceTitle(e) { + const flag = e.detail.checked + debugger // 杩欎釜鏃跺�檆hecked鐨勫�兼槸fals let checkResourceTitleList = [] const item = e.currentTarget.dataset.item @@ -329,20 +329,16 @@ ids.push(item.id) }) // console.log(list, 'list789'); - const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); + const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids, flag); this.setData({ treeList: updatedTreeList // 鏇存柊 treeList 鏁版嵁 }); 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'); @@ -352,7 +348,9 @@ }) } }) - // this.onCloudShoppingCart() + this.setData({ + openIds: this.data.openIds + }) }, // 瀛愰」鍕鹃�� checkResource(e) { @@ -384,41 +382,50 @@ }) }, // 鍔犲叆璐墿杞� - async onCloudShoppingCart() { - let requests = [] - const item = this.data.cloudShoppingCart - console.log(item, 'item'); - item.forEach((items) => { - if (items.saleMethod.length) { - requests.push({ - saleMethodId: items.saleMethod[0].Id, - count: 1 - }) - } - }) + async onCloudShoppingCart(e) { + + let shoppingCartGetId = [] + const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id + console.log(saleMethodId); let query = { - remarks: '浜戝涔�', - requests + start: 0, + size: 999, + filterList: [], + searchList: [] } - // 鏌ヨ璁㈠崟 - let initOrderRes = await app.MG.store.initOrder(query) - let parameter = { - orderNum: initOrderRes.orderNumber + + const res = await app.MG.store.getShoppingCartProductList(query) + res.datas.forEach(item => { + shoppingCartGetId.push(item.saleMethod.id) + }) + if (shoppingCartGetId.includes(saleMethodId)) { + console.log(111); + + wx.showToast({ + icon: 'error', + title: '宸叉坊鍔�', + }) + this.setData({ + shoppingCart: false + }) + } else { + let query = { + requests: [{ + saleMethodId: saleMethodId, + storeEventId: null, + // agentCode: '鐢靛瓙涔�' + }] + } + const addRes = await app.MG.store.addShoppingCart(query) + console.log(addRes, 'addRes'); + wx.showToast({ + icon: 'success', + title: '娣诲姞鎴愬姛', + }) } - const confirmOrderRes = await app.MG.store.confirmOrder(parameter) - // if (confirmOrderRes.orderNumber) { - // wx.navigateTo({ - // url: `/pages/cart/paymentPage/index?orderNumber=${confirmOrderRes.orderNumber}`, - // }) - // requests = [] - // } + }, }, - onCheckAllChange(e) { - // debugger - // console.log('checkbox', e.detail.value); - // this.setData({ - // checkAllValues: event.detail, - // }); - } + + catchtap() {} }) \ No newline at end of file -- Gitblit v1.9.1