longyvfengyun
2022-03-15 b78ea3c61dc8184f6a8a612d5aa1adae2dec2de0
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
<template>
  <div class="login-wrapper">
    <div class="login_container">
      <div class="sliderCon">
        <div class="logo">
          <img :src="logoUrl" class="logoImg" />
          {{ platformName }}
        </div>
        <img src="../assets/images/login-img.png" class="picImg" />
      </div>
      <div class="login_box">
        <div class="login-tools">
          <el-tooltip
              effect="dark"
              :content="loginType.text"
              placement="top">
            <i v-if="showPhoneLogin" :class="loginType.icon" @click="showPsdLogin"></i>
          </el-tooltip>
        </div>
        <div class="title">{{ loginType.title }}</div>
        <!--  登录表单区 -->
        <el-form
          label-width="0px"
          class="login_from"
          :model="loginForm"
          ref="loginFormRef"
          v-if="psdLogin"
        >
          <!-- 用户名 -->
          <el-form-item prop="username">
            <el-input
              class="input"
              v-model="loginForm.username"
              prefix-icon="el-icon-user"
              @keyup.enter.native.stop="onSubmit"
            ></el-input>
          </el-form-item>
          <!-- 密码 -->
          <el-form-item prop="password">
            <el-input
              class="input"
              v-model="loginForm.password"
              prefix-icon="el-icon-lock"
              type="password"
              @keyup.enter.native.stop="onSubmit"
            ></el-input>
          </el-form-item>
          <el-form-item v-if="sysConfig.verifyCode.value">
            <el-row :gutter="8">
              <el-col :span="14">
                <el-input class="input" placeholder="验证码" v-model="loginForm.verify" @keyup.enter.native.stop="onSubmit"></el-input>
              </el-col>
              <el-col :span="8">
                <v-sidentify :identifyCode="verifyCode" @click="changeVerifyCode"></v-sidentify>
              </el-col>
            </el-row>
          </el-form-item>
          <el-form-item class="btns">
            <el-button
              :loading="loading"
              type="primary"
              @click="onSubmit"
              class="loginBtn"
              >登录</el-button
            >
          </el-form-item>
          <el-row>
            <el-col :span="12">
              <el-form-item v-if="!register">
                <a href="javascript:;" @click="license.show = true" class="regBtn"
                >平台注册</a
                >
              </el-form-item>
              <el-form-item v-else>
                <a href="javascript:;" class="regBtn">已激活</a>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item>
                <div class="text-right">
                  <a href="javascript:;" class="regBtn" @click="pwd.show=true">密码修改>></a>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-form
            label-width="0px"
            class="login_from"
            :model="loginForm"
            v-else>
          <!-- 手机号 -->
          <el-form-item>
            <el-input
              class="input"
              v-model="phoneInfo.phoneNum"
              prefix-icon="el-icon-phone">
            </el-input>
          </el-form-item>
          <div class="flex-row">
            <div class="flex-content">
              <!-- 验证码 -->
              <el-form-item>
                <el-input v-model="phoneInfo.code"></el-input>
              </el-form-item>
            </div>
            <div class="flex-footer">
              <el-button type="primary" @click="getVerifyCode" :disabled="codeBtn.disabled">{{codeBtn.text}}</el-button>
            </div>
          </div>
          <el-form-item class="btns">
            <el-button
              :loading="loading"
              type="primary"
              class="loginBtn"
              @click="phoneVerifyCodeLogin">登录</el-button>
          </el-form-item>
          <el-row>
            <el-col :span="12">
              <el-form-item v-if="!register">
                <a href="javascript:;" @click="license.show = true" class="regBtn"
                >平台注册</a
                >
              </el-form-item>
              <el-form-item v-else>
                <a href="javascript:;" class="regBtn">已激活</a>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item>
                <div class="text-right">
                  <a href="javascript:;" class="regBtn" @click="pwd.show=true">密码修改>></a>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!-- license弹框输入面板 -->
      <el-dialog
        title="平台注册提示"
        width="600px"
        :visible.sync="license.show"
        :close-on-click-modal="false"
        top="0"
        class="dialog-center"
        :modal-append-to-body="false"
      >
        <add-license
          v-if="license.show"
          :visible.sync="license.show"
        ></add-license>
      </el-dialog>
      <!-- 人脸登陆 -->
      <el-dialog
        title="人脸登陆"
        width="480px"
        :visible.sync="face.show"
        :close-on-click-modal="false"
        top="0"
        class="dialog-center"
        :modal-append-to-body="false"
      >
        <face-login
          v-if="face.show"
          :visible.sync="face.show"
          @success="checkServeLicense"
        ></face-login>
      </el-dialog>
      <!-- 功能描述 -->
      <el-dialog
        title="配置清单"
        width="960px"
        :visible.sync="config.show"
        :close-on-click-modal="false"
        top="0"
        class="dialog-center"
        :modal-append-to-body="false"
      >
        <config-info></config-info>
      </el-dialog>
      <!--  uKey的验证 -->
      <el-dialog
        title="uKey绑定"
        width="750px"
        :visible.sync="uKey.show"
        :close-on-click-modal="false"
        top="0"
        class="dialog-center"
        :modal-append-to-body="false"
      >
        <ukey-bind v-if="uKey.show" :visible.sync="uKey.show"></ukey-bind>
      </el-dialog>
      <!-- 密码修改 -->
      <el-dialog
          title="密码修改"
          width="400px"
          :visible.sync="pwd.show"
          :close-on-click-modal="false"
          top="0"
          class="dialog-center"
          :modal-append-to-body="false"
      >
        <pwd-change
          v-if="pwd.show"
          :show-name="showName"
          :visible.sync="pwd.show"
          :name="loginForm.username"
          :first-change="true"></pwd-change>
      </el-dialog>
      <div class="tools-container">
        <div
          class="tools-item"
          :class="uKeyState"
          v-if="$CFG.uKey.value"
          @click="uKey.show = true"
        >
          <span class="iconfont el-icon-CombinedShape"></span>
        </div>
        <div
          class="tools-item"
          v-if="$CFG.face.value"
          @click="face.show = true"
        >
          <span class="iconfont el-icon-renlianshibie"></span>
        </div>
        <div class="tools-item" @click="config.show = true">
          <span class="iconfont el-icon-peizhi"></span>
        </div>
      </div>
    </div>
    <div class="copy-right" v-if="copyRight.value">
      {{ copyRight.data }}
    </div>
  </div>
</template>
 
<script>
import AddLicense from "@/pages/AddLicense";
import FaceLogin from "@/components/face/FaceLogin";
import sysConfig from "@/assets/js/config"
import {
  login,
  initDBPool,
  checkLoginSession,
  uKeyLogin,
  getRandomFromServer,
  loginSignVerity,
  phoneVerifyCodeLogin,
  getLoginVerity
} from "@/assets/js/api";
import ConfigInfo from "@/pages/configInfo";
import UkeyBind from "@/components/UKeyBind";
import nfdw from "@/assets/images/nfdw-log.png";
import gjdw from "@/assets/images/gjdw-log.png";
import gjdx from "@/assets/images/gjdx-log.png";
import qwh from "@/assets/images/qwh-logo.png";
import yuanchange from "@/assets/images/yuanchang_logo2.png";
import platform from "@/assets/js/config";
import SoftUKey from "@/assets/js/tools/SoftUKey";
import SoftKey3W from "@/assets/js/Syunew3";
import verifyComponent from "@/components/verifyComponent";
import randomString from "@/assets/js/tools/randomString";
import pwdChange from "@/components/PwdChange";
import const_user from "@/assets/js/const/const_user";
import AES from "@/common/AES";
import md5 from "js-md5";
 
import {
  getVerifyCode
} from "@/assets/js/api";
import {formatSeconds} from "@/assets/js/tools";
import RSA from "@/assets/js/tools/RSA";
import const_num from "@/assets/js/const/const_num";
import formatPassword from "@/assets/js/tools/formatPassword";
 
export default {
  components: {
    UkeyBind,
    ConfigInfo,
    AddLicense,
    FaceLogin,
    'v-sidentify': verifyComponent,
    pwdChange,
  },
  data() {
    let readSeconds = Number(sessionStorage.getItem("readSeconds"));
    return {
      sysConfig: sysConfig,
      register: false,
      loading: false,
      labelPosition: "right" /*  登录表单 */,
      formLabelAlign: {
        name: "",
        region: "",
        type: "",
      },
      /* 登录表单el-form 的 数据绑定 */
      loginForm: {
        username: "",
        password: "",
        verify: ""
      },
      verifyCode: "",
      license: {
        show: false,
      },
      face: {
        show: false,
      },
      config: {
        show: false,
      },
      uKey: {
        show: false,
      },
      platformName: "",
      logoConfig: platform.logo,
      copyRight: platform.copyRight,
      softUKey: new SoftUKey(SoftKey3W),
      pwd: {
        show: false,
      },
      userType: const_user.type,
      userStatus: const_user.status,
      showPhoneLogin: platform.messageCode.value,
      psdLogin: true,
      phoneInfo: {
        phoneNum: "",
        code: ""
      },
      readSeconds: readSeconds?readSeconds:0,
      codeBtnLoading: false,
      showName: true,
    };
  },
  created() {
    this.searchPlatformName();
  },
  methods: {
    /* 初始化连接池  检测后台session*/
    async woData() {
      const [pool, sessions] = await Promise.all([
        initDBPool,
        checkLoginSession,
      ]);
      /*   console.log('pool',pool);
                console.log('sessions',sessions); */
    },
    onSubmit() {
      if (!this.register && process.env.NODE_ENV != "dev") {
        this.$layer.msg("平台未注册,请先注册平台!");
        return;
      }
      if (this.loading) {
        return;
      }
 
      if (this.$CFG.uKey.value) {
        this.uKeyLogin();
      } else {
        this.normalLogin();
      }
    },
    normalLogin() {
      // 校验用户
      if (this.loginForm.username && this.loginForm.password) {
        // 开启等待框
        this.loading = true;
        login(this.loginForm.username, this.loginForm.password, this.loginForm.verify)
          .then((res) => {
            // 对结果进行处理
            this.handleLogin(res);
          })
          .catch((error) => {
            // 关闭等待
            this.loading = false;
            console.log(error);
            this.changeVerifyCode();
            this.$message.error("网络异常");
          });
      } else {
        this.$message.error("用户名或密码不能为空");
      }
    },
    getRandomFromServer() {
      getRandomFromServer()
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            let randomNumber = rs.data;
            this.softUKey.getSign(randomNumber, this.checkUKeySign);
          } else {
            this.$message.error("服务器连接异常!");
          }
        })
        .catch((error) => {
          this.$message.error("服务器连接异常!");
        });
    },
    checkUKeySign(result) {
      let reg = new RegExp("&", "g");
      result.inPath = result.inPath.replace(reg, "%26");
      result.inPath = result.inPath.replace(/\\/g, "huodongwei");
      loginSignVerity(result)
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            this.uKeyLogin();
          } else {
            this.$message.error("UKey签名校验失败!");
          }
        })
        .catch((error) => {
          this.$message.error("服务器连接异常!");
        });
    },
    uKeyLogin() {
      //
      if (!this.$store.state.ukey.connect) {
        this.$message.error("请先安装uKey客户端服务");
        return;
      }
      if (!this.$store.state.ukey.isIn) {
        this.$message.warning("请先插入uKey");
        return;
      }
 
      // 校验用户
      if (this.loginForm.username && this.loginForm.password) {
        // 开启等待框
        this.loading = true;
        uKeyLogin(
          this.loginForm.username,
          this.loginForm.password,
          this.$store.state.ukey.id
        )
          .then((res) => {
            // 对结果进行处理
            this.handleLogin(res);
          })
          .catch((error) => {
            // 关闭等待
            this.loading = false;
            console.log(error);
            this.$message.error("网络异常");
          });
      } else {
        this.$message.error("用户名或密码不能为空");
      }
    },
    getVerifyCode() {
      let num = this.phoneInfo.phoneNum;
      if (!this.register && process.env.NODE_ENV != "dev") {
        this.$layer.msg("平台未注册,请先注册平台!");
        return;
      }
      if(num.trim() == "") {
        this.$message.error("手机号不能为空");
        return;
      }
      this.codeBtnLoading = true;
      getVerifyCode(num).then(res=>{
        let rs = JSON.parse(res.data.result);
        this.codeBtnLoading = false;
        if(rs.code==1) {
          this.$message.success("发送成功!");
          this.readSeconds = 360;
          this.startReadSeconds();
        }else {
          this.$message.error(rs.msg);
        }
      }).catch(error=>{
        this.codeBtnLoading = false;
        console.log(error);
      });
    },
    phoneVerifyCodeLogin() {
      let num = this.phoneInfo.phoneNum;
      let code = this.phoneInfo.code;
      if (!this.register && process.env.NODE_ENV != "dev") {
        this.$layer.msg("平台未注册,请先注册平台!");
        return;
      }
      if(num.trim() == "") {
        this.$message.error("手机号不能为空");
        return;
      }
      if(code.trim() == "") {
        this.$message.error("验证码不能为空");
        return;
      }
      this.loading = true;
      phoneVerifyCodeLogin(num, code).then(res=>{
        this.handleLogin(res, true)
      }).catch(error => {
        // 关闭等待
        this.loading = false;
        console.log(error);
        this.$message.error("网络异常");
      });
    },
    handleLogin(res, phoneLogin) {
      // 关闭等待
      this.loading = false;
      let rs = JSON.parse(res.data.result);
      if (rs.code == 1) {
        console.log(rs);
        this.$message.success("登录成功");
        // 重置登录时间
        this.readSeconds = 0;
        sessionStorage.setItem("readSeconds", "0");
        if(phoneLogin) {
          sessionStorage.setItem("username", rs.msgN);
        }else {
          sessionStorage.setItem("username", this.loginForm.username);
        }
        sessionStorage.setItem("userId", rs.data);
        sessionStorage.setItem("userPower", rs.data2);
        sessionStorage.setItem("userPowerGroup", rs.sum);
        // 自动登录无法返回登录页
        if (this.$store.state.user.autoLogin) {
          this.$router.replace("/home");
        } else {
          this.$router.push("/home");
        }
 
        // 设置用户的权限
        this.$store.dispatch("user/getPermits");
      }else if(rs.code == 3) {
        this.pwd.show = true;
        this.$nextTick(()=>{
          this.$message.error(rs.msg);
        });
      } else {
        this.changeVerifyCode();
        this.$message.error(rs.msg);
      }
    },
    checkServeLicense() {
      // 校验服务器是否注册
      this.$apis.license
        .checkServeLicense()
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            this.register = true;
          } else {
            this.$layer.msg("平台未注册!请先注册。");
            this.license.show = true;
            this.register = false;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    autoLogin() {
      // 自动登录
      // this.$apis.login
      //   .checkReferer()
      //   .then((res) => {
      //     let rs = JSON.parse(res.data.result);
      //     if (rs) {
      //       this.$store.dispatch("user/changeAutoLogin", 1);
      //       this.loginForm.username = "zhdl";
      //       this.loginForm.password = "123456";
      //       this.normalLogin();
      //     }
      //   })
      //   .catch((error) => {});
      let autoLogin = this.$route.query.autoLogin;
      let uid = this.$route.query.uid;
      let pageName = this.$route.query.pageName;
      if (autoLogin) {
        this.$apis.userMager.userInfo
          .getUserLoginInfo(uid)
          .then((res) => {
            let rs = JSON.parse(res.data.result);
            if (rs.code == 1) {
              let data = rs.data;
              this.$store.dispatch("user/changeAutoLogin", 1);
              this.$store.dispatch("user/changePage", pageName);
              this.loginForm.username = data.UName;
              this.loginForm.password = data.USnId;
              this.normalLogin();
            } else {
              this.init();
            }
          })
          .catch((error) => {
            this.$notify.error({
              title: "错误",
              message: "输入信息无效,请手动登录!",
            });
            this.init();
            console.log(error);
          });
      }
      // let pattern = /(localhost)|(www\.sw-ht\.com)/;
      // let where = document.referrer;
      // if(pattern.test(where)) {
      //   this.$store.dispatch('user/changeAutoLogin', 1);
      //   this.loginForm.username = "zhdl";
      //   this.loginForm.password = "123456";
      //   this.normalLogin();
      // }else {
      //   this.$store.dispatch('user/changeAutoLogin', 0);
      // }
    },
    searchPlatformName() {
      this.$apis.pageSetting.realTime
        .searchName()
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            let data = rs.data[0];
            this.platformName = data.param;
          } else {
            this.platformName = "蓄电池后台监控管理平台";
          }
          sessionStorage.setItem("platformName", this.platformName);
        })
        .catch((error) => {
          this.platformName = "蓄电池后台监控管理平台";
          sessionStorage.setItem("platformName", this.platformName);
        });
    },
    init() {
      // 初始化user的信息
      this.$store.commit("user/init");
      // 初始化登录状态
      sessionStorage.setItem("username", "");
      this.checkServeLicense();
      if(this.readSeconds > 0) {
        this.startReadSeconds();
      }
 
      // 查询密码规则
      this.searchPasswordRules();
      // 初始化置动
      this.$store.dispatch("user/changeAutoLogin", 0);
      this.$store.dispatch("user/changePage", "m1c0");
    },
    changeVerifyCode() {
      let loading = this.$layer.loading();
      getLoginVerity().then(res=>{
        this.$layer.close(loading);
        let rs = JSON.parse(res.data.result);
        if(rs.code == 1) {
          this.verifyCode = rs.data+"";
        }else{
          this.verifyCode = "";
        }
        this.loginForm.verify = "";
      }).catch(error=>{
        this.$layer.close(loading);
        this.verifyCode = "";
        this.loginForm.verify = "";
      });
    },
    showPsdLogin() {
      this.psdLogin = this.psdLogin?false:true;
    },
    startReadSeconds() {
      let timer = "";
      timer = setInterval(()=>{
        if(this.readSeconds == 0) {
          clearInterval(timer);
        }else {
          this.readSeconds--;
          sessionStorage.setItem("readSeconds", this.readSeconds);
        }
      }, 1000);
    },
    getServerTime(callback) {
      this.$apis.login.getServerTime().then(res=>{
        let rs = JSON.parse(res.data.result);
        if(rs.code == 1) {
          sessionStorage.setItem("serverStamp", rs.data);
        }else {
          sessionStorage.setItem("serverStamp", new Date().getTime()+"");
        }
        setTimeout(()=>{
          callback();
        }, 500);
 
      }).catch(error => {
        sessionStorage.setItem("serverStamp", new Date().getTime()+"");
        callback();
        console.log(error);
      });
    },
    closeBrowser() {
      this.$apis.login.closeBrowser().then(res=>{
        console.log(res);
      }).catch(error => {
        console.log(error);
      });
    },
    searchPasswordRules() {
      this.$apis.pageSetting.realTime.searchParam({
        categoryId: 10
      }).then(res=>{
        let rs = JSON.parse(res.data.result);
        if(rs.code == 1 && rs.data.length != 0) {
          let data = rs.data;
          // 读取字符长度
          sessionStorage.setItem("passwordNum", data[0].status);
          // 读取密码类型
          sessionStorage.setItem("passwordType", data[1].status);
        }else {
          // 读取字符长度
          sessionStorage.setItem("passwordNum", "8");
          // 读取密码类型
          sessionStorage.setItem("passwordType", "4");
        }
      }).catch(error=>{
        // 读取字符长度
        sessionStorage.setItem("passwordNum", "8");
        // 读取密码类型
        sessionStorage.setItem("passwordType", "4");
      });
    },
  },
  computed: {
    uKeyState() {
      let state = -1;
      let uKey = this.$store.state.ukey;
      let cls = "state-error";
      // 设置uKey的状态
      if (uKey.connect) {
        if (uKey.isIn) {
          state = 1;
        } else {
          state = 0;
        }
      } else {
        state = -1;
      }
      // 根据状态确定uKey图表的颜色
      switch (state) {
        case 0:
          cls = "state-default";
          break;
        case 1:
          cls = "";
          break;
        default:
          cls = "state-error";
          break;
      }
      return cls;
    },
    logoUrl() {
      let logoConfig = this.logoConfig;
      let image = yuanchange;
 
      if (!logoConfig.value) {
        return image;
      }
 
      switch (logoConfig.fileName) {
        case "nfdw":
          image = nfdw;
          break;
        case "gjdx":
          image = gjdx;
          break;
        case "qwh":
          image = qwh;
          break;
        case "gjdw":
          image = gjdw;
          break;
      }
      return image;
    },
    loginType() {
      if(this.psdLogin) {
        return {
          text: "手机号登录",
          title: "账号密码登录",
          icon: "el-icon-mobile-phone"
        }
      }else {
        return {
          text: "账号密码登录",
          title: "手机号登录",
          icon: "el-icon-lock"
        }
      }
    },
    codeBtn() {
      let seconds = this.readSeconds;
      if(seconds<=0) {
        return {
          text: "获取验证码",
          disabled: false
        }
      }else {
        return {
          text: formatSeconds(seconds),
          disabled: true,
        }
      }
    }
  },
  mounted() {
    this.getServerTime(()=>{
      this.changeVerifyCode();
      let autoLogin = this.$route.query.autoLogin;
      if (autoLogin) {
        // 自动登录
        this.autoLogin();
      } else {
        // 初始化
        this.init();
      }
    });
    //console.log(formatPassword("123"));
    //console.log(AES.encrypt("123456"));
    //console.log(encodeURIComponent("B17jjjYoBkbfZChw/fHzcA=="));
    //console.log(decodeURIComponent("B17jjjYoBkbfZChw%2FfHzcA%3D%3D"))
    //console.log(AES.decrypt("FCGylc7v1wXzmTqpRXPPGA=="));
    //console.log(md5("a123456"));
    //console.log(JSON.stringify("5OUaEnC33sVNY+jeXlx3Qg=="));
    // let rsaWord = RSA.encrypt("123456");
    // console.log(rsaWord);
    // console.log(RSA.decrypt("", const_num.privateKey));
  },
};
</script>
 
<style>
.login_from .el-input__inner {
  height: 48px;
  line-height: 48px;
}
 
.el-science-blue .login_from .el-input.is-disabled .el-input__inner,
.el-science-blue .login_from .el-input__inner {
  background-color: transparent;
  border-color: #e4e4e4;
  color: #868686;
}
 
.el-science-blue .login_from .el-input__prefix,
.el-input__suffix,
.el-science-blue .login_from .el-select .el-input .el-select__caret {
  color: #007fe1;
}
</style>
 
<style lang="less" scoped>
.login-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}
 
/* 登录大盒子背景 */
.login_container {
  width: 100%;
  height: 100%;
  background: url(../assets/images/login-bg.jpg) 0 0 no-repeat;
  background-size: 100% 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
 
.tools-container {
  position: absolute;
  bottom: 0;
  right: 0;
  background-color: #ffffff;
}
 
.tools-container .tools-item {
  padding: 8px;
  cursor: pointer;
}
 
.tools-container .tools-item:hover {
  background-color: #e4e4e4;
}
 
.tools-container .iconfont {
  font-size: 22px;
  color: #0080ff;
}
 
.tools-container .state-default .iconfont {
  color: #808080;
}
 
.tools-container .state-error .iconfont {
  color: #ff0000;
}
 
.sliderCon {
  margin-top: -6vh;
 
  .logo {
    display: flex;
    align-items: center;
    font-size: 48px;
    color: #007fe1;
    font-weight: bold;
 
    .logoImg {
      height: 50px;
      margin-right: 14px;
    }
  }
 
  .picImg {
    width: 580px;
    margin-top: 12vh;
  }
}
 
/* 登录框 */
.login_box {
  width: 440px;
  background-color: #fff;
  border-radius: 3px;
  padding: 40px 60px 10px 60px;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  outline: 8px solid hsla(0,0%,100%,.4);
  .title {
    font-size: 20px;
    color: #007fe1;
    font-weight: bold;
    margin-bottom: 30px;
  }
 
  /* v图片的盒子 */
 
  .avatar {
    height: 130px;
    width: 130px;
    border: 1px solid #eee;
    border-radius: 50%;
    /* 边框圆角 */
    padding: 10px;
    box-shadow: 0 0 10px #ddd;
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    /* v图片 */
 
    img {
      width: 130px;
      height: 130px;
      border-radius: 50%;
      background-color: #eeeeee;
    }
  }
}
 
.login-tools {
  position: absolute;
  top: 25px;
  right: 16px;
  font-size: 26px;
  z-index: 999;
}
.el-icon-mobile-phone,
.el-icon-lock {
  color: #0b388a;
}
.el-icon-mobile-phone:hover,
.el-icon-lock:hover {
  cursor: pointer;
  color: #ff0000;
}
 
/* 登录按钮 */
.btns {
  text-align: center;
}
 
.loginBtn {
  width: 100%;
  display: block;
  text-align: center;
  height: 48px;
  margin-top: 10px;
}
 
.regBtn {
  color: #007fe1;
  margin-right: 10px;
}
 
@media screen and (max-width: 1680px) {
  .sliderCon .logo {
    font-size: 40px;
  }
 
  .sliderCon .picImg {
    width: 480px;
  }
 
  .login_box {
    width: 400px;
  }
}
</style>
 
<style scoped>
.copy-right {
  position: absolute;
  width: 100%;
  text-align: center;
  bottom: 16px;
  z-index: 999;
  font-size: 12px;
}
.flex-row {
  display: flex;
  flex-direction: row;
}
.flex-row .flex-content {
  flex: 1;
}
.flex-row .flex-footer {
  margin-left: 8px;
}
.text-right {
  text-align: right;
}
</style>