index.vue
1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template lang="pug">
.login
LoginForm(class="login-card" ref="loginRef" @on-success-valid="handleLogin" :loading="btnLoading")
</template>
<script>
import LoginForm from '_c/loginForm'
import { mapActions, mapState, mapMutations } from 'vuex'
export default {
components: {
LoginForm
},
data() {
return {
isRegister: false,
btnLoading: false
}
},
computed: {
...mapState(['roles'])
},
mounted() {
this.SET_ROUTER_TEMP('')
},
methods: {
...mapActions(['login']),
...mapMutations(['SET_ROUTER_TEMP']),
async handleLogin({ username, password }) {
try {
this.btnLoading = true
const { code } = await this.login({ username, password })
if (code === 0) {
this.$router.push({ path: '/' })
} else {
this.$refs.loginRef.updateCaptcha()
}
} catch (error) {
console.log(error)
} finally {
this.btnLoading = false
}
}
}
}
</script>
<style lang="scss">
.login {
width: 100%;
height: 100%;
background: center / cover no-repeat url('../../assets/image/login-bg.png');
position: relative;
.login-card {
position: absolute;
top: 195px;
bottom: 195px;
right: 188px;
}
}
</style>