| | |
| | | } |
| | | }); |
| | | const flag = list.findIndex((item) => item.checked == true); |
| | | console.log(this.properties.treeList) |
| | | }, |
| | | }, |
| | | methods: { |
| | |
| | | }; // 触发事件的选项 |
| | | this.triggerEvent("downloadTeach", myEventDetail, myEventOption); |
| | | }, |
| | | // 判断资源是否购买 |
| | | resourceIsBuy(data) { |
| | | if (data.saleMethod && data.saleMethod.length) { |
| | | const saleData = data.saleMethod.find((item) => item.SaleType == 'Normal') |
| | | if (saleData.State == 'Disable') return false |
| | | const isSHow = this.properties.buyIds.some( |
| | | (item) => item == saleData.Id |
| | | ); |
| | | // 已经购买 |
| | | if (isShow) return false |
| | | // 未购买,查看销售方式是否过期 |
| | | if (!isShow) { |
| | | const flag = new Date(saleData.EndDate).getTime() >= new Date().getTime() && |
| | | new Date(saleData.BeginDate).getTime() <= new Date().getTime() |
| | | if (flag) { |
| | | // 为过期 ,需要购买 |
| | | return true |
| | | } else { |
| | | // 已过期 无需购买 |
| | | return false |
| | | } |
| | | } |
| | | } else { |
| | | return false; |
| | | } |
| | | }, |
| | | |
| | | |
| | | // 判断当前目标是否已购买 |
| | | async getCmsDataByQrcode(item) { |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | | productId: this.properties.bookInfo.id, |
| | | itemId: item.id, |
| | | itemFields: { |
| | | // 资源类型,试读文件,是否允许下载等参数 |
| | | selectType: [], |
| | | freeFile: [], |
| | | file: [], |
| | | protectedFile: [], |
| | | resourcesClassification: [], |
| | | isDownload: [], |
| | | jsek_resourceBrief: [], |
| | | jsek_link: [], |
| | | jsek_questionBank: [], |
| | | learnSelectType: [] |
| | | }, |
| | | pading: { |
| | | start: 0, |
| | | size: 999 |
| | | } |
| | | } |
| | | const data = await app.MG.store.getProductDetail(query) |
| | | return data?.datas ?? [] |
| | | }, |
| | | |
| | | // 跳转音视频播放器 |
| | | goPlayer(e) { |
| | | // 检查登录状态 |
| | | // if (this.properties.bookInfo.IsTextbook) return |
| | | const goPlayerFun = async () => { |
| | | const item = e.currentTarget.dataset.item; |
| | | const parent = e.currentTarget.dataset.parent; |
| | |
| | | } |
| | | } |
| | | if (this.properties.tab == "jsek_cloudLearning") { |
| | | // 1.找出所有父级目录和本身(有销售方式) 和 云学习本身(有销售方式) 放到一个数组 为空则暂未开放销售 |
| | | let learn = [] |
| | | if (this.properties.isCloundHaveSaleMethod) { |
| | | // 1.1 云学习有销售方式,加入父级数组 |
| | | learn.push(this.properties.learnMenu) |
| | | } else { |
| | | // 1.2 云学习无销售方式,将父级目录和本身加入数组 |
| | | learn = this.handleTreeData(this.properties.learnList).filter( |
| | | (citem) => citem.saleMethod && |
| | | citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal' && ditem.Price > 0) && |
| | | new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() && |
| | | new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() && |
| | | item.productLinkPath.includes(citem.productLinkPath) |
| | | ) |
| | | } |
| | | // 2.找出这个数组里已购买的 形成新数组 为空则未购买 |
| | | let buyList = [] |
| | | if (learn.length) buyList = learn.filter((item) => this.properties.buyIds.includes(item.saleMethod.find((citem) => citem.SaleType == 'Normal').Id)) |
| | | // 有父级(包含销售方式),且未购买 |
| | | if (learn.length && !buyList.length && !item.freeFile) return wx.showToast({ |
| | | // // 1.找出所有父级目录和本身(有销售方式) 和 云学习本身(有销售方式) 放到一个数组 为空则暂未开放销售 |
| | | // let learn = [] |
| | | // if (this.properties.isCloundHaveSaleMethod) { |
| | | // // 1.1 云学习有销售方式,加入父级数组 |
| | | // learn.push(this.properties.learnMenu) |
| | | // } else { |
| | | // // 1.2 云学习无销售方式,将父级目录和本身加入数组 |
| | | // learn = this.handleTreeData(this.properties.learnList).filter( |
| | | // (citem) => citem.saleMethod && |
| | | // citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal' && ditem.Price > 0) && |
| | | // new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() && |
| | | // new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() && |
| | | // item.productLinkPath.includes(citem.productLinkPath) |
| | | // ) |
| | | // } |
| | | // // 2.找出这个数组里已购买的 形成新数组 为空则未购买 |
| | | // let buyList = [] |
| | | // if (learn.length) buyList = learn.filter((item) => this.properties.buyIds.includes(item.saleMethod.find((citem) => citem.SaleType == 'Normal').Id)) |
| | | // // 有父级(包含销售方式),且未购买 |
| | | if (!item.isbuy && !item.freeFile) return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请先购买该资源', |
| | | title: '请先激活或购买资源', |
| | | }) |
| | | if (item.protectedFile || item.freeFile) { |
| | | const currentSaleMaths = await this.getCmsDataByQrcode(item) |
| | | let file = item.fileMap[item.protectedFile] ? item.fileMap[item.protectedFile] : item.fileMap[item.freeFile] |
| | | if (file && file.protectType !== "Public") { |
| | | const isBuyData = currentSaleMaths.purchasedSaleMethodIdList?.includes(item.saleMethod[0]?.Id) |
| | | if (!isBuyData) { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请先购买该资源', |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | // if (!item.isbuy && item.freeFile) { |
| | | // let file = item.fileMap[item.freeFile] |
| | | // if (file && file.protectType !== "Public") { |
| | | // if (!item.isbuy) { |
| | | // return wx.showToast({ |
| | | // icon: 'error', |
| | | // title: '请先购买该资源', |
| | | // }); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | let url; |
| | | if (item.selectType == "video" || item.learnSelectType == "video") { |
| | |
| | | } |
| | | wx.navigateTo({ |
| | | url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parentProductLinkPath}&parentName=${parentName}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}&formPath=${this.properties.tab}&applyState=${this.properties.applyState}&deadline=${this.properties.deadline}`, |
| | | // url: '/packageDomain/pages/resourceDetails/myVideo/index?formPath=jsek_cloudLearning&parentName=gggg&cmsId=137103&productLinkPath=137103\\137105\\159492&activeId=159492&parentProductLinkPath=137105&source=qrcode&bookName=fffff&bookId=6745' |
| | | // url: '/packageDomain/pages/resourceDetails/myVideo/index?formPath=jsek_cloudLearning&parentName=YDHYD&cmsId=161974&productLinkPath=161974\\161976\\162006&activeId=162006&parentProductLinkPath=161976&source=qrcode&bookName=fffff&bookId=7136' |
| | | }); |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token && this.data.tab != 'jsek_teachingResources') { |
| | | loginInfo(app, (data) => { |
| | | if (data) {} |
| | | if (data) { |
| | | wx.redirectTo({ |
| | | url: '/packageBookService/pages/bookServices/detail/index?id=' + this.data.bookInfo.id + '&name=' + encodeURI(this.data.bookInfo.name), |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | goPlayerFun() |
| | |
| | | // 拿到当前项子项 |
| | | flattenTree(tree) { |
| | | let result = []; |
| | | let that = this |
| | | |
| | | function flatten(node) { |
| | | |
| | | result.push(node); |
| | | if (node.children && node.children.length > 0) { |
| | | node.children.forEach((child) => { |