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

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

View File

@ -89,7 +89,7 @@ Page({
noPermission() { noPermission() {
Dialog.confirm({ Dialog.confirm({
title: '提示', title: '提示',
message: '当前手机号不是用电管理联系账号', message: '当前手机号未录入系统,请联系管理员,或点击手动绑定',
confirmButtonText: '手动绑定', confirmButtonText: '手动绑定',
cancelButtonText: '取消', cancelButtonText: '取消',
}) })

View File

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

View File

@ -82,13 +82,12 @@ const parseResponse = function (response, url) {
alertError("服务异常") alertError("服务异常")
return return
} }
// const { statusCode } = response; const { statusCode } = response;
const { code } = response?.data || {}; if (!statusCode) {
console.log('url', url,'code', code, 'response.data', response.data)
if (!code) {
alertError("服务异常") alertError("服务异常")
return return
} }
console.log('url', url,'statusCode', statusCode, 'response.data', response)
if (code === 401) { if (code === 401) {
const currentUrl = getPageUrl() const currentUrl = getPageUrl()
@ -113,6 +112,8 @@ const parseResponse = function (response, url) {
if (500 <= code && code < 600) { if (500 <= code && code < 600) {
return { code: 500, message: "服务错误" } return { code: 500, message: "服务错误" }
} }
const { code } = response?.data || {};
return response.data; return response.data;
} }