diff --git a/course/courseDetail/courseDetail.vue b/course/courseDetail/courseDetail.vue index 8dab7c6..2c7709d 100644 --- a/course/courseDetail/courseDetail.vue +++ b/course/courseDetail/courseDetail.vue @@ -230,7 +230,6 @@ }, onShow() { const pages = getCurrentPages() - console.log(444,pages) const { options } = pages[pages.length - 1] this.cid = options.cid this.mallId = options.mallId @@ -358,15 +357,47 @@ // 判断文件是图片/视频/pdf等 handleFileType(row) { const type = row.fileType - if (this.$util.exts.video.includes(type)) { - row.isVideo = true - } else if (this.$util.exts.img.includes(type)) { - row.isPic = true - } else if (this.$util.exts.doc.includes(type)) { - row.isDoc = true + const platform = uni.getSystemInfoSync().platform + console.log(444, platform) + // ppt安卓下没法用webview或者用微软的office服务预览(皆会没法显示),因此下载到本地查看 + if ((type === 'pptx' || type === 'ppt') && platform === 'android') { + this.curRow = {} + uni.showLoading({ + title: '加载中', + mask: true + }) + uni.downloadFile({ + url: row.fileUrl, + success: function(res) { + console.log(11, res) + // 新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx。 + uni.openDocument({ + filePath: res.tempFilePath, + fileType: row.fileType, + showMenu: true, // 允许出现分享功能 + success: res => { + uni.hideLoading() + }, + fail: openError => { + uni.hideLoading() + } + }) + }, + fail: function(err) { + uni.hideLoading() + } + }) + } else { + if (this.$util.exts.video.includes(type)) { + row.isVideo = true + } else if (this.$util.exts.img.includes(type)) { + row.isPic = true + } else if (this.$util.exts.doc.includes(type)) { + row.isDoc = true + } + row.viewUrl = row.fileUrl + this.curRow = row } - row.viewUrl = row.fileUrl - this.curRow = row }, // 预览文件 secClick(row) {