From f591c27b57e2418c9495bc02ae8cfff84d35bc18 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期二, 16 七月 2024 16:27:56 +0800
Subject: [PATCH] init

---
 common/request.js |   58 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/common/request.js b/common/request.js
index c243a1d..18df404 100644
--- a/common/request.js
+++ b/common/request.js
@@ -9,38 +9,72 @@
 	if(uni.getStorageSync('tk')){
 		options.header = {
 			'Content-type': options.header || 'application/json',
-			'tk':uni.getStorageSync('tk'),
-			'uid': uni.getStorageSync('uid')
+			'Authorization':uni.getStorageSync('tk'),
+			// 'uid': uni.getStorageSync('uid')
 		};
 	}
 	else {
 		options.header = {
-			'Content-type': options.header || 'application/json'
+			'Content-type': options.header || 'application/json',
+			'Authorization': ''
 		};
 	}
 	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) == 403){
 				uni.showToast({
 					icon: 'none',
-					duration: 3000,
+					duration: 2000,
 					position: 'top',
-					title: `${res.data.msg}`
+					title: `${res.data.message}`
 				});
-				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)
+			}else if(Number(res.data.code) == 200){
+				
+				if(res.data.msg == '您点击太快了,请稍后尝试'){
+					uni.showToast({
+						icon: 'none',
+						duration: 2000,
+						position: 'top',
+						title: `${res.data.message}`
+					});
+				}
 			}
+				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