| | |
| | | methodId: [], |
| | | paymentPage: false, |
| | | superior: false, |
| | | checkAllState: false, |
| | | checkAllState: true, |
| | | }, |
| | | |
| | | /** |
| | |
| | | bookId: options.bookId, |
| | | }); |
| | | this.getResourceClass(); |
| | | console.log(options); |
| | | this.getResourceData({ |
| | | productLinkPath: options.productLinkPath, |
| | | refCode: options.refCode, |
| | |
| | | loading: false, |
| | | openLearnids: result, |
| | | }); |
| | | console.log("教学资源", list); |
| | | } |
| | | } else { |
| | | // 无数据 |
| | |
| | | let item = []; |
| | | let selectAllId = []; |
| | | const child = this.selectComponent("#tree"); |
| | | |
| | | console.log( |
| | | child.data.superiorPurchaseSaleMethodId, |
| | | "superiorPurchaseSaleMethodId" |
| | | ); |
| | | console.log(child.data.sonPurchaseSaleMethodId, "child.data"); |
| | | // console.log(child.data.selectAll, 'selectAll'); |
| | | item = child.data.superiorPurchaseSaleMethodId; |
| | | const sonItem = child.data.sonPurchaseSaleMethodId; |
| | | let selectAll = child.data.selectAll; |
| | | if (selectAll) { |
| | | // console.log(selectAll); |
| | | selectAll.forEach((item) => { |
| | | if (item.saleMethod != 0) { |
| | | // console.log(item, 'item'); |
| | | selectAllId.push(item.saleMethod[0].Id); |
| | | } |
| | | }); |
| | | console.log(selectAllId); |
| | | app.MG.store |
| | | .initOrder({ |
| | | requests: selectAllId.map((id) => ({ |
| | |
| | | .then((res) => { |
| | | if (res) { |
| | | wx.navigateTo({ |
| | | url: |
| | | "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | url: "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | }); |
| | | selectAllId = []; |
| | | child.setData({ |
| | |
| | | }); |
| | | } |
| | | if (item) { |
| | | console.log(item, "sadsdasd"); |
| | | // 拿到id |
| | | item.forEach((items) => { |
| | | if (items.saleMethod != 0) { |
| | | saleMethodIds.push(items.saleMethod[0].Id); |
| | | } |
| | | }); |
| | | console.log(saleMethodIds, "saleMethodIds"); |
| | | |
| | | app.MG.store |
| | | .initOrder({ |
| | | requests: saleMethodIds.map((id) => ({ |
| | |
| | | .then((res) => { |
| | | if (res) { |
| | | wx.navigateTo({ |
| | | url: |
| | | "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | url: "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | }); |
| | | |
| | | child.setData({ |
| | |
| | | .then((res) => { |
| | | if (res) { |
| | | wx.navigateTo({ |
| | | url: |
| | | "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | url: "/pages/cart/paymentPage/index?orderNumber=" + res.orderNumber, |
| | | }); |
| | | this.setData({ |
| | | paymentPage: true, |
| | |
| | | }); |
| | | } |
| | | }, |
| | | }); |
| | | |
| | | // 章节勾选方法 |
| | | findAndUpdateItemsByIds(tree, ids, state) { |
| | | function findAndUpdate(node) { |
| | | if (ids.includes(node.id)) { |
| | | // console.log(node, 'node'); |
| | | node.checked = state; // 将目标项的 check 属性设置为 true |
| | | } |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | | findAndUpdate(child); // 递归处理子节点 |
| | | } |
| | | } |
| | | } |
| | | for (let node of tree) { |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | // console.log(tree, 'tree345'); |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | // 单个勾选方法 |
| | | checkResoucrceInfo(tree, id) { |
| | | function findAndUpdate(node) { |
| | | if (node.sysType == "CmsFolder" && node.children.length > 0) { |
| | | for (let index = 0; index < node.children.length; index++) { |
| | | const element = node.children[index]; |
| | | findAndUpdate(element); |
| | | } |
| | | } else if (id == node.id && node.sysType == "CmsItem") { |
| | | node.checked = !node.checked; // 将目标项的 check 属性设置为 true |
| | | } |
| | | } |
| | | for (let node of tree) { |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | // 章节勾选事件 |
| | | changeListChecked(e) { |
| | | const ids = e.detail.ids |
| | | const state = e.detail.flag |
| | | const updated = this.findAndUpdateItemsByIds(this.data.learn, ids, state) |
| | | this.setData({ |
| | | learn: updated |
| | | }) |
| | | }, |
| | | // 单个勾选事件 |
| | | changeResourceChecked(e) { |
| | | const id = e.detail.id |
| | | const updated = this.checkResoucrceInfo(this.data.learn, id) |
| | | this.setData({ |
| | | learn: updated |
| | | }) |
| | | } |
| | | }); |