新增注册功能

This commit is contained in:
zjl 2024-12-16 15:40:20 +08:00
parent 083cb40169
commit 59c5329d26
2 changed files with 11 additions and 37 deletions

View File

@ -12,7 +12,7 @@ VITE_DROP_CONSOLE = true
# 跨域代理,可以配置多个,请注意不要换行 # 跨域代理,可以配置多个,请注意不要换行
#VITE_PROXY = [["/appApi","http://localhost:8001"],["/upload","http://localhost:8001/upload"]] #VITE_PROXY = [["/appApi","http://localhost:8001"],["/upload","http://localhost:8001/upload"]]
VITE_PROXY=[["/api","http://192.168.124.203:8081/api"]] VITE_PROXY=[["/api","http://127.0.0.1:8081/api"]]
# API 接口地址 # API 接口地址
VITE_GLOB_API_URL = VITE_GLOB_API_URL =

View File

@ -4,12 +4,12 @@
:show-label="false" :show-label="false"
:show-require-mark="false" :show-require-mark="false"
size="large" size="large"
:model="formInline" :model="formData"
:rules="rules" :rules="rules"
class="register-form" class="register-form"
> >
<el-form-item prop="username"> <el-form-item prop="username">
<el-input v-model="formInline.username" placeholder="请输入用户名"> <el-input v-model="formData.username" placeholder="请输入用户名">
<template #prefix> <template #prefix>
<el-icon class="el-input__icon" size="18" color="#808695"> <el-icon class="el-input__icon" size="18" color="#808695">
<PersonOutline /> <PersonOutline />
@ -18,7 +18,7 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="mobile"> <el-form-item prop="mobile">
<el-input v-model="formInline.mobile" placeholder="请输入手机号码"> <el-input v-model="formData.mobile" placeholder="请输入手机号码">
<template #prefix> <template #prefix>
<el-icon class="el-input__icon" size="18" color="#808695"> <el-icon class="el-input__icon" size="18" color="#808695">
<Iphone /> <Iphone />
@ -27,7 +27,7 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="code"> <el-form-item prop="code">
<el-input v-model.trim="formInline.code" placeholder="验证码"> <el-input v-model.trim="formData.code" placeholder="验证码">
<template #prefix> <template #prefix>
<el-icon class="el-input__icon" size="18" color="#808695"> <el-icon class="el-input__icon" size="18" color="#808695">
<SafetyCertificateOutlined /> <SafetyCertificateOutlined />
@ -41,12 +41,7 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item prop="password"> <el-form-item prop="password">
<el-input <el-input v-model="formData.password" type="password" show-password placeholder="请输入密码">
v-model="formInline.password"
type="password"
show-password
placeholder="请输入密码"
>
<template #prefix> <template #prefix>
<el-icon class="el-input__icon" size="18" color="#808695"> <el-icon class="el-input__icon" size="18" color="#808695">
<Lock /> <Lock />
@ -56,7 +51,7 @@
</el-form-item> </el-form-item>
<el-form-item prop="retPassword"> <el-form-item prop="retPassword">
<el-input <el-input
v-model="formInline.retPassword" v-model="formData.retPassword"
type="password" type="password"
show-password show-password
placeholder="请再次输入密码" placeholder="请再次输入密码"
@ -83,7 +78,7 @@
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div class="flex-initial"> <div class="flex-initial">
<el-form-item prop="agreement"> <el-form-item prop="agreement">
<el-checkbox v-model="formInline.agreement">我同意隐私协议</el-checkbox> <el-checkbox v-model="formData.agreement">我同意隐私协议</el-checkbox>
</el-form-item> </el-form-item>
</div> </div>
</div> </div>
@ -108,22 +103,10 @@
const isGetCode = ref(false); const isGetCode = ref(false);
const emit = defineEmits(['backLogin']); const emit = defineEmits(['backLogin']);
// /**
// *
// */
// interface FormState {
// username: string;
// password: string;
// retPassword: string;
// mobile: string;
// code: string;
// agreement: boolean;
// }
/** /**
* 定义表单参数 * 定义表单参数
*/ */
const formInline = reactive({ const formData = reactive({
username: '', username: '',
password: '', password: '',
retPassword: '', retPassword: '',
@ -160,16 +143,7 @@
loading.value = true; loading.value = true;
formRef.value.validate(async (valid) => { formRef.value.validate(async (valid) => {
if (valid) { if (valid) {
// const { code, msg } = await register(formData);
const params = {
username: formInline.username,
password: formInline.password,
retPassword: formInline.retPassword,
mobile: formInline.mobile,
code: formInline.code,
agreement: formInline.agreement,
};
const { code, msg } = await register(params);
if (code == ResultEnum.SUCCESS) { if (code == ResultEnum.SUCCESS) {
ElMessage.success('注册成功,请登录'); ElMessage.success('注册成功,请登录');
backLogin(); backLogin();
@ -198,7 +172,7 @@
* 获取验证码 * 获取验证码
*/ */
function getCode() { function getCode() {
if (!formInline.mobile) { if (!formData.mobile) {
formRef.value.validateField('mobile'); formRef.value.validateField('mobile');
return; return;
} }