30 lines
719 B
TypeScript
30 lines
719 B
TypeScript
import type { ApiResponse } from "@/types";
|
|
import { http } from "@/utils";
|
|
export interface LoginInput {
|
|
username: string;
|
|
password: string;
|
|
mobile?: string;
|
|
smsCode?: string;
|
|
provinceCode: string;
|
|
areaCode: string;
|
|
tenantId: string;
|
|
clientType?: "WEB" | "MINI";
|
|
}
|
|
|
|
export interface TokenPayload {
|
|
accessToken: string;
|
|
refreshToken: string;
|
|
tokenType: string;
|
|
expiresIn: number;
|
|
}
|
|
|
|
export async function login(input: LoginInput) {
|
|
return http.post<ApiResponse<TokenPayload>>("/auth/tokens", input);
|
|
}
|
|
|
|
export async function refreshToken(refreshToken: string) {
|
|
return http.post<ApiResponse<TokenPayload>>("/auth/tokens/refresh", {
|
|
refreshToken
|
|
});
|
|
}
|