| | |
| | | |
| | | import Message from 'tdesign-miniprogram/message/message'; |
| | | const util = require('./components/util') // 引入封装过的加载提示 |
| | | const app = getApp() |
| | | Component({ |
| | | properties: { |
| | |
| | | } |
| | | }, |
| | | data: { |
| | | activeValues: [0] |
| | | activeValues: [0], |
| | | webpageSrc: '' |
| | | }, |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | |
| | | methods: { |
| | | // 节点展开 |
| | | handleChange(e) { |
| | |
| | | goPlayer(e) { |
| | | const item = e.currentTarget.dataset.item |
| | | const parent = e.currentTarget.dataset.parent |
| | | console.log(item.selectType); |
| | | debugger |
| | | // "pages/resourceDetails/myAudio/index", |
| | | // "pages/resourceDetails/myVideo/index", |
| | | // "pages/resourceDetails/document/index", |
| | | |
| | | |
| | | |
| | | let url |
| | | if (item.selectType == 'video') { |
| | | url = '/pages/resourceDetails/myVideo/index' |
| | | } else if (item.selectType == 'audio') { |
| | | url = '/pages/resourceDetails/myAudio/index' |
| | | } else if (item.selectType == 'picture' || item.selectType == 'zip') { |
| | | url = '/pages/resourceDetails/document/index' |
| | | } |
| | | |
| | | // else { |
| | | // |
| | | // } |
| | | wx.navigateTo({ |
| | | url: `/pages/resourceDetails/index?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}`, |
| | | 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}`, |
| | | }) |
| | | console.log(e); |
| | | |
| | | |
| | | 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, // 地址已打码,自己换个其他的地址("https://www.xxxxx.com/file/测试通知.pdf") |
| | | 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.selectType == 'webpage') { |
| | | console.log(11); |
| | | this.setData({ |
| | | webpageSrc: item.jsek_link |
| | | }) |
| | | console.log(this.data.webpageSrc, 'webpageSrc'); |
| | | } |
| | | |
| | | |
| | | |
| | | }, |
| | | // 拿到所有项 |
| | | getAllChildren(id) { |
| | |
| | | result.push(...item.children); |
| | | } |
| | | } |
| | | console.log(this.properties.treeList); |
| | | this.properties.treeList.forEach(item => { |
| | | findChildren(item); |
| | | }); |
| | |
| | | // 章节勾选 |
| | | checkResourceTitle(e) { |
| | | const item = e.currentTarget.dataset.item |
| | | console.log(item, 'item'); |
| | | let list = this.flattenTree([item]) |
| | | let ids = [] |
| | | list.forEach(item => { |
| | |
| | | const tab = this.findAndUpdateItemsByIds([item], ids) |
| | | console.log(ids, tab); |
| | | } |
| | | }, |
| | | onCloudShoppingCart() { |
| | | console.log(this.properties.treeList); |
| | | }, |
| | | oncheckbox() { |
| | | console.log(111); |
| | | } |
| | | }) |