diff --git a/src/api/user.ts b/src/api/user.ts index dafc55e..6639c95 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -53,9 +53,12 @@ import type { ApiResponse, PageResult } from './common/types' */ export interface LoginParams { - phone: string + activeTab: string + username: string password: string - verifyCode?: string + phone: string + email: string + code: string } export interface RegisterParams { @@ -101,27 +104,24 @@ export interface UserQueryParams { // 用户API接口 export const userApi = { - + //注册 register(data: RegisterParams) { return request.post('/user/register', data) }, - // 手机号密码登录 + // 登录 login(data: LoginParams) { - return request.post>('/auth/login', data) + return request.post>('/user/login', data) }, - - - // 发送验证码 sendVerifyEmailCode(email: string) { return request.post('/user/getEmailCode', { email }) }, // 发送验证码 sendVerifyPhoneCode(phone: string) { - return request.post('/user/getphoneCode', { phone }) + return request.post('/user/getPhoneCode', { phone }) }, // 获取当前登录用户信息 diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index 2e33d4c..a6d9696 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -292,15 +292,14 @@ const handleLogin = async () => { switch (activeTab.value) { case 'account': formRef = accountFormRef.value - formData = accountForm + formData = { ...accountForm, activeTab: activeTab.value }; break case 'phone': formRef = phoneFormRef.value - formData = phoneForm - break + formData = { ...phoneForm, activeTab: activeTab.value }; case 'email': formRef = emailFormRef.value - formData = emailForm + formData = { ...emailForm, activeTab: activeTab.value }; break } @@ -310,7 +309,9 @@ const handleLogin = async () => { if (valid) { loading.value = true try { - // TODO: 调用登录API + + await userApi.login(formData) + await new Promise(resolve => setTimeout(resolve, 1000)) // 保存token和用户信息 @@ -326,7 +327,7 @@ const handleLogin = async () => { const redirect = route.query.redirect as string router.push(redirect || '/') } catch (error) { - ElMessage.error('登录失败,请检查输入信息') + //ElMessage.error('登录失败,请检查输入信息') } finally { loading.value = false }