From 756af153eabc0fb667a11e17788650689c13cd81 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Mon, 16 Dec 2024 15:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=A7=88ppt=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=AE=89=E5=8D=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- course/courseDetail/courseDetail.vue | 49 +++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) 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) {