From c212c9ab501e1aff9e2dd90e8e87871c0bc7f1bc Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期二, 30 七月 2024 14:03:29 +0800
Subject: [PATCH] fix bug
---
plugins/http.js | 53 ++++++++++++++++++++++++++++++-----------------------
1 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/plugins/http.js b/plugins/http.js
index db3b571..47b71d6 100644
--- a/plugins/http.js
+++ b/plugins/http.js
@@ -64,14 +64,15 @@
msg: ''
})
} else {
- console.log('res',res.data)
+ console.log('res', res.data)
if (res.data.code == ('0')) {
resolve({
data: res.data.data,
code: 0,
msg: ''
})
- } else if (res.data.code === '3000'||res.data&&res.data.code&&res.data.code.startsWith('3000')) {
+ } else if (res.data.code === '3000' || res.data && res.data.code &&
+ res.data.code.startsWith('3000')) {
if (Array.isArray(res.data.data)) {
if (res.data.data.length > 0 && res.data.data[0]
.msg) {
@@ -87,8 +88,28 @@
code: parseInt(res.data.code),
msg: res.data.data || res.data.msg
})
- } else if (res.data.code === '4000'||res.data&&res.data.code&&res.data.code.startsWith('4000')) {
- message.showToast('系统异常')
+ } else if (res.data.code === '4000' || res.data && res.data.code &&
+ res.data.code.startsWith('4000')) {
+ message.showToast('系统异常')
+ } else if (res.data.code === '401' || res.data && res.data.code &&
+ res.data.code.startsWith('401')) {
+ message.showToast('登录信息失效')
+ storage.removeItem('token')
+ reject({
+ data: null,
+ code: 401,
+ msg: 'Unauthorized'
+ })
+ // #ifdef PUB_CUSTOMER
+ uni.reLaunch({
+ url: '/pages/user/supplier-user'
+ })
+ // #endif
+ // #ifndef PUB_CUSTOMER
+ uni.reLaunch({
+ url: '/pages/login/supplier-login'
+ })
+
} else {
if (res.data.data && typeof res.data.data === 'string') {
message.showToast(res.data.data)
@@ -128,20 +149,6 @@
})
// #endif
- // if (!http.isShowMessage) {
- // http.isShowMessage = true
- // message.confirm('登录状态已失效,是否重新登录?').then(() => {
- // uni.navigateTo({
- // url: '/pages/account/login'
- // })
- // http.isShowMessage = false
- // }).catch(() => {
- // uni.reLaunch({
- // url: '/pages/home'
- // })
- // http.isShowMessage = false
- // })
- // }
} else if (res.statusCode === 403) {
message.showToast('请求被拒绝')
reject({
@@ -216,7 +223,7 @@
if (res.statusCode === 200) {
const obj = JSON.parse(res.data)
console.log('res debug2', obj)
- if (obj.code.startsWith('200')||obj.code==='0') {
+ if (obj.code.startsWith('200') || obj.code === '0') {
resolve({
data: obj.data,
code: 0,
@@ -238,10 +245,10 @@
})
})
},
-
+
async requestCode(method, url, options) {
try {
- return await http.requestTemp(method, `${pre}/${version}`+ url, options)
+ return await http.requestTemp(method, `${pre}/${version}` + url, options)
} catch (e) {
return e
}
@@ -259,7 +266,7 @@
try {
return await http.uploadTemp(filePath, dto)
} catch (e) {
- console.log('error',e)
+ console.log('error', e)
return e
}
},
@@ -297,4 +304,4 @@
}
-export default http
+export default http
\ No newline at end of file
--
Gitblit v1.9.3