|
@@ -4,9 +4,9 @@
|
|
|
<v-col cols="10">
|
|
<v-col cols="10">
|
|
|
<v-text-field
|
|
<v-text-field
|
|
|
v-model="userLogin.username"
|
|
v-model="userLogin.username"
|
|
|
- placeholder="请输入手机号/邮箱"
|
|
|
|
|
- label="手机号/邮箱"
|
|
|
|
|
- :rules="[() => userLogin.username != null || '手机号/邮箱不能为空']"
|
|
|
|
|
|
|
+ placeholder="请输入手机号"
|
|
|
|
|
+ label="手机号"
|
|
|
|
|
+ :rules="[() => userLogin.username != null || '手机号不能为空']"
|
|
|
clearable
|
|
clearable
|
|
|
/>
|
|
/>
|
|
|
</v-col>
|
|
</v-col>
|
|
@@ -17,9 +17,9 @@
|
|
|
<v-col cols="5">
|
|
<v-col cols="5">
|
|
|
<v-text-field
|
|
<v-text-field
|
|
|
v-model="userLogin.password"
|
|
v-model="userLogin.password"
|
|
|
- placeholder="请输入验证码"
|
|
|
|
|
- label="验证码"
|
|
|
|
|
- :rules="[() => userLogin.password != null || '验证码不能为空']"
|
|
|
|
|
|
|
+ placeholder="请输入短信验证码"
|
|
|
|
|
+ label="短信验证码"
|
|
|
|
|
+ :rules="[() => userLogin.password != null || '短信验证码不能为空']"
|
|
|
clearable
|
|
clearable
|
|
|
/>
|
|
/>
|
|
|
</v-col>
|
|
</v-col>
|
|
@@ -36,7 +36,7 @@
|
|
|
<v-col cols="5">
|
|
<v-col cols="5">
|
|
|
<v-text-field
|
|
<v-text-field
|
|
|
v-model="userLogin.captchaCode"
|
|
v-model="userLogin.captchaCode"
|
|
|
- placeholder="图形验证码"
|
|
|
|
|
|
|
+ placeholder="请输入图形验证码"
|
|
|
label="图形验证码"
|
|
label="图形验证码"
|
|
|
:rules="[() => userLogin.captchaCode != null || '图形验证码不能为空']"
|
|
:rules="[() => userLogin.captchaCode != null || '图形验证码不能为空']"
|
|
|
clearable
|
|
clearable
|
|
@@ -46,6 +46,7 @@
|
|
|
<v-row justify="center">
|
|
<v-row justify="center">
|
|
|
<v-btn color="primary" @click="submitLogin">登录/注册</v-btn>
|
|
<v-btn color="primary" @click="submitLogin">登录/注册</v-btn>
|
|
|
</v-row>
|
|
</v-row>
|
|
|
|
|
+
|
|
|
<v-snackbar
|
|
<v-snackbar
|
|
|
v-model="showMessage"
|
|
v-model="showMessage"
|
|
|
:top="true"
|
|
:top="true"
|
|
@@ -70,24 +71,27 @@
|
|
|
import { randomString, getCaptchaUrl } from '@/utils'
|
|
import { randomString, getCaptchaUrl } from '@/utils'
|
|
|
import { getVerifyCode } from '@/api/user/account'
|
|
import { getVerifyCode } from '@/api/user/account'
|
|
|
import { getPubkey } from '@/api/user/auth'
|
|
import { getPubkey } from '@/api/user/auth'
|
|
|
|
|
+import { JSEncrypt } from 'jsencrypt'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'Register',
|
|
name: 'Register',
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
captchaUrl: '',
|
|
captchaUrl: '',
|
|
|
- showMessage: false,
|
|
|
|
|
|
|
+ captchaBase64: '',
|
|
|
userLogin: {
|
|
userLogin: {
|
|
|
accountType: 1,
|
|
accountType: 1,
|
|
|
- loginType: 2,
|
|
|
|
|
|
|
+ loginType: 1,
|
|
|
username: null,
|
|
username: null,
|
|
|
password: null,
|
|
password: null,
|
|
|
captchaCode: null,
|
|
captchaCode: null,
|
|
|
r: null,
|
|
r: null,
|
|
|
- plat: 'web',
|
|
|
|
|
- showMessage: false,
|
|
|
|
|
- message: ''
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ plat: 'web'
|
|
|
|
|
+ },
|
|
|
|
|
+ pubkey: '',
|
|
|
|
|
+ pubkeyR: '',
|
|
|
|
|
+ showMessage: false,
|
|
|
|
|
+ message: ''
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
@@ -96,6 +100,23 @@ export default {
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
submitLogin() {
|
|
submitLogin() {
|
|
|
|
|
+ this.userLogin.password = this.$options.methods.encryptPassword(this.userLogin.password, this.pubkey, this.pubkeyR)
|
|
|
|
|
+ if (this.userLogin.username === '') {
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ this.message = '手机号不能为空'
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.userLogin.password === '' || this.userLogin.password === null) {
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ this.message = '短信验证码不能为空'
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.userLogin.captchaCode === '') {
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ this.message = '图形验证码不能为空'
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 将数据返回给父组件
|
|
// 将数据返回给父组件
|
|
|
this.$emit('login', this.userLogin)
|
|
this.$emit('login', this.userLogin)
|
|
|
},
|
|
},
|
|
@@ -117,22 +138,33 @@ export default {
|
|
|
console.error(error.message)
|
|
console.error(error.message)
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ encryptPassword(password, pubkey, pubkeyR) {
|
|
|
|
|
+ var encryptor = new JSEncrypt()
|
|
|
|
|
+ encryptor.setPublicKey(pubkey)
|
|
|
|
|
+ return encryptor.encrypt(pubkeyR + password)
|
|
|
|
|
+ },
|
|
|
getVerifyCode() {
|
|
getVerifyCode() {
|
|
|
|
|
+ if (this.userLogin.username === null || this.userLogin.username === '') {
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ this.message = '请填写手机号'
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const verifyCodeReq = {}
|
|
const verifyCodeReq = {}
|
|
|
verifyCodeReq.receiver = this.userLogin.username
|
|
verifyCodeReq.receiver = this.userLogin.username
|
|
|
verifyCodeReq.notifyType = 2
|
|
verifyCodeReq.notifyType = 2
|
|
|
- getVerifyCode(verifyCodeReq)
|
|
|
|
|
- .then(res => {
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- this.showMessage = true
|
|
|
|
|
- this.message = '验证码已发送, 请注意查收'
|
|
|
|
|
- } else {
|
|
|
|
|
- console.error(res.msg)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .catch(error => {
|
|
|
|
|
- console.error(error.message)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ getVerifyCode(verifyCodeReq).then(res => {
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ this.message = '验证码已发送, 请注意查收'
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ this.message = res.msg
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ this.showMessage = true
|
|
|
|
|
+ this.message = error
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|