| | |
| | | type: String, |
| | | value: '' |
| | | }, |
| | | openTeachids: { |
| | | openIds: { |
| | | type: Array, |
| | | value: '' |
| | | }, |
| | | openLearnids: { |
| | | type: Array, |
| | | value: "" |
| | | value: [], |
| | | } |
| | | , |
| | | isShowCheck: { |
| | | type: Boolean, |
| | | value: false, |
| | | } |
| | | }, |
| | | data: { |
| | | activeValues: [0], |
| | | activeValues: [1, 2], |
| | | webpageSrc: '', |
| | | cloudShoppingCart: [] |
| | | }, |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | |
| | |
| | | // 判断资源是否购买 |
| | | resourceIsBuy(data) { |
| | | if (data.saleMethod && data.saleMethod.length) { |
| | | const isSHow = buyIdList.value.some((item) => item == data.saleMethod[0].Id) |
| | | if (data.saleMethod[0].State == 'Disable') return false |
| | | const isSHow = this.properties.buyIds.some((item) => item == data.saleMethod[0].Id) |
| | | return !isSHow |
| | | } else { |
| | | return false |
| | |
| | | }, |
| | | // 跳转音视频播放器 |
| | | goPlayer(e) { |
| | | console.log(e); |
| | | // debugger |
| | | if (this.properties.isShowCheck) return true |
| | | const item = e.currentTarget.dataset.item |
| | | const parent = e.currentTarget.dataset.parent |
| | | let url |
| | | if (item.selectType == 'video') { |
| | | if (item.selectType == 'video' || item.learnSelectType == 'video') { |
| | | url = '/packageDomain/pages/resourceDetails/myVideo/index' |
| | | } else if (item.selectType == 'audio') { |
| | | } else if (item.selectType == 'audio' || item.learnSelectType == 'audio') { |
| | | url = '/packageDomain/pages/resourceDetails/myAudio/index' |
| | | } else if (item.selectType == 'picture' || item.selectType == 'zip') { |
| | | url = '/packageDomain/pages/resourceDetails/document/index' |
| | | } |
| | | |
| | | // else { |
| | | // |
| | | // } |
| | | if (this.properties.tab == 'jsek_cloudLearning' && this.resourceIsBuy(item)) { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请先购买该资源', |
| | | }) |
| | | } |
| | | wx.navigateTo({ |
| | | url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parent.productLinkPath}&parentName=${parent.name}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}`, |
| | | }) |
| | |
| | | return result |
| | | }, |
| | | |
| | | |
| | | |
| | | findAndUpdateItemById(tree, id) { |
| | | function findAndUpdate(node) { |
| | | if (node.id === id) { |
| | | node.check = true; // 将目标项的 check 属性设置为 true |
| | | return true; // 返回 true 表示找到了目标项 |
| | | } |
| | | if (node.children && node.children.length > 0) { |
| | | for (let child of node.children) { |
| | | if (findAndUpdate(child)) { |
| | | return true; // 如果在子节点中找到了目标项,则直接返回 true |
| | | } |
| | | } |
| | | } |
| | | return false; // 表示未找到目标项 |
| | | } |
| | | |
| | | for (let node of tree) { |
| | | if (findAndUpdate(node)) { |
| | | break; // 如果在顶层节点中找到了目标项,直接退出循环 |
| | | } |
| | | } |
| | | }, |
| | | // 变为true |
| | | findAndUpdateItemsByIds(tree, ids) { |
| | | |
| | | function findAndUpdate(node) { |
| | | |
| | | if (ids.includes(node.id)) { |
| | | // console.log(node, 'node'); |
| | | node.checked = !node.checked // 将目标项的 check 属性设置为 true |
| | |
| | | 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") { |
| | | debugger |
| | | node.checked = !node.checked // 将目标项的 check 属性设置为 true |
| | | } |
| | | } |
| | | for (let node of tree) { |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | |
| | | // 章节勾选 |
| | | checkResourceTitle(e) { |
| | | // 这个时候checked的值是fals |
| | | const item = e.currentTarget.dataset.item |
| | | |
| | | let list = this.flattenTree([item]) |
| | | |
| | | |
| | | let ids = [] |
| | | list.forEach(item => { |
| | | ids.push(item.id) |
| | | }) |
| | | |
| | | const updatedTreeList = this.findAndUpdateItemsByIds(this.properties.treeList, ids); |
| | | // console.log(updatedTreeList, 'updatedTreeList'); //这个时候checked的值就变成了true |
| | | |
| | | this.setData({ |
| | | treeList: updatedTreeList // 更新 treeList 数据 |
| | | }); |
| | | |
| | | console.log(list, 'list'); |
| | | list.forEach(items => { |
| | | console.log(items.checked, 'itesasd'); |
| | |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | this.onCloudShoppingCart() |
| | | }, |
| | | // 子项勾选 |
| | | checkResource(e) { |
| | | const item = e.currentTarget.dataset.item |
| | | |
| | | |
| | | // let list = this.flattenTree([item]) |
| | | // console.log(list, 'list121'); |
| | | // let ids = [] |
| | | // list.forEach(items => { |
| | | // console.log(items.id, 'itemsId'); |
| | | // ids.push(items.id) |
| | | // }) |
| | | const citem = e.currentTarget.dataset.item |
| | | this.checkResoucrceInfo(this.properties.treeList, citem.id) |
| | | }, |
| | | // 加入购物车 |
| | | async onCloudShoppingCart() { |
| | | |
| | | |
| | | |
| | | let requests = [] |
| | | const item = this.data.cloudShoppingCart |
| | | console.log(item, 'item'); |