第 1 阶段:用户与认证, mock登陆ok

This commit is contained in:
yml
2026-05-22 15:21:36 +08:00
parent 8e7f1f17f0
commit 9a79603e10
21 changed files with 780 additions and 4 deletions
+46
View File
@@ -0,0 +1,46 @@
import { apiClient } from './client'
export interface AuthUser {
id: number
phone: string
nickname: string
realname_status: string
risk_status: string
credit_score: number
status: string
}
export interface TokenPair {
access_token: string
refresh_token: string
token_type: string
expires_in: number
}
export interface LoginData {
user: AuthUser
tokens: TokenPair
}
interface ApiResponse<T> {
code: string
message: string
data: T
}
export async function sendSmsCode(phone: string) {
const { data } = await apiClient.post<ApiResponse<{ phone: string; expires_in: number }>>('/auth/sms/send', {
phone,
})
return data.data
}
export async function loginWithSms(phone: string, code: string) {
const { data } = await apiClient.post<ApiResponse<LoginData>>('/auth/sms/login', { phone, code })
return data.data
}
export async function fetchMe() {
const { data } = await apiClient.get<ApiResponse<AuthUser>>('/me')
return data.data
}