|
@@ -1,14 +1,480 @@
|
1
|
1
|
<template>
|
2
|
|
- <div></div>
|
|
2
|
+ <div class="wrap">
|
|
3
|
+ <div class="logo">
|
|
4
|
+ <img class="logo_img" src="../../assets/img/login/logo.png" />
|
|
5
|
+ <span class="logo_title">星火云鸽管控平台</span>
|
|
6
|
+ </div>
|
|
7
|
+ <div class="loginInner">
|
|
8
|
+ <div class="welcome">欢迎登录</div>
|
|
9
|
+ <!-- <div class="login_type">-->
|
|
10
|
+ <!-- <div @click="usertype = 1" :class="[usertype == 1 ? 'active' : '']">-->
|
|
11
|
+ <!-- 账号登录-->
|
|
12
|
+ <!-- </div>-->
|
|
13
|
+ <!-- <div @click="usertype = 2" :class="[usertype == 2 ? 'active' : '']">-->
|
|
14
|
+ <!-- 验证码登录-->
|
|
15
|
+ <!-- </div>-->
|
|
16
|
+ <!-- </div>-->
|
|
17
|
+ <Form ref="loginForm" :model="loginForm" :rules="formRules">
|
|
18
|
+ <FormItem prop="loginname">
|
|
19
|
+ <img class="img" src="../../assets/img/login/user.png" alt="" />
|
|
20
|
+ <Input
|
|
21
|
+ v-model="loginForm.loginname"
|
|
22
|
+ clearable
|
|
23
|
+ @keyup.enter.native="login_by_username('loginForm')"
|
|
24
|
+ placeholder="请输入账号"
|
|
25
|
+ />
|
|
26
|
+ </FormItem>
|
|
27
|
+ <FormItem prop="loginpwd">
|
|
28
|
+ <img class="img" src="../../assets/img/login/pw.png" alt="" />
|
|
29
|
+ <Input
|
|
30
|
+ type="password"
|
|
31
|
+ class="show_input"
|
|
32
|
+ oncopy="return false"
|
|
33
|
+ onpaste="return false"
|
|
34
|
+ oncut="return false"
|
|
35
|
+ v-model="loginForm.loginpwd"
|
|
36
|
+ @keyup.enter.native="login_by_username('loginForm')"
|
|
37
|
+ placeholder="请输入密码"
|
|
38
|
+ />
|
|
39
|
+ <div class="pwd">
|
|
40
|
+ <img
|
|
41
|
+ v-if="show_pw"
|
|
42
|
+ @click="togglePw"
|
|
43
|
+ src="../../assets/img/login/open.svg"
|
|
44
|
+ alt=""
|
|
45
|
+ />
|
|
46
|
+ <img
|
|
47
|
+ v-else
|
|
48
|
+ @click="togglePw"
|
|
49
|
+ src="../../assets/img/login/close.svg"
|
|
50
|
+ alt=""
|
|
51
|
+ />
|
|
52
|
+ </div>
|
|
53
|
+ </FormItem>
|
|
54
|
+ <FormItem prop="msgcode" class="changecode">
|
|
55
|
+ <img class="img" src="../../assets/img/login/code.png" alt="" />
|
|
56
|
+ <Input
|
|
57
|
+ v-model="loginForm.msgcode"
|
|
58
|
+ class="input"
|
|
59
|
+ @keyup.enter.native="login_by_username('loginForm')"
|
|
60
|
+ v-noFill
|
|
61
|
+ readonly
|
|
62
|
+ placeholder="请输入验证码"
|
|
63
|
+ />
|
|
64
|
+ <img
|
|
65
|
+ v-if="code_info.base64Str"
|
|
66
|
+ class="code_img"
|
|
67
|
+ :src="code_info.base64Str"
|
|
68
|
+ @click="getCodeImg()"
|
|
69
|
+ title="点击刷新验证码"
|
|
70
|
+ />
|
|
71
|
+ <span class="emit_code" v-else @click="getCodeImg()">获取验证码</span>
|
|
72
|
+ </FormItem>
|
|
73
|
+ <FormItem class="btn_bottom">
|
|
74
|
+ <Checkbox v-model="pwd">记住密码</Checkbox>
|
|
75
|
+ </FormItem>
|
|
76
|
+ </Form>
|
|
77
|
+ <Button
|
|
78
|
+ :loading="wait_flag"
|
|
79
|
+ type="primary"
|
|
80
|
+ @click.enter="login_by_username('loginForm')"
|
|
81
|
+ >登 录</Button
|
|
82
|
+ >
|
|
83
|
+ </div>
|
|
84
|
+ </div>
|
3
|
85
|
</template>
|
4
|
86
|
|
5
|
87
|
<script>
|
|
88
|
+import { img_code } from "@/api/admin";
|
|
89
|
+
|
|
90
|
+const Base64 = require("js-base64").Base64;
|
6
|
91
|
export default {
|
7
|
92
|
data() {
|
8
|
|
- return {};
|
|
93
|
+ // 手机号验证
|
|
94
|
+ const phoneCheck = async (rule, value, callback) => {
|
|
95
|
+ var filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
|
|
96
|
+ this.isemit = false;
|
|
97
|
+ if (!value) {
|
|
98
|
+ return callback(new Error("手机号码不能为空"));
|
|
99
|
+ }
|
|
100
|
+ let blnTest = filter.test(value);
|
|
101
|
+ if (!blnTest) {
|
|
102
|
+ return callback(new Error("手机号码格式不正确"));
|
|
103
|
+ } else {
|
|
104
|
+ this.isemit = true;
|
|
105
|
+ }
|
|
106
|
+ };
|
|
107
|
+ return {
|
|
108
|
+ code_info: {
|
|
109
|
+ base64Str: "",
|
|
110
|
+ msgcode: ""
|
|
111
|
+ },
|
|
112
|
+ usertype: 1,
|
|
113
|
+ time1: null,
|
|
114
|
+ isemit: false,
|
|
115
|
+ userInfo: {},
|
|
116
|
+ wait_flag: false,
|
|
117
|
+ loginForm: {
|
|
118
|
+ loginname: "",
|
|
119
|
+ loginpwd: "",
|
|
120
|
+ msgcode: "",
|
|
121
|
+ phone: ""
|
|
122
|
+ },
|
|
123
|
+ formRules: {
|
|
124
|
+ loginname: [
|
|
125
|
+ { required: true, message: "账号不能为空", trigger: "blur" },
|
|
126
|
+ {
|
|
127
|
+ min: 4,
|
|
128
|
+ max: 18,
|
|
129
|
+ message: "账号长度为4~18个字符"
|
|
130
|
+ }
|
|
131
|
+ ],
|
|
132
|
+ loginpwd: [
|
|
133
|
+ { required: true, message: "密码不能为空", trigger: "blur" },
|
|
134
|
+ {
|
|
135
|
+ min: 6,
|
|
136
|
+ max: 16,
|
|
137
|
+ message: "密码长度为6~16个字符"
|
|
138
|
+ }
|
|
139
|
+ ],
|
|
140
|
+ phone: [{ required: true, validator: phoneCheck, trigger: "blur" }],
|
|
141
|
+ msgcode: [
|
|
142
|
+ { required: true, message: "短信验证码不能为空", trigger: "blur" }
|
|
143
|
+ ]
|
|
144
|
+ },
|
|
145
|
+ pwd: false,
|
|
146
|
+ show_pw: false,
|
|
147
|
+ time: 0
|
|
148
|
+ };
|
|
149
|
+ },
|
|
150
|
+ directives: {
|
|
151
|
+ // 防止input输入框自动填充
|
|
152
|
+ noFill: {
|
|
153
|
+ inserted: (el) => {
|
|
154
|
+ let inputEl = el.getElementsByTagName("input")[0];
|
|
155
|
+ if (inputEl) {
|
|
156
|
+ inputEl.addEventListener("focus", () => {
|
|
157
|
+ inputEl.removeAttribute("readonly");
|
|
158
|
+ });
|
|
159
|
+ inputEl.addEventListener("blur", () => {
|
|
160
|
+ inputEl.setAttribute("readonly", "readonly");
|
|
161
|
+ });
|
|
162
|
+ }
|
|
163
|
+ }
|
|
164
|
+ }
|
|
165
|
+ },
|
|
166
|
+ created() {
|
|
167
|
+ // this.$removeEncodeStorage("userInfo");
|
|
168
|
+ // 在页面加载时从cookie获取登录信息
|
|
169
|
+ let loginname = this.getCookie("loginname");
|
|
170
|
+ let loginpwd = Base64.decode(this.getCookie("loginpwd"));
|
|
171
|
+ // 如果存在赋值给表单,并且将记住密码勾选
|
|
172
|
+ if (loginname) {
|
|
173
|
+ this.loginForm.loginname = loginname;
|
|
174
|
+ this.loginForm.loginpwd = loginpwd;
|
|
175
|
+ this.pwd = true;
|
|
176
|
+ }
|
|
177
|
+ },
|
|
178
|
+ watch: {
|
|
179
|
+ time() {
|
|
180
|
+ if (this.time == 0) {
|
|
181
|
+ if (this.time1) {
|
|
182
|
+ clearInterval(this.time1);
|
|
183
|
+ }
|
|
184
|
+ }
|
|
185
|
+ }
|
|
186
|
+ },
|
|
187
|
+ mounted() {
|
|
188
|
+ window.addEventListener("copy", this.inputHandle);
|
|
189
|
+ window.addEventListener("paste", this.inputHandle);
|
|
190
|
+ window.addEventListener("cut", this.inputHandle);
|
|
191
|
+ },
|
|
192
|
+ beforeDestroy() {
|
|
193
|
+ window.removeEventListener("copy", this.inputHandle);
|
|
194
|
+ window.removeEventListener("paste", this.inputHandle);
|
|
195
|
+ window.removeEventListener("cut", this.inputHandle);
|
|
196
|
+ clearInterval(this.time1);
|
9
|
197
|
},
|
10
|
|
- methods: {}
|
|
198
|
+ methods: {
|
|
199
|
+ //获取验证码
|
|
200
|
+ getCodeImg() {
|
|
201
|
+ if (!this.loginForm.loginname) {
|
|
202
|
+ this.$Message.error("请输入账号");
|
|
203
|
+ return;
|
|
204
|
+ }
|
|
205
|
+ img_code({
|
|
206
|
+ loginname: this.loginForm.loginname
|
|
207
|
+ }).then((data) => {
|
|
208
|
+ console.log(data);
|
|
209
|
+ if (data.code === 0) {
|
|
210
|
+ this.code_info = data.obj;
|
|
211
|
+ } else {
|
|
212
|
+ this.$Message.error(data.msg);
|
|
213
|
+ }
|
|
214
|
+ });
|
|
215
|
+ },
|
|
216
|
+ inputHandle() {
|
|
217
|
+ let edit = document.querySelector(".show_input");
|
|
218
|
+ edit.oncopy = function () {
|
|
219
|
+ return false;
|
|
220
|
+ };
|
|
221
|
+ edit.onpaste = function () {
|
|
222
|
+ return false;
|
|
223
|
+ };
|
|
224
|
+ edit.oncut = function () {
|
|
225
|
+ return false;
|
|
226
|
+ };
|
|
227
|
+ },
|
|
228
|
+ //切换眼睛
|
|
229
|
+ togglePw() {
|
|
230
|
+ this.show_pw = !this.show_pw;
|
|
231
|
+ let input = document.querySelector(".show_input input");
|
|
232
|
+ if (this.show_pw) {
|
|
233
|
+ input.setAttribute("type", "text");
|
|
234
|
+ } else {
|
|
235
|
+ input.setAttribute("type", "password");
|
|
236
|
+ }
|
|
237
|
+ },
|
|
238
|
+ //登录
|
|
239
|
+ login_by_username(name) {
|
|
240
|
+ let that = this;
|
|
241
|
+ this.$refs[name].validate((valid) => {
|
|
242
|
+ if (valid) {
|
|
243
|
+ if (
|
|
244
|
+ this.loginForm.msgcode.toLowerCase() !==
|
|
245
|
+ this.code_info.msgcode.toLowerCase()
|
|
246
|
+ ) {
|
|
247
|
+ this.$Message.error("验证码不正确");
|
|
248
|
+ return;
|
|
249
|
+ }
|
|
250
|
+ this.wait_flag = true;
|
|
251
|
+ }
|
|
252
|
+ });
|
|
253
|
+ },
|
|
254
|
+ // 记住密码功能
|
|
255
|
+ set_userInfo() {
|
|
256
|
+ if (this.pwd) {
|
|
257
|
+ this.setCookie("loginname", this.loginForm.loginname, 86400);
|
|
258
|
+ this.setCookie("usertype", this.loginForm.usertype, 86400);
|
|
259
|
+ // base64加密密码
|
|
260
|
+ let loginpwd = Base64.encode(this.loginForm.loginpwd);
|
|
261
|
+ this.setCookie("loginpwd", loginpwd, 86400);
|
|
262
|
+ } else {
|
|
263
|
+ this.setCookie("loginname", "");
|
|
264
|
+ this.setCookie("loginpwd", "");
|
|
265
|
+ }
|
|
266
|
+ },
|
|
267
|
+ //验证码登录
|
|
268
|
+ go_type() {},
|
|
269
|
+ //忘记密码
|
|
270
|
+ tousecrt() {},
|
|
271
|
+ // 获取cookie
|
|
272
|
+ getCookie: function (key) {
|
|
273
|
+ if (document.cookie.length > 0) {
|
|
274
|
+ var start = document.cookie.indexOf(key + "=");
|
|
275
|
+ if (start !== -1) {
|
|
276
|
+ start = start + key.length + 1;
|
|
277
|
+ var end = document.cookie.indexOf(";", start);
|
|
278
|
+ if (end === -1) end = document.cookie.length;
|
|
279
|
+ return unescape(document.cookie.substring(start, end));
|
|
280
|
+ }
|
|
281
|
+ }
|
|
282
|
+ return "";
|
|
283
|
+ },
|
|
284
|
+ // 保存cookie
|
|
285
|
+ setCookie: function (cName, value, expiredays) {
|
|
286
|
+ var exdate = new Date();
|
|
287
|
+ exdate.setDate(exdate.getDate() + expiredays);
|
|
288
|
+ document.cookie =
|
|
289
|
+ cName +
|
|
290
|
+ "=" +
|
|
291
|
+ decodeURIComponent(value) +
|
|
292
|
+ (expiredays == null ? "" : ";expires=" + exdate.toGMTString());
|
|
293
|
+ }
|
|
294
|
+ }
|
11
|
295
|
};
|
12
|
296
|
</script>
|
13
|
297
|
|
14
|
|
-<style lang="less" scoped></style>
|
|
298
|
+<style lang="less" scoped>
|
|
299
|
+.wrap {
|
|
300
|
+ height: 100%;
|
|
301
|
+ background: url("../../assets/img/login/bj.png") no-repeat;
|
|
302
|
+ background-size: 100% 100%;
|
|
303
|
+ position: relative;
|
|
304
|
+ .logo {
|
|
305
|
+ position: absolute;
|
|
306
|
+ top: 70px;
|
|
307
|
+ left: 60px;
|
|
308
|
+ width: 300px;
|
|
309
|
+ height: 50px;
|
|
310
|
+ display: flex;
|
|
311
|
+ align-items: center;
|
|
312
|
+ .logo_img {
|
|
313
|
+ width: 45px;
|
|
314
|
+ height: 45px;
|
|
315
|
+ margin-right: 10px;
|
|
316
|
+ }
|
|
317
|
+ .logo_title {
|
|
318
|
+ color: #414354;
|
|
319
|
+ font-size: 20px;
|
|
320
|
+ font-weight: 700;
|
|
321
|
+ font-family: "HarmonyOSSansSC";
|
|
322
|
+ }
|
|
323
|
+ }
|
|
324
|
+ .loginInner {
|
|
325
|
+ width: 400px;
|
|
326
|
+ height: 440px;
|
|
327
|
+ padding: 40px;
|
|
328
|
+ border-radius: 20px;
|
|
329
|
+ opacity: 0.88;
|
|
330
|
+ background: #ffffff;
|
|
331
|
+ box-shadow: 0 0 18px 0 #deeaffe0;
|
|
332
|
+ position: absolute;
|
|
333
|
+ right: 160px;
|
|
334
|
+ bottom: 160px;
|
|
335
|
+ .welcome {
|
|
336
|
+ height: 30px;
|
|
337
|
+ color: #000000;
|
|
338
|
+ font-size: 24px;
|
|
339
|
+ font-family: "AlibabaPuHuiTi";
|
|
340
|
+ text-align: center;
|
|
341
|
+ }
|
|
342
|
+ .login_type {
|
|
343
|
+ height: 40px;
|
|
344
|
+ display: flex;
|
|
345
|
+ justify-content: center;
|
|
346
|
+ align-items: center;
|
|
347
|
+ margin-bottom: 10px;
|
|
348
|
+ div {
|
|
349
|
+ color: #7c8db5;
|
|
350
|
+ font-size: 16px;
|
|
351
|
+ font-family: "SourceHanSansCN";
|
|
352
|
+ cursor: pointer;
|
|
353
|
+ &:first-of-type {
|
|
354
|
+ margin-right: 20px;
|
|
355
|
+ }
|
|
356
|
+ }
|
|
357
|
+ .active {
|
|
358
|
+ color: #253a70;
|
|
359
|
+ position: relative;
|
|
360
|
+ &::after {
|
|
361
|
+ display: block;
|
|
362
|
+ content: "";
|
|
363
|
+ height: 2px;
|
|
364
|
+ width: 30px;
|
|
365
|
+ background-color: #339dff;
|
|
366
|
+ position: absolute;
|
|
367
|
+ top: 24px;
|
|
368
|
+ left: 30%;
|
|
369
|
+ }
|
|
370
|
+ }
|
|
371
|
+ }
|
|
372
|
+ /deep/ .ivu-form {
|
|
373
|
+ .ivu-form-item {
|
|
374
|
+ .ivu-form-item-content {
|
|
375
|
+ position: relative;
|
|
376
|
+ .img {
|
|
377
|
+ position: absolute;
|
|
378
|
+ z-index: 33;
|
|
379
|
+ width: 16px;
|
|
380
|
+ height: 16px;
|
|
381
|
+ top: 12px;
|
|
382
|
+ left: 15px;
|
|
383
|
+ }
|
|
384
|
+ .ivu-input-wrapper {
|
|
385
|
+ width: 100%;
|
|
386
|
+ // height: 47px;
|
|
387
|
+ input {
|
|
388
|
+ &:-moz-placeholder {
|
|
389
|
+ color: #999 !important;
|
|
390
|
+ }
|
|
391
|
+ }
|
|
392
|
+ .ivu-input {
|
|
393
|
+ height: 40px;
|
|
394
|
+ padding-left: 40px;
|
|
395
|
+ }
|
|
396
|
+ .ivu-input-icon {
|
|
397
|
+ line-height: 50px;
|
|
398
|
+ }
|
|
399
|
+ .ivu-input-icon-clear {
|
|
400
|
+ line-height: 50px;
|
|
401
|
+ }
|
|
402
|
+ // padding-left: 20px;
|
|
403
|
+ }
|
|
404
|
+ .ivu-checkbox-wrapper {
|
|
405
|
+ span {
|
|
406
|
+ font-size: 15px;
|
|
407
|
+ font-family: "Microsoft YaHei";
|
|
408
|
+ font-weight: 400;
|
|
409
|
+ color: rgba(136, 136, 136, 1);
|
|
410
|
+ line-height: 17px;
|
|
411
|
+ }
|
|
412
|
+ }
|
|
413
|
+ .pwd {
|
|
414
|
+ position: absolute;
|
|
415
|
+ z-index: 33;
|
|
416
|
+ width: 16px;
|
|
417
|
+ height: 16px;
|
|
418
|
+ top: 12px;
|
|
419
|
+ right: 15px;
|
|
420
|
+ }
|
|
421
|
+ .pwd img {
|
|
422
|
+ width: 16px;
|
|
423
|
+ height: 16px;
|
|
424
|
+ vertical-align: top;
|
|
425
|
+ cursor: pointer;
|
|
426
|
+ }
|
|
427
|
+ }
|
|
428
|
+ }
|
|
429
|
+ .btn_bottom {
|
|
430
|
+ height: 32px;
|
|
431
|
+ .ivu-form-item-content {
|
|
432
|
+ display: flex;
|
|
433
|
+ justify-content: space-between;
|
|
434
|
+ a {
|
|
435
|
+ //color: @theme_color;
|
|
436
|
+ }
|
|
437
|
+ }
|
|
438
|
+ }
|
|
439
|
+ }
|
|
440
|
+ /deep/ .ivu-btn {
|
|
441
|
+ width: 100%;
|
|
442
|
+ height: 40px;
|
|
443
|
+ span {
|
|
444
|
+ font-size: 18px;
|
|
445
|
+ font-family: "Microsoft YaHei";
|
|
446
|
+ font-weight: 400;
|
|
447
|
+ color: rgba(255, 255, 255, 1);
|
|
448
|
+ }
|
|
449
|
+ }
|
|
450
|
+ .changecode {
|
|
451
|
+ display: flex;
|
|
452
|
+ /deep/ .ivu-form-item-content {
|
|
453
|
+ width: 100%;
|
|
454
|
+ .input {
|
|
455
|
+ width: calc(100% - 120px) !important;
|
|
456
|
+ margin-right: 10px;
|
|
457
|
+ }
|
|
458
|
+ .emit_code {
|
|
459
|
+ display: inline-block;
|
|
460
|
+ width: 110px;
|
|
461
|
+ line-height: 40px;
|
|
462
|
+ height: 40px;
|
|
463
|
+ text-align: center;
|
|
464
|
+ border: 1px solid #339dff;
|
|
465
|
+ border-radius: 6px;
|
|
466
|
+ cursor: pointer;
|
|
467
|
+ color: #339dff;
|
|
468
|
+ vertical-align: bottom;
|
|
469
|
+ }
|
|
470
|
+ .code_img {
|
|
471
|
+ width: 110px;
|
|
472
|
+ height: 40px;
|
|
473
|
+ cursor: pointer;
|
|
474
|
+ vertical-align: bottom;
|
|
475
|
+ }
|
|
476
|
+ }
|
|
477
|
+ }
|
|
478
|
+ }
|
|
479
|
+}
|
|
480
|
+</style>
|