feat(aihr): align figma pages for release

This commit is contained in:
2026-07-14 02:04:36 +08:00
parent 922fe7ff29
commit 87360a25d3
51 changed files with 3575 additions and 629 deletions
+3
View File
@@ -5,6 +5,7 @@ export const clientIdKey = 'aihr_mobile_client_id';
export const phoneKey = 'aihr_mobile_phone';
export const loginRedirectKey = 'aihr_mobile_login_redirect';
export const positionKey = 'aihr_mobile_position';
export const roleKey = 'aihr_mobile_role';
export const phonePattern = /^1[3-9]\d{9}$/;
export const userPositionOptions = ['生活顾问', '保安', '保洁', '保修', '客服'] as const;
@@ -106,6 +107,7 @@ export const saveAuth = (result: LoginResult, phone: string) => {
const previousPhone = uni.getStorageSync(phoneKey) || '';
if (previousPhone && previousPhone !== phone) {
uni.removeStorageSync(positionKey);
uni.removeStorageSync(roleKey);
}
uni.setStorageSync(tokenKey, result.access_token);
uni.setStorageSync(clientIdKey, result.client_id);
@@ -117,6 +119,7 @@ export const clearAuth = () => {
uni.removeStorageSync(clientIdKey);
uni.removeStorageSync(phoneKey);
uni.removeStorageSync(positionKey);
uni.removeStorageSync(roleKey);
uni.removeStorageSync(loginRedirectKey);
};
+30 -1
View File
@@ -1,9 +1,10 @@
import type { OrgSnapshotResponse } from '@/types/api';
import type { MobileIdentity, OrgSnapshotResponse, RoleKey } from '@/types/api';
import { apiRequest } from './api';
import {
getAuth,
hasSelectedPosition,
normalizePosition,
roleKey,
saveSelectedPosition,
type UserPosition
} from './auth';
@@ -17,6 +18,31 @@ export const userTabPages = new Set([
export const isUserRoute = (url: string) => url.startsWith('/pages/user/');
export const isSupervisorRoute = (url: string) => url.startsWith('/pages/supervisor/');
export const routeForMobileRole = (role: RoleKey, requested: string) => {
if (role === 'supervisor' && (isUserRoute(requested) || isSupervisorRoute(requested))) {
return '/pages/supervisor/index/index';
}
return requested;
};
export const hydrateMobileRole = async (): Promise<RoleKey> => {
try {
const identity = await apiRequest<MobileIdentity>({
url: '/api/aihr/mobile/me',
method: 'GET',
timeout: 15000,
clearAuthOnUnauthorized: false
});
const role = identity.role === 'supervisor' ? 'supervisor' : 'user';
uni.setStorageSync(roleKey, role);
return role;
} catch {
return (uni.getStorageSync(roleKey) === 'supervisor' ? 'supervisor' : 'user') as RoleKey;
}
};
export const positionSetupUrl = (redirect: string) =>
`/pages/auth/position/index?redirect=${encodeURIComponent(redirect || '/pages/user/today/index')}`;
@@ -46,6 +72,9 @@ export const hydratePositionFromOrg = async (phone = getAuth().phone): Promise<U
};
export const nextUserRouteAfterLogin = async (redirect: string) => {
const role = await hydrateMobileRole();
const roleRoute = routeForMobileRole(role, redirect);
if (roleRoute !== redirect) return roleRoute;
if (!isUserRoute(redirect) || hasSelectedPosition()) return redirect;
const officialPosition = await hydratePositionFromOrg();
return normalizePosition(officialPosition) ? redirect : positionSetupUrl(redirect);
+7
View File
@@ -81,6 +81,13 @@ export const getPracticeHistory = () => {
});
};
export const getPracticeHistoryDetail = (id: number) =>
apiRequest<ReviewDetail>({
url: `/api/aihr/mobile/practice/history/${id}`,
method: 'GET',
timeout: 15000
});
export const getCompetencyProfile = () => {
const extPartyId = encodeURIComponent(currentExtPartyId());
return apiRequest<CompetencyProfile>({