修改提示描述,修改下载文件名字,修改接口响应判断
This commit is contained in:
parent
26ec060327
commit
f00bcbe8d1
|
@ -89,7 +89,7 @@ Page({
|
|||
noPermission() {
|
||||
Dialog.confirm({
|
||||
title: '提示',
|
||||
message: '当前手机号不是用电管理联系账号',
|
||||
message: '当前手机号未录入系统,请联系管理员,或点击手动绑定',
|
||||
confirmButtonText: '手动绑定',
|
||||
cancelButtonText: '取消',
|
||||
})
|
||||
|
|
|
@ -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,8 +77,14 @@ Page({
|
|||
alertInfo("下载文件失败")
|
||||
return;
|
||||
}
|
||||
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: res.tempFilePath,
|
||||
filePath: newPath,
|
||||
fileType: [ "pdf"], // 3. 这个必须写合法类型,不然下载不了 !!!
|
||||
success: function (res) {
|
||||
resolve()
|
||||
|
@ -88,7 +94,14 @@ Page({
|
|||
console.log('打开失败错误为', e)
|
||||
rej()
|
||||
}
|
||||
});
|
||||
},
|
||||
fail(res) {
|
||||
console.error(res)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -82,13 +82,12 @@ const parseResponse = function (response, url) {
|
|||
alertError("服务异常")
|
||||
return
|
||||
}
|
||||
// const { statusCode } = response;
|
||||
const { code } = response?.data || {};
|
||||
console.log('url', url,'code', code, 'response.data', response.data)
|
||||
if (!code) {
|
||||
const { statusCode } = response;
|
||||
if (!statusCode) {
|
||||
alertError("服务异常")
|
||||
return
|
||||
}
|
||||
console.log('url', url,'statusCode', statusCode, 'response.data', response)
|
||||
if (code === 401) {
|
||||
const currentUrl = getPageUrl()
|
||||
|
||||
|
@ -113,6 +112,8 @@ const parseResponse = function (response, url) {
|
|||
if (500 <= code && code < 600) {
|
||||
return { code: 500, message: "服务错误" }
|
||||
}
|
||||
const { code } = response?.data || {};
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user