From 75e3bca44b111c167b9389e4e51b2ce577a9f9e0 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期日, 10 八月 2025 10:35:50 +0800
Subject: [PATCH] 优化更新

---
 吉安PDA/pages/home/home.vue |  102 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 65 insertions(+), 37 deletions(-)

diff --git "a/\345\220\211\345\256\211PDA/pages/home/home.vue" "b/\345\220\211\345\256\211PDA/pages/home/home.vue"
index 1c36adb..2f88570 100644
--- "a/\345\220\211\345\256\211PDA/pages/home/home.vue"
+++ "b/\345\220\211\345\256\211PDA/pages/home/home.vue"
@@ -7,42 +7,24 @@
 			<view class="card">
 				<view class="top">
 					<view class="userImage">
-						<!-- <open-data type="userAvatarUrl"></open-data> -->
 						<u-avatar :src="src" size="146"></u-avatar>
 					</view>
 				</view>
 				<view class="bottom" @tap.native="Login">
 					<view class="left">
 						<view class="user-text">
-							<!-- <open-data type="userNickName"></open-data> -->
 							<text style="text-align: center;">{{userNickName}}</text>
 						</view>
-						<!-- <view class="user-phone"> 171****4133 </view> -->
 					</view>
 					<view class="right flex-center">
 						<u-icon class="icon" name="arrow-right"></u-icon>
 					</view>
 				</view>
-				<!-- <view class="settings" @click="settings">
-					<view class="left">
-						<view class="settings-text">
-							<open-data type="userNickName"></open-data>
-							<text style="text-align: center;">璁剧疆</text>
-						</view>
-						<view class="user-phone"> 171****4133 </view>
-					</view>
-					<view class="right flex-center">
-						<u-icon class="icon" name="arrow-right"></u-icon>
-					</view>
-				</view> -->
 			</view>
 		</view>
 		<view class="list-card">
 		</view>
 		<view class="quit flex-center">
-			<!-- <view class="btn flex-center" @click="LastLogin">
-				鏇存柊绋嬪簭
-			</view> -->
 			<view class="btn flex-center" @click="LastLogin">
 				閫�鍑虹櫥褰�
 			</view>
@@ -225,35 +207,73 @@
 </style>
 
 <script>
-	//import {  } from "@/common/api/{$}.js";
 	import httpInterceptor from '@/common/http.interceptor.js'
 	export default {
 		data() {
 			return {
 				src: "",
 				userNickName: '璇风櫥褰�',
+				// 杩囨湡鏃堕棿妫�鏌ュ畾鏃跺櫒
+				checkExpirationTimer: null
 			};
 		},
-		//鐩戝惉椤甸潰鍒濆鍖栵紝鍏跺弬鏁板悓 onLoad 鍙傛暟锛屼负涓婁釜椤甸潰浼犻�掔殑鏁版嵁锛屽弬鏁扮被鍨嬩负 Object锛堢敤浜庨〉闈紶鍙傦級锛岃Е鍙戞椂鏈烘棭浜� onLoad
-		onInit() {},
-		//鐩戝惉椤甸潰鍔犺浇锛屽叾鍙傛暟涓轰笂涓〉闈紶閫掔殑鏁版嵁锛屽弬鏁扮被鍨嬩负 Object锛堢敤浜庨〉闈紶鍙傦級
 		onLoad() {
-			let isLogin = this.hasLogin();
-			if (isLogin) {
-				let haslogin = uni.getStorageSync('jo_user')
-				this.userNickName = haslogin.userName;
-				this.src = httpInterceptor.baseUrl + "/" + haslogin.img;
+			// 妫�鏌ョ櫥褰曠姸鎬佸拰鏄惁杩囨湡
+			this.checkLoginStatus();
+			
+			// 璁剧疆瀹氭椂妫�鏌ワ紝姣�30鍒嗛挓妫�鏌ヤ竴娆�
+			this.checkExpirationTimer = setInterval(() => {
+				this.checkLoginExpiration();
+			}, 30 * 60 * 1000);
+		},
+		onUnload() {
+			// 椤甸潰鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒
+			if (this.checkExpirationTimer) {
+				clearInterval(this.checkExpirationTimer);
 			}
 		},
-		//鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚銆傛敞鎰忓鏋滄覆鏌撻�熷害蹇紝浼氬湪椤甸潰杩涘叆鍔ㄧ敾瀹屾垚鍓嶈Е鍙�
-		onReady() {},
-		//鐩戝惉椤甸潰鏄剧ず銆傞〉闈㈡瘡娆″嚭鐜板湪灞忓箷涓婇兘瑙﹀彂锛屽寘鎷粠涓嬬骇椤甸潰鐐硅繑鍥為湶鍑哄綋鍓嶉〉闈�
-		beforeDestroy() {},
-		//椤甸潰婊氬姩鍒板簳閮ㄧ殑浜嬩欢锛堜笉鏄痵croll-view婊氬埌搴曪級锛屽父鐢ㄤ簬涓嬫媺涓嬩竴椤垫暟鎹��
-		onReachBottom() {},
-		onShareAppMessage(res) {},
-		created() {},
+		onShow() {
+			// 椤甸潰鏄剧ず鏃跺啀娆℃鏌�
+			this.checkLoginStatus();
+		},
 		methods: {
+			// 妫�鏌ョ櫥褰曠姸鎬�
+			checkLoginStatus() {
+				let isLogin = this.hasLogin();
+				if (isLogin) {
+					// 妫�鏌ユ槸鍚﹁繃鏈�
+					if (this.checkLoginExpiration()) {
+						let haslogin = uni.getStorageSync('jo_user')
+						this.userNickName = haslogin.userName;
+						this.src = httpInterceptor.baseUrl + "/" + haslogin.img;
+					}
+				}
+			},
+			
+			// 妫�鏌ョ櫥褰曟槸鍚﹁繃鏈�
+			checkLoginExpiration() {
+				const expirationTime = uni.getStorageSync('jo_expiration_time');
+				const currentTime = new Date().getTime();
+				
+				// 濡傛灉娌℃湁璁剧疆杩囨湡鏃堕棿锛岃涓烘湭鐧诲綍
+				if (!expirationTime) {
+					this.logout();
+					return false;
+				}
+				
+				// 妫�鏌ユ槸鍚﹁繃鏈�
+				if (currentTime > expirationTime) {
+					uni.showToast({
+						title: '鐧诲綍宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�',
+						icon: 'none',
+						duration: 2000
+					});
+					this.logout();
+					return false;
+				}
+				return true;
+			},
+
 			hasLogin() {
 				let haslogin = uni.getStorageSync('jo_user')
 				if (haslogin == null || haslogin == "") {
@@ -263,11 +283,19 @@
 				}
 			},
 
+			// 閫�鍑虹櫥褰�
 			LastLogin() {
-				//uni.clearStorage();
+				this.logout();
+			},
+			
+			// 缁熶竴鐨勯��鍑虹櫥褰曞鐞�
+			logout() {
 				uni.removeStorageSync('jo_id_token');
 				uni.removeStorageSync('jo_user');
 				uni.removeStorageSync('jo_userImg');
+				uni.removeStorageSync('jo_expiration_time'); // 娓呴櫎杩囨湡鏃堕棿
+				this.userNickName = '璇风櫥褰�';
+				this.src = "";
 				this.$u.route('/pages/login/login');
 			},
 
@@ -279,4 +307,4 @@
 			}
 		},
 	};
-</script>
\ No newline at end of file
+</script>

--
Gitblit v1.9.3