1. 管理员管理模块拆分
2. 图片上传自动压缩(大于850kb) 3. 省市区选择组件重构,支持搜索
This commit is contained in:
@@ -3,13 +3,15 @@ import { baseRequestClient, requestClient } from '#/api/request';
|
||||
export namespace AuthApi {
|
||||
/** 登录接口参数 */
|
||||
export interface LoginParams {
|
||||
login_method?: 'phone' | 'login_account' | 'job_number'; // 登录方式类型
|
||||
account: string;
|
||||
password?: string;
|
||||
username?: string;
|
||||
phone?: string; // 手机号(当login_method为phone时)
|
||||
code?: string;
|
||||
login_account?: string; // 登录账号(当login_method为login_account时)
|
||||
job_number?: string; // 工号(当login_method为job_number时)
|
||||
/** @deprecated 兼容旧客户端 */
|
||||
login_method?: 'phone' | 'login_account' | 'job_number';
|
||||
username?: string;
|
||||
phone?: string;
|
||||
login_account?: string;
|
||||
job_number?: string;
|
||||
}
|
||||
|
||||
/** 登录接口返回值 */
|
||||
@@ -24,13 +26,8 @@ export namespace AuthApi {
|
||||
|
||||
/** 发送验证码返回结果 */
|
||||
export interface SendCodeResult {
|
||||
code?: string; // 开发环境返回验证码
|
||||
accounts?: Array<{
|
||||
id: number;
|
||||
login_account: string;
|
||||
job_number: string;
|
||||
}>; // 如果手机号绑定多个账号,返回账号列表
|
||||
need_select?: boolean; // 是否需要选择账号/工号
|
||||
code?: string;
|
||||
need_select?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +35,20 @@ export namespace AuthApi {
|
||||
* 登录
|
||||
*/
|
||||
export async function loginApi(data: AuthApi.LoginParams) {
|
||||
const params: any = {
|
||||
login_method: data.login_method || 'phone', // 添加默认值
|
||||
if (data.account) {
|
||||
return requestClient.post<AuthApi.LoginResult>('login', {
|
||||
account: data.account,
|
||||
password: data.password,
|
||||
code: data.code,
|
||||
});
|
||||
}
|
||||
|
||||
const params: Record<string, unknown> = {
|
||||
login_method: data.login_method || 'phone',
|
||||
password: data.password,
|
||||
code: data.code,
|
||||
};
|
||||
|
||||
|
||||
if (data.login_method === 'phone') {
|
||||
params.phone = data.phone || data.username;
|
||||
} else if (data.login_method === 'login_account') {
|
||||
@@ -51,23 +56,32 @@ export async function loginApi(data: AuthApi.LoginParams) {
|
||||
} else if (data.login_method === 'job_number') {
|
||||
params.job_number = data.job_number;
|
||||
}
|
||||
|
||||
|
||||
return requestClient.post<AuthApi.LoginResult>('login', params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
export async function sendVerificationCode(params: {
|
||||
account?: string;
|
||||
password?: string;
|
||||
login_method?: 'phone' | 'login_account' | 'job_number';
|
||||
username?: string;
|
||||
phone?: string;
|
||||
login_account?: string;
|
||||
job_number?: string;
|
||||
}) {
|
||||
const requestParams: any = {
|
||||
if (params.account) {
|
||||
return requestClient.post<AuthApi.SendCodeResult>('send-verification-code', {
|
||||
account: params.account,
|
||||
});
|
||||
}
|
||||
|
||||
const requestParams: Record<string, unknown> = {
|
||||
login_method: params.login_method || 'phone',
|
||||
};
|
||||
|
||||
|
||||
if (params.login_method === 'phone') {
|
||||
requestParams.phone = params.phone || params.username;
|
||||
} else if (params.login_method === 'login_account') {
|
||||
@@ -75,8 +89,11 @@ export async function sendVerificationCode(params: {
|
||||
} else if (params.login_method === 'job_number') {
|
||||
requestParams.job_number = params.job_number;
|
||||
}
|
||||
|
||||
return requestClient.post<AuthApi.SendCodeResult>('send-verification-code', requestParams);
|
||||
|
||||
return requestClient.post<AuthApi.SendCodeResult>(
|
||||
'send-verification-code',
|
||||
requestParams,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user