| | |
| | | }, |
| | | learnList: { |
| | | type: Array, |
| | | value: [] |
| | | value: [], |
| | | }, |
| | | bookInfo: { |
| | | type: Object, |
| | |
| | | checkAllState: { |
| | | type: Boolean, |
| | | }, |
| | | deadline: { |
| | | type: String, |
| | | }, |
| | | }, |
| | | data: { |
| | | sonPurchaseSaleMethodId: "", |
| | |
| | | selectAll: [], |
| | | shoppingCart: true, |
| | | stop: false, |
| | | cart: true |
| | | cart: true, |
| | | canExecute: true |
| | | }, |
| | | ready() {}, |
| | | |
| | |
| | | goPlayer(e) { |
| | | // 检查登录状态 |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | | |
| | | if (token) { |
| | | 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 : '教学资源' |
| | | console.log('item', item); |
| | | const parentProductLinkPath = parent ? |
| | | parent.productLinkPath : |
| | | wx.getStorageSync("teachResourcesPath"); |
| | | const parentName = parent ? parent.name : "教学资源"; |
| | | let url; |
| | | if (item.selectType == 'zip') { |
| | | if (this.properties.applyState == 'Normal') { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请前往PC端下载', |
| | | }) |
| | | } else { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请先申请下载', |
| | | }) |
| | | } |
| | | } |
| | | if (this.properties.isShowCheck && this.resourceIsBuy(item)) { |
| | | return false; |
| | | } |
| | |
| | | "请先购买该资源" : "请先点击领取查看按钮", |
| | | }); |
| | | } |
| | | 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}`, |
| | | }); |
| | | |
| | | |
| | | if (item.selectType == "document" || item.selectType == "pdf") { |
| | | const fileLink = |
| | | app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file; |
| | | console.log(fileLink, "fileLink"); |
| | | //提示加载中 |
| | | util.showLoading(); |
| | | // 单次下载允许的最大文件为 200MB |
| | | wx.downloadFile({ |
| | | url: fileLink, |
| | | success: function (res) { |
| | | console.log(res, "wx.downloadFile success res"); |
| | | if (res.statusCode != 200) { |
| | | util.hideLoadingWithErrorTips(); |
| | | return false; |
| | | } |
| | | var Path = res.tempFilePath; //返回的文件临时地址,用于后面打开本地预览所用 |
| | | wx.openDocument({ |
| | | filePath: Path, |
| | | showMenu: true, |
| | | success: function (res) { |
| | | console.log("打开成功"); |
| | | util.hideLoading(); |
| | | }, |
| | | }); |
| | | }, |
| | | fail: function (err) { |
| | | console.log(err, "wx.downloadFile fail err"); |
| | | util.hideLoadingWithErrorTips(); |
| | | }, |
| | | if ( |
| | | item.saleMethod.length == 0 && |
| | | item.sysType == "CmsItem" && |
| | | this.properties.tab == "jsek_cloudLearning" |
| | | ) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "暂未开始销售,请联系管理员", |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // if (item.selectType == "document" || item.selectType == "pdf") { |
| | | // const fileLink = app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file; |
| | | |
| | | // let filePath = wx.env.USER_DATA_PATH + '/' + item.name |
| | | // console.log(filePath, 'filePath'); |
| | | 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: "资源不可用,请联系管理员", |
| | | }); |
| | | } |
| | | } else if ((this.properties.tab == "jsek_teachingResources" || this.properties.tab == "jsek_cloudLearning") && (!item.file && !item.freeFile && !item.protectedFile)) { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '暂无资源', |
| | | }) |
| | | } |
| | | 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}`, |
| | | }); |
| | | if (item.selectType == "pdf" || item.selectType == "document") { |
| | | const fileLink = item.file ? item.file : item.freeFile |
| | | console.log(fileLink); |
| | | wx.navigateTo({ |
| | | url: "/packageBookService/pages/components/webView/index?md5=" + |
| | | fileLink + |
| | | "&fileName=" + |
| | | item.name + |
| | | "&fileType=pdf" + |
| | | "&bookBuy=true" |
| | | }); |
| | | } |
| | | // if (item.selectType == "document") { |
| | | // // freeFile |
| | | // // if (item.selectType == "document") { |
| | | // // item.selectType = "pptx"; |
| | | // // } |
| | | // const fileLink = item.file ? |
| | | // app.config.requestCtx + "/file/api/ApiDownload?md5=" + item.file : |
| | | // app.config.requestCtx + |
| | | // "/file/api/ApiDownload?md5=" + |
| | | // item.freeFile; |
| | | // console.log(fileLink, "fileLink"); |
| | | // //提示加载中 |
| | | // util.showLoading(); |
| | | // // 单次下载允许的最大文件为 200MB |
| | | // wx.downloadFile({ |
| | | // url: fileLink, |
| | | // // filePath: wx.env.USER_DATA_PATH + `/${item.name}.${item.selectType}`, |
| | | // filePath: wx.env.USER_DATA_PATH + `/${item.name}.${item.selectType}`, |
| | | // success: function (res) { |
| | | |
| | | // console.log(res, "wx.downloadFile success res"); |
| | | // if (res.statusCode != 200) { |
| | | // util.hideLoadingWithErrorTips(); |
| | | // return false; |
| | | // } |
| | | // var Path = res.tempFilePath; //返回的文件临时地址,用于后面打开本地预览所用 |
| | | |
| | | // wx.saveFile({ |
| | | // tempFilePath: Path, |
| | | // let data = res.filePath; |
| | | // wx.openDocument({ |
| | | // filePath: data, |
| | | // showMenu: true, |
| | | // success: function (res) { |
| | | // var savedFilePath = res.savedFilePath; |
| | | // // 将文件保存为 item.name |
| | | // wx.saveFile({ |
| | | // tempFilePath: savedFilePath, |
| | | // filePath: wx.env.USER_DATA_PATH + '/' + item.name, |
| | | // success: function (res) { |
| | | // wx.openDocument({ |
| | | // filePath: res.savedFilePath, |
| | | // showMenu: true, |
| | | // success: function (res) { |
| | | // util.hideLoading(); |
| | | // }, |
| | | // }); |
| | | // }, |
| | | // fail: function (err) { |
| | | // util.hideLoadingWithErrorTips(); |
| | | // } |
| | | // }); |
| | | // console.log("打开成功"); |
| | | // util.hideLoading(); |
| | | // }, |
| | | // fail: function (err) { |
| | | // util.hideLoadingWithErrorTips(); |
| | | // } |
| | | // }); |
| | | // }, |
| | | // fail: function (err) { |
| | | // console.log(err, "wx.downloadFile fail err"); |
| | | // util.hideLoadingWithErrorTips(); |
| | | // }, |
| | | // }); |
| | | // } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if (item.selectType == "webpage") { |
| | | this.setData({ |
| | | webpageSrc: item.jsek_link, |
| | | }); |
| | | console.log(this.data.webpageSrc, "webpageSrc"); |
| | | } |
| | | } |
| | | }, |
| | |
| | | for (let node of tree) { |
| | | findAndUpdate(node); // 对每个顶层节点执行查找和更新操作 |
| | | } |
| | | // console.log(tree, 'tree345'); |
| | | return tree; // 返回修改后的完整数组 |
| | | }, |
| | | |
| | |
| | | // 这个时候checked的值是fals |
| | | let checkResourceTitleList = []; |
| | | const item = e.currentTarget.dataset.item; |
| | | const parent = this.findParentById(this.properties.learnList, item.id) |
| | | let childrenList |
| | | let flagNum |
| | | if (parent) childrenList = parent.children.filter(citem => citem.id !== item.id) |
| | | if (childrenList) flagNum = childrenList.findIndex(item => item.checked == false) |
| | | const parent = this.findParentById(this.properties.learnList, item.id); |
| | | let childrenList; |
| | | let flagNum; |
| | | if (parent) |
| | | childrenList = parent.children.filter((citem) => citem.id !== item.id); |
| | | if (childrenList) |
| | | flagNum = childrenList.findIndex((item) => item.checked == false); |
| | | let list = this.flattenTree([item]); |
| | | let ids = []; |
| | | list.forEach((item) => { |
| | | if (item.sysType == 'CmsFolder' || (item.sysType == 'CmsItem' && item.saleMethod.length)) |
| | | if ( |
| | | item.sysType == "CmsFolder" || |
| | | (item.sysType == "CmsItem" && item.saleMethod.length) |
| | | ) |
| | | ids.push(item.id); |
| | | }); |
| | | var myEventDetail = { |
| | |
| | | }; // 触发事件的选项 |
| | | this.triggerEvent("changeListChecked", myEventDetail, myEventOption); |
| | | if (flagNum == -1) { |
| | | let checkedState |
| | | let checkedState; |
| | | var myEventDetail = { |
| | | ids: [parent.id], |
| | | flag, |
| | |
| | | // 子项勾选 |
| | | checkResource(e) { |
| | | const citem = e.currentTarget.dataset.item; |
| | | const parent = e.currentTarget.dataset.parent |
| | | let outermost |
| | | if (parent) outermost = this.findParentById(this.properties.learnList, parent.id) |
| | | const childrenList = parent.children.filter(item => item.id !== citem.id && item.saleMethod.length) |
| | | const flag = childrenList.findIndex(item => item.checked == false) |
| | | const parent = e.currentTarget.dataset.parent; |
| | | let outermost; |
| | | if (parent) |
| | | outermost = this.findParentById(this.properties.learnList, parent.id); |
| | | const childrenList = parent.children.filter( |
| | | (item) => item.id !== citem.id && item.saleMethod.length |
| | | ); |
| | | const flag = childrenList.findIndex((item) => item.checked == false); |
| | | // 改变该项checked |
| | | var myEventDetail = { |
| | | id: citem.id |
| | | id: citem.id, |
| | | }; |
| | | var myEventOption = { |
| | | bubbles: true, |
| | |
| | | this.triggerEvent("changeResourceChecked", myEventDetail, myEventOption); |
| | | // 通过判断,联通父级checked |
| | | if (flag == -1) { |
| | | let checkedState |
| | | citem.checked == false ? checkedState = true : checkedState = false |
| | | let checkedState; |
| | | citem.checked == false ? (checkedState = true) : (checkedState = false); |
| | | var myEventDetail = { |
| | | ids: [parent.id], |
| | | flag: checkedState, |
| | |
| | | } |
| | | // 联通最外层级checked, 如果所有子项勾选, 且当前最外层未勾选, 则加上最外层的勾选 |
| | | if (!citem.checked && outermost) { |
| | | let allchildren = this.flattenTree([outermost]) |
| | | allchildren = allchildren.filter(item => item.sysType == 'CmsItem' && item.id !== citem.id && item.saleMethod.length) |
| | | const satate = allchildren.findIndex(item => item.checked == false) |
| | | let allchildren = this.flattenTree([outermost]); |
| | | allchildren = allchildren.filter( |
| | | (item) => |
| | | item.sysType == "CmsItem" && |
| | | item.id !== citem.id && |
| | | item.saleMethod.length |
| | | ); |
| | | const satate = allchildren.findIndex((item) => item.checked == false); |
| | | if (satate == -1) { |
| | | var myEventDetail = { |
| | | ids: [outermost.id], |
| | |
| | | async onCloudShoppingCart(e) { |
| | | let shoppingCartGetId = []; |
| | | |
| | | const item = e.currentTarget.dataset.item |
| | | const item = e.currentTarget.dataset.item; |
| | | console.log(item.isShopCar); |
| | | const saleMethodId = e.currentTarget.dataset.item.saleMethod[0].Id; |
| | | console.log(saleMethodId); |
| | |
| | | filterList: [], |
| | | searchList: [], |
| | | }; |
| | | |
| | | const res = await app.MG.store.getShoppingCartProductList(query); |
| | | res.datas.forEach((item) => { |
| | | shoppingCartGetId.push(item.saleMethod.id); |
| | | }); |
| | | if (shoppingCartGetId.includes(saleMethodId)) { |
| | | console.log(111); |
| | | // this.data.updateShoppingCartHidden(); |
| | | // this.data.updateCloudLearning(); |
| | | |
| | | wx.showToast({ |
| | | icon: "error", |
| | | title: "已添加", |
| | |
| | | icon: "success", |
| | | title: "添加成功", |
| | | }); |
| | | item.isShopCar = false |
| | | this.triggerEvent("updateCloudLearning") |
| | | item.isShopCar = false; |
| | | this.triggerEvent("updateCloudLearning"); |
| | | } |
| | | |
| | | } |
| | | }, |
| | | sadd() { |
| | |
| | | findParentById(arr, id) { |
| | | for (let i = 0; i < arr.length; i++) { |
| | | const item = arr[i]; |
| | | // 检查当前项是否匹配(即它是不是我们要找的项) |
| | | // 检查当前项是否匹配(即它是不是我们要找的项) |
| | | if (item.id === id) { |
| | | // 如果当前项就是我们要找的项,则它没有父级,返回 null |
| | | // 如果当前项就是我们要找的项,则它没有父级,返回 null |
| | | return null; |
| | | } |
| | | // 递归查找当前项的子项 |
| | | // 递归查找当前项的子项 |
| | | const child = this.findChildById(item.children, id); |
| | | if (child) { |
| | | // 如果在子项中找到匹配的项,返回当前项作为父级 |
| | | // 如果在子项中找到匹配的项,返回当前项作为父级 |
| | | return item; |
| | | } |
| | | } |
| | | // 如果没有找到匹配的父项,返回 null |
| | | // 如果没有找到匹配的父项,返回 null |
| | | return null; |
| | | }, |
| | | |
| | | // 辅助函数,用于递归查找子项 |
| | | // 辅助函数,用于递归查找子项 |
| | | findChildById(children, id) { |
| | | if (!children) { |
| | | return null; |
| | |
| | | for (let i = 0; i < children.length; i++) { |
| | | const child = children[i]; |
| | | if (child.id === id) { |
| | | // 如果找到匹配的项,返回它 |
| | | // 如果找到匹配的项,返回它 |
| | | return child; |
| | | } |
| | | // 递归检查子项的子项 |
| | | // 递归检查子项的子项 |
| | | const subChild = this.findChildById(child.children, id); |
| | | if (subChild) { |
| | | return subChild; |
| | | } |
| | | } |
| | | // 如果没有找到匹配的项,返回 null |
| | | // 如果没有找到匹配的项,返回 null |
| | | return null; |
| | | } |
| | | }, |
| | | }, |
| | | }); |