修改提示描述,修改下载文件名字,修改接口响应判断

This commit is contained in:
2024-10-21 13:35:50 +08:00
parent 26ec060327
commit f00bcbe8d1
3 changed files with 30 additions and 16 deletions

View File

@@ -51,8 +51,8 @@ Page({
switch (envVersion) {
// 开发版
case 'develop':
api = `http://localhost:9001`;
// api = `https://zgd.hbhcbn.com/recharge-print-api-test`;
// api = `http://localhost:9001`;
api = `https://zgd.hbhcbn.com/recharge-print-api-test`;
// api = `https://zgd.hbhcbn.com/recharge-print-api-test`;
break;
// 体验版
@@ -77,18 +77,31 @@ Page({
alertInfo("下载文件失败")
return;
}
wx.openDocument({
filePath: res.tempFilePath,
fileType: [ "pdf"], // 3. 这个必须写合法类型,不然下载不了
success: function (res) {
resolve()
const fs = wx.getFileSystemManager()
const newPath = wx.env.USER_DATA_PATH + '/' + `收据-${detail.time}.pdf`
fs.rename({
oldPath: res.tempFilePath,
newPath: newPath,
success() {
wx.openDocument({
filePath: newPath,
fileType: [ "pdf"], // 3. 这个必须写合法类型,不然下载不了
success: function (res) {
resolve()
},
fail: function (e) {
alertError("打开失败")
console.log('打开失败错误为', e)
rej()
}
});
},
fail: function (e) {
alertError("打开失败")
console.log('打开失败错误为', e)
rej()
fail(res) {
console.error(res)
}
})
}
}
})