| | |
| | | productLinkPath: '', |
| | | refCode: '', |
| | | haider: false, |
| | | naData: false |
| | | naData: false, |
| | | bookRefCode: [] |
| | | }, |
| | | |
| | | /** |
| | |
| | | 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)) { |
| | | 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 |
| | |
| | | } |
| | | } |
| | | // 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的空数组 |
| | |
| | | itemFields: { |
| | | SysType: 'CmsFolder', |
| | | // 资源类型,试读文件,是否允许下载等参数 |
| | | learnSelectType: [], |
| | | selectType: [], |
| | | freeFile: [], |
| | | file: [], |
| | |
| | | } |
| | | }); |
| | | // 显示 需要购买的和需要免费领取的 |
| | | const arr = res.datas.cmsDatas[0].datas.filter(item => this.resourceIsBuy(item)) |
| | | if (!arr.length) { |
| | | return this.setData({ |
| | | loading: false, |
| | | haider: true, |
| | | noData: true |
| | | }) |
| | | } |
| | | this.getTreeList(arr, 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") { |
| | |
| | | // productLinkPath: this.data.productLinkPath, |
| | | // refCode: this.data.refCode, |
| | | // }); |
| | | // this.getResourceCode( |
| | | // res.datas.id, |
| | | // res.datas.rootCmsItemId |
| | | // ) |
| | | this.getResourceDataList({ |
| | | productLinkPath: this.data.productLinkPath, |
| | | refCode: this.data.refCode, |
| | | }) |
| | | }); |
| | | |
| | | }, |
| | | getResourceCode(bookId, cmsId) { |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: bookId, |
| | | cmsPath: cmsId, |
| | | itemFields: { |
| | | SysType: 'Cms' |
| | | }, |
| | | pading: { |
| | | start: 99, |
| | | size: 0 |
| | | } |
| | | } |
| | | app.MG.store.getProductDetail(query).then(res => { |
| | | console.log('图书资源', res.datas.cmsDatas[0].datas); |
| | | }) |
| | | }, |
| | | // 获取已购买商品 |
| | | getShoppingCartProductGet() { |
| | |
| | | if (isSHow) { |
| | | return false; |
| | | } else { |
| | | return data.saleMethod[0].price > 0 ? true : false; |
| | | return data.saleMethod[0].Price > 0 ? true : false; |
| | | } |
| | | return !isSHow; |
| | | } else { |
| | |
| | | this.setData({ |
| | | resourceClassList: JSON.parse(res[0].config).option, |
| | | }); |
| | | |
| | | }); |
| | | }, |
| | | checkAll() { |