diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index 2ab7c78..c734a1e 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -228,6 +228,17 @@ const local: any = { birthDate: 'Birth Date', birthDatePlaceholder: 'Please select birth date', birthDateRequired: 'Please select birth date', + usernameLengthLimit:"Username is too short", + usernameExists:"The username is already registered", + usernameRequired:"The username cannot be empty", + phoneInvalid:"The mobile phone number is incorrect", + phoneExists:"The mobile phone number has been registered", + emailInvalid:"The email is incorrect", + emailExists:"The email has been registered", + emailRequired:"The email cannot be empty", + codeRequired:"The code cannot be empty", + passwordRequired:"The password cannot be empty", + passwordLength:"The password is too short", }, resetPwd: { title: 'Reset Password' diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index 1f725c6..e264186 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -228,6 +228,17 @@ const local:any = { birthDate: '出生日期', birthDatePlaceholder: '请选择出生日期', birthDateRequired: '请选择出生日期', + usernameLengthLimit:"用户名太短", + usernameExists:"用户名已经注册", + usernameRequired:"用户名不能为空", + phoneInvalid:"手机号格式不正确", + phoneExists:"手机号已经注册", + emailInvalid:"邮箱格式不正确", + emailExists:"邮箱已经注册", + emailRequired:"邮箱不能为空", + codeRequired:"验证码不能为空", + passwordRequired:"密码不能为空", + passwordLength:"密码太短", }, resetPwd: { title: '重置密码' diff --git a/src/service/api/auth.ts b/src/service/api/auth.ts index 45163c8..b6a3a89 100644 --- a/src/service/api/auth.ts +++ b/src/service/api/auth.ts @@ -21,7 +21,13 @@ export function sendCaptcha(body:Api.Auth.EmailCaptcha){ }) } //验证注册 - +export function doCheckUserRepeat(body:Api.Auth.CheckBody){ + return request({ + url:'/u/user/checkRepeat', + method:'post', + data:body + }) +} //添加注册 export function fetchRegister(body: Api.Auth.RegisterBody) { return request({ diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index 132d094..910a23a 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -7,7 +7,7 @@ import { localStg } from '@/utils/storage'; import { $t } from '@/locales'; import { useRouteStore } from '../route'; import { clearAuthStorage, emptyInfo, getToken } from './shared'; -import {sendCaptcha} from "@/service/api/auth"; +import {doCheckUserRepeat, sendCaptcha} from "@/service/api/auth"; export const useAuthStore = defineStore(SetupStoreId.Auth, () => { const routeStore = useRouteStore(); @@ -122,6 +122,16 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { } return false; } + //check User + + /** + * 检查用户信息是否已存在 + */ + async function checkUserRepeat(checkForm:Api.Auth.CheckBody) { + const { data, error } = await doCheckUserRepeat(checkForm); + return { exists: data, error }; + } + /** * Register new user */ @@ -163,5 +173,6 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { refreshUserInfo, register, captcha, + checkUserRepeat, }; }); diff --git a/src/typings/api.d.ts b/src/typings/api.d.ts index 63746d2..ebdc1c5 100644 --- a/src/typings/api.d.ts +++ b/src/typings/api.d.ts @@ -152,6 +152,11 @@ declare namespace Api { interface EmailCaptcha{ email:string; } + interface CheckBody{ + username?: string; + email?: string; + phonenumber?:string; + } } /** diff --git a/src/typings/auto-imports.d.ts b/src/typings/auto-imports.d.ts index ae8942e..57b1c30 100644 --- a/src/typings/auto-imports.d.ts +++ b/src/typings/auto-imports.d.ts @@ -53,6 +53,7 @@ declare global { const doAddDict: typeof import('../service/api/dict')['doAddDict'] const doAddMenu: typeof import('../service/api/menu')['doAddMenu'] const doAddPost: typeof import('../service/api/post')['doAddPost'] + const doCheckUserRepeat: typeof import('../service/api/auth')['doCheckUserRepeat'] const doDeleteDept: typeof import('../service/api/dept')['doDeleteDept'] const doDeleteDict: typeof import('../service/api/dict')['doDeleteDict'] const doDeleteLogout: typeof import('../service/api/auth')['doDeleteLogout'] diff --git a/src/views/_builtin/login/modules/register.vue b/src/views/_builtin/login/modules/register.vue index 62afc6c..8075f80 100644 --- a/src/views/_builtin/login/modules/register.vue +++ b/src/views/_builtin/login/modules/register.vue @@ -1,9 +1,9 @@