From 3b612cf0221a8caee22081c0ecc277839c34d2bc Mon Sep 17 00:00:00 2001 From: Guwan Date: Sat, 7 Dec 2024 13:48:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E5=90=8E=E7=AB=AF=E8=81=94=E8=B0=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=AC=AC=E4=B8=80=E4=B8=AAts=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/{ => common}/types.ts | 3 +- src/api/user.ts | 21 ++++++++++- src/views/LoginView.vue | 1 - src/views/RegisterView.vue | 71 ++++++++++++++++++----------------- 4 files changed, 58 insertions(+), 38 deletions(-) rename src/api/{ => common}/types.ts (94%) diff --git a/src/api/types.ts b/src/api/common/types.ts similarity index 94% rename from src/api/types.ts rename to src/api/common/types.ts index d2f61f9..0ea6569 100644 --- a/src/api/types.ts +++ b/src/api/common/types.ts @@ -3,6 +3,7 @@ export interface ApiResponse { code: number message: string data: T + timestamp: number } // 分页请求参数接口 @@ -18,4 +19,4 @@ export interface PageResult { total: number page: number pageSize: number -} \ No newline at end of file +} diff --git a/src/api/user.ts b/src/api/user.ts index d049100..2278bfb 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,5 +1,5 @@ import request from '@/utils/request' -import type { ApiResponse, PageResult } from './types' +import type { ApiResponse, PageResult } from './common/types' // 定义接口的请求参数类型 @@ -58,6 +58,13 @@ export interface LoginParams { verifyCode?: string } + +export interface RegisterParams { + phone: string + password: string + verifyCode?: string +} + // 定义后端返回的用户信息类型 export interface UserInfo { id: number @@ -84,8 +91,18 @@ export interface UserQueryParams { ageRange?: [number, number] } + + + // 用户API接口 export const userApi = { + + + register(data: RegisterParams) { + return request.post>('/auth/login', data) + }, + + // 手机号密码登录 login(data: LoginParams) { return request.post>('/auth/login', data) @@ -98,7 +115,7 @@ export const userApi = { // 发送验证码 sendVerifyEmailCode(email: string) { - return request.post>('/user/getEmailCode', { email }) + return request.post('/user/getEmailCode', { email }) }, // 获取当前登录用户信息 diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index ba972ec..2e33d4c 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -279,7 +279,6 @@ const sendEmailCode = async () => { ElMessage.warning('请先输入邮箱') return } - console.log(111) await userApi.sendVerifyEmailCode(emailForm.email) ElMessage.success('验证码已发送') startCooldown('email') diff --git a/src/views/RegisterView.vue b/src/views/RegisterView.vue index b629839..0c25fc6 100644 --- a/src/views/RegisterView.vue +++ b/src/views/RegisterView.vue @@ -14,8 +14,8 @@

智慧养老平台

创建新账号

- - - @@ -36,7 +36,7 @@ - - + - 手机验证 - +
- - @@ -105,7 +105,7 @@ - 邮箱验证
- +
- - @@ -155,7 +155,7 @@ -
- 注 册 - +