|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div>
|
|
<div>
|
|
|
- <v-row justify="center">
|
|
|
|
|
|
|
+ <!--<v-row justify="center">
|
|
|
<v-col cols="10">
|
|
<v-col cols="10">
|
|
|
<v-text-field
|
|
<v-text-field
|
|
|
v-model="userRegistry.username"
|
|
v-model="userRegistry.username"
|
|
@@ -12,7 +12,7 @@
|
|
|
@blur="selectUsername"
|
|
@blur="selectUsername"
|
|
|
/>
|
|
/>
|
|
|
</v-col>
|
|
</v-col>
|
|
|
- </v-row>
|
|
|
|
|
|
|
+ </v-row>-->
|
|
|
<v-row justify="center">
|
|
<v-row justify="center">
|
|
|
<v-col cols="10">
|
|
<v-col cols="10">
|
|
|
<v-text-field
|
|
<v-text-field
|
|
@@ -22,8 +22,7 @@
|
|
|
:rules="[() => userRegistry.email != null || '邮箱不能为空']"
|
|
:rules="[() => userRegistry.email != null || '邮箱不能为空']"
|
|
|
type="email"
|
|
type="email"
|
|
|
clearable
|
|
clearable
|
|
|
- @input="checkEmail"
|
|
|
|
|
- @blur="selectEmail"
|
|
|
|
|
|
|
+ @blur="checkEmail"
|
|
|
/>
|
|
/>
|
|
|
</v-col>
|
|
</v-col>
|
|
|
</v-row>
|
|
</v-row>
|
|
@@ -65,10 +64,10 @@
|
|
|
</v-col>
|
|
</v-col>
|
|
|
<v-col cols="5">
|
|
<v-col cols="5">
|
|
|
<v-text-field
|
|
<v-text-field
|
|
|
- v-model="userRegistry.captcha"
|
|
|
|
|
|
|
+ v-model="userRegistry.captchaCode"
|
|
|
placeholder="验证码"
|
|
placeholder="验证码"
|
|
|
label="验证码"
|
|
label="验证码"
|
|
|
- :rules="[() => userRegistry.captcha != null || '验证码不能为空']"
|
|
|
|
|
|
|
+ :rules="[() => userRegistry.captchaCode != null || '验证码不能为空']"
|
|
|
clearable
|
|
clearable
|
|
|
/>
|
|
/>
|
|
|
</v-col>
|
|
</v-col>
|
|
@@ -81,7 +80,7 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import { randomString, getCaptchaUrl } from '@/utils'
|
|
import { randomString, getCaptchaUrl } from '@/utils'
|
|
|
-import { getRegVerifyCode, isUsernameExist, selectUsername, isEmailRegistered, selectEmail } from '@/api/user/account'
|
|
|
|
|
|
|
+import { getRegVerifyCode, isUsernameExist, selectUsername, isEmailExist } from '@/api/user/account'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'Register',
|
|
name: 'Register',
|
|
@@ -89,15 +88,13 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
captchaUrl: '',
|
|
captchaUrl: '',
|
|
|
captchaBase64: '',
|
|
captchaBase64: '',
|
|
|
- r: '',
|
|
|
|
|
showMessage: false,
|
|
showMessage: false,
|
|
|
userRegistry: {
|
|
userRegistry: {
|
|
|
regType: 1,
|
|
regType: 1,
|
|
|
- username: '',
|
|
|
|
|
email: '',
|
|
email: '',
|
|
|
password: '',
|
|
password: '',
|
|
|
regVerifyCode: '',
|
|
regVerifyCode: '',
|
|
|
- captcha: '',
|
|
|
|
|
|
|
+ captchaCode: '',
|
|
|
r: ''
|
|
r: ''
|
|
|
},
|
|
},
|
|
|
verifyCode: {
|
|
verifyCode: {
|
|
@@ -136,8 +133,12 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
checkEmail() {
|
|
checkEmail() {
|
|
|
- console.log('检查邮箱')
|
|
|
|
|
- isEmailRegistered(this.userRegistry.email)
|
|
|
|
|
|
|
+ const email = this.userRegistry.email
|
|
|
|
|
+ if (email === null || email === '') {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ isEmailExist(this.userRegistry.email)
|
|
|
.then(res => {
|
|
.then(res => {
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
console.log(res.msg)
|
|
console.log(res.msg)
|
|
@@ -149,17 +150,6 @@ export default {
|
|
|
console.error(error.message)
|
|
console.error(error.message)
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- selectEmail() {
|
|
|
|
|
- selectEmail(this.userRegistry.email).then(res => {
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- console.log(res.msg)
|
|
|
|
|
- } else {
|
|
|
|
|
- alert(res.data)
|
|
|
|
|
- }
|
|
|
|
|
- }).catch(error => {
|
|
|
|
|
- console.error(error.message)
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
submitRegister() {
|
|
submitRegister() {
|
|
|
var re = /^(([^()[\]\\.,;:\s@\"]+(\.[^()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
var re = /^(([^()[\]\\.,;:\s@\"]+(\.[^()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
|
if (!re.test(this.userRegistry.email)) {
|
|
if (!re.test(this.userRegistry.email)) {
|
|
@@ -168,8 +158,8 @@ export default {
|
|
|
} else if (this.userRegistry.password === '' || this.userRegistry.password.length < 6) {
|
|
} else if (this.userRegistry.password === '' || this.userRegistry.password.length < 6) {
|
|
|
console.log('password 字段不符合要求')
|
|
console.log('password 字段不符合要求')
|
|
|
return
|
|
return
|
|
|
- } else if (this.userRegistry.captcha === '' || this.userRegistry.username === '') {
|
|
|
|
|
- alert('captcha 或 username 字段不符合要求')
|
|
|
|
|
|
|
+ } else if (this.userRegistry.captchaCode === '') {
|
|
|
|
|
+ alert('captchaCode 或 username 字段不符合要求')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -181,9 +171,10 @@ export default {
|
|
|
this.$emit('register', this.userRegistry)
|
|
this.$emit('register', this.userRegistry)
|
|
|
},
|
|
},
|
|
|
getCaptcha() {
|
|
getCaptcha() {
|
|
|
- this.r = randomString(10)
|
|
|
|
|
|
|
+ const randomStr = randomString(10)
|
|
|
|
|
+ this.userRegistry.r = randomStr
|
|
|
// 图片上发送点击事件时,captchaUrl 的值发生变化,然后才去请求后端
|
|
// 图片上发送点击事件时,captchaUrl 的值发生变化,然后才去请求后端
|
|
|
- this.captchaUrl = getCaptchaUrl(this.r)
|
|
|
|
|
|
|
+ this.captchaUrl = getCaptchaUrl(randomStr)
|
|
|
/* getBase64Captcha(this.captchaUrl)
|
|
/* getBase64Captcha(this.captchaUrl)
|
|
|
.then(res => {
|
|
.then(res => {
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|