login.vue
6.97 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<template>
<div id="login">
<div class="login-logo"><img src="./images/logo-login.png" /></div>
<div class="login-con">
<!-- <div class="login-title">用户登录</div>-->
<div class="login-user" :class="{ 'select-border': change.user }">
<img class="user-icon" src="./images/user.svg" />
<!-- <div class="line-mid"></div>-->
<input
type="text"
class="user-input"
placeholder="请输入您的账号"
v-model="userInfo.username"
@focus="reduceBorder('user')"
@blur="addBorder('user')"
/>
<span class="warning" v-show="warning.user">账号不能为空</span>
</div>
<div class="login-user user-mt" :class="{ 'select-border': change.pass }">
<img class="user-icon" src="./images/password.svg" />
<!-- <div class="line-mid"></div>-->
<input
type="password"
class="user-input"
placeholder="请输入您的密码"
v-model="userInfo.password"
v-show="!selectEye"
@focus="reduceBorder('pass')"
@blur="addBorder('pass')"
/>
<input
type="text"
class="user-input"
placeholder="请输入您的密码"
v-model="userInfo.password"
v-show="selectEye"
@focus="reduceBorder('pass')"
@blur="addBorder('pass')"
/>
<img
class="password-eye"
src="./images/open.svg"
@click="selectEyes"
v-show="selectEye"
/>
<img
class="password-eye"
src="./images/close.svg"
@click="selectEyes"
v-show="!selectEye"
/>
<span class="warning" v-show="warning.pass">密码不能为空</span>
</div>
<div class="login-remake">
<i
class="icon iconfont iconfuxuan1 icon-style"
v-show="!selectIcon"
@click="selectRemeber"
></i>
<i
class="icon iconfont iconfuxuan-xuanzhong icon-select"
v-show="selectIcon"
@click="selectRemeber"
></i>
<span class="remake_txt" @click="selectRemeber">记住账号密码</span>
</div>
<div id="loginBtn" class="login-btn" @click="goHome">登录</div>
</div>
<div class="reserved-con">
<div class="reserved-words">版权所有:2020©某某市自然资源和规划</div>
<div class="reserved-words line-two">
技术支持:西安市自然资源规划局信息中心
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
selectIcon: true,
selectEye: false,
userInfo: {
username: "",
password: "",
},
change: {
//边框
user: false,
pass: false,
},
warning: {
user: false,
pass: false,
},
canDo: 1,
};
},
mounted() {
this.initPage();
},
methods: {
initPage() {
let userInfo =
localStorage.getItem("userInfo") &&
JSON.parse(localStorage.getItem("userInfo"));
if (userInfo) {
this.userInfo.username = userInfo.username;
this.userInfo.password = userInfo.password;
}
},
selectRemeber() {
this.selectIcon = !this.selectIcon;
},
goHome() {
if (this.canDo) {
this.canDo = 0;
if (
this.userInfo.username == "admin" &&
this.userInfo.password == "123456"
) {
if (this.selectIcon) {
localStorage.setItem("userInfo", JSON.stringify(this.userInfo));
} else {
localStorage.removeItem("userInfo");
}
// this.$store.dispatch('user/login', this.userInfo).then(() => {
// this.$router.push('/home')
// }).catch(() => {
// })
// this.$store.dispatch("permission_routes/getMenus");
this.$router.push("/panel");
} else if (!this.userInfo.username || !this.userInfo.password) {
this.$message({
duration: 2000,
message: "账号或密码不能为空,请重新输入",
type: "error",
});
} else {
this.$message({
duration: 2000,
message: "账号或密码不正确,请重新输入",
type: "error",
});
}
setTimeout(() => {
this.canDo = 1;
}, 2000);
}
},
selectEyes() {
this.selectEye = !this.selectEye;
},
reduceBorder(type) {
//获取焦点
if (type == "user") {
this.change.user = true;
} else {
this.change.pass = true;
}
},
addBorder(type) {
//失去焦点
if (type == "user") {
this.change.user = false;
if (!this.userInfo.username) {
this.warning.user = true;
} else {
this.warning.user = false;
}
} else {
this.change.pass = false;
if (!this.userInfo.password) {
this.warning.pass = true;
} else {
this.warning.pass = false;
}
}
},
},
};
</script>
<style lang="less" scoped>
#login {
width: 100vw;
height: 100vh;
background: url("./images/login-bg.png") no-repeat bottom center;
background-size: 100% 100%;
overflow: hidden;
//position: relative;
.login-logo {
//display: block;
//position: absolute;
//top: 8%;
//left: 0;
//right: 0;
margin-top: 8%;
height: 38px;
width: 100%;
text-align: center;
}
.login-logo img{
height: 100%;
}
.login-con {
//position: absolute;
//top: 24%;
//left: 0;
//right: 0;
margin: 88px auto;
width: 380px;
}
//.login-title {
// width: 320px;
// margin: 0 auto;
// font-size: 14px;
// font-weight: 500;
//}
.login-user {
width: 100%;
height: 46px;
border: 1px solid rgba(155, 155, 155, 1);
box-sizing: border-box;
margin: 38px auto auto auto;
border-radius: 2px;
//position: relative;
.user-icon {
float: left;
margin: 13px auto auto 10px;
//float: left;
width: 28px;
height: 18px;
//margin-top: 11px;
}
//.line-mid {
// width: 1px;
// height: 16px;
// background: #cbcbcb;
// float: left;
// margin-top: 11px;
// margin-right: 9px;
//}
.user-input {
width: 80%;
float: left;
font-size: 16px;
//margin-top: 11px;
//background: none;
outline: 0;
border: none;
color: #4a4a4a;
line-height: 266%;
//box-shadow: inset 0 0 0 1000px #fff !important;
}
.password-eye {
float: right;
width: 16px;
height: 16px;
margin-right: 12px;
margin-top: 13px;
cursor: pointer;
}
.warning {
font-size: 12px;
color: red;
position: absolute;
left: 0;
bottom: -18px;
}
}
.user-mt {
margin-top: 26px;
}
.select-border {
border: 1px solid rgba(0, 113, 255, 1);
}
.login-remake {
width: 320px;
height: 14px;
margin: 0 auto;
margin-top: 26px;
.icon-style {
font-size: 12px;
color: #5b5b5b;
float: left;
line-height: 14px;
cursor: pointer;
}
.icon-select {
font-size: 12px;
color: rgba(0, 127, 255, 1);
float: left;
line-height: 14px;
cursor: pointer;
}
.remake_txt {
font-size: 12px;
line-height: 14px;
color: #5b5b5b;
margin-left: 6px;
float: left;
cursor: pointer;
}
}
.login-btn {
width: 100%;
height: 40px;
background: rgba(0, 127, 255, 1);
border-radius: 1px;
margin: 0 auto;
margin-top: 40px;
font-size: 16px;
line-height: 40px;
text-align: center;
color: #fff;
cursor: pointer;
}
.reserved-con {
margin: 38px auto;
}
.reserved-words {
font-size: 12px;
color: #b4b4b4;
text-align: center;
}
.line-two {
margin-top: 8px;
}
}
</style>