From 00891bc86d6600741935e2c5ba179228d153d62e Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Wed, 6 Aug 2025 17:46:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(postConsult):=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E5=90=8E=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除保存文件到本地的中间步骤,直接使用临时文件路径打开文档,减少不必要的用户等待时间和代码复杂度 --- pages_order/work/postConsult.vue | 46 ++++++++++++---------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/pages_order/work/postConsult.vue b/pages_order/work/postConsult.vue index 2d10ada..a5ef99e 100644 --- a/pages_order/work/postConsult.vue +++ b/pages_order/work/postConsult.vue @@ -151,38 +151,20 @@ url: template, success: (res) => { if (res.statusCode === 200) { - uni.saveFile({ - tempFilePath: res.tempFilePath, - success: (saveRes) => { - uni.showToast({ - title: '下载成功', - icon: 'success' - }) - // 保存成功后直接打开文件 - setTimeout(() => { - uni.openDocument({ - filePath: saveRes.savedFilePath, - success: () => { - console.log('文件打开成功') - }, - fail: (err) => { - console.log('文件打开失败', err) - uni.showToast({ - title: '文件已保存,请在文件管理器中查看', - icon: 'none', - duration: 3000 - }) - } - }) - }, 1000) - }, - fail: () => { - uni.showToast({ - title: '保存失败', - icon: 'none' - }) - } - }) + uni.openDocument({ + filePath: res.tempFilePath, + success: () => { + console.log('文件打开成功') + }, + fail: (err) => { + console.log('文件打开失败', err) + uni.showToast({ + title: '文件已保存,请在文件管理器中查看', + icon: 'none', + duration: 3000 + }) + } + }) } }, fail: () => {