From 999c2811465079edb5f1337ab593f93a5915d525 Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期三, 11 九月 2024 15:56:58 +0800
Subject: [PATCH] update 禁用用户问题

---
 plugins/http.js |   35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/plugins/http.js b/plugins/http.js
index bd19a45..bfc3dd2 100644
--- a/plugins/http.js
+++ b/plugins/http.js
@@ -52,7 +52,7 @@
 				dataType: options.dataType ? options.dataType : 'json',
 				data: options.data || null,
 				header,
-				success: (res) => {
+				success: async (res) => {
 					if (!options.ignore) {
 						message.hideLoading()
 					}
@@ -87,13 +87,13 @@
 									validmsg = res.data.msg
 									message.showToast(res.data.data)
 								}
-								if(validmsg){
+								if (validmsg) {
 									//兼容安卓手机提醒过快问题
 									setTimeout(() => {
 										message.showToast(validmsg)
 									}, 200)
 								}
-								
+
 
 
 								reject({
@@ -107,13 +107,10 @@
 							} else if (res.data.code === '401' || res.data && res.data.code &&
 								res.data.code.startsWith('401')) {
 								console.log('resp', res)
+								// storage.removeItem('token')
+								await store.dispatch('logout')
 								message.showToast('登录信息失效')
-								storage.removeItem('token')
-								reject({
-									data: null,
-									code: 401,
-									msg: 'Unauthorized'
-								})
+
 								// #ifdef PUB_CUSTOMER
 								uni.reLaunch({
 									url: '/pages/user/supplier-user'
@@ -124,6 +121,11 @@
 									url: '/pages/login/supplier-login'
 								})
 								// #endif
+								reject({
+									data: null,
+									code: 401,
+									msg: 'Unauthorized'
+								})
 
 							} else {
 								if (res.data.data && typeof res.data.data === 'string') {
@@ -148,13 +150,11 @@
 						// commit('updat')
 						// store.commit('updateLogin', false)
 						console.log('401', res)
-						message.showToast('登录信息失效')
 						storage.removeItem('token')
-						reject({
-							data: null,
-							code: 401,
-							msg: 'Unauthorized'
-						})
+						await store.dispatch('logout')
+						message.showToast('登录信息失效')
+
+
 						// #ifdef PUB_CUSTOMER
 						uni.reLaunch({
 							url: '/pages/user/supplier-user'
@@ -165,6 +165,11 @@
 							url: '/pages/login/supplier-login'
 						})
 						// #endif
+						reject({
+							data: null,
+							code: 401,
+							msg: 'Unauthorized'
+						})
 
 					} else if (res.statusCode === 403) {
 						message.showToast('请求被拒绝')

--
Gitblit v1.9.3