简单验证登录接口

This commit is contained in:
jqtmviyu@gmail.com 2021-01-13 17:09:57 +08:00
parent 2864a04f24
commit 209d318f09

View File

@ -57,6 +57,8 @@
<script>
import { validMobile } from '@/utils/validate'
// api
import { login } from '@/api/user'
export default {
name: 'Login',
@ -125,19 +127,26 @@ export default {
})
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
this.$store.dispatch('user/login', this.loginForm).then(() => {
this.$router.push({ path: this.redirect || '/' })
this.loading = false
}).catch(() => {
this.loading = false
})
} else {
console.log('error submit!!')
return false
}
// this.$refs.loginForm.validate(valid => {
// if (valid) {
// this.loading = true
// this.$store.dispatch('user/login', this.loginForm).then(() => {
// this.$router.push({ path: this.redirect || '/' })
// this.loading = false
// }).catch(() => {
// this.loading = false
// })
// } else {
// console.log('error submit!!')
// return false
// }
// })
login({
mobile: '13800000002',
password: '123456'
}).then(res => {
console.log(res.data)
})
}
}