登录验证
This commit is contained in:
@@ -20,6 +20,12 @@ export async function login(username: string, password: string, captchaToken?: s
|
||||
setToken(res.accessToken);
|
||||
return res.user;
|
||||
}
|
||||
export async function phonelogin(phone: string, code: string): Promise<User> {
|
||||
// if (USE_MOCK) return mock.mockLogin({ username, password });
|
||||
const res = await api.post<{ accessToken: string; user: User }>('/auth/sms-login', { phone, code }, false);
|
||||
setToken(res.accessToken);
|
||||
return res.user;
|
||||
}
|
||||
|
||||
export async function register(phone: string, code: string, password: string): Promise<User> {
|
||||
const res = await api.post<{ accessToken: string; user: User }>('/auth/register', { phone, code, password }, false);
|
||||
@@ -211,9 +217,9 @@ export async function getParameters(): Promise<any[]> {
|
||||
|
||||
// ── SMS ───────────────────────────────────────────────────
|
||||
|
||||
export async function sendSms(phone: string, captchaToken?: string): Promise<void> {
|
||||
export async function sendSms(phone: string, scene: string): Promise<void> {
|
||||
if (USE_MOCK) return;
|
||||
await api.post('/sms/send', { phone, captcha_token: captchaToken }, false);
|
||||
await api.post('/sms/send', { phone, scene: scene }, false);
|
||||
}
|
||||
|
||||
export async function verifySms(phone: string, code: string): Promise<{ token: string }> {
|
||||
@@ -351,3 +357,10 @@ export async function deleteHistory(id: string): Promise<void> {
|
||||
export async function calculateCredits(): Promise<any[]> {
|
||||
return api.get('/credits/credit-ratios');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 获取验证码
|
||||
export async function getSendcode(phone: string): Promise<any> {
|
||||
return api.post('/sms/send', { phone });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user