downLoadFile(filePath) {
uni.showLoading({
title: '下载中...',
})
uni.downloadFile({
url: filePath,
success: (data) => {
if (data.statusCode === 200) {
uni.saveFile({
tempFilePath: data.tempFilePath,
success: function (res) {
uni.openDocument({
filePath: res.savedFilePath,
success: function (res) {
uni.hideLoading()
},
fail: (err) => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '打开文件'
});
}
});
},
fail: (err) => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '保存失败'
});
}
});
}
},
fail: (err) => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '下载失败'
});
}
});
},