Login.vue
11.3 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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<template>
<el-container class="container">
<div class="login_page">
<div class="login_header">
<img
class="home-logo-img"
:src="logoPath"
:key="logoPath"
alt="company-logo"
/>
<span class="home-logo-title">{{ homeTitle }}</span>
</div>
<div class="login_box">
<div class="left"></div>
<div class="right">
<div class="login_card">
<div class="login_bg"></div>
<div class="login-content">
<h2 class="h2">欢迎登录</h2>
<h3 class="h3">车辆管理系统</h3>
<!-- <h1 class="login-title">{{title}}</h1> -->
<el-form>
<el-form-item class="username-wrapper" prop="name">
<el-input
class="login-input username-input"
placeholder="请输入用户名"
maxLength="50"
v-model="formInline.user"
>
</el-input>
</el-form-item>
<el-form-item class="form-wrapper pwd-wrapper" prop="pass">
<el-input
class="login-input"
placeholder="请输入密码"
v-model="formInline.password"
maxLength="20"
show-password
autocomplete="off"
>
</el-input>
</el-form-item>
<el-form-item class="login-button-wrapper">
<el-checkbox class="check_tips" v-model="checked"
>请阅读并同意<a
href="https://img02.glsx.com.cn/weapp/resource/saas/scrm/html/privacy.html"
target="_blank"
>《隐私协议》</a
>和<a
href="https://img02.glsx.com.cn/weapp/resource/saas/scrm/html/agreement.html"
target="_blank"
>《用户协议》</a
></el-checkbox
>
<el-button
class="login-button"
type="primary"
html-type="submit"
:disabled="!checked"
@keyup.enter="handleSubmit"
@click.native.prevent="handleSubmit"
>
登录
</el-button>
</el-form-item>
<el-form-item> </el-form-item>
</el-form>
</div>
</div>
</div>
</div>
<div class="login_footer">
Copyright ©2012-2023 粤ICP备12034057号 深圳广联数科科技有限公司 版权所有
</div>
</div>
</el-container>
</template>
<script>
import { ElMessage } from "element-plus";
import HomeHeader from "components/Header/HomeHeader";
import HomeContent from "components/HomeContent/HomeContent";
import HomeFooter from "components/Footer/HomeFooter";
import {
onMounted,
watch,
reactive,
toRefs,
getCurrentInstance,
onBeforeMount,
} from "vue";
import { useStore } from "vuex";
import LoginService from "@/services/Login";
import { trimSpace } from "@/utils/tools/tools";
export default {
name: "LoginPage",
components: {
HomeHeader,
HomeContent,
HomeFooter,
},
setup() {
const store = useStore();
const state = reactive({
logoPath: store.state.app.logo,
homeTitle: "",
alertMsg: "",
showAlert: false,
alertArr: [],
randomVal: "0",
formInline: {
user: "",
password: "",
captcha: "",
},
title: store.state.app.title,
logo: store.state.app.logo,
checked: false,
});
let logoPath = store.state.app.logo;
const { ctx: _this } = getCurrentInstance();
const loginService = new LoginService();
onBeforeMount(() => {
document.onkeydown = (e) => {
if (e.keyCode === 13) {
handleSubmit();
}
};
});
// 登录提交验证 用户名只限制长度50 验证码暂时屏蔽
const handleSubmit = async () => {
const value = state.formInline,
captchaId = state.captchaId,
{ user, password, captcha } = value;
// state.alertArr = [];
// state.showAlert = false;
if (trimSpace(user).length <= 0) {
// state.alertArr.push("请输入用户名");
// state.showAlert = true;
ElMessage({
message: "请输入用户名",
type: "error",
});
return false;
}
// if(!validate_username(user)) {
// state.alertArr.push('用户名格式不正确');
// state.showAlert = true;
// return false;
// }
if (trimSpace(password).length <= 0) {
// state.alertArr.push("请输入密码");
// state.showAlert = true;
ElMessage({
message: "请输入密码",
type: "error",
});
return false;
}
// if(trimSpace(captcha).length <= 0) {
// state.alertArr.push('请输入验证码');
// state.showAlert = true;
// return false;
// }
// params: captcha, captchaId 验证码暂时屏蔽
store.dispatch("app/showLoading", true);
const params = { account: user, password };
let uuid = localStorage.getItem("uuid");
let isUpdate = false
if (!uuid) {
uuid = createUuid();
isUpdate = true
}
params.specialMark = uuid;
console.log(params);
await loginService.loginAction(params).then(
(res) => {
store.dispatch("app/showLoading", false);
if (res.code === 200) {
const { token, user } = res.data;
// 是否更新uuid
if(isUpdate){
localStorage.setItem("uuid", uuid);
}
store.dispatch("app/setUserInfo", user);
store.dispatch("app/setToken", token);
} else {
const { message } = res;
// state.alertArr.push(message);
// state.showAlert = true;
ElMessage({
message: message,
type: "error",
});
store.dispatch("app/showLoading", false);
}
},
(err) => {
store.dispatch("app/showLoading", false);
}
);
};
// 生成uuid
const createUuid = () => {
return "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, function (c) {
var r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
};
watch(
() => store.state.app.logo,
(n, o) => {
state.logoPath = n;
console.log("logoPath:", n);
}
);
watch(
() => store.state.app.logo,
(n, o) => {
state.logo = n;
}
);
watch(
() => store.state.app.title,
(n, o) => {
state.title = n;
}
);
console.log(logoPath);
return { ...toRefs(state), handleSubmit };
},
};
</script>
<style lang="less" scoped>
@import "styles/variables.less";
// .container {
// position: fixed;
// height: 100%;
// top: 0;
// left: 0;
// width: 100%;
// min-width: 1190px;
// overflow-y: scroll;
// }
.login_page {
height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
background: url("../assets/images/bg.jpg") no-repeat center center;
background-size: cover;
.login_header {
width: 100%;
height: 56px;
background: #fff;
overflow: hidden;
.home-logo-img {
max-width: 100%;
max-height: 56px;
margin-left: 24px;
}
// padding:20px;
}
.login_box {
width: 100%;
flex: 1;
//height: calc(100vh - 120px);
//background: url("../../assets/images/car-bg.png") no-repeat;
//background: url("../assets/images/car-bg.png") no-repeat;
background-size: cover;
display: flex;
justify-content: space-between;
.right {
flex: 2;
display: flex;
align-items: center;
justify-content: flex-end;
padding: 0 120px 0 0;
@media (max-width: 414px) {
padding: 0;
}
}
.login_card {
position: relative;
width: 416px;
height: 480px;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
.login_bg {
position: absolute;
width: 416px;
height: 480px;
background: linear-gradient(180deg, #335fb8 0%, #142f7a 100%);
box-shadow: 0px 8px 40px 12px rgba(2, 14, 73, 0.35);
border-radius: 2px;
opacity: 0.8;
border: 1px solid;
border-image: linear-gradient(
180deg,
rgba(74, 104, 165, 1),
rgba(54, 78, 135, 0.4),
rgba(36, 55, 108, 1)
)
1 1;
}
.login-content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: 0 48px;
box-sizing: border-box;
.h2,
.h3 {
color: #ffffff;
line-height: 30px;
text-align: center;
margin: 0;
padding: 0;
}
.h2 {
font-size: 20px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
margin-top: 64px;
}
.h3 {
font-size: 24px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
margin: 12px 0 48px 0;
}
.login-title {
height: 55px;
font-size: 22px;
color: #333;
font-weight: bold;
}
.login-input {
width: 100%;
}
.login-button-wrapper {
margin-top: 48px;
.login-button {
width: 320px;
height: 48px;
background: #0077ff;
border-radius: 4px;
}
}
}
}
}
.login_card:after {
position: absolute;
display: block;
content: "";
background: url("../assets/images/light.png") no-repeat;
background-size: 100% auto;
width: 253px;
height: 17px;
top: -6px;
left: 50%;
transform: translateX(-50%);
}
.login_footer {
display: flex;
align-items: center;
justify-content: center;
height: 32px;
font-size: 12px;
text-align: center;
color: #999;
background: #fff;
}
}
.check_tips {
color: #fff;
a {
color: #0077ff;
}
}
</style>
<style scoped>
.login_box >>> .el-input__inner {
background: #0f213d;
/* box-shadow: 0px 0px 12px 0px rgba(93, 131, 191, 0.4); */
border-radius: 4px;
/* border: 1px solid #4b68a5; */
border: 1px solid #0f213d;
color: #fff;
}
.login_box >>> .el-input__inner:focus {
box-shadow: 0px 0px 16px 0px rgba(93, 131, 191, 0.8);
border: 1px solid #626a7a;
}
.login_box >>> .el-input__inner:-webkit-autofill {
/* -webkit-box-shadow: 0 0 0px 1000px #0f213d inset; */
background: #0f213d !important;
}
.login_box >>> input:-internal-autofill-selected {
/* background: #0f213d !important; */
transition: background-color 5000s ease-in-out s !important;
}
.login_box >>> input::-webkit-input-placeholder {
color: #626a7a;
}
.login_box >>> input::-moz-input-placeholder {
color: #626a7a;
}
.login_box >>> input::-ms-input-placeholder {
color: #626a7a;
}
</style>