From f5d67b69142c78be1ee996f53b6bb8e4c954761c Mon Sep 17 00:00:00 2001
From: zhouwenxuan <1175765986@qq.com>
Date: 星期三, 15 十一月 2023 10:06:38 +0800
Subject: [PATCH] 页面跳转修改

---
 common/request.js |   40 +++++++++++++++++++++++++++++++---------
 1 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/common/request.js b/common/request.js
index 6765f68..b659d38 100644
--- a/common/request.js
+++ b/common/request.js
@@ -1,7 +1,6 @@
 import VUE_APP_BASE_URL from './constant.js';
 
 let server_url = VUE_APP_BASE_URL;
-console.log("url",server_url)
 let token = uni.getStorageSync('tk');
 export function service(options = {}) {
 	console.log(("option",options))
@@ -22,26 +21,49 @@
 	return new Promise((resolved, rejected) => {
 		//成功
 		options.success = (res) => {
-			if (Number(res.data.code) == 100) { 
-				resolved(res.data);
-			} else {
+			// if (Number(res.data.code) == 100) {
+			if(Number(res.data.code) == 405){
 				uni.showToast({
 					icon: 'none',
-					duration: 3000,
+					duration: 2000,
 					position: 'top',
 					title: `${res.data.msg}`
 				});
-				rejected(res.data.msg); 
-				uni.navigateTo({
-				  url: '/pages/index/index'
-				})
+				rejected(res.data.msg);
+				setTimeout(()=>{
+					uni.clearStorageSync();
+					uni.clearStorage();
+					uni.navigateTo({
+						url: '/pages/index/index'
+					})
+				},2000)
 			}
+				resolved(res.data);
+			// } else {
+			// 	uni.showToast({
+			// 		icon: 'none',
+			// 		duration: 3000,
+			// 		position: 'top',
+			// 		title: `${res.data.msg}`
+			// 	});
+			// 	rejected(res.data.msg);
+			// 	setTimeout(()=>{
+			// 		uni.navigateTo({
+			// 			url: '/pages/index/index'
+			// 		})
+			// 	},2000)
+			// }
 		}
 		options.fail = (err) => {
 			uni.showToast({
 				icon: "none",
 				title: '服务响应失败'
 			});
+			uni.clearStorageSync();
+			uni.clearStorage();
+			uni.navigateTo({
+				url: '/pages/index/index'
+			})
 			rejected(err); 
 		}
 		uni.request(options);

--
Gitblit v1.9.2