index.vue
4.88 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<template>
<div class="bg">
<div class="login-inner-bg login">
<div class="user_style">
<h3>欢迎登录</h3>
<el-form
:model="user"
:rules="rules"
ref="user"
id="loginform"
class="demo-ruleForm"
>
<el-form-item prop="account">
<el-input v-model="user.account" placeholder="用户名"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
type="password"
v-model="user.password"
placeholder="登录密码"
></el-input>
</el-form-item>
<el-form-item>
<el-checkbox
label="记住用户名"
@change="checkUserName"
></el-checkbox>
</el-form-item>
<el-form-item id="login">
<el-button type="primary" style="width: 100%" @click="login('user')"
>登录</el-button
>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script>
import { loginIn } from "@/api/login.js";
import { api, getAction } from "@/api/manageApi";
export default {
name: "Login",
data() {
return {
user: {
account: "",
password: "",
checkStatus: false,
},
rules: {
account: [{ required: true, message: "请填写帐号", trigger: "blur" }],
password: [{ required: true, message: "请填写密码", trigger: "blur" }],
},
};
},
created() {
const params = {};
const queryOptions = {
conditionGroup: {
conditions: [
{
property: "code",
value: "BDCJGPT",
operator: "EQ",
},
],
queryRelation: "AND",
},
};
params.queryOptions = JSON.stringify(queryOptions);
//根据子系统code获取子系统详细信息
getAction(api.subsystem, params).then((res) => {
if (res.status === 1) {
this.$store.dispatch("products/setData", res.content[0]);
} else {
this.$message.error({ message: res.message, showClose: true });
}
});
},
mounted() {
// this.checkUserName();
},
methods: {
//记住用户名
checkUserName: function (flag) {
this.user.checkStatus = flag;
if (this.user.checkStatus) {
localStorage.setItem("accountId", this.user.account);
let name = localStorage.getItem("accountId");
if (name === "") {
return;
} else {
this.user.account = name;
}
} else {
this.user.account = localStorage.getItem("accountId");
}
},
login(user) {
var self = this;
this.$refs[user].validate((valid) => {
if (valid) {
loginIn(self.user.account, self.user.password)
.then((res) => {
if (res.status === 1) {
//存储token
sessionStorage.setItem("token", `Bearer ${res.content}`);
//登录成功后需判断有无重定向,没有重定向则跳转首页
this.$router.replace(this.$route.query.redirect || "/");
} else {
//错误处理
}
})
.catch((error) => {
// console.dir(error);
});
}
});
},
},
computed: {
productName() {
return this.$store.state.products.products.name;
},
},
components: {},
};
</script>
<style scoped lang="scss">
.bg {
width: 100%;
height: 100%;
background: url(../../image/loginBg.jpg) no-repeat;
background-size: 100% 100%;
overflow: hidden;
}
.login-inner-bg {
background: url(../../image/loginBoxBg.png) no-repeat;
width: 400px;
height: 350px;
margin: 35vh auto;
overflow: hidden;
background-size: 100% 100%;
box-sizing: border-box;
padding: 20px;
}
.login .user_style {
margin: 40px 20px 0;
h3 {
color: #fff;
font-weight: normal;
text-align: center;
margin-bottom: 20px;
}
}
.login .btn {
width: 100%;
height: 6vh;
background-color: #00c2de;
border-radius: 5px;
font-size: 1.4vw;
color: #ffffff;
}
.login .btn:hover {
cursor: pointer;
background-color: #2d8cf0;
}
#loginform .el-button {
background: #409eff !important;
color: #ffffff !important;
}
#loginform .el-button:hover {
cursor: pointer !important;
background-color: #2d8cf0 !important;
}
.inputUser .ivu-input {
padding: 6px 24px !important;
border: 1px solid #9f9f9f !important;
}
#loginform .el-input__inner {
width: 100% !important;
caret-color: #000 !important;
color: #606266 !important;
border-radius: 4px !important;
border: 1px solid #67c23a !important;
background: #fff !important;
opacity: 1 !important;
}
#loginform .el-input__inner::-webkit-input-placeholder {
/* WebKit browsers */
color: #80807f !important;
}
.el-checkbox__label {
color: #fff;
}
</style>
<style></style>