2026-04-17 16:31:32 +08:00
|
|
|
import type { ApiResponse } from "@/types";
|
|
|
|
|
import { http } from "@/utils";
|
|
|
|
|
export interface LoginInput {
|
2026-04-14 16:27:47 +08:00
|
|
|
username: string;
|
|
|
|
|
password: string;
|
2026-04-17 16:31:32 +08:00
|
|
|
mobile?: string;
|
|
|
|
|
smsCode?: string;
|
2026-04-14 16:27:47 +08:00
|
|
|
provinceCode: string;
|
|
|
|
|
areaCode: string;
|
|
|
|
|
tenantId: string;
|
2026-04-17 16:31:32 +08:00
|
|
|
clientType?: "WEB" | "MINI";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface TokenPayload {
|
|
|
|
|
accessToken: string;
|
|
|
|
|
refreshToken: string;
|
|
|
|
|
tokenType: string;
|
|
|
|
|
expiresIn: number;
|
2026-04-14 16:27:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function login(input: LoginInput) {
|
2026-04-17 16:31:32 +08:00
|
|
|
return http.post<ApiResponse<TokenPayload>>("/auth/tokens", input);
|
2026-04-16 18:12:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function refreshToken(refreshToken: string) {
|
2026-04-17 16:31:32 +08:00
|
|
|
return http.post<ApiResponse<TokenPayload>>("/auth/tokens/refresh", {
|
2026-04-16 18:12:09 +08:00
|
|
|
refreshToken
|
|
|
|
|
});
|
2026-04-14 16:27:47 +08:00
|
|
|
}
|