| | |
| | | checkAllState: true, |
| | | productLinkPath: '', |
| | | refCode: '', |
| | | haider: false |
| | | haider: false, |
| | | naData: false |
| | | }, |
| | | |
| | | /** |
| | |
| | | wx.navigateBack(); |
| | | }, |
| | | |
| | | // 获取所有子项数量 |
| | | getChildrenItem(data) { |
| | | let num = 0 |
| | | |
| | | function getNum(data) { |
| | | for (let index = 0; index < data.length; index++) { |
| | | const item = data[index]; |
| | | if (item.sysType == 'CmsItem') { |
| | | num += 1 |
| | | } else if (item.sysType == 'CmsFolder') { |
| | | if (item.children && item.children.length) |
| | | getNum(item.children) |
| | | } |
| | | } |
| | | } |
| | | getNum(data) |
| | | return num |
| | | }, |
| | | |
| | | // 给·目录添加子项数量 |
| | | changeResourceChildren(list) { |
| | | const changeList = (list) => { |
| | | for (let index = 0; index < list.length; index++) { |
| | | const item = list[index]; |
| | | if (item.sysType == 'CmsFolder' && item.children && item.children.length) { |
| | | item.childrenItem = this.getChildrenItem([item]) |
| | | changeList(item.children) |
| | | } else if (item.sysType == 'CmsFolder' && item.children && !item.children.length) { |
| | | item.childrenItem = 0 |
| | | } else if (item.sysType == 'CmsFolder' && !item.children) { |
| | | item.childrenItem = 0 |
| | | } |
| | | } |
| | | } |
| | | changeList(list) |
| | | return list |
| | | }, |
| | | |
| | | // 扁平化数据转换tree |
| | | getTreeList(rootList, pathLength, newArr, path) { |
| | | for (const item of rootList) { |
| | | if (item.productLinkPath.length == pathLength && item.productLinkPath.includes(path)) { |
| | | item.checked = false; |
| | | if ((pathLength - item.productLinkPath.length >= 0 && pathLength - item.productLinkPath.length <= 3) && item.productLinkPath.includes(path)) { |
| | | if (item.sysType == 'CmsItem') { |
| | | if (item.selectType == 'webpage') { |
| | | item.disabled = true |
| | |
| | | if (item.file && item.fileMap && item.fileMap[item.file]) { |
| | | if (item.fileMap[item.file].protectType == 'Private') item.disabled = true |
| | | } |
| | | |
| | | item.isbuy = this.isShowNeedBuy(item); |
| | | item.isShopCar = this.isShoppingCart(item); |
| | | } |
| | | // newArr.push(item) |
| | | // 在插入过程中对数据进行排序 |
| | | newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item) |
| | | // 在插入过程中对数据进行排序 并且去除已经领取和购买的 |
| | | if (item.sysType == 'CmsFolder') { |
| | | newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item) |
| | | } else if (item.sysType == 'CmsItem' && this.resourceIsBuy(item)) { |
| | | newArr = this.insertAndSortObjectsByProductLinkPath(newArr, item) |
| | | } |
| | | } |
| | | } |
| | | //给数组里面再添加一个children的空数组 |
| | |
| | | } |
| | | } |
| | | }); |
| | | this.getTreeList(res.datas.cmsDatas[0].datas, 17, list, '\\') |
| | | // 显示 需要购买的和需要免费领取的 |
| | | // const arr = res.datas.cmsDatas[0].datas.filter(item => this.resourceIsBuy(item)) |
| | | // if (!arr.length) { |
| | | // return this.setData({ |
| | | // loading: false, |
| | | // haider: true, |
| | | // noData: true |
| | | // }) |
| | | // } |
| | | // debugger |
| | | const num = query.cmsPath.length + 6 |
| | | this.getTreeList(res.datas.cmsDatas[0].datas, num, list, '\\') |
| | | list = this.ensureTreeConsistency(list) |
| | | list = this.changeResourceChildren(list) |
| | | console.log('修改后云', list); |
| | | let result = []; |
| | | if (type.refCode == "jsek_teachingResources") { |
| | |
| | | }, |
| | | //购买按钮 |
| | | batchPurchase() { |
| | | if (!this.data.learn.length) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: '暂无数据', |
| | | }) |
| | | } |
| | | let saleMethodIds = []; |
| | | let requests = []; |
| | | let item = []; |