简单验证登录接口

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