|
@@ -13,12 +13,11 @@ export const userMixin = {
|
|
|
pubkeyR: '',
|
|
pubkeyR: '',
|
|
|
captchaCode: '',
|
|
captchaCode: '',
|
|
|
userLogin: {
|
|
userLogin: {
|
|
|
- accountType: 1,
|
|
|
|
|
- loginType: 1,
|
|
|
|
|
- username: null,
|
|
|
|
|
- password: null,
|
|
|
|
|
|
|
+ principal: null,
|
|
|
|
|
+ credential: null,
|
|
|
captchaCode: null,
|
|
captchaCode: null,
|
|
|
- plat: 1
|
|
|
|
|
|
|
+ loginType: 1,
|
|
|
|
|
+ plat: 2
|
|
|
},
|
|
},
|
|
|
loginDialog: false,
|
|
loginDialog: false,
|
|
|
registerDialog: false,
|
|
registerDialog: false,
|
|
@@ -41,14 +40,14 @@ export const userMixin = {
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
fetchPubkey() {
|
|
fetchPubkey() {
|
|
|
- getPubkey().then(res => {
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- this.pubkey = res.data.pubkey
|
|
|
|
|
- this.pubkeyR = res.data.r
|
|
|
|
|
|
|
+ getPubkey().then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ this.pubkey = resp.data.pubkey
|
|
|
|
|
+ this.pubkeyR = resp.data.r
|
|
|
|
|
|
|
|
this.getCaptcha()
|
|
this.getCaptcha()
|
|
|
} else {
|
|
} else {
|
|
|
- this.message = res.msg
|
|
|
|
|
|
|
+ this.message = resp.msg
|
|
|
this.showMessage = true
|
|
this.showMessage = true
|
|
|
}
|
|
}
|
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
@@ -57,9 +56,9 @@ export const userMixin = {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
getCaptcha() {
|
|
getCaptcha() {
|
|
|
- getCaptchaCode().then(res => {
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- this.captchaCode = res.data
|
|
|
|
|
|
|
+ getCaptchaCode().then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ this.captchaCode = resp.data
|
|
|
this.dialogVisible = true
|
|
this.dialogVisible = true
|
|
|
} else {
|
|
} else {
|
|
|
this.message = '获取图形验证码失败, 请重新刷新页面'
|
|
this.message = '获取图形验证码失败, 请重新刷新页面'
|
|
@@ -73,7 +72,7 @@ export const userMixin = {
|
|
|
return encryptor.encrypt(pubkeyR + password)
|
|
return encryptor.encrypt(pubkeyR + password)
|
|
|
},
|
|
},
|
|
|
fetchVerifyCode() {
|
|
fetchVerifyCode() {
|
|
|
- if (this.userLogin.username === null || this.userLogin.username === '') {
|
|
|
|
|
|
|
+ if (this.userLogin.principal === null || this.userLogin.principal === '') {
|
|
|
this.$message.success('请填写手机号')
|
|
this.$message.success('请填写手机号')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -92,13 +91,13 @@ export const userMixin = {
|
|
|
}, 1000)
|
|
}, 1000)
|
|
|
|
|
|
|
|
const verifyCodeReq = {}
|
|
const verifyCodeReq = {}
|
|
|
- verifyCodeReq.receiver = this.userLogin.username
|
|
|
|
|
|
|
+ verifyCodeReq.receiver = this.userLogin.principal
|
|
|
verifyCodeReq.notifyType = 2
|
|
verifyCodeReq.notifyType = 2
|
|
|
- getVerifyCode(verifyCodeReq).then(res => {
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
|
|
+ getVerifyCode(verifyCodeReq).then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
this.$message.success('验证码已发送, 请注意查收')
|
|
this.$message.success('验证码已发送, 请注意查收')
|
|
|
} else {
|
|
} else {
|
|
|
- this.$message.warning(res.msg)
|
|
|
|
|
|
|
+ this.$message.warning(resp.msg)
|
|
|
}
|
|
}
|
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
|
this.$message.error(error)
|
|
this.$message.error(error)
|
|
@@ -119,11 +118,11 @@ export const userMixin = {
|
|
|
loginBtn() {
|
|
loginBtn() {
|
|
|
// 显示加载效果
|
|
// 显示加载效果
|
|
|
this.isLoading = true
|
|
this.isLoading = true
|
|
|
- if (this.userLogin.username === '') {
|
|
|
|
|
|
|
+ if (this.userLogin.principal === '') {
|
|
|
this.$message.warning('手机号不能为空')
|
|
this.$message.warning('手机号不能为空')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (this.userLogin.password === '' || this.userLogin.password === null) {
|
|
|
|
|
|
|
+ if (this.userLogin.credential === '' || this.userLogin.credential === null) {
|
|
|
this.$message.warning('短信验证码不能为空')
|
|
this.$message.warning('短信验证码不能为空')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -132,12 +131,12 @@ export const userMixin = {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.userLogin.password = this.encryptPassword(this.userLogin.password, this.pubkey, this.pubkeyR)
|
|
|
|
|
- login(this.userLogin).then(res => {
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- const resData = res.data
|
|
|
|
|
- const userInfo = resData.userInfo
|
|
|
|
|
- const userToken = resData.userToken
|
|
|
|
|
|
|
+ this.userLogin.credential = this.encryptPassword(this.userLogin.credential, this.pubkey, this.pubkeyR)
|
|
|
|
|
+ login(this.userLogin).then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ const respData = resp.data
|
|
|
|
|
+ const userInfo = respData.accountInfo
|
|
|
|
|
+ const userToken = respData.accountToken
|
|
|
// 保存授权信息到本地缓存
|
|
// 保存授权信息到本地缓存
|
|
|
setUserToken(userToken)
|
|
setUserToken(userToken)
|
|
|
this.$store.commit('UPDATE_USER_INFO', userInfo)
|
|
this.$store.commit('UPDATE_USER_INFO', userInfo)
|
|
@@ -147,7 +146,7 @@ export const userMixin = {
|
|
|
this.$router.go(0)
|
|
this.$router.go(0)
|
|
|
} else {
|
|
} else {
|
|
|
// 登录失败
|
|
// 登录失败
|
|
|
- this.$message.warning(res.msg)
|
|
|
|
|
|
|
+ this.$message.warning(resp.msg)
|
|
|
}
|
|
}
|
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
|
// 登录请求错误
|
|
// 登录请求错误
|
|
@@ -156,8 +155,8 @@ export const userMixin = {
|
|
|
this.userLogin = {
|
|
this.userLogin = {
|
|
|
accountType: 1,
|
|
accountType: 1,
|
|
|
loginType: 1,
|
|
loginType: 1,
|
|
|
- username: null,
|
|
|
|
|
- password: null,
|
|
|
|
|
|
|
+ principal: null,
|
|
|
|
|
+ credential: null,
|
|
|
captchaCode: null,
|
|
captchaCode: null,
|
|
|
plat: 1
|
|
plat: 1
|
|
|
}
|
|
}
|
|
@@ -169,15 +168,15 @@ export const userMixin = {
|
|
|
cancelButtonText: '取消',
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
}).then(() => {
|
|
|
- logout().then(res => {
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
|
|
+ logout().then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
Vue.$cookies.remove('token')
|
|
Vue.$cookies.remove('token')
|
|
|
this.$store.commit('USER_LOGOUT')
|
|
this.$store.commit('USER_LOGOUT')
|
|
|
removeAll()
|
|
removeAll()
|
|
|
} else {
|
|
} else {
|
|
|
this.$notify.error({
|
|
this.$notify.error({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
- message: res.msg
|
|
|
|
|
|
|
+ message: resp.msg
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}).catch((e) => {
|
|
}).catch((e) => {
|
|
@@ -197,57 +196,6 @@ export const userMixin = {
|
|
|
message: '已取消'
|
|
message: '已取消'
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
- // 点击注册
|
|
|
|
|
- register() {
|
|
|
|
|
- if (this.password !== this.repassword) {
|
|
|
|
|
- this.$message.warning('密码输入不一致')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- // 先判断验证码是否正确
|
|
|
|
|
- /* checkCode(this.rcode).then(res => {
|
|
|
|
|
- if (res === 1) {
|
|
|
|
|
- // 验证码正确,提交头像,在成功的回调中注册用户
|
|
|
|
|
- this.$refs.uploadImg.submit()
|
|
|
|
|
- } else if (res === -1) {
|
|
|
|
|
- this.$message.warning('验证码已失效,请重新获取!')
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$message.warning('验证码错误!')
|
|
|
|
|
- }
|
|
|
|
|
- })*/
|
|
|
|
|
- },
|
|
|
|
|
- // 选择图片时
|
|
|
|
|
- imgChange(file) {
|
|
|
|
|
- this.imageUrl = URL.createObjectURL(file.raw)
|
|
|
|
|
- },
|
|
|
|
|
- // 上传成功时
|
|
|
|
|
- handleAvatarSuccess(res, file) {
|
|
|
|
|
- this.avatarurl = res
|
|
|
|
|
- // console.log(res);// 服务器返回的文件名称
|
|
|
|
|
- // 注册
|
|
|
|
|
- /* register(this.phone, this.password, this.nickname, this.avatarurl, this.phone).then(res => {
|
|
|
|
|
- // console.log(res);
|
|
|
|
|
- if (res === 1) {
|
|
|
|
|
- this.$message.success('注册成功!')
|
|
|
|
|
- this.dialogVisible2 = false
|
|
|
|
|
- this.password = ''
|
|
|
|
|
- } else if (res === -1) {
|
|
|
|
|
- this.$message.warning('该手机号码已经被注册!如有疑问,请联系管理员!')
|
|
|
|
|
- }
|
|
|
|
|
- })*/
|
|
|
|
|
- },
|
|
|
|
|
- // 上传之前
|
|
|
|
|
- beforeAvatarUpload(file) {
|
|
|
|
|
- const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
|
|
|
|
|
- const isLt2M = file.size / 1024 / 1024 < 2
|
|
|
|
|
-
|
|
|
|
|
- if (!isJPG) {
|
|
|
|
|
- this.$message.error('上传头像图片格式错误!')
|
|
|
|
|
- }
|
|
|
|
|
- if (!isLt2M) {
|
|
|
|
|
- this.$message.error('上传头像图片大小不能超过 2MB!')
|
|
|
|
|
- }
|
|
|
|
|
- return isJPG && isLt2M
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|