Browse Source

refactor(postConsult): 简化文件下载后的处理逻辑

移除保存文件到本地的中间步骤,直接使用临时文件路径打开文档,减少不必要的用户等待时间和代码复杂度
master
前端-胡立永 1 month ago
parent
commit
00891bc86d
1 changed files with 14 additions and 32 deletions
  1. +14
    -32
      pages_order/work/postConsult.vue

+ 14
- 32
pages_order/work/postConsult.vue View File

@ -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: () => {


Loading…
Cancel
Save