| | |
| | | |
| | | import Message from 'tdesign-miniprogram/message/message'; |
| | | const util = require('./components/util') // 引入封装过的加载提示 |
| | | const app = getApp() |
| | |
| | | openIds: { |
| | | type: Array, |
| | | value: [], |
| | | } |
| | | , |
| | | }, |
| | | isShowCheck: { |
| | | type: Boolean, |
| | | value: false, |
| | |
| | | superiorPurchaseSaleMethodId: [], |
| | | activeValues: [1, 2], |
| | | webpageSrc: '', |
| | | cloudShoppingCart: [] |
| | | cloudShoppingCart: [], |
| | | selectAll: [] |
| | | }, |
| | | ready() { |
| | | this.setData({ |
| | |
| | | }) |
| | | console.log('准备'); |
| | | }, |
| | | onShow() { |
| | | debugger |
| | | this.setData({ |
| | | sonPurchaseSaleMethodId: '' |
| | | }) |
| | | }, |
| | | |
| | | onLoad() { |
| | | this.setData({ |
| | | sonPurchaseSaleMethodId: '' |
| | | sonPurchaseSaleMethodId: [] |
| | | }) |
| | | console.log(this.data.sonPurchaseSaleMethodId, 'sonPurchaseSaleMethodId789'); |
| | | }, |
| | | observers: { |
| | | 'openIds': function (newValue) { |
| | |
| | | // 拿到所有项 |
| | | getAllChildren(id) { |
| | | let result = []; |
| | | |
| | | function findChildren(item) { |
| | | if (item.id === id) { |
| | | if (item.children && item.children.length > 0) { |
| | |
| | | // 拿到当前项子项 |
| | | flattenTree(tree) { |
| | | let result = []; |
| | | |
| | | function flatten(node) { |
| | | result.push(node); |
| | | if (node.children && node.children.length > 0) { |
| | |
| | | const element = node.children[index]; |
| | | findAndUpdate(element) |
| | | } |
| | | } |
| | | else if (id == node.id && node.sysType == "CmsItem") { |
| | | } else if (id == node.id && node.sysType == "CmsItem") { |
| | | node.checked = !node.checked // 将目标项的 check 属性设置为 true |
| | | } |
| | | } |
| | |
| | | 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 |
| | | }) |
| | |
| | | this.setData({ |
| | | 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 |
| | | }) |
| | | } |
| | | |
| | | } |
| | | |
| | | // console.log(this.data.superiorPurchaseSaleMethodId, 'superiorPurchaseSaleMethodId'); |
| | |
| | | if (!this.properties.paymentPage) { |
| | | sonPurchaseSaleMethodId.push(citem.saleMethod[0].Id) |
| | | } |
| | | |
| | | |
| | | this.setData({ |
| | | sonPurchaseSaleMethodId: sonPurchaseSaleMethodId |
| | | }) |
| | | console.log(this.data.sonPurchaseSaleMethodId); |
| | | } else { |
| | | // 取消选中的时候删除id |
| | | |
| | | } |
| | | |
| | | this.setData({ |
| | | treeList: updataList, |
| | | |
| | | }) |
| | | }, |
| | | // 加入购物车 |