2023-01-29 13:44:19 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="main">
|
2023-06-27 09:29:43 +08:00
|
|
|
<a-form ref="formRef" class="user-layout-register" name="custom-validation" :model="formState" :rules="rules" v-bind="layout" @finish="handleFinish" @finishFailed="handleFinishFailed">
|
2023-06-28 15:42:10 +08:00
|
|
|
<a-tabs :tab-bar-style="{ textAlign: 'center', borderBottom: 'unset' }">
|
|
|
|
|
<a-tab-pane key="register" tab="用户注册"> </a-tab-pane>
|
|
|
|
|
</a-tabs>
|
|
|
|
|
<a-form-item required has-feedback name="username" label="用户名">
|
|
|
|
|
<a-input v-model:value="formState.username" placeholder="用户名" size="large" autocomplete="off">
|
2023-01-29 13:44:19 +08:00
|
|
|
<template #prefix>
|
|
|
|
|
<span class="iconify" data-icon="ion:person" data-inline="false"></span>
|
|
|
|
|
</template>
|
|
|
|
|
</a-input>
|
|
|
|
|
</a-form-item>
|
2023-06-28 15:42:10 +08:00
|
|
|
<a-form-item has-feedback name="password" label="密码">
|
|
|
|
|
<a-input-password v-model:value="formState.password" placeholder="密码" size="large" autocomplete="off">
|
2023-01-29 13:44:19 +08:00
|
|
|
<template #prefix>
|
|
|
|
|
<span class="iconify" data-icon="ion:lock-closed" data-inline="false"></span>
|
|
|
|
|
</template>
|
|
|
|
|
</a-input-password>
|
|
|
|
|
</a-form-item>
|
2023-06-28 15:42:10 +08:00
|
|
|
<a-form-item has-feedback name="confirmPassword" label="确认密码">
|
|
|
|
|
<a-input-password v-model:value="formState.confirmPassword" placeholder="确认密码" size="large" autocomplete="off">
|
2023-01-29 13:44:19 +08:00
|
|
|
<template #prefix>
|
|
|
|
|
<span class="iconify" data-icon="ion:lock-closed" data-inline="false"></span>
|
|
|
|
|
</template>
|
|
|
|
|
</a-input-password>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
|
|
|
|
|
<a-form-item>
|
|
|
|
|
<a-button type="primary" size="large" html-type="submit" class="login-button">注册</a-button>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
|
|
|
|
|
<a-form-item class="user-login-other">
|
|
|
|
|
<router-link class="register" :to="{ name: 'login' }"> 登录 </router-link>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-form>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2023-03-16 19:24:01 +00:00
|
|
|
<script lang="ts">
|
2023-01-29 13:44:19 +08:00
|
|
|
import { defineComponent, reactive, ref, toRaw } from "vue";
|
|
|
|
|
import { useUserStore } from "/src/store/modules/user";
|
|
|
|
|
export default defineComponent({
|
2023-06-27 09:29:43 +08:00
|
|
|
name: "RegisterPage",
|
2023-01-29 13:44:19 +08:00
|
|
|
setup() {
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
const formRef = ref();
|
2023-03-16 19:24:01 +00:00
|
|
|
const formState: any = reactive({
|
2023-01-29 13:44:19 +08:00
|
|
|
username: "",
|
2023-06-27 09:29:43 +08:00
|
|
|
password: "",
|
|
|
|
|
confirmPassword: ""
|
2023-01-29 13:44:19 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const rules = {
|
|
|
|
|
username: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
trigger: "change",
|
|
|
|
|
message: "请输入用户名"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
password: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
trigger: "change",
|
|
|
|
|
message: "请输入密码"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
confirmPassword: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
trigger: "change",
|
|
|
|
|
message: "请确认密码"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
const layout = {
|
|
|
|
|
labelCol: {
|
|
|
|
|
span: 0
|
|
|
|
|
},
|
|
|
|
|
wrapperCol: {
|
|
|
|
|
span: 24
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-16 19:24:01 +00:00
|
|
|
const handleFinish = async (values: any) => {
|
2023-06-27 09:29:43 +08:00
|
|
|
await userStore.register(
|
2023-01-29 13:44:19 +08:00
|
|
|
toRaw({
|
|
|
|
|
password: formState.password,
|
|
|
|
|
username: formState.username
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-16 19:24:01 +00:00
|
|
|
const handleFinishFailed = (errors: any) => {
|
2023-01-29 13:44:19 +08:00
|
|
|
console.log(errors);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const resetForm = () => {
|
|
|
|
|
formRef.value.resetFields();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
formState,
|
|
|
|
|
formRef,
|
|
|
|
|
rules,
|
|
|
|
|
layout,
|
|
|
|
|
handleFinishFailed,
|
|
|
|
|
handleFinish,
|
|
|
|
|
resetForm
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less">
|
|
|
|
|
@import "../../../style/theme/index.less";
|
2023-06-27 09:29:43 +08:00
|
|
|
.user-layout-register {
|
2023-01-29 13:44:19 +08:00
|
|
|
label {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.login-title {
|
2023-06-27 09:29:43 +08:00
|
|
|
// color: @primary-color;
|
2023-01-29 13:44:19 +08:00
|
|
|
font-size: 18px;
|
|
|
|
|
text-align: center;
|
2023-06-27 09:29:43 +08:00
|
|
|
margin: 30px;
|
|
|
|
|
margin-top: 50px;
|
2023-01-29 13:44:19 +08:00
|
|
|
}
|
|
|
|
|
.getCaptcha {
|
|
|
|
|
display: block;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 40px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.forge-password {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button.login-button {
|
|
|
|
|
padding: 0 15px;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
height: 40px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-login-other {
|
|
|
|
|
text-align: left;
|
|
|
|
|
margin-top: 30px;
|
|
|
|
|
margin-bottom: 30px;
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
|
|
|
|
|
.item-icon {
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
color: rgba(0, 0, 0, 0.2);
|
|
|
|
|
margin-left: 16px;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: color 0.3s;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
color: @primary-color;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.register {
|
|
|
|
|
float: right;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.iconify {
|
|
|
|
|
color: rgba(0, 0, 0, 0.45);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|