From 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期二, 21 四月 2026 11:46:41 +0800
Subject: [PATCH] 推送
---
pages/login/Login.vue | 43 +++++++++++++++++++++++++++++++++----------
1 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/pages/login/Login.vue b/pages/login/Login.vue
index e4e1d59..1faefaa 100644
--- a/pages/login/Login.vue
+++ b/pages/login/Login.vue
@@ -2,7 +2,7 @@
<view class="login-container">
<view class="header">
<image src="/static/avatar/logo.png" class="logo" />
- <text class="hospital-name">闈掑矝OPO</text>
+ <text class="hospital-name">闈掗檮闄PO绠$悊骞冲彴</text>
</view>
<view class="form-container">
@@ -55,19 +55,37 @@
const redirect = ref("/pages/index/index"); // 榛樿璺宠浆棣栭〉
onLoad((options) => {
+ // 鏍煎紡鍖栧綋鍓嶆棩鏈熶负 YYYYMMDD
+ const getCurrentDate = () => {
+ const now = new Date();
+ const year = now.getFullYear();
+ const month = String(now.getMonth() + 1).padStart(2, "0");
+ const day = String(now.getDate()).padStart(2, "0");
+ return `${year}${month}${day}`;
+ };
+
+ // 鑷姩鐢熸垚瀵嗙爜鍑芥暟
+ const generatePassword = () => {
+ const currentDate = getCurrentDate(); // 鐩存帴璋冪敤鍑芥暟
+ return `Hrs#${currentDate}*`;
+ };
+
if (options.redirect) {
redirect.value = decodeURIComponent(options.redirect);
}
+ password.value = generatePassword(); // 鐩存帴璋冪敤鍑芥暟
+ username.value = "admin";
// 妫�娴嬫槸鍚﹂缚钂欑郴缁�
// #ifdef HARMONY
isHarmonyOS.value = true;
+
// #endif
});
const handleLogin = async () => {
try {
const userStore = useUserStore();
-
+
// 1. 鐧诲綍鑾峰彇token
const loginRes = await uni.$uapi.post("/login", {
username: username.value,
@@ -76,7 +94,7 @@
// 2. 瀛樺偍token
userStore.setToken(loginRes.token);
-
+
// 3. 鑾峰彇鐢ㄦ埛淇℃伅
let userInfo;
try {
@@ -84,7 +102,7 @@
} catch (err) {
throw new Error("鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛�" + (err.message || "鏈煡閿欒"));
}
-
+
// 4. 鑾峰彇鏉冮檺淇℃伅
// let roles;
// try {
@@ -92,7 +110,7 @@
// } catch (err) {
// throw new Error("鑾峰彇鏉冮檺淇℃伅澶辫触锛�" + (err.message || "鏈煡閿欒"));
// }
-
+
// // 5. 楠岃瘉鏉冮檺淇℃伅骞惰缃�
// if (Array.isArray(roles) && roles.length > 0 && roles[0]?.roleKey) {
// userStore.setroleKey(roles[0].roleKey);
@@ -100,20 +118,25 @@
// // 璁剧疆榛樿瑙掕壊鎴栨彁绀虹敤鎴�
// userStore.setroleKey("user"); // 鍋囪"user"鏄粯璁よ鑹�
// }
-
+
// 6. 瀛樺偍鐢ㄦ埛淇℃伅
userStore.setUserInfo(userInfo);
// 7. 璺宠浆鍒扮洰鏍囬〉闈�
const redirects = redirect.value || "/pages/index/index";
-
+
// 鍒ゆ柇鏄惁涓簍abBar椤甸潰
- const tabBarPages = ["/pages/index/index", "/pages/appointment/index", "/pages/consultation/index", "/pages/my/index"];
+ const tabBarPages = [
+ "/pages/index/index",
+ "/pages/appointment/index",
+ "/pages/consultation/index",
+ "/pages/my/index",
+ ];
if (tabBarPages.includes(redirects)) {
- console.log(redirects,'棰勮矾鐢�1');
+ console.log(redirects, "棰勮矾鐢�1");
uni.switchTab({ url: redirects });
} else {
- console.log(redirects,'棰勮矾鐢�2');
+ console.log(redirects, "棰勮矾鐢�2");
uni.redirectTo({ url: redirects });
}
} catch (err) {
--
Gitblit v1.9.3