优化
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
|
||||
<script>
|
||||
import { validUsername } from '@/utils/validate'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
|
||||
export default {
|
||||
name: 'login',
|
||||
@@ -78,12 +79,18 @@ export default {
|
||||
this.$refs.loginForm.validate(valid => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
this.$store.dispatch('Login', this.loginForm).then(() => {
|
||||
setToken('data.token')
|
||||
this.$store.commit('SET_TOKEN', 'data.token')
|
||||
setTimeout(() => {
|
||||
this.loading = false
|
||||
this.$router.push({ path: '/' })
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
}, 2000);
|
||||
// this.$store.dispatch('Login', this.loginForm).then(() => {
|
||||
// this.loading = false
|
||||
// this.$router.push({ path: '/' })
|
||||
// }).catch(() => {
|
||||
// this.loading = false
|
||||
// })
|
||||
} else {
|
||||
console.log('error submit!!')
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user