fix login loading screen

This commit is contained in:
Jack Goh
2018-06-13 21:50:06 +08:00
parent b622d81d94
commit fde70b744f
2 changed files with 12 additions and 7 deletions
+11 -6
View File
@@ -80,6 +80,12 @@ export default {
methods: {
async login () {
// Submit the form.
const { data } = await this.form.post('/api/login')
// Add loading screen
const loading = this.$loading({
lock: true,
text: 'Logging in',
@@ -87,25 +93,24 @@ export default {
background: 'rgba(0, 0, 0, 0.7)'
})
// Submit the form.
const { data } = await this.form.post('/api/login')
// Save the token.
this.$store.dispatch('auth/saveToken', {
token: data.token,
remember: this.remember
remember: this.remember,
})
// Fetch the user.
await this.$store.dispatch('auth/fetchUser')
// Redirect home.
if (store.getters['auth/user'].role === 'admin') {
loading.close()
this.$router.push({ name: 'admin.home' })
loading.close()
}
loading.close()
this.$router.push({ name: 'home' })
loading.close()
}
}
}
+1 -1
View File
@@ -16,7 +16,7 @@
</el-row>
<br>
<el-row :gutter="20" type="flex" justify="center" align="middle">
<el-col :xs="18" :sm="18" :md="8" :lg="8" :xl="8"><div class="grid-content bg-purple" align="left"><el-input type="number" v-model="booking.amount" placeholder="Amount"/></div></el-col>
<el-col :xs="18" :sm="18" :md="8" :lg="8" :xl="8"><div class="grid-content bg-purple" align="left"><el-input v-model="booking.amount" placeholder="Amount"/></div></el-col>
</el-row>
<!-- Input-Amount-end -->
<hr>