Browse Source

feat(文件下载): 下载成功后自动打开文件

添加文件下载成功后自动打开功能,提升用户体验。若打开失败则显示提示信息引导用户手动查看。
master
前端-胡立永 1 month ago
parent
commit
1e4cf5a971
1 changed files with 18 additions and 1 deletions
  1. +18
    -1
      pages_order/work/postConsult.vue

+ 18
- 1
pages_order/work/postConsult.vue View File

@ -153,11 +153,28 @@
if (res.statusCode === 200) {
uni.saveFile({
tempFilePath: res.tempFilePath,
success: () => {
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({


Loading…
Cancel
Save