Jelajahi Sumber

修改返回路径

wangxy 1 bulan lalu
induk
melakukan
ee9f05f774
2 mengubah file dengan 56 tambahan dan 20 penghapusan
  1. 32 12
      App.vue
  2. 24 8
      utils/request.js

+ 32 - 12
App.vue

@@ -30,12 +30,22 @@
 			// #endif
 			// #ifdef H5
 			if (cacheManager.get('auth')) {
-				uni.reLaunch({
-					url: `/pages/admin/ShouYe/shouye`,
-					success() {
-						
-					}
-				})
+				if (cacheManager.get('auth').type == 2) {
+					uni.reLaunch({
+						url: `/pages/admin/ShouYe/shouye`,
+						success() {
+							
+						}
+					})
+				} else {
+					uni.reLaunch({
+						url: `/pages/client/ShouYe/shouye`,
+						success() {
+					
+						}
+					})
+				}
+			
 			}
 			// #endif
 		},
@@ -55,12 +65,22 @@
 			// #endif
 			// #ifdef H5
 			if (cacheManager.get('auth')) {
-				uni.reLaunch({
-					url: `/pages/admin/ShouYe/shouye`,
-					success() {
-
-					}
-				})
+				if (cacheManager.get('auth').type === 2) {
+					uni.reLaunch({
+						url: `/pages/admin/ShouYe/shouye`,
+						success() {
+					
+						}
+					})
+				} else {
+					uni.reLaunch({
+						url: `/pages/client/ShouYe/shouye`,
+						success() {
+					
+						}
+					})
+				}
+			
 			} 
 			// #endif
 		},

+ 24 - 8
utils/request.js

@@ -53,24 +53,40 @@ const request = config => {
 				if (code === 401) {
 					showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
 						if (res.confirm) {
-							if (cacheManager.get('auth')) {
+							const auth = cacheManager.get('auth')
+							if (auth) {
 								cacheManager.clearAll()
 							}
-							uni.reLaunch({
-								url: '/pages/Login/index'
-							})
+							if (auth.type == 2) {
+								uni.reLaunch({
+									url: '/pages/Login/index'
+								})
+							} else {
+								uni.reLaunch({
+									url: '/pages/Login/clientIndex'
+								})
+							}
+						
 						}
 					})
 					reject('无效的会话,或者会话已过期,请重新登录。')
 				} else if (code === 405) {
 					showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
 						if (res.confirm) {
-							if (cacheManager.get('auth')) {
+							const auth = cacheManager.get('auth')
+							if (auth) {
 								cacheManager.clearAll()
 							}
-							uni.reLaunch({
-								url: '/pages/Login/index'
-							})
+							if (auth.type == 2) {
+								uni.reLaunch({
+									url: '/pages/Login/index'
+								})
+							} else {
+								uni.reLaunch({
+									url: '/pages/Login/clientIndex'
+								})
+							}
+							
 						}
 
 					})