fix(mobile): require employee position before user flow

This commit is contained in:
2026-07-09 17:09:26 +08:00
parent 8b92a7e9ac
commit 8f73cb0c84
13 changed files with 473 additions and 33 deletions
+5 -15
View File
@@ -41,6 +41,7 @@ import type { LoginResult } from '@/types/api';
import { apiRequest } from '@/services/api';
import { consumeLoginRedirect, getAuth, isLoggedIn, phoneKey, saveAuth, validatePhone } from '@/services/auth';
import { resetPageScroll } from '@/services/navigation';
import { goToMobileTarget, nextUserRouteAfterLogin } from '@/services/position';
const stored = getAuth();
const phone = ref(stored.phone || uni.getStorageSync(phoneKey) || '');
@@ -48,20 +49,9 @@ const smsCode = ref('');
const sending = ref(false);
const loggingIn = ref(false);
const message = ref('');
const tabPages = new Set([
'/pages/user/today/index',
'/pages/user/practice/index',
'/pages/user/sop/index',
'/pages/user/profile/index'
]);
const goAfterLogin = () => {
const goAfterLogin = async () => {
const redirect = consumeLoginRedirect() || '/pages/user/today/index';
if (tabPages.has(redirect)) {
uni.switchTab({ url: redirect });
return;
}
uni.redirectTo({ url: redirect });
goToMobileTarget(await nextUserRouteAfterLogin(redirect));
};
const sendCode = async () => {
@@ -115,7 +105,7 @@ const login = async () => {
throw new Error('登录响应缺少认证信息');
}
saveAuth(result, value);
goAfterLogin();
await goAfterLogin();
} catch (error) {
message.value = error instanceof Error ? error.message : '登录失败';
} finally {
@@ -126,7 +116,7 @@ const login = async () => {
onShow(() => {
resetPageScroll();
if (isLoggedIn()) {
goAfterLogin();
void goAfterLogin();
}
});
</script>