|
|
@@ -102,8 +102,13 @@ export default { |
|
|
|
} |
|
|
|
return { |
|
|
|
loginForm: { |
|
|
|
username: '13588441519', |
|
|
|
password: '123abc.' |
|
|
|
username: 13588441519, |
|
|
|
password: 123456, |
|
|
|
// password: '123abc.' |
|
|
|
mobile: 13588441519, |
|
|
|
oauthCode: 13588441519, |
|
|
|
openId: 13588441519, |
|
|
|
wechatAppId: 13588441519 |
|
|
|
}, |
|
|
|
loginRules: { |
|
|
|
username: [{ required: true, trigger: 'blur', validator: validateUsername }], |
|
|
@@ -133,6 +138,7 @@ export default { |
|
|
|
// window.addEventListener('storage', this.afterQRScan) |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
// 自动获取焦点 |
|
|
|
if (this.loginForm.username === '') { |
|
|
|
this.$refs.username.focus() |
|
|
|
} else if (this.loginForm.password === '') { |
|
|
@@ -146,6 +152,7 @@ export default { |
|
|
|
// window.removeEventListener('storage', this.afterQRScan) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 监听用户键盘输入 |
|
|
|
checkCapslock(e) { |
|
|
|
const { key } = e |
|
|
|
this.capsTooltip = key && key.length === 1 && (key >= 'A' && key <= 'Z') |
|
|
@@ -162,12 +169,24 @@ export default { |
|
|
|
}, |
|
|
|
handleLogin() { |
|
|
|
this.$refs.loginForm.validate(valid => { |
|
|
|
// 自定义登陆验证,如符合验证console.log输出true |
|
|
|
console.log(valid) |
|
|
|
console.log(this.redirect, this.$route) |
|
|
|
if (valid) { |
|
|
|
this.loading = true |
|
|
|
// this.$store.dispatch('user/login', this.loginForm) |
|
|
|
// .then(() => { |
|
|
|
// console.log(this.redirect, this.otherQuery) |
|
|
|
// this.$router.push({ path: this.redirect || '/', query: this.otherQuery }) |
|
|
|
// this.loading = false |
|
|
|
// }) |
|
|
|
// .catch(() => { |
|
|
|
// this.loading = false |
|
|
|
// }) |
|
|
|
|
|
|
|
this.$store.dispatch('user/login', this.loginForm) |
|
|
|
.then(() => { |
|
|
|
.then(res => { |
|
|
|
console.log(res) |
|
|
|
console.log(this.redirect, this.otherQuery) |
|
|
|
this.$router.push({ path: this.redirect || '/', query: this.otherQuery }) |
|
|
|
this.loading = false |
|
|
|