| | |
| | | }, |
| | | cloundMenuIsBuy: { |
| | | type: Boolean |
| | | }, |
| | | learnMenu: { |
| | | type: Object |
| | | }, |
| | | isCloundHaveSaleMethod: { |
| | | type: Boolean |
| | | } |
| | | }, |
| | | data: { |
| | |
| | | purchaseList: [] |
| | | }, |
| | | ready() {}, |
| | | |
| | | onLoad() {}, |
| | | observers: { |
| | | treeList: function (newValue) { |
| | |
| | | // 跳转音视频播放器 |
| | | goPlayer(e) { |
| | | // 检查登录状态 |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token) return false |
| | | const item = e.currentTarget.dataset.item; |
| | | const parent = e.currentTarget.dataset.parent; |
| | | const parentProductLinkPath = parent ? |
| | | parent.productLinkPath : |
| | | wx.getStorageSync("teachResourcesPath"); |
| | | const parentName = parent ? parent.name : "教学资源"; |
| | | // 资源购买页面(只展示未购买资源) 点击不跳转 |
| | | if (this.properties.isShowCheck) return false; |
| | | if (item.selectType == "webpage") { |
| | | // 网页类型跳转到网址复制页,因为url传参不能传 带参数的网络地址,所以此处要把网络地址里的传参摘出来,放到url里 |
| | | let urlData = '' |
| | | const flags = item.jsek_link.indexOf("?") |
| | | if (flags > -1) { |
| | | urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length) |
| | | const goPlayerFun = () => { |
| | | const item = e.currentTarget.dataset.item; |
| | | const parent = e.currentTarget.dataset.parent; |
| | | const parentProductLinkPath = parent ? |
| | | parent.productLinkPath : |
| | | wx.getStorageSync("teachResourcesPath"); |
| | | const parentName = parent ? parent.name : "教学资源"; |
| | | // 资源购买页面(只展示未购买资源) 点击不跳转 |
| | | if (this.properties.isShowCheck) return false; |
| | | if (item.selectType == "webpage" || item.learnSelectType == "webpage") { |
| | | // 网页类型跳转到网址复制页,因为url传参不能传 带参数的网络地址,所以此处要把网络地址里的传参摘出来,放到url里 |
| | | let urlData = '' |
| | | const flags = item.jsek_link.indexOf("?") |
| | | if (flags > -1) { |
| | | urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length) |
| | | } |
| | | url = '/packageBookService/pages/bookServices/linkPage/index' |
| | | return wx.navigateTo({ |
| | | url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}` |
| | | }) |
| | | } |
| | | url = '/packageBookService/pages/bookServices/linkPage/index' |
| | | return wx.navigateTo({ |
| | | url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}` |
| | | }) |
| | | } |
| | | if (!item.file && !item.freeFile && !item.protectedFile) { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '暂无资源', |
| | | }) |
| | | } |
| | | if (item.selectType == 'zip') { |
| | | if (this.properties.applyState == 'Normal') { |
| | | if (!item.file && !item.freeFile && !item.protectedFile) { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '暂无资源', |
| | | }) |
| | | } |
| | | if (item.selectType == 'zip' || item.learnSelectType == 'zip') { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请前往PC端下载', |
| | | }) |
| | | } else { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请先申请下载', |
| | | }) |
| | | } |
| | | } |
| | | if (this.properties.tab == "jsek_teachingResources" && (item.file || item.freeFile)) { |
| | | let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile] |
| | | if (file && file.protectType !== "Public") { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "资源不可用,请联系管理员", |
| | | }); |
| | | } |
| | | } |
| | | if (this.properties.tab == "jsek_cloudLearning") { |
| | | // 判断父级或自身是否购买 |
| | | var myEventOption = { |
| | | bubbles: true, |
| | | composed: true, |
| | | }; |
| | | // 出发判断云学习是否购买判断 |
| | | this.triggerEvent("getCloundIsBuy", {}, myEventOption) |
| | | if (!this.properties.cloundMenuIsBuy) { |
| | | // 云学习未购买,查找以购买的目录和资源本身 |
| | | const learn = this.handleTreeData(this.properties.treeList).filter( |
| | | (citem) => citem.saleMethod && |
| | | citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal') && |
| | | 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) |
| | | ) |
| | | // 资源和父级目录都无销售方式 |
| | | // if (!learn.length) return wx.showToast({ |
| | | // icon: 'error', |
| | | // title: '暂未开售', |
| | | // }) |
| | | const buyList = learn.filter((citem) => this.properties.buyIds.includes(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').Id)) |
| | | // 资源和本身都未购买 |
| | | if (!buyList.length) { |
| | | const itemSaleMethod = item.saleMethod && item.saleMethod.length ? item.saleMethod.find(citem => citem.SaleType == 'Normal') : undefined |
| | | if (this.properties.tab == "jsek_teachingResources" && (item.file || item.freeFile)) { |
| | | let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile] |
| | | if (file && file.protectType !== "Public") { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: itemSaleMethod && itemSaleMethod.Price == 0 ? '请先领取资源' : '请先购买资源', |
| | | }) |
| | | icon: "none", |
| | | title: "资源不可用,请联系管理员", |
| | | }); |
| | | } |
| | | } |
| | | 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) return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请先购买该资源', |
| | | }) |
| | | if (item.protectedFile || item.freeFile) { |
| | | let file = item.fileMap[item.protectedFile] ? item.fileMap[item.protectedFile] : item.fileMap[item.freeFile] |
| | | if (file && file.protectType !== "Public") { |
| | | return wx.showToast({ |
| | | icon: 'none', |
| | | title: "资源不可用,请联系管理员", |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | let url; |
| | | if (item.selectType == "video" || item.learnSelectType == "video") { |
| | | url = "/packageDomain/pages/resourceDetails/myVideo/index"; |
| | | } |
| | | if ( |
| | | item.selectType == "audio" || |
| | | item.learnSelectType == "audio" |
| | | ) { |
| | | url = "/packageDomain/pages/resourceDetails/myAudio/index"; |
| | | } |
| | | if (item.selectType == "picture" || item.selectType == 'document' || item.selectType == 'pdf' || item.learnSelectType == "picture" || item.learnSelectType == 'document' || item.learnSelectType == 'pdf') { |
| | | url = "/packageDomain/pages/resourceDetails/document/index"; |
| | | } |
| | | 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}`, |
| | | }); |
| | | } |
| | | let url; |
| | | if (item.selectType == "video" || item.learnSelectType == "video") { |
| | | url = "/packageDomain/pages/resourceDetails/myVideo/index"; |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | if (!token && this.data.tab != 'jsek_teachingResources') { |
| | | loginInfo(app, (data) => { |
| | | if (data) goPlayerFun() |
| | | }) |
| | | } else { |
| | | goPlayerFun() |
| | | } |
| | | if ( |
| | | item.selectType == "audio" || |
| | | item.learnSelectType == "audio" |
| | | ) { |
| | | url = "/packageDomain/pages/resourceDetails/myAudio/index"; |
| | | } |
| | | if (item.selectType == "picture") { |
| | | url = "/packageDomain/pages/resourceDetails/document/index"; |
| | | } |
| | | 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}`, |
| | | }); |
| | | |
| | | }, |
| | | |
| | | // 拿到所有项 |
| | |
| | | |
| | | // 全选 |
| | | checkAll() { |
| | | wx.showLoading() |
| | | const ids = []; |
| | | let list = []; |
| | | let checked = ""; |
| | |
| | | composed: true, |
| | | }; // 触发事件的选项 |
| | | this.triggerEvent("changeCheckAll", myEventDetail, myEventOption); |
| | | wx.hideLoading() |
| | | }, |
| | | |
| | | // 章节勾选 |
| | | checkResourceTitle(e) { |
| | | wx.showLoading() |
| | | const flag = e.detail.checked; |
| | | // 这个时候checked的值是fals |
| | | const item = e.currentTarget.dataset.item; |
| | |
| | | }, |
| | | // 子项勾选 |
| | | checkResource(e) { |
| | | wx.showLoading() |
| | | const citem = e.currentTarget.dataset.item; |
| | | const parent = e.currentTarget.dataset.parent; |
| | | let outermost; |
| | |
| | | }); |
| | | if (shoppingCartGetId.includes(saleMethodId)) { |
| | | wx.showToast({ |
| | | icon: "error", |
| | | icon: "success", |
| | | title: "已添加", |
| | | }); |
| | | this.setData({ |