login.vue
2.02 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<template>
<div class="login">
<p>
<span>用户名</span>
<input v-model="login_data.login_code" @keyup.enter="loginHandler" />
</p>
<p>
<span>密码</span>
<input type="password" v-model="login_data.login_password" @keyup.enter="loginHandler" />
</p>
<el-button type="primary" @click="loginHandler">登录</el-button>
</div>
</template>
<script>
export default {
data () {
return {
login_data: {
login_code: '',
login_password: '1'
}
}
},
methods: {
loginHandler () {
if (this.login_data.login_code === '') {
this.$vux.toast.show({
type: 'warn',
text: '请输入账号!'
})
return;
}
axios.post('b/auth/syslogin', this.login_data)
.then(res => {
if (res.data.ret === 'OK') {
let user = res.data.content.user;
window.localStorage['user_name'] = user.user_name
window.localStorage['role'] = user.role
window.localStorage['user_id'] = user.user_id
if (user.role === 'PB') {
window.localStorage['prov_id'] = user.parent_id;
}
if (user.role === 'FB') {
window.localStorage['fran_id'] = user.parent_id;
}
if (user.role === 'SM' || user.role === 'SE') {
window.localStorage['store_id'] = user.parent_id;
}
this.$router.push('./function_list')
} else {
this.$vux.toast.text(res.data.msg);
}
})
.catch(err => {
console.error(err);
})
}
}
}
</script>
<style lang="less" scoped>
.login {
position: absolute;
top: 25%;
left: 50%;
transform: translateX(-50%);
padding: 1.8rem 2.5rem;
width: 15rem;
button {
margin-top: 1.2rem;
position: absolute;
right: 2.5rem;
}
input {
display: block;
width: 95%;
padding: 0.8rem 0.4rem;
background: #fff;
border: 1px solid #d6d7dc;
font-size: 0.95rem;
}
}
</style>