|
@@ -31,7 +31,7 @@
|
|
|
</v-row>
|
|
</v-row>
|
|
|
<v-row justify="center">
|
|
<v-row justify="center">
|
|
|
<v-col cols="5">
|
|
<v-col cols="5">
|
|
|
- <img :src="captchaUrl" alt="图形验证码" title="点击刷新" style="cursor:pointer;" @click="getCaptcha">
|
|
|
|
|
|
|
+ <img :src="captchaCode" alt="图形验证码" title="点击刷新" style="cursor:pointer;" @click="getCaptcha">
|
|
|
</v-col>
|
|
</v-col>
|
|
|
<v-col cols="5">
|
|
<v-col cols="5">
|
|
|
<v-text-field
|
|
<v-text-field
|
|
@@ -68,8 +68,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { randomString, getCaptchaUrl } from '@/utils'
|
|
|
|
|
-import { getVerifyCode } from '@/api/user/account'
|
|
|
|
|
|
|
+import { getVerifyCode, getCaptchaCode } from '@/api/user/account'
|
|
|
import { getPubkey } from '@/api/user/auth'
|
|
import { getPubkey } from '@/api/user/auth'
|
|
|
import { JSEncrypt } from 'jsencrypt'
|
|
import { JSEncrypt } from 'jsencrypt'
|
|
|
|
|
|
|
@@ -77,8 +76,7 @@ export default {
|
|
|
name: 'Register',
|
|
name: 'Register',
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- captchaUrl: '',
|
|
|
|
|
- captchaBase64: '',
|
|
|
|
|
|
|
+ captchaCode: '',
|
|
|
userLogin: {
|
|
userLogin: {
|
|
|
accountType: 1,
|
|
accountType: 1,
|
|
|
loginType: 1,
|
|
loginType: 1,
|
|
@@ -86,7 +84,7 @@ export default {
|
|
|
password: null,
|
|
password: null,
|
|
|
captchaCode: null,
|
|
captchaCode: null,
|
|
|
r: null,
|
|
r: null,
|
|
|
- plat: 'web'
|
|
|
|
|
|
|
+ plat: 1
|
|
|
},
|
|
},
|
|
|
pubkey: '',
|
|
pubkey: '',
|
|
|
pubkeyR: '',
|
|
pubkeyR: '',
|
|
@@ -95,7 +93,6 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
- this.getCaptcha()
|
|
|
|
|
this.fetchPubkey()
|
|
this.fetchPubkey()
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
@@ -121,21 +118,29 @@ export default {
|
|
|
this.$emit('login', this.userLogin)
|
|
this.$emit('login', this.userLogin)
|
|
|
},
|
|
},
|
|
|
getCaptcha() {
|
|
getCaptcha() {
|
|
|
- const randomStr = randomString(10)
|
|
|
|
|
- this.userLogin.r = randomStr
|
|
|
|
|
- // 图片上发送点击事件时,captchaUrl 的值发生变化,然后才去请求后端
|
|
|
|
|
- this.captchaUrl = getCaptchaUrl(randomStr)
|
|
|
|
|
|
|
+ getCaptchaCode().then(res => {
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ this.captchaCode = 'data:image/jpeg;base64,' + res.data
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.message = '获取图形验证码失败, 请重新刷新页面'
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
fetchPubkey() {
|
|
fetchPubkey() {
|
|
|
getPubkey().then(res => {
|
|
getPubkey().then(res => {
|
|
|
if (res.code === 0) {
|
|
if (res.code === 0) {
|
|
|
this.pubkey = res.data.pubkey
|
|
this.pubkey = res.data.pubkey
|
|
|
this.pubkeyR = res.data.r
|
|
this.pubkeyR = res.data.r
|
|
|
|
|
+
|
|
|
|
|
+ this.getCaptcha()
|
|
|
} else {
|
|
} else {
|
|
|
- alert(res.data)
|
|
|
|
|
|
|
+ this.message = res.msg
|
|
|
|
|
+ this.showMessage = true
|
|
|
}
|
|
}
|
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
|
- console.error(error.message)
|
|
|
|
|
|
|
+ this.message = error.message
|
|
|
|
|
+ this.showMessage = true
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
encryptPassword(password, pubkey, pubkeyR) {
|
|
encryptPassword(password, pubkey, pubkeyR) {
|