javascript
uni.downloadFile({
url: that.baseUrl + '/app-api/erp/income/certificate/apply' + '?' +
`type=${that.proveInfo.code}`,
header: {
'Authorization': 'Bearer test01'
},
success(res) {
console.log(res);
const tempFilePath = res.tempFilePath;
let fileManager = uni.getFileSystemManager();
fileManager.saveFile({
tempFilePath: tempFilePath,
filePath: `${uni.env.USER_DATA_PATH}/file/${that.proveInfo.desc}.pdf`,
success: (result) => {
console.log(result);
uni.showToast({
content: '文件保存成功,路径:' + result.savedFilePath,
});
},
fail: (err) => {
console.log(err)
}
})
},
fail(res) {
console.log(res);
uni.alert({
content: res.errorMessage || res.error,
});
},
});