登录注册
This commit is contained in:
parent
adb3347fa0
commit
06e67e1460
|
|
@ -1,8 +1,8 @@
|
||||||
// SM 配置
|
// SM 配置
|
||||||
export const SM_CONFIG = {
|
export const SM_CONFIG = {
|
||||||
SALT: '2cc0c5f9f1749f1632efa9f63e902323', // SM3 盐值(16 字节)
|
SALT: '2cc0c5f9f1749f1632efa9f63e902323', // SM3 盐值(16 字节)
|
||||||
SM4_KEY:"78d1295afa99449b99d6f83820e6965c", // SM4 对称加密密钥
|
SM4_KEY: "78d1295afa99449b99d6f83820e6965c", // SM4 对称加密密钥
|
||||||
SM4_SALT:"f555adf6c01d0ab0761e626a2dae34a2",
|
SM4_SALT: "f555adf6c01d0ab0761e626a2dae34a2",
|
||||||
SM2_PUBLIC_KEY: 'your-public-key', // SM2 公钥
|
SM2_PUBLIC_KEY: 'your-public-key', // SM2 公钥
|
||||||
SM2_PRIVATE_KEY: 'your-private-key' // SM2 私钥
|
SM2_PRIVATE_KEY: 'your-private-key' // SM2 私钥
|
||||||
}
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ export const AES_CONFIG = {
|
||||||
|
|
||||||
export function generateUUID() {
|
export function generateUUID() {
|
||||||
// 使用当前时间戳和随机数生成一个 UUID
|
// 使用当前时间戳和随机数生成一个 UUID
|
||||||
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
const r = Math.random() * 16 | 0; // 生成随机数
|
const r = Math.random() * 16 | 0; // 生成随机数
|
||||||
const v = c === 'x' ? r : (r & 0x3 | 0x8); // 根据 UUID 规范生成相应的值
|
const v = c === 'x' ? r : (r & 0x3 | 0x8); // 根据 UUID 规范生成相应的值
|
||||||
return v.toString(16); // 转换为十六进制
|
return v.toString(16); // 转换为十六进制
|
||||||
|
|
|
||||||
1167
src/views/login1.vue
1167
src/views/login1.vue
File diff suppressed because it is too large
Load Diff
|
|
@ -1,116 +1,183 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="container-rg">
|
<div class="container-rg">
|
||||||
<div class="lef-cont">
|
<div class="lef-cont">
|
||||||
<div class="circle1"></div>
|
<div class="circle1"></div>
|
||||||
<div class="circle2"></div>
|
<div class="circle2"></div>
|
||||||
<div class="tit">
|
<div class="tit">
|
||||||
<span style="padding-bottom: 15px">您好,</span>
|
<span style="padding-bottom: 15px">您好,</span>
|
||||||
<span>欢迎来到输变电工程施工现场安全风险预警系统</span>
|
<span>欢迎来到输变电工程施工现场安全风险预警系统</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tit-en">
|
<div class="tit-en">
|
||||||
<span style="padding-bottom: 15px">Hello!</span>
|
<span style="padding-bottom: 15px">Hello!</span>
|
||||||
<span>Welcome to the Safety Construction Warning System</span>
|
<span>Welcome to the Safety Construction Warning System</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="img-cont">
|
<div class="img-cont">
|
||||||
<img src="@/assets/images/warn-bg.png">
|
<img src="@/assets/images/warn-bg.png" />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="register">
|
||||||
|
<el-form
|
||||||
|
ref="registerForm"
|
||||||
|
:model="registerForm"
|
||||||
|
:rules="registerRules"
|
||||||
|
class="register-form"
|
||||||
|
>
|
||||||
|
<h3 class="title">输变电工程施工现场安全风险预警系统</h3>
|
||||||
|
|
||||||
|
<el-form-item prop="nickName">
|
||||||
|
<el-input
|
||||||
|
v-model="registerForm.nickName"
|
||||||
|
type="text"
|
||||||
|
auto-complete="off"
|
||||||
|
placeholder="请输入姓名"
|
||||||
|
>
|
||||||
|
<svg-icon
|
||||||
|
slot="prefix"
|
||||||
|
icon-class="user"
|
||||||
|
class="el-input__icon input-icon"
|
||||||
|
/>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item prop="mobile">
|
||||||
|
<el-input
|
||||||
|
v-model="registerForm.mobile"
|
||||||
|
type="text"
|
||||||
|
auto-complete="off"
|
||||||
|
:placeholder="`请输入${
|
||||||
|
config.registersConfig.phoneRegisters
|
||||||
|
? '手机号'
|
||||||
|
: ''
|
||||||
|
}${
|
||||||
|
config.registersConfig.emailRegisters ? '/邮箱' : ''
|
||||||
|
}`"
|
||||||
|
>
|
||||||
|
<svg-icon
|
||||||
|
slot="prefix"
|
||||||
|
icon-class="phone"
|
||||||
|
class="el-input__icon input-icon"
|
||||||
|
/>
|
||||||
|
</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"
|
||||||
|
show-password
|
||||||
|
>
|
||||||
|
<svg-icon
|
||||||
|
slot="prefix"
|
||||||
|
icon-class="password"
|
||||||
|
class="el-input__icon input-icon"
|
||||||
|
/>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item prop="confirmPassword">
|
||||||
|
<el-input
|
||||||
|
v-model="registerForm.confirmPassword"
|
||||||
|
type="password"
|
||||||
|
placeholder="确认密码"
|
||||||
|
auto-complete="off"
|
||||||
|
@keyup.enter.native="handleRegister"
|
||||||
|
show-password
|
||||||
|
>
|
||||||
|
<svg-icon
|
||||||
|
slot="prefix"
|
||||||
|
icon-class="password"
|
||||||
|
class="el-input__icon input-icon"
|
||||||
|
/>
|
||||||
|
</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"
|
||||||
|
>
|
||||||
|
<svg-icon
|
||||||
|
slot="prefix"
|
||||||
|
icon-class="validCode"
|
||||||
|
class="el-input__icon input-icon"
|
||||||
|
/>
|
||||||
|
</el-input>
|
||||||
|
<div class="register-code">
|
||||||
|
<img
|
||||||
|
:src="codeUrl"
|
||||||
|
@click="getCode"
|
||||||
|
class="register-code-img"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item
|
||||||
|
v-show="config.registersConfig.verificationCode"
|
||||||
|
prop="verificationCode"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
v-model="registerForm.verificationCode"
|
||||||
|
:readonly="!isSendingCode"
|
||||||
|
placeholder="请输入验证码"
|
||||||
|
>
|
||||||
|
<template slot="append">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="sendCode"
|
||||||
|
:disabled="
|
||||||
|
isSendingCode || captchaEnabled
|
||||||
|
? !registerForm.code
|
||||||
|
: false
|
||||||
|
"
|
||||||
|
class="send-code-button"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
isSendingCode
|
||||||
|
? `${countdown}s`
|
||||||
|
: '获取验证码'
|
||||||
|
}}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<svg-icon
|
||||||
|
slot="prefix"
|
||||||
|
icon-class="message"
|
||||||
|
class="el-input__icon input-icon"
|
||||||
|
/>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item style="width: 100%">
|
||||||
|
<el-button
|
||||||
|
:loading="loading"
|
||||||
|
size="medium"
|
||||||
|
type="primary"
|
||||||
|
style="width: 100%"
|
||||||
|
@click.native.prevent="handleRegister"
|
||||||
|
>
|
||||||
|
<span v-if="!loading">注 册</span>
|
||||||
|
<span v-else>注 册 中...</span>
|
||||||
|
</el-button>
|
||||||
|
<div style="float: right">
|
||||||
|
<router-link class="link-type" :to="'/login'"
|
||||||
|
>使用已有账户登录</router-link
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<!-- 底部 -->
|
||||||
|
<div class="el-register-footer">
|
||||||
|
<span
|
||||||
|
>Copyright © 2018-2024 bonus.vip All Rights Reserved.</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="register">
|
|
||||||
<el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form">
|
|
||||||
<h3 class="title">输变电工程施工现场安全风险预警系统</h3>
|
|
||||||
|
|
||||||
<el-form-item prop="nickName">
|
|
||||||
<el-input v-model="registerForm.nickName" type="text" auto-complete="off" placeholder="请输入姓名">
|
|
||||||
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon"/>
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item prop="mobile">
|
|
||||||
<el-input v-model="registerForm.mobile" type="text" auto-complete="off"
|
|
||||||
:placeholder="`请输入${config.registersConfig.phoneRegisters ? '手机号' : ''}${config.registersConfig.emailRegisters ? '/邮箱' : ''}`">
|
|
||||||
<svg-icon slot="prefix" icon-class="phone" class="el-input__icon input-icon"/>
|
|
||||||
</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"
|
|
||||||
show-password
|
|
||||||
>
|
|
||||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon"/>
|
|
||||||
</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"
|
|
||||||
show-password
|
|
||||||
>
|
|
||||||
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon"/>
|
|
||||||
</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"
|
|
||||||
>
|
|
||||||
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon"/>
|
|
||||||
</el-input>
|
|
||||||
<div class="register-code">
|
|
||||||
<img :src="codeUrl" @click="getCode" class="register-code-img"/>
|
|
||||||
</div>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item v-show="config.registersConfig.verificationCode" prop="verificationCode">
|
|
||||||
<el-input v-model="registerForm.verificationCode" :readonly="!isSendingCode" placeholder="请输入验证码">
|
|
||||||
<template slot="append">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
@click="sendCode"
|
|
||||||
:disabled="isSendingCode || captchaEnabled?!registerForm.code:false"
|
|
||||||
class="send-code-button"
|
|
||||||
>
|
|
||||||
{{ isSendingCode ? `${countdown}s` : '获取验证码' }}
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
<svg-icon slot="prefix" icon-class="message" class="el-input__icon input-icon"/>
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item style="width:100%;">
|
|
||||||
<el-button
|
|
||||||
:loading="loading"
|
|
||||||
size="medium"
|
|
||||||
type="primary"
|
|
||||||
style="width:100%;"
|
|
||||||
@click.native.prevent="handleRegister"
|
|
||||||
>
|
|
||||||
<span v-if="!loading">注 册</span>
|
|
||||||
<span v-else>注 册 中...</span>
|
|
||||||
</el-button>
|
|
||||||
<div style="float: right;">
|
|
||||||
<router-link class="link-type" :to="'/login'">使用已有账户登录</router-link>
|
|
||||||
</div>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<!-- 底部 -->
|
|
||||||
<div class="el-register-footer">
|
|
||||||
<span>Copyright © 2018-2024 bonus.vip All Rights Reserved.</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -119,242 +186,329 @@ import { validateNewPassword } from '@/utils/validate'
|
||||||
import { decryptCBC } from '@/utils/aescbc'
|
import { decryptCBC } from '@/utils/aescbc'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Register',
|
name: 'Register',
|
||||||
computed: {
|
computed: {
|
||||||
LOGIN() {
|
LOGIN() {
|
||||||
return LOGIN
|
return LOGIN
|
||||||
|
},
|
||||||
|
config() {
|
||||||
|
return (
|
||||||
|
JSON.parse(localStorage.getItem('systemConfig')) || {
|
||||||
|
registersConfig: {
|
||||||
|
phoneRegisters: true,
|
||||||
|
emailRegisters: true,
|
||||||
|
verificationCode: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
) // 获取 JSON 对象
|
||||||
|
},
|
||||||
},
|
},
|
||||||
config() {
|
data() {
|
||||||
return JSON.parse(localStorage.getItem('systemConfig')) || {registersConfig: {
|
// 验证姓名是否符合要求
|
||||||
phoneRegisters: true,
|
const validateNickName = (rule, value, callback) => {
|
||||||
emailRegisters: true,
|
const regex = /^[\u4e00-\u9fa5]{2,4}$/
|
||||||
verificationCode:true
|
if (!value) {
|
||||||
}}; // 获取 JSON 对象
|
callback(new Error('请输入姓名'))
|
||||||
},
|
} else if (!regex.test(value)) {
|
||||||
},
|
callback(new Error('名字必须是2到4个汉字'))
|
||||||
data() {
|
} else {
|
||||||
// 验证姓名是否符合要求
|
callback()
|
||||||
const validateNickName = (rule, value, callback) => {
|
}
|
||||||
const regex = /^[\u4e00-\u9fa5]{2,4}$/
|
|
||||||
if (!value) {
|
|
||||||
callback(new Error('请输入姓名'))
|
|
||||||
} else if (!regex.test(value)) {
|
|
||||||
callback(new Error('名字必须是2到4个汉字'))
|
|
||||||
} else {
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证密码是否一致
|
|
||||||
const equalToPassword = (rule, value, callback) => {
|
|
||||||
if (this.registerForm.password !== value) {
|
|
||||||
callback(new Error('两次输入的密码不一致'))
|
|
||||||
} else {
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
codeUrl: '',
|
|
||||||
isSendingCode: false,
|
|
||||||
countdown: 0,
|
|
||||||
registerForm: {
|
|
||||||
username: '',
|
|
||||||
password: '',
|
|
||||||
confirmPassword: '',
|
|
||||||
verificationCode: '',
|
|
||||||
mobile: '',
|
|
||||||
nickName: '',
|
|
||||||
code: '',
|
|
||||||
uuid: '',
|
|
||||||
phoneUuid: '',
|
|
||||||
mobileCodeType: 'REGISTER'
|
|
||||||
},
|
|
||||||
registerRules: {
|
|
||||||
nickName: [
|
|
||||||
{ required: true, trigger: 'blur', validator: validateNickName }
|
|
||||||
],
|
|
||||||
mobile: [
|
|
||||||
{ required: true, message: '请输入手机号/邮箱', trigger: 'blur' },
|
|
||||||
{ validator: this.validateContact, trigger: 'blur' }
|
|
||||||
],
|
|
||||||
password: [
|
|
||||||
{ required: true, trigger: 'blur', message: '请输入您的密码' },
|
|
||||||
{ validator: validateNewPassword, trigger: 'blur' }
|
|
||||||
],
|
|
||||||
confirmPassword: [
|
|
||||||
{ required: true, trigger: 'blur', message: '请再次输入您的密码' },
|
|
||||||
{ required: true, validator: equalToPassword, trigger: 'blur' }
|
|
||||||
],
|
|
||||||
code: [{ required: true, trigger: 'change', message: '请输入验证码' }]
|
|
||||||
},
|
|
||||||
loading: false,
|
|
||||||
captchaEnabled: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
|
||||||
this.getCode()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 获取验证码图片
|
|
||||||
getCode() {
|
|
||||||
getCodeImg().then(res => {
|
|
||||||
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
|
||||||
if (this.captchaEnabled) {
|
|
||||||
this.codeUrl = 'data:image/gif;base64,' + res.img
|
|
||||||
this.registerForm.uuid = res.uuid
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
// 处理注册请求
|
// 验证密码是否一致
|
||||||
handleRegister() {
|
const equalToPassword = (rule, value, callback) => {
|
||||||
this.$refs.registerForm.validate(valid => {
|
if (this.registerForm.password !== value) {
|
||||||
if (valid) {
|
callback(new Error('两次输入的密码不一致'))
|
||||||
this.loading = true
|
} else {
|
||||||
register(this.registerForm).then(res => {
|
callback()
|
||||||
const username = this.registerForm.username
|
}
|
||||||
this.$alert(`<font color="red">恭喜你,您的账号 ${username} 注册成功!</font>`, '系统提示', {
|
}
|
||||||
dangerouslyUseHTMLString: true,
|
|
||||||
type: 'success'
|
return {
|
||||||
}).then(() => {
|
codeUrl: '',
|
||||||
this.$router.push('/login')
|
isSendingCode: false,
|
||||||
}).catch(() => {
|
countdown: 0,
|
||||||
|
registerForm: {
|
||||||
|
username: '',
|
||||||
|
password: '',
|
||||||
|
confirmPassword: '',
|
||||||
|
verificationCode: '',
|
||||||
|
mobile: '',
|
||||||
|
nickName: '',
|
||||||
|
code: '',
|
||||||
|
uuid: '',
|
||||||
|
phoneUuid: '',
|
||||||
|
mobileCodeType: 'REGISTER',
|
||||||
|
},
|
||||||
|
registerRules: {
|
||||||
|
nickName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
trigger: 'blur',
|
||||||
|
validator: validateNickName,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
mobile: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入手机号/邮箱',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
{ validator: this.validateContact, trigger: 'blur' },
|
||||||
|
],
|
||||||
|
password: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
trigger: 'blur',
|
||||||
|
message: '请输入您的密码',
|
||||||
|
},
|
||||||
|
{ validator: validateNewPassword, trigger: 'blur' },
|
||||||
|
],
|
||||||
|
confirmPassword: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
trigger: 'blur',
|
||||||
|
message: '请再次输入您的密码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
validator: equalToPassword,
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
code: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
trigger: 'change',
|
||||||
|
message: '请输入验证码',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
captchaEnabled: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getCode()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 获取验证码图片
|
||||||
|
getCode() {
|
||||||
|
getCodeImg().then((res) => {
|
||||||
|
this.captchaEnabled =
|
||||||
|
res.captchaEnabled === undefined ? true : res.captchaEnabled
|
||||||
|
if (this.captchaEnabled) {
|
||||||
|
this.codeUrl = 'data:image/gif;base64,' + res.img
|
||||||
|
this.registerForm.uuid = res.uuid
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
},
|
||||||
this.loading = false
|
|
||||||
if (this.captchaEnabled) {
|
// 处理注册请求
|
||||||
this.getCode()
|
handleRegister() {
|
||||||
|
this.$refs.registerForm.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 发送验证码
|
||||||
|
sendCode() {
|
||||||
|
if (!this.registerForm.mobile) {
|
||||||
|
this.$message.error('请先填写手机号')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
})
|
this.$store
|
||||||
}
|
.dispatch('GetPhoneCode', this.registerForm)
|
||||||
})
|
.then((res) => {
|
||||||
},
|
console.log(res)
|
||||||
|
this.isSendingCode = true
|
||||||
|
this.countdown = 60
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
this.countdown -= 1
|
||||||
|
if (this.countdown <= 0) {
|
||||||
|
clearInterval(timer)
|
||||||
|
/* this.isSendingCode = false */
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.loading = false
|
||||||
|
if (this.captchaEnabled) {
|
||||||
|
this.getCode()
|
||||||
|
}
|
||||||
|
this.isSendingCode = false
|
||||||
|
this.countdown = 0
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
// 发送验证码
|
// 验证手机号或邮箱格式
|
||||||
sendCode() {
|
validateContact(rule, value, callback) {
|
||||||
if (!this.registerForm.mobile) {
|
const phoneRegex = /^1[3-9]\d{9}$/
|
||||||
this.$message.error('请先填写手机号')
|
const emailRegex =
|
||||||
return
|
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
|
||||||
}
|
|
||||||
this.$store.dispatch('GetPhoneCode', this.registerForm)
|
if (!value) {
|
||||||
.then(res => {
|
return callback(new Error('请输入电子邮件或电话号码'))
|
||||||
console.log(res)
|
|
||||||
this.isSendingCode = true
|
|
||||||
this.countdown = 60
|
|
||||||
const timer = setInterval(() => {
|
|
||||||
this.countdown -= 1
|
|
||||||
if (this.countdown <= 0) {
|
|
||||||
clearInterval(timer)
|
|
||||||
}
|
}
|
||||||
}, 1000)
|
|
||||||
})
|
if (!phoneRegex.test(value) && !emailRegex.test(value)) {
|
||||||
.catch(() => {
|
return callback(new Error('必须是有效的电子邮件或电话号码'))
|
||||||
this.loading = false
|
}
|
||||||
if (this.captchaEnabled) {
|
|
||||||
this.getCode()
|
callback()
|
||||||
}
|
},
|
||||||
this.isSendingCode = false
|
|
||||||
this.countdown = 0
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 验证手机号或邮箱格式
|
|
||||||
validateContact(rule, value, callback) {
|
|
||||||
const phoneRegex = /^1[3-9]\d{9}$/
|
|
||||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
|
|
||||||
|
|
||||||
if (!value) {
|
|
||||||
return callback(new Error('请输入电子邮件或电话号码'))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!phoneRegex.test(value) && !emailRegex.test(value)) {
|
|
||||||
return callback(new Error('必须是有效的电子邮件或电话号码'))
|
|
||||||
}
|
|
||||||
|
|
||||||
callback()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style rel="stylesheet/scss" lang="scss">
|
<style rel="stylesheet/scss" lang="scss">
|
||||||
.container {
|
.container-rg {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
align-items: center;
|
||||||
align-items: center;
|
height: 100%;
|
||||||
height: 100%;
|
}
|
||||||
background-image: url("../assets/images/bg.png");
|
|
||||||
background-size: cover;
|
.lef-cont {
|
||||||
|
width: 50%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: #7288fa;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 5%;
|
||||||
|
position: relative;
|
||||||
|
.circle1 {
|
||||||
|
position: absolute;
|
||||||
|
top: 8%;
|
||||||
|
left: 8%;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: #8ea0fb;
|
||||||
|
}
|
||||||
|
.circle2 {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(8% + 25px);
|
||||||
|
left: calc(8% + 25px);
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.tit {
|
||||||
|
margin-top: 10%;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-size: 32px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.tit-en {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.img-cont {
|
||||||
|
width: 300px;
|
||||||
|
height: 300px;
|
||||||
|
margin: 80px auto;
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 95%;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.register {
|
.register {
|
||||||
width: 42%;
|
width: 50%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
margin: 0px auto 30px auto;
|
margin: 0px auto 30px auto;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #707070;
|
color: #707070;
|
||||||
}
|
}
|
||||||
|
|
||||||
.register-form {
|
.register-form {
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
width: 400px;
|
width: 400px;
|
||||||
padding: 25px 25px 5px 25px;
|
padding: 25px 25px 5px 25px;
|
||||||
|
|
||||||
.el-input {
|
.el-input {
|
||||||
height: 38px;
|
height: 38px;
|
||||||
|
|
||||||
input {
|
input {
|
||||||
height: 38px;
|
height: 38px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.input-icon {
|
.input-icon {
|
||||||
height: 39px;
|
height: 39px;
|
||||||
width: 14px;
|
width: 14px;
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.register-tip {
|
.register-tip {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #bfbfbf;
|
color: #bfbfbf;
|
||||||
}
|
}
|
||||||
|
|
||||||
.register-code {
|
.register-code {
|
||||||
width: 33%;
|
width: 33%;
|
||||||
height: 38px;
|
height: 38px;
|
||||||
float: right;
|
float: right;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-register-footer {
|
.el-register-footer {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-family: Arial;
|
font-family: Arial;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.register-code-img {
|
.register-code-img {
|
||||||
height: 38px;
|
height: 38px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue