2025-06-14 18:03:55 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="register">
|
2025-09-27 15:45:56 +08:00
|
|
|
<img :src="loginBg" alt="" srcset="" class="login-bg" />
|
|
|
|
|
<el-form
|
|
|
|
|
ref="registerForm"
|
|
|
|
|
:model="registerForm"
|
|
|
|
|
:rules="registerRules"
|
|
|
|
|
class="register-form"
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src="./../assets/images/ems/logo.png"
|
|
|
|
|
alt=""
|
|
|
|
|
srcset=""
|
|
|
|
|
class="login-logo"
|
|
|
|
|
/>
|
2025-06-14 18:03:55 +08:00
|
|
|
<el-form-item prop="username">
|
2025-09-27 15:45:56 +08:00
|
|
|
<el-input
|
|
|
|
|
v-model="registerForm.username"
|
|
|
|
|
type="text"
|
|
|
|
|
auto-complete="off"
|
|
|
|
|
placeholder="账号"
|
|
|
|
|
>
|
|
|
|
|
<svg-icon
|
|
|
|
|
slot="prefix"
|
|
|
|
|
icon-class="user"
|
|
|
|
|
class="el-input__icon input-icon"
|
|
|
|
|
/>
|
2025-06-14 18:03:55 +08:00
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="password">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="registerForm.password"
|
|
|
|
|
type="password"
|
|
|
|
|
auto-complete="off"
|
|
|
|
|
placeholder="密码"
|
|
|
|
|
@keyup.enter.native="handleRegister"
|
|
|
|
|
>
|
2025-09-27 15:45:56 +08:00
|
|
|
<svg-icon
|
|
|
|
|
slot="prefix"
|
|
|
|
|
icon-class="password"
|
|
|
|
|
class="el-input__icon input-icon"
|
|
|
|
|
/>
|
2025-06-14 18:03:55 +08:00
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="confirmPassword">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="registerForm.confirmPassword"
|
|
|
|
|
type="password"
|
|
|
|
|
auto-complete="off"
|
|
|
|
|
placeholder="确认密码"
|
|
|
|
|
@keyup.enter.native="handleRegister"
|
|
|
|
|
>
|
2025-09-27 15:45:56 +08:00
|
|
|
<svg-icon
|
|
|
|
|
slot="prefix"
|
|
|
|
|
icon-class="password"
|
|
|
|
|
class="el-input__icon input-icon"
|
|
|
|
|
/>
|
2025-06-14 18:03:55 +08:00
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="code" v-if="captchaEnabled">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="registerForm.code"
|
|
|
|
|
auto-complete="off"
|
|
|
|
|
placeholder="验证码"
|
|
|
|
|
style="width: 63%"
|
|
|
|
|
@keyup.enter.native="handleRegister"
|
|
|
|
|
>
|
2025-09-27 15:45:56 +08:00
|
|
|
<svg-icon
|
|
|
|
|
slot="prefix"
|
|
|
|
|
icon-class="validCode"
|
|
|
|
|
class="el-input__icon input-icon"
|
|
|
|
|
/>
|
2025-06-14 18:03:55 +08:00
|
|
|
</el-input>
|
|
|
|
|
<div class="register-code">
|
2025-09-27 15:45:56 +08:00
|
|
|
<img :src="codeUrl" @click="getCode" class="register-code-img" />
|
2025-06-14 18:03:55 +08:00
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
2025-09-27 15:45:56 +08:00
|
|
|
<el-form-item style="width: 100%">
|
2025-06-14 18:03:55 +08:00
|
|
|
<el-button
|
|
|
|
|
:loading="loading"
|
|
|
|
|
size="medium"
|
|
|
|
|
type="primary"
|
2025-09-27 15:45:56 +08:00
|
|
|
style="width: 100%"
|
2025-06-14 18:03:55 +08:00
|
|
|
@click.native.prevent="handleRegister"
|
|
|
|
|
>
|
|
|
|
|
<span v-if="!loading">注 册</span>
|
|
|
|
|
<span v-else>注 册 中...</span>
|
|
|
|
|
</el-button>
|
2025-09-27 15:45:56 +08:00
|
|
|
<div style="float: right">
|
|
|
|
|
<router-link class="link-type" :to="'/login'"
|
|
|
|
|
>使用已有账户登录</router-link
|
|
|
|
|
>
|
2025-06-14 18:03:55 +08:00
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<!-- 底部 -->
|
|
|
|
|
<div class="el-register-footer">
|
2025-10-21 15:42:00 +08:00
|
|
|
<span>Copyright © 2025 上动新能源 版权所有</span>
|
2025-06-14 18:03:55 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-09-27 15:45:56 +08:00
|
|
|
import { getCodeImg, register } from "@/api/login";
|
|
|
|
|
import intervalUpdate from "@/mixins/ems/intervalUpdate";
|
2025-06-14 18:03:55 +08:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "Register",
|
2025-09-27 15:45:56 +08:00
|
|
|
mixins: [intervalUpdate],
|
|
|
|
|
computed: {
|
|
|
|
|
loginBg() {
|
|
|
|
|
return require(`./../assets/images/ems/loginBg/${this.bgNum}.png`);
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-06-14 18:03:55 +08:00
|
|
|
data() {
|
|
|
|
|
const equalToPassword = (rule, value, callback) => {
|
|
|
|
|
if (this.registerForm.password !== value) {
|
2025-09-27 15:45:56 +08:00
|
|
|
callback(new Error("两次输入的密码不一致"));
|
2025-06-14 18:03:55 +08:00
|
|
|
} else {
|
2025-09-27 15:45:56 +08:00
|
|
|
callback();
|
2025-06-14 18:03:55 +08:00
|
|
|
}
|
2025-09-27 15:45:56 +08:00
|
|
|
};
|
2025-06-14 18:03:55 +08:00
|
|
|
return {
|
2025-09-27 15:45:56 +08:00
|
|
|
bgNum: 1,
|
2025-06-14 18:03:55 +08:00
|
|
|
codeUrl: "",
|
|
|
|
|
registerForm: {
|
|
|
|
|
username: "",
|
|
|
|
|
password: "",
|
|
|
|
|
confirmPassword: "",
|
|
|
|
|
code: "",
|
2025-09-27 15:45:56 +08:00
|
|
|
uuid: "",
|
2025-06-14 18:03:55 +08:00
|
|
|
},
|
|
|
|
|
registerRules: {
|
|
|
|
|
username: [
|
|
|
|
|
{ required: true, trigger: "blur", message: "请输入您的账号" },
|
2025-09-27 15:45:56 +08:00
|
|
|
{
|
|
|
|
|
min: 2,
|
|
|
|
|
max: 20,
|
|
|
|
|
message: "用户账号长度必须介于 2 和 20 之间",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
2025-06-14 18:03:55 +08:00
|
|
|
],
|
|
|
|
|
password: [
|
|
|
|
|
{ required: true, trigger: "blur", message: "请输入您的密码" },
|
2025-09-27 15:45:56 +08:00
|
|
|
{
|
|
|
|
|
min: 5,
|
|
|
|
|
max: 20,
|
|
|
|
|
message: "用户密码长度必须介于 5 和 20 之间",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
pattern: /^[^<>"'|\\]+$/,
|
|
|
|
|
message: "不能包含非法字符:< > \" ' \\\ |",
|
|
|
|
|
trigger: "blur",
|
|
|
|
|
},
|
2025-06-14 18:03:55 +08:00
|
|
|
],
|
|
|
|
|
confirmPassword: [
|
|
|
|
|
{ required: true, trigger: "blur", message: "请再次输入您的密码" },
|
2025-09-27 15:45:56 +08:00
|
|
|
{ required: true, validator: equalToPassword, trigger: "blur" },
|
2025-06-14 18:03:55 +08:00
|
|
|
],
|
2025-09-27 15:45:56 +08:00
|
|
|
code: [{ required: true, trigger: "change", message: "请输入验证码" }],
|
2025-06-14 18:03:55 +08:00
|
|
|
},
|
|
|
|
|
loading: false,
|
2025-09-27 15:45:56 +08:00
|
|
|
captchaEnabled: true,
|
|
|
|
|
};
|
2025-06-14 18:03:55 +08:00
|
|
|
},
|
|
|
|
|
created() {
|
2025-09-27 15:45:56 +08:00
|
|
|
this.getCode();
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.updateInterval(this.updateBgNum, 5000);
|
2025-06-14 18:03:55 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2025-09-27 15:45:56 +08:00
|
|
|
updateBgNum() {
|
|
|
|
|
if (this.bgNum >= 4) this.bgNum = 0;
|
|
|
|
|
this.bgNum += 1;
|
|
|
|
|
},
|
2025-06-14 18:03:55 +08:00
|
|
|
getCode() {
|
2025-09-27 15:45:56 +08:00
|
|
|
getCodeImg().then((res) => {
|
|
|
|
|
this.captchaEnabled =
|
|
|
|
|
res.captchaEnabled === undefined ? true : res.captchaEnabled;
|
2025-06-14 18:03:55 +08:00
|
|
|
if (this.captchaEnabled) {
|
2025-09-27 15:45:56 +08:00
|
|
|
this.codeUrl = "data:image/gif;base64," + res.img;
|
|
|
|
|
this.registerForm.uuid = res.uuid;
|
2025-06-14 18:03:55 +08:00
|
|
|
}
|
2025-09-27 15:45:56 +08:00
|
|
|
});
|
2025-06-14 18:03:55 +08:00
|
|
|
},
|
|
|
|
|
handleRegister() {
|
2025-09-27 15:45:56 +08:00
|
|
|
this.$refs.registerForm.validate((valid) => {
|
2025-06-14 18:03:55 +08:00
|
|
|
if (valid) {
|
2025-09-27 15:45:56 +08:00
|
|
|
this.loading = true;
|
|
|
|
|
register(this.registerForm)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
const username = this.registerForm.username;
|
|
|
|
|
this.$alert(
|
|
|
|
|
"<font color='red'>恭喜你,您的账号 " +
|
|
|
|
|
username +
|
|
|
|
|
" 注册成功!</font>",
|
|
|
|
|
"系统提示",
|
|
|
|
|
{
|
|
|
|
|
dangerouslyUseHTMLString: true,
|
|
|
|
|
type: "success",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
.then(() => {
|
|
|
|
|
this.$router.push("/login");
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {});
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
if (this.captchaEnabled) {
|
|
|
|
|
this.getCode();
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-06-14 18:03:55 +08:00
|
|
|
}
|
2025-09-27 15:45:56 +08:00
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2025-06-14 18:03:55 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style rel="stylesheet/scss" lang="scss">
|
|
|
|
|
.register {
|
2025-09-28 14:31:24 +08:00
|
|
|
padding-left: 180px;
|
2025-06-14 18:03:55 +08:00
|
|
|
display: flex;
|
2025-09-27 15:45:56 +08:00
|
|
|
justify-content: left;
|
2025-06-14 18:03:55 +08:00
|
|
|
align-items: center;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
2025-09-27 15:45:56 +08:00
|
|
|
.login-bg {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
z-index: 1;
|
|
|
|
|
display: block;
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
.login-logo {
|
|
|
|
|
display: block;
|
|
|
|
|
width: 70%;
|
|
|
|
|
height: auto;
|
|
|
|
|
margin: 0 auto;
|
2025-06-14 18:03:55 +08:00
|
|
|
}
|
|
|
|
|
.register-form {
|
2025-09-27 15:45:56 +08:00
|
|
|
z-index: 2;
|
2025-06-14 18:03:55 +08:00
|
|
|
border-radius: 6px;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
width: 400px;
|
2025-09-27 15:45:56 +08:00
|
|
|
padding: 0 25px 5px 25px;
|
2025-06-14 18:03:55 +08:00
|
|
|
.el-input {
|
|
|
|
|
height: 38px;
|
|
|
|
|
input {
|
|
|
|
|
height: 38px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.input-icon {
|
|
|
|
|
height: 39px;
|
|
|
|
|
width: 14px;
|
|
|
|
|
margin-left: 2px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.register-tip {
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
color: #bfbfbf;
|
|
|
|
|
}
|
|
|
|
|
.register-code {
|
|
|
|
|
width: 33%;
|
|
|
|
|
height: 38px;
|
|
|
|
|
float: right;
|
|
|
|
|
img {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.el-register-footer {
|
2025-10-21 15:42:00 +08:00
|
|
|
z-index:2;
|
2025-06-14 18:03:55 +08:00
|
|
|
height: 40px;
|
|
|
|
|
line-height: 40px;
|
|
|
|
|
position: fixed;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
text-align: center;
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-family: Arial;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
letter-spacing: 1px;
|
|
|
|
|
}
|
|
|
|
|
.register-code-img {
|
|
|
|
|
height: 38px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|