cloud-web-corejs 1.0.232 → 1.0.234

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import {encode} from "js-base64";
1
+ import { encode } from "js-base64";
2
2
  import settingConfig from "@/settings";
3
3
  import QRcode from "qrcode";
4
4
 
5
5
  function getUrlParams(url) {
6
6
  let result = {};
7
7
  if (url) {
8
- let urlStr = url.split('?')[1];
8
+ let urlStr = url.split("?")[1];
9
9
  const urlSearchParams = new URLSearchParams(urlStr);
10
10
  result = Object.fromEntries(urlSearchParams.entries());
11
11
  }
@@ -13,49 +13,49 @@ function getUrlParams(url) {
13
13
  }
14
14
 
15
15
  export default {
16
- name: 'Login',
17
- props:{
18
- lang: [String,Function]
16
+ name: "Login",
17
+ props: {
18
+ lang: [String, Function],
19
19
  },
20
20
  components: {},
21
21
  data() {
22
22
  return {
23
23
  isCounting: false,
24
24
  countdown: 0,
25
- buttonText: this.$t1('获取验证码'),
25
+ buttonText: this.$t1("获取验证码"),
26
26
  smsTimer: null,
27
27
  isRememberPassword: false,
28
28
  loginForm: {
29
- username: '',
30
- password: ''
29
+ username: "",
30
+ password: "",
31
31
  },
32
32
  loginRules: {
33
33
  username: [
34
34
  {
35
35
  required: true,
36
- trigger: 'blur'
37
- }
36
+ trigger: "blur",
37
+ },
38
38
  ],
39
39
  password: [
40
40
  {
41
41
  required: true,
42
- trigger: 'blur'
43
- }
44
- ]
42
+ trigger: "blur",
43
+ },
44
+ ],
45
45
  },
46
- passwordType: 'password',
46
+ passwordType: "password",
47
47
  capsTooltip: false,
48
48
  loading: false,
49
49
  showDialog: false,
50
50
  redirect: undefined,
51
51
  otherQuery: {},
52
52
  // isChangeBackground: false,
53
- backgroundClass: '',
53
+ backgroundClass: "",
54
54
  hasLogin: false,
55
55
  showView: false,
56
56
  loginForm2: {
57
57
  username: null,
58
- smsCode: null
58
+ smsCode: null,
59
59
  },
60
60
  activeName: "first",
61
61
  searchParam: {},
@@ -69,12 +69,12 @@ export default {
69
69
  settingConfig: settingConfig,
70
70
  qrExpired: false,
71
71
  loginConfig: {},
72
- imageUrl: '',
73
- loginMethod: '',
72
+ imageUrl: "",
73
+ loginMethod: "",
74
74
 
75
- accountLoagin:true,
76
- phoneLogin:false,
77
- qrLogin:false,
75
+ accountLoagin: true,
76
+ phoneLogin: false,
77
+ qrLogin: false,
78
78
  };
79
79
  },
80
80
  watch: {
@@ -86,8 +86,8 @@ export default {
86
86
  this.otherQuery = this.getOtherQuery(query);
87
87
  }
88
88
  },
89
- immediate: true
90
- }
89
+ immediate: true,
90
+ },
91
91
  },
92
92
  beforeDestroy() {
93
93
  this.clearQrLoginTimer();
@@ -105,55 +105,56 @@ export default {
105
105
  },
106
106
  destroyed() {
107
107
  // window.removeEventListener('storage', this.afterQRScan)
108
- window.removeEventListener('keydown', this.keyDown, false);
108
+ window.removeEventListener("keydown", this.keyDown, false);
109
109
  },
110
110
  methods: {
111
- handleLoginConfig(){
111
+ handleLoginConfig() {
112
112
  let loginConfig = this.$store.getters.loginConfig || {};
113
113
  this.loginConfig = loginConfig;
114
114
  this.initImage();
115
115
  this.initLoginMethod();
116
116
  },
117
- initImage(){
117
+ initImage() {
118
118
  //初始化登录图片
119
119
  let loginConfig = this.loginConfig;
120
- if(loginConfig?.attachments?.length){
121
- this.imageUrl = loginConfig.attachments[0].domain + loginConfig.attachments[0].source;
120
+ if (loginConfig?.attachments?.length) {
121
+ this.imageUrl =
122
+ loginConfig.attachments[0].domain + loginConfig.attachments[0].source;
122
123
  }
123
124
  },
124
125
 
125
- initLoginMethod(){
126
+ initLoginMethod() {
126
127
  let loginConfig = this.loginConfig?.login_method;
127
- if(loginConfig?.length){
128
+ if (loginConfig?.length) {
128
129
  this.accountLoagin = loginConfig.includes(1);
129
130
  this.phoneLogin = loginConfig.includes(2);
130
131
  this.qrLogin = loginConfig.includes(3);
131
- if(this.accountLoagin){
132
+ if (this.accountLoagin) {
132
133
  this.activeName = "first";
133
- }else if(this.phoneLogin){
134
+ } else if (this.phoneLogin) {
134
135
  this.activeName = "second";
135
- }else if(this.qrLogin){
136
+ } else if (this.qrLogin) {
136
137
  this.activeName = "third";
137
138
  this.$nextTick(() => {
138
139
  this.initQR();
139
- })
140
+ });
140
141
  }
141
- }else{
142
+ } else {
142
143
  this.accountLoagin = true;
143
144
  this.phoneLogin = settingConfig.mobileLoginEnabled;
144
145
  this.qrLogin = settingConfig.qrLoginEnabled;
145
146
  }
146
147
  },
147
- initLang(){
148
+ initLang() {
148
149
  let lang = this.$route.query.lang;
149
- if(!lang && !!this.lang){
150
- if(typeof this.lang === "function"){
150
+ if (!lang && !!this.lang) {
151
+ if (typeof this.lang === "function") {
151
152
  lang = this.lang();
152
- }else{
153
+ } else {
153
154
  lang = this.lang;
154
155
  }
155
156
  }
156
- if(lang){
157
+ if (lang) {
157
158
  this.$i18n.locale = lang;
158
159
  localStorage.setItem("i18n-lang", lang);
159
160
  }
@@ -170,12 +171,19 @@ export default {
170
171
  }
171
172
  // 获取URL参数
172
173
  const urlParams = this.$route.query;
173
- if (ssoParams.ticket || "bear_portalsso" == urlParams.access || urlParams.ticket) {
174
+ if (
175
+ ssoParams.ticket ||
176
+ "bear_portalsso" == urlParams.access ||
177
+ urlParams.ticket
178
+ ) {
174
179
  //小熊单点登录
175
180
  this.bearSsoLogin();
176
181
  } else if (searchParam.gatewayToken) {
177
- this.showContent = false
182
+ this.showContent = false;
178
183
  this.handleGatewayTokenLogin();
184
+ } else if (searchParam.xtoken) {
185
+ this.showContent = false;
186
+ this.handleXTokenLogin();
179
187
  } else {
180
188
  //正常登陆
181
189
  this.login();
@@ -183,22 +191,22 @@ export default {
183
191
  },
184
192
  keyDown(e) {
185
193
  //如果是回车则执行登录方法
186
- if (e.keyCode == 13 && e.target.nodeName != 'INPUT') {
187
- let closeBtn = document.querySelector('.el-dialog__close');
194
+ if (e.keyCode == 13 && e.target.nodeName != "INPUT") {
195
+ let closeBtn = document.querySelector(".el-dialog__close");
188
196
  closeBtn && closeBtn.click();
189
- if (this.activeName == "third") return
197
+ if (this.activeName == "third") return;
190
198
  this.handleLogin();
191
199
  }
192
200
  },
193
201
  checkCapslock(e) {
194
- const {key} = e;
195
- this.capsTooltip = key && key.length === 1 && (key >= 'A' && key <= 'Z');
202
+ const { key } = e;
203
+ this.capsTooltip = key && key.length === 1 && key >= "A" && key <= "Z";
196
204
  },
197
205
  showPwd() {
198
- if (this.passwordType === 'password') {
199
- this.passwordType = '';
206
+ if (this.passwordType === "password") {
207
+ this.passwordType = "";
200
208
  } else {
201
- this.passwordType = 'password';
209
+ this.passwordType = "password";
202
210
  }
203
211
  this.$nextTick(() => {
204
212
  this.$refs.password.focus();
@@ -206,54 +214,54 @@ export default {
206
214
  },
207
215
  handleLogin() {
208
216
  let loadingObj = null;
209
- let reqData = {}
210
- if (this.activeName == 'first') {
217
+ let reqData = {};
218
+ if (this.activeName == "first") {
211
219
  //账号密码登录
212
220
  loadingObj = this.$baseLoading();
213
- let password = encode(this.loginForm.password + '');
214
- reqData = {username: this.loginForm.username, password: password};
221
+ let password = encode(this.loginForm.password + "");
222
+ reqData = { username: this.loginForm.username, password: password };
215
223
  } else {
216
224
  //手机验证码登录
217
225
  let username = this.loginForm2.username;
218
226
  let smsCode = this.loginForm2.smsCode;
219
227
  if (!username || !smsCode) {
220
- this.$baseAlert(this.$t1('请输入手机号和验证码'));
228
+ this.$baseAlert(this.$t1("请输入手机号和验证码"));
221
229
  return;
222
230
  }
223
231
  loadingObj = this.$baseLoading();
224
- reqData = {username: username, smsCode: smsCode, "mode": "sms"}
232
+ reqData = { username: username, smsCode: smsCode, mode: "sms" };
225
233
  }
226
234
 
227
235
  if (settingConfig.i18nEnabled) {
228
236
  //登录传语种到后台
229
- let language = this.$i18n?.locale
237
+ let language = this.$i18n?.locale;
230
238
  if (language && language != "zh") {
231
239
  reqData.language = language;
232
240
  }
233
241
  }
234
242
 
235
243
  this.$store
236
- .dispatch('user/login2', reqData)
237
- .then(res => {
244
+ .dispatch("user/login2", reqData)
245
+ .then((res) => {
238
246
  setTimeout(function () {
239
247
  loadingObj.close();
240
248
  }, 200);
241
- if (res.type == 'success') {
242
- localStorage.removeItem('currentMenuId');
249
+ if (res.type == "success") {
250
+ localStorage.removeItem("currentMenuId");
243
251
  this.rememberPassword();
244
252
  /*this.$router.push({
245
253
  path: '/'
246
254
  });*/
247
255
  this.loading = false;
248
- window.removeEventListener('keydown', this.keyDown, false);
249
- this.handleRedirectUrl()
256
+ window.removeEventListener("keydown", this.keyDown, false);
257
+ this.handleRedirectUrl();
250
258
  } else {
251
259
  setTimeout(function () {
252
260
  loadingObj.close();
253
261
  }, 200);
254
262
  }
255
263
  })
256
- .catch(e => {
264
+ .catch((e) => {
257
265
  this.loading = false;
258
266
  setTimeout(function () {
259
267
  loadingObj.close();
@@ -263,21 +271,21 @@ export default {
263
271
  },
264
272
  getOtherQuery(query) {
265
273
  return Object.keys(query).reduce((acc, cur) => {
266
- if (cur !== 'redirect') {
274
+ if (cur !== "redirect") {
267
275
  acc[cur] = query[cur];
268
276
  }
269
277
  return acc;
270
278
  }, {});
271
279
  },
272
280
  initPassword() {
273
- var u = localStorage.getItem('login_info');
281
+ var u = localStorage.getItem("login_info");
274
282
  var login_info;
275
283
  if (u) {
276
284
  login_info = JSON.parse(u);
277
285
  var username = login_info.username;
278
286
  var password = login_info.password;
279
287
  var isRememberPassword = login_info.isRememberPassword;
280
- if (isRememberPassword == 'true') {
288
+ if (isRememberPassword == "true") {
281
289
  this.isRememberPassword = true;
282
290
  this.loginForm.username = username;
283
291
  this.loginForm.password = password;
@@ -288,26 +296,40 @@ export default {
288
296
  if (this.isRememberPassword) {
289
297
  var username = this.loginForm.username;
290
298
  var password = this.loginForm.password;
291
- var login_info = {username: username, password: password, isRememberPassword: 'true'};
292
- localStorage.setItem('login_info', JSON.stringify(login_info));
299
+ var login_info = {
300
+ username: username,
301
+ password: password,
302
+ isRememberPassword: "true",
303
+ };
304
+ localStorage.setItem("login_info", JSON.stringify(login_info));
293
305
  } else {
294
- localStorage.removeItem('login_info');
306
+ localStorage.removeItem("login_info");
295
307
  }
296
308
  },
297
309
  changeBackground() {
298
- if (location.host.indexOf('pcp.sc.5mall.com') >= 0 || location.host.indexOf('pip.bears.com.cn') >= 0) {
299
- this.backgroundClass = 'pcp';
300
- } else if (location.host.indexOf('chigo.sc.5mall.com') >= 0) {
301
- this.backgroundClass = 'chigo';
310
+ if (
311
+ location.host.indexOf("pcp.sc.5mall.com") >= 0 ||
312
+ location.host.indexOf("pip.bears.com.cn") >= 0
313
+ ) {
314
+ this.backgroundClass = "pcp";
315
+ } else if (location.host.indexOf("chigo.sc.5mall.com") >= 0) {
316
+ this.backgroundClass = "chigo";
302
317
  } else {
303
- this.backgroundClass = 'tc';
318
+ this.backgroundClass = "tc";
304
319
  }
305
320
  },
306
321
  login() {
307
- let url = window.MAIN_WEB_PREFIX + '/index.html/#/login';
308
- if (self != top && (process.env.NODE_ENV == 'development' || self.host == parent.host)) {
322
+ let url = window.MAIN_WEB_PREFIX + "/index.html/#/login";
323
+ if (
324
+ self != top &&
325
+ (process.env.NODE_ENV == "development" || self.host == parent.host)
326
+ ) {
309
327
  parent.location.href = url;
310
- } else if (process.env.NODE_ENV !== 'development' && window.MAIN_WEB_PREFIX && window.MAIN_WEB_PREFIX != window.WEB_PREFIX) {
328
+ } else if (
329
+ process.env.NODE_ENV !== "development" &&
330
+ window.MAIN_WEB_PREFIX &&
331
+ window.MAIN_WEB_PREFIX != window.WEB_PREFIX
332
+ ) {
311
333
  window.location.href = url;
312
334
  }
313
335
  /* let lang = this.$route.query.lang;
@@ -318,14 +340,13 @@ export default {
318
340
  } */
319
341
  // window.addEventListener('storage', this.afterQRScan)
320
342
 
321
- window.removeEventListener('keydown', this.keyDown, false);
322
- window.addEventListener('keydown', this.keyDown, false);
343
+ window.removeEventListener("keydown", this.keyDown, false);
344
+ window.addEventListener("keydown", this.keyDown, false);
323
345
  this.changeBackground();
324
346
  this.initPassword();
325
347
  this.showView = true;
326
348
  },
327
349
  bearSsoLogin() {
328
-
329
350
  //小熊SSO返回判断--目前因为小熊单点返回ticket有问题要特殊处理
330
351
  let urlParams = {};
331
352
  if (location.search) {
@@ -340,26 +361,26 @@ export default {
340
361
 
341
362
  //&& loginPath ===window.location.href
342
363
  if (urlParams.ticket) {
343
- console.log("进入回调方法=================")
344
- this.$store.dispatch('user/clearToken')
364
+ console.log("进入回调方法=================");
365
+ this.$store.dispatch("user/clearToken");
345
366
  this.$http({
346
- url: USER_PREFIX + '/auth/idmLogin',
367
+ url: USER_PREFIX + "/auth/idmLogin",
347
368
  method: `post`,
348
- data: {ticket: urlParams.ticket},
369
+ data: { ticket: urlParams.ticket },
349
370
  isLoading: true,
350
371
  modalStrictly: true,
351
- success: res => {
372
+ success: (res) => {
352
373
  let token = res.objx;
353
- console.log("token", token)
354
- this.$store.dispatch('user/addToken', {token}).then(res => {
355
- localStorage.removeItem('currentMenuId');
374
+ console.log("token", token);
375
+ this.$store.dispatch("user/addToken", { token }).then((res) => {
376
+ localStorage.removeItem("currentMenuId");
356
377
  this.rememberPassword();
357
378
  /*this.$router.push({
358
379
  path: '/'
359
380
  });*/
360
381
  this.loading = false;
361
- window.removeEventListener('keydown', this.keyDown, false);
362
- let redirect = sessionStorage.getItem("loginRedirect")
382
+ window.removeEventListener("keydown", this.keyDown, false);
383
+ let redirect = sessionStorage.getItem("loginRedirect");
363
384
  this.handleRedirectUrl(redirect);
364
385
  });
365
386
  },
@@ -368,20 +389,20 @@ export default {
368
389
  },
369
390
  error: () => {
370
391
  this.showView = true;
371
- }
392
+ },
372
393
  });
373
394
  } else {
374
- console.log("进入单点方法")
395
+ console.log("进入单点方法");
375
396
  let redirect = this.$route.query.redirect || "";
376
397
  this.$http({
377
- url: USER_PREFIX + '/auth/idmLoginUrl',
398
+ url: USER_PREFIX + "/auth/idmLoginUrl",
378
399
  method: `post`,
379
400
  data: {},
380
401
  isLoading: true,
381
402
  modalStrictly: true,
382
- success: res => {
383
- sessionStorage.setItem("loginRedirect", redirect)
384
- location.href = res.objx
403
+ success: (res) => {
404
+ sessionStorage.setItem("loginRedirect", redirect);
405
+ location.href = res.objx;
385
406
  // location.href = res.objx+"&redirect="+redirect;
386
407
  },
387
408
  fail: () => {
@@ -389,47 +410,48 @@ export default {
389
410
  },
390
411
  error: () => {
391
412
  this.showView = true;
392
- }
413
+ },
393
414
  });
394
415
  }
395
416
  },
396
417
  sendCode() {
397
418
  if (this.isCounting) {
398
- return
419
+ return;
399
420
  }
400
421
  let mobile = this.loginForm2.username;
401
422
  if (!mobile) {
402
423
  this.$baseAlert("请输入手机号");
403
- return
424
+ return;
404
425
  }
405
426
 
406
427
  this.$http({
407
- url: USER_PREFIX + '/auth/sendSmsCode',
428
+ url: USER_PREFIX + "/auth/sendSmsCode",
408
429
  method: `post`,
409
- data: {mobile: mobile},
430
+ data: { mobile: mobile },
410
431
  isLoading: true,
411
- success: res => {
432
+ success: (res) => {
412
433
  this.$message({
413
434
  message: res.content,
414
- type: 'success',
415
- duration: 1500
435
+ type: "success",
436
+ duration: 1500,
416
437
  });
417
- this.isCounting = true
418
- this.countdown = 60
419
- this.buttonText = this.$t1('60秒后重新获取')
438
+ this.isCounting = true;
439
+ this.countdown = 60;
440
+ this.buttonText = this.$t1("60秒后重新获取");
420
441
  this.clearSmsTimer();
421
442
  this.smsTimer = setInterval(() => {
422
443
  this.countdown--;
423
- this.buttonText = this.$t1('{time}秒后重新获取',{time:this.countdown})
444
+ this.buttonText = this.$t1("{time}秒后重新获取", {
445
+ time: this.countdown,
446
+ });
424
447
  if (this.countdown == 0) {
425
448
  this.clearSmsTimer();
426
- this.isCounting = false
427
- this.buttonText = this.$t1('获取验证码')
449
+ this.isCounting = false;
450
+ this.buttonText = this.$t1("获取验证码");
428
451
  }
429
- }, 1000)
430
- }
452
+ }, 1000);
453
+ },
431
454
  });
432
-
433
455
  },
434
456
  clearSmsTimer() {
435
457
  if (this.smsTimer) {
@@ -437,31 +459,30 @@ export default {
437
459
  this.smsTimer = null;
438
460
  }
439
461
  },
440
- mobileLogin() {
441
-
442
- },
462
+ mobileLogin() {},
443
463
  handleRedirectUrl(redirect) {
444
- redirect = redirect || this.$route.query.redirect
464
+ redirect = redirect || this.$route.query.redirect;
445
465
  let path = null;
446
466
  if (redirect && redirect.startsWith("/outLinkView")) {
447
467
  path = this.addParamToUrl(redirect, "hasToken", "true");
448
468
  } else {
449
- path = '/';
469
+ path = "/";
450
470
  }
451
471
  this.getWebPrefix((webPrefix) => {
452
- let prefix = webPrefix ? ('/' + webPrefix) : '';
472
+ let prefix = webPrefix ? "/" + webPrefix : "";
453
473
  let ssotoken = this.searchParam.gatewayToken;
474
+ let xtoken = this.searchParam.xtoken;
454
475
  if (prefix && prefix !== window.WEB_PREFIX) {
455
- location.href = prefix + '/index.html' + path
456
- } else if (!!ssotoken) {
476
+ location.href = prefix + "/index.html" + path;
477
+ } else if (!!ssotoken || !!xtoken) {
457
478
  prefix = prefix || window.WEB_PREFIX;
458
- location.href = prefix + '/index.html' + path
479
+ location.href = prefix + "/index.html" + path;
459
480
  } else {
460
481
  this.$router.push({
461
- path: path
482
+ path: path,
462
483
  });
463
484
  }
464
- })
485
+ });
465
486
  /*if (redirect && redirect.startsWith("/outLinkView")) {
466
487
  let path = this.addParamToUrl(redirect, "hasToken", "true");
467
488
  this.$router.push({
@@ -474,65 +495,79 @@ export default {
474
495
  }*/
475
496
  },
476
497
  addParamToUrl(url, paramKey, paramValue) {
477
- var regex = new RegExp('([?&])' + paramKey + '=.*?(&|$)', 'i');
498
+ var regex = new RegExp("([?&])" + paramKey + "=.*?(&|$)", "i");
478
499
  if (url.match(regex)) {
479
- url = url.replace(regex, '$1' + paramKey + '=' + paramValue + '$2');
500
+ url = url.replace(regex, "$1" + paramKey + "=" + paramValue + "$2");
480
501
  } else {
481
- url += (url.indexOf('?') === -1 ? '?' : '&') + paramKey + '=' + paramValue;
502
+ url +=
503
+ (url.indexOf("?") === -1 ? "?" : "&") + paramKey + "=" + paramValue;
482
504
  }
483
505
  return url;
484
506
  },
485
507
  getWebPrefix(callback) {
486
508
  this.$http({
487
- url: USER_PREFIX + '/auth/getWebPrefix',
509
+ url: USER_PREFIX + "/auth/getWebPrefix",
488
510
  method: `post`,
489
511
  data: {},
490
512
  isLoading: true,
491
- success: res => {
492
- let webPrefix = res.objx
493
- callback && callback(webPrefix)
494
- }
513
+ success: (res) => {
514
+ let webPrefix = res.objx;
515
+ callback && callback(webPrefix);
516
+ },
495
517
  });
496
518
  },
497
519
  handleGatewayTokenLogin() {
498
- let ssotoken = this.searchParam.gatewayToken
499
- let companycode = this.searchParam.entCode
520
+ let ssotoken = this.searchParam.gatewayToken;
521
+ let companycode = this.searchParam.entCode;
500
522
  this.$store
501
- .dispatch('user/login2', {ssotoken, companycode})
502
- .then(res => {
523
+ .dispatch("user/login2", { ssotoken, companycode })
524
+ .then((res) => {
503
525
  if (res.type == "success") {
504
526
  this.$nextTick(() => {
505
- this.handleRedirectUrl()
527
+ this.handleRedirectUrl();
506
528
  });
507
529
  }
508
530
  });
509
531
  },
510
-
532
+ handleXTokenLogin() {
533
+ let xtoken = this.searchParam.xtoken;
534
+ let companycode = this.searchParam.entCode;
535
+ this.$store
536
+ .dispatch("user/login2", { xtoken, companycode })
537
+ .then((res) => {
538
+ if (res.type == "success") {
539
+ this.handleRedirectUrl();
540
+ }
541
+ });
542
+ },
511
543
  /**二维码登录begin*/
512
544
  guid() {
513
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (t) {
514
- var e = 16 * Math.random() | 0;
515
- return ("x" == t ? e : 3 & e | 8).toString(16);
516
- });
545
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
546
+ /[xy]/g,
547
+ function (t) {
548
+ var e = (16 * Math.random()) | 0;
549
+ return ("x" == t ? e : (3 & e) | 8).toString(16);
550
+ }
551
+ );
517
552
  },
518
553
  initQR() {
519
554
  this.clearQrLoginTimer();
520
555
  this.qrExpired = true;
521
- let option = {width: 300, height: 300};
556
+ let option = { width: 300, height: 300 };
522
557
  this.qrContent = this.guid();
523
- this.createQR(this.qrContent, option).then(url => {
558
+ this.createQR(this.qrContent, option).then((url) => {
524
559
  this.qrExpired = false;
525
- this.qrBase64 = url
560
+ this.qrBase64 = url;
526
561
  this.createQrLoginTimer();
527
- })
562
+ });
528
563
  },
529
564
  // 生成二维码
530
565
  createQR(content, options) {
531
566
  return new Promise((resolve, reject) => {
532
- QRcode.toDataURL(content, options).then(url => {
533
- resolve(url)
534
- })
535
- })
567
+ QRcode.toDataURL(content, options).then((url) => {
568
+ resolve(url);
569
+ });
570
+ });
536
571
  },
537
572
  changeTab() {
538
573
  // this.initQR();
@@ -545,58 +580,57 @@ export default {
545
580
  },
546
581
  clearQrLoginTimer() {
547
582
  if (this.qrTimer1) {
548
- clearTimeout(this.qrTimer1)
583
+ clearTimeout(this.qrTimer1);
549
584
  this.qrTimer1 = null;
550
585
  }
551
586
  if (this.qrTimer2) {
552
- clearTimeout(this.qrTimer2)
587
+ clearTimeout(this.qrTimer2);
553
588
  this.qrTimer2 = null;
554
589
  }
555
590
  },
556
591
  createQrLoginTimer() {
557
- this.checkQrLoginTimerHanlde()
592
+ this.checkQrLoginTimerHanlde();
558
593
  this.qrTimer2 = setTimeout(() => {
559
594
  this.qrExpired = true;
560
595
  this.clearQrLoginTimer();
561
- }, 60000)
596
+ }, 60000);
562
597
  },
563
598
  checkQrLoginTimerHanlde() {
564
599
  this.qrTimer1 = setTimeout(() => {
565
600
  this.checkQrLoginStatusHanlde();
566
- }, 3000)
601
+ }, 3000);
567
602
  },
568
603
  checkQrLoginStatusHanlde() {
569
604
  if (this.qrExpired) {
570
- return
605
+ return;
571
606
  }
572
607
  this.$http({
573
- url: USER_PREFIX + '/auth/login',
608
+ url: USER_PREFIX + "/auth/login",
574
609
  method: `post`,
575
- data: {as: this.qrContent},
610
+ data: { as: this.qrContent },
576
611
  // isLoading: true,
577
612
  failMsg: false,
578
- success: res => {
613
+ success: (res) => {
579
614
  let token = res.objx;
580
615
  if (token) {
581
616
  this.$message({
582
- message: this.$t1('登录成功'),
583
- type: 'success'
617
+ message: this.$t1("登录成功"),
618
+ type: "success",
584
619
  });
585
620
  this.clearQrLoginTimer();
586
- this.$store.dispatch('user/addToken', {token}).then(res => {
587
- localStorage.removeItem('currentMenuId');
621
+ this.$store.dispatch("user/addToken", { token }).then((res) => {
622
+ localStorage.removeItem("currentMenuId");
588
623
  this.rememberPassword();
589
624
  this.loading = false;
590
- window.removeEventListener('keydown', this.keyDown, false);
625
+ window.removeEventListener("keydown", this.keyDown, false);
591
626
  this.handleRedirectUrl();
592
627
  });
593
628
  } else {
594
629
  this.checkQrLoginTimerHanlde();
595
630
  }
596
- }
631
+ },
597
632
  });
598
- }
633
+ },
599
634
  /**二维码登录end*/
600
-
601
- }
602
- }
635
+ },
636
+ };