eoss-ui 0.7.22 → 0.7.24

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.
Files changed (119) hide show
  1. package/lib/button-group.js +48 -7
  2. package/lib/button.js +48 -7
  3. package/lib/calogin.js +48 -7
  4. package/lib/checkbox-group.js +48 -7
  5. package/lib/data-table-form.js +48 -7
  6. package/lib/data-table.js +48 -7
  7. package/lib/date-picker.js +48 -7
  8. package/lib/dialog.js +48 -7
  9. package/lib/eoss-ui.common.js +608 -525
  10. package/lib/flow-group.js +70 -9
  11. package/lib/flow-list.js +129 -88
  12. package/lib/flow.js +340 -294
  13. package/lib/form.js +48 -7
  14. package/lib/handle-user.js +48 -7
  15. package/lib/handler.js +48 -7
  16. package/lib/icon.js +48 -7
  17. package/lib/index.js +1 -1
  18. package/lib/input-number.js +48 -7
  19. package/lib/input.js +48 -7
  20. package/lib/login.js +74 -16
  21. package/lib/main.js +176 -135
  22. package/lib/nav.js +48 -7
  23. package/lib/page.js +48 -7
  24. package/lib/pagination.js +48 -7
  25. package/lib/player.js +48 -7
  26. package/lib/qr-code.js +48 -7
  27. package/lib/radio-group.js +48 -7
  28. package/lib/retrial-auth.js +48 -7
  29. package/lib/select-ganged.js +48 -7
  30. package/lib/select.js +48 -7
  31. package/lib/selector-panel.js +48 -7
  32. package/lib/selector.js +48 -7
  33. package/lib/sizer.js +48 -7
  34. package/lib/steps.js +48 -7
  35. package/lib/switch.js +48 -7
  36. package/lib/table-form.js +48 -7
  37. package/lib/tabs.js +48 -7
  38. package/lib/theme-chalk/index.css +1 -1
  39. package/lib/theme-chalk/login.css +1 -1
  40. package/lib/tips.js +48 -7
  41. package/lib/tree-group.js +48 -7
  42. package/lib/tree.js +48 -7
  43. package/lib/upload.js +48 -7
  44. package/lib/utils/util.js +48 -7
  45. package/lib/wujie.js +48 -7
  46. package/lib/wxlogin.js +48 -7
  47. package/package.json +160 -160
  48. package/packages/.DS_Store +0 -0
  49. package/packages/button-group/src/main.vue +346 -346
  50. package/packages/calogin/.DS_Store +0 -0
  51. package/packages/calogin/src/main.vue +412 -412
  52. package/packages/data-table/src/column.vue +988 -988
  53. package/packages/data-table/src/main.vue +1831 -1831
  54. package/packages/date-picker/.DS_Store +0 -0
  55. package/packages/date-picker/src/.DS_Store +0 -0
  56. package/packages/flow/.DS_Store +0 -0
  57. package/packages/flow/src/.DS_Store +0 -0
  58. package/packages/flow/src/component/Circulate.vue +413 -413
  59. package/packages/flow/src/component/CommonOpinions.vue +373 -373
  60. package/packages/flow/src/component/FileList.vue +97 -97
  61. package/packages/flow/src/component/FreeCirculation.vue +240 -240
  62. package/packages/flow/src/component/SendMsg.vue +242 -242
  63. package/packages/flow/src/component/taskUnionExamine.vue +738 -738
  64. package/packages/flow/src/freeStartFlow.vue +2847 -2847
  65. package/packages/flow/src/main.vue +3843 -3843
  66. package/packages/flow/src/processForm.vue +1370 -1366
  67. package/packages/flow/src/processReject.vue +308 -308
  68. package/packages/flow/src/reset.vue +941 -941
  69. package/packages/flow/src/startTaskRead.vue +691 -691
  70. package/packages/flow/src/supervise.vue +159 -159
  71. package/packages/flow-group/src/main.vue +717 -696
  72. package/packages/flow-list/.DS_Store +0 -0
  73. package/packages/flow-list/src/main.vue +1770 -1770
  74. package/packages/form/.DS_Store +0 -0
  75. package/packages/form/src/main.vue +3901 -3901
  76. package/packages/form/src/table.vue +1512 -1512
  77. package/packages/handle-user/src/main.vue +137 -137
  78. package/packages/handler/src/main.vue +496 -496
  79. package/packages/icon/src/main.vue +104 -104
  80. package/packages/login/.DS_Store +0 -0
  81. package/packages/login/src/main.vue +2020 -1994
  82. package/packages/login/src/resetPassword.vue +557 -557
  83. package/packages/main/.DS_Store +0 -0
  84. package/packages/main/src/.DS_Store +0 -0
  85. package/packages/main/src/default/userinfo.vue +502 -502
  86. package/packages/main/src/public/search.vue +464 -464
  87. package/packages/main/src/simplicity/avatar.vue +82 -82
  88. package/packages/main/src/simplicity/handler.vue +263 -263
  89. package/packages/main/src/simplicity/index.vue +2125 -2125
  90. package/packages/main/src/simplicity/user.vue +259 -259
  91. package/packages/main/src/simplicity/userinfo.vue +398 -398
  92. package/packages/menu/.DS_Store +0 -0
  93. package/packages/select/.DS_Store +0 -0
  94. package/packages/select/src/main.vue +782 -782
  95. package/packages/selector/.DS_Store +0 -0
  96. package/packages/selector/src/main.vue +761 -761
  97. package/packages/selector-panel/.DS_Store +0 -0
  98. package/packages/selector-panel/src/main.vue +1027 -1027
  99. package/packages/selector-panel/src/selection.vue +170 -170
  100. package/packages/switch/src/main.vue +170 -170
  101. package/packages/theme-chalk/lib/index.css +1 -1
  102. package/packages/theme-chalk/lib/login.css +1 -1
  103. package/packages/theme-chalk/src/.DS_Store +0 -0
  104. package/packages/theme-chalk/src/flow.scss +351 -351
  105. package/packages/theme-chalk/src/form.scss +501 -501
  106. package/packages/theme-chalk/src/handler.scss +148 -148
  107. package/packages/theme-chalk/src/icon.scss +1817 -1817
  108. package/packages/theme-chalk/src/login.scss +987 -984
  109. package/packages/theme-chalk/src/selector.scss +92 -92
  110. package/packages/theme-chalk/src/simplicity.scss +1366 -1366
  111. package/packages/theme-chalk/src/upload.scss +172 -172
  112. package/packages/upload/.DS_Store +0 -0
  113. package/packages/upload/src/main.vue +1343 -1343
  114. package/src/.DS_Store +0 -0
  115. package/src/config/api.js +315 -315
  116. package/src/index.js +163 -163
  117. package/src/utils/.DS_Store +0 -0
  118. package/src/utils/rules.js +18 -18
  119. package/src/utils/util.js +49 -9
@@ -1,1994 +1,2020 @@
1
- <template>
2
- <div
3
- v-if="!code"
4
- class="es-login-screen"
5
- :class="{
6
- 'es-login-medium': size == 'medium',
7
- 'es-login-small': size == 'small',
8
- 'es-login-mini': size == 'mini'
9
- }"
10
- :style="getBackground(loginBackgroundImg)"
11
- >
12
- <div
13
- v-if="loginDownloadApp"
14
- class="es-download-app"
15
- @click="handleDownLoadApps"
16
- >
17
- <i class="el-icon-mobile-phone"></i>下载APP
18
- </div>
19
- <img v-if="loginLogoImg" class="es-login-logo" :src="loginLogoImg" />
20
- <slot></slot>
21
- <slot name="warning" :contents="warningText"></slot>
22
- <div
23
- class="es-login"
24
- v-loading.fullscreen.lock="submit"
25
- element-loading-text="登录中..."
26
- element-loading-spinner="el-icon-loading"
27
- element-loading-background="rgba(0, 0, 0, 0.65)"
28
- :class="{
29
- 'es-simple': mode == 'simple',
30
- 'es-adaptive': !isScale && !isFixed
31
- }"
32
- :style="transform"
33
- >
34
- <img v-if="loginNameImg" class="es-login-name" :src="loginNameImg" />
35
- <div
36
- class="es-login-main"
37
- :style="getBackground(loginMainImg)"
38
- :class="{
39
- 'es-models': modelLength > 2 && mode !== 'complex',
40
- 'es-complex': mode == 'complex'
41
- }"
42
- >
43
- <div class="es-login-complex-title" v-if="mode == 'complex'">
44
- 欢迎登录
45
- </div>
46
- <div
47
- v-if="modelLength > 1 || mode == 'complex'"
48
- :class="{
49
- 'es-login-models': modelLength > 2 && mode !== 'complex',
50
- 'es-login-model': modelLength == 2 || mode == 'complex'
51
- }"
52
- >
53
- <template v-if="this.mode == 'complex'">
54
- <template v-if="loginModel.indexOf('3') > -1">
55
- <template v-for="item in switchs">
56
- <div
57
- v-if="item.tips"
58
- v-show="switchActive != item.type"
59
- class="es-login-model-tips"
60
- :key="item.type + '_0'"
61
- :style="getBackground(item.background)"
62
- >
63
- {{ item.tips }}
64
- </div>
65
- <span
66
- v-show="switchActive != item.type"
67
- class="es-icon-box"
68
- @click="switchLoginType(item)"
69
- :title="modelLength > 2 ? item.name : ''"
70
- :key="item.type + '_1'"
71
- >
72
- <i :class="[item.icon, 'es-icon']"></i>
73
- </span>
74
- </template>
75
- </template>
76
- </template>
77
- <template v-else>
78
- <template v-for="item in icons">
79
- <div
80
- class="es-login-model-item-tips"
81
- v-if="modelLength == 2"
82
- v-show="active != item.type && modelTips"
83
- :key="item.type"
84
- >
85
- {{ item.name }}点这里<i class="es-icon-zhixiangyou"></i>
86
- </div>
87
- <span
88
- v-show="modelLength > 2 || active != item.type"
89
- class="es-icon-box"
90
- @click="switchLogin(item)"
91
- :title="item.name"
92
- :key="item.name"
93
- :class="[{ 'es-icon-active': active == item.type }]"
94
- >
95
- <i :class="[item.icon, 'es-icon']"></i>
96
- </span>
97
- </template>
98
- </template>
99
- </div>
100
- <div v-if="loginTitleImg" class="es-login-title-image">
101
- <img class="es-login-title-img" :src="loginTitleImg" />
102
- </div>
103
- <template v-else-if="mode !== 'complex'">
104
- <slot name="login-title" :type="active">
105
- <div class="es-login-title">
106
- <span class="es-login-title-content">{{ title }}</span>
107
- </div>
108
- </slot>
109
- </template>
110
- <div class="es-login-form-box">
111
- <div
112
- v-if="mode == 'complex'"
113
- class="es-login-complex-models"
114
- :class="{ 'es-complex-title': active == '3' }"
115
- >
116
- <template v-if="active == '3'">
117
- <div class="es-login-complex-models-item es-active">
118
- {{ title }}
119
- </div>
120
- </template>
121
- <template v-else>
122
- <template v-for="item in icons">
123
- <div
124
- v-if="item.type !== '3'"
125
- class="es-login-complex-models-item"
126
- :class="{ 'es-active': active == item.type }"
127
- :key="item.type"
128
- @click="switchLogin(item)"
129
- >
130
- {{ item.name }}
131
- </div>
132
- </template>
133
- </template>
134
- </div>
135
- <template v-if="isShow(active) && (active == 0 || active == 12)">
136
- <el-form
137
- :ref="'login' + active"
138
- class="es-login-form"
139
- :model="formData"
140
- >
141
- <el-form-item prop="username" :rules="username.rules">
142
- <es-input
143
- v-model="formData.username"
144
- type="text"
145
- name="username"
146
- tabindex="1"
147
- exclude
148
- :placeholder="username.placeholder"
149
- :focusShow="focusShow"
150
- :data="users"
151
- @select="handleBlur"
152
- >
153
- <template slot="prefix">
154
- <i class="es-icon-zhanghao es-label-user"></i>
155
- </template>
156
- </es-input>
157
- </el-form-item>
158
- <el-form-item prop="password" :rules="password.rules">
159
- <el-input
160
- v-model="formData.password"
161
- name="password"
162
- tabindex="2"
163
- type="password"
164
- :placeholder="password.placeholder"
165
- autocomplete="off"
166
- show-password
167
- @paste.native.capture="handlePaste"
168
- @copy.native.capture="handlePaste"
169
- >
170
- <template slot="prefix">
171
- <i class="es-icon-mima es-label-password"></i>
172
- </template>
173
- </el-input>
174
- </el-form-item>
175
- <el-form-item
176
- prop="identifyingCode"
177
- :rules="[
178
- {
179
- required: true,
180
- message: '验证码不能为空',
181
- trigger: 'change'
182
- }
183
- ]"
184
- v-if="imgCode || showVerifyCode"
185
- >
186
- <el-input
187
- name="identifyingCode"
188
- tabindex="3"
189
- type="text"
190
- v-model="formData.identifyingCode"
191
- placeholder="请输入验证码"
192
- autocomplete="off"
193
- class="es-label-image-code"
194
- >
195
- <template slot="prefix">
196
- <i class="es-icon-yanzheng es-label-code-image"></i>
197
- </template>
198
- <template slot="suffix">
199
- <img
200
- v-show="imgCode && (active == '0' || active == '12')"
201
- class="es-img-code"
202
- :src="imageCode"
203
- @click.stop="getImgCode"
204
- />
205
- </template>
206
- </el-input>
207
- </el-form-item>
208
- <div>
209
- <div class="es-password-handle">
210
- <el-checkbox
211
- v-show="remember && (active == '0' || active == '12')"
212
- v-model="checked"
213
- >记住密码</el-checkbox
214
- >
215
- <div v-show="showForget" class="es-password-forget">
216
- <span @click="handleForget">忘记密码</span>
217
- </div>
218
- </div>
219
- <el-button
220
- class="es-button-submit"
221
- type="primary"
222
- @click="handleLogin"
223
- >登录</el-button
224
- >
225
- </div>
226
- </el-form>
227
- </template>
228
- <template
229
- v-if="isShow(active) && (active == 3 || active == 7 || active == 9)"
230
- >
231
- <div
232
- class="es-login-qrcode"
233
- :class="{ 'es-login-qrcode-complex': mode == 'complex' }"
234
- >
235
- <div class="es-login-down-app" v-if="mode !== 'complex'">
236
- 打开
237
- <template v-if="active == 3">
238
- <a
239
- class="es-login-app-name es-pointer"
240
- target="_blank"
241
- :href="downloadApp"
242
- v-if="downloadApp"
243
- >{{ app }}app</a
244
- >
245
- <span
246
- class="es-login-app-name es-pointer"
247
- v-else
248
- @click="handleDownLoadApp"
249
- >{{ app }}app
250
- </span>
251
- </template>
252
- <span class="es-login-app-name" v-else
253
- >{{ active == 7 ? '钉钉' : '微信' }}app </span
254
- >,扫描二维码
255
- </div>
256
- <div class="es-login-qrcode-box">
257
- <es-qr-code
258
- :content="identifyingId"
259
- :logo="qrimg"
260
- auto
261
- v-if="active == 3 && identifyingId"
262
- ></es-qr-code>
263
- <div class="es-wx-qrcode-box" v-if="active == 9">
264
- <es-wxlogin
265
- href="data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7CiAgICB3aWR0aDogMTAwJSAhaW1wb3J0YW50OwogICAgYm94LXNpemluZzogYm9yZGVyLWJveCAhaW1wb3J0YW50OwogICAgbWFyZ2luOiAwICFpbXBvcnRhbnQ7Cn0KCi5pbXBvd2VyQm94IC5pbmZvLAouaW1wb3dlckJveCAudGl0bGUgewogICAgZGlzcGxheTogbm9uZSAhaW1wb3J0YW50Owp9"
266
- auto
267
- :appid="wechatAppid"
268
- :scope="wechatScope"
269
- :redirect_uri="redirectUri"
270
- ></es-wxlogin>
271
- </div>
272
- </div>
273
- <div
274
- v-if="active == 3 && mode == 'complex'"
275
- class="es-login-complex-app"
276
- >
277
- <div class="es-login-complex-scan">
278
- <i class="es-icon-scan"></i>
279
- <span class="es-login-complex-scan-tips"
280
- >打开app<br />扫一扫登录</span
281
- >
282
- </div>
283
- <div class="es-login-complex-download">
284
- <a
285
- class="es-login-app-name es-pointer"
286
- target="_blank"
287
- :href="downloadApp"
288
- v-if="downloadApp"
289
- >下载app</a
290
- >
291
- <span
292
- class="es-login-app-name es-pointer"
293
- v-else
294
- @click="handleDownLoadApp"
295
- >下载app
296
- </span>
297
- </div>
298
- </div>
299
- <div
300
- v-if="
301
- active == 3 &&
302
- loginModel.indexOf('0') > -1 &&
303
- mode == 'complex'
304
- "
305
- class="es-to-login"
306
- >
307
- <span class="es-pointer" @click="switchLoginType()"
308
- >账号登录<i class="es-icon-youbian"></i
309
- ></span>
310
- </div>
311
- </div>
312
- </template>
313
- <template v-if="isShow(active) && (active == 6 || active == 11)">
314
- <el-form
315
- :ref="'login' + active"
316
- class="es-login-form es-login-verify"
317
- :model="formData"
318
- >
319
- <el-form-item
320
- prop="target"
321
- :rules="active == 6 ? phone.rules : email.rules"
322
- >
323
- <el-input
324
- v-model="formData.target"
325
- type="text"
326
- name="target"
327
- tabindex="4"
328
- :placeholder="
329
- active == 6 ? phone.placeholder : email.placeholder
330
- "
331
- autocomplete="off"
332
- >
333
- <template slot="prefix">
334
- <i class="es-icon-zhanghao es-label-user"></i>
335
- </template>
336
- </el-input>
337
- </el-form-item>
338
- <el-form-item
339
- prop="verificationCode"
340
- :rules="[{ required: true, message: '验证码不能为空' }]"
341
- >
342
- <el-input
343
- name="verificationCode"
344
- type="text"
345
- v-model="formData.verificationCode"
346
- placeholder="请输入验证码"
347
- autocomplete="off"
348
- class="es-label-image-code es-label-get-code"
349
- tabindex="5"
350
- >
351
- <template slot="prefix">
352
- <i class="es-icon-yanzheng es-label-code-image"></i>
353
- </template>
354
- <template slot="suffix">
355
- <el-button
356
- class="es-get-code"
357
- type="primary"
358
- :disabled="disabled"
359
- @click.stop="getCode"
360
- >{{ btnText }}</el-button
361
- >
362
- </template>
363
- </el-input>
364
- </el-form-item>
365
- <div>
366
- <div class="es-password-handle">
367
- <el-checkbox
368
- v-show="remember && active == '0'"
369
- v-model="checked"
370
- >记住密码</el-checkbox
371
- >
372
- <div
373
- v-show="showForget"
374
- class="es-password-forget"
375
- @click="handleForget"
376
- >
377
- 忘记密码
378
- </div>
379
- </div>
380
- <el-button
381
- class="es-button-submit"
382
- type="primary"
383
- @click="handleLogin"
384
- >登录</el-button
385
- >
386
- </div>
387
- </el-form>
388
- </template>
389
- <div class="es-downloadSetup" v-if="downloadSetup || $slots.button">
390
- <slot name="button"></slot>
391
- <span class="es-setup" @click="downloadExe"
392
- >初次使用请下载一键安装包</span
393
- >
394
- </div>
395
- <div class="es-warning" v-if="showWarnInfo">
396
- {{ warningText }}
397
- </div>
398
- </div>
399
- </div>
400
- </div>
401
- <slot name="footer" :copyright="copyright">
402
- <div class="es-login-icp">
403
- <template v-for="item in copyright">
404
- <a
405
- v-if="item.url || item.open"
406
- class="es-login-icp-item"
407
- :target="item.open ? '_blank' : '_self'"
408
- :style="{
409
- color: '#63c2ff',
410
- ...item.style
411
- }"
412
- :key="item.title"
413
- :href="item.url || item.open"
414
- >
415
- {{ item.title }}
416
- </a>
417
- <span
418
- v-else
419
- class="es-login-icp-item"
420
- :style="item.style || copyrightStyle"
421
- :key="item.title"
422
- >
423
- {{ item.title }}
424
- </span>
425
- <template v-if="item.children && item.children.length">
426
- <template v-for="child in item.children">
427
- <a
428
- v-if="child.url || child.open"
429
- class="es-login-icp-child-item"
430
- :target="child.open ? '_blank' : '_self'"
431
- :style="{
432
- color: '#63c2ff',
433
- ...child.style
434
- }"
435
- :key="child.title"
436
- :href="child.url || child.open"
437
- >
438
- {{ child.title }}
439
- </a>
440
- <span
441
- v-else
442
- class="es-login-icp-child-item"
443
- :style="child.style || copyrightStyle"
444
- :key="child.title"
445
- >
446
- {{ child.title }}
447
- </span>
448
- </template>
449
- </template>
450
- </template>
451
- </div>
452
- </slot>
453
- <es-dialog
454
- :title="operationCheckCode ? '修改密码' : '密码重置'"
455
- width="680px"
456
- height="auto"
457
- :visible.sync="showResetPassword"
458
- >
459
- <slot
460
- name="resetPassword"
461
- :secret="secret"
462
- :is-encrypt="isEncrypt"
463
- v-if="showResetPassword"
464
- >
465
- <reset-password
466
- :secret="secret"
467
- :is-encrypt="isEncrypt"
468
- :type="passModifyModel"
469
- :username="formData.username"
470
- :operationCheckCode="operationCheckCode"
471
- @success="handleSuccess"
472
- ></reset-password>
473
- </slot>
474
- </es-dialog>
475
- <es-dialog
476
- title="客户端下载"
477
- width="80%"
478
- height="80%"
479
- custom-class="es-clients-dialog"
480
- :visible.sync="showDownLoadApp"
481
- >
482
- <es-clients :downloads="download" :showTips="showIosTips"></es-clients>
483
- </es-dialog>
484
- <es-dialog
485
- title="请进行身份效验"
486
- width="420px"
487
- height="380px"
488
- :show-scale="false"
489
- :visible.sync="showAssistance"
490
- @close="closeAssistance"
491
- >
492
- <es-qr-code :content="checkCode" v-if="checkCode"></es-qr-code>
493
- </es-dialog>
494
- <transition name="launch-fade">
495
- <div class="es-launch-image" :style="_launchImage" v-show="showLaunch">
496
- <p class="es-launch-text es-launch-user-name">{{ userName }},您好!</p>
497
- <p class="es-launch-text es-launch-system-name">
498
- 欢迎进入{{ sysName }}
499
- </p>
500
- </div>
501
- </transition>
502
- <es-ca-login
503
- v-if="isCaLogin"
504
- ref="calogin"
505
- :showSelect="showKeySelect"
506
- :install-path="installPath"
507
- :ca-model="caLoginModel"
508
- :identifyingId="identifyingId"
509
- :success="caLogin"
510
- @error="handleError"
511
- ></es-ca-login>
512
- </div>
513
- </template>
514
- <script>
515
- import { debounce } from 'throttle-debounce';
516
- import resetPassword from './resetPassword.vue';
517
- import store from 'eoss-ui/src/utils/store';
518
- import util from 'eoss-ui/src/utils/util';
519
- import rules from 'eoss-ui/src/utils/rules.js';
520
- import {
521
- initLogin,
522
- changeImg,
523
- doUserLogin,
524
- doQrLogin,
525
- getLoginCode,
526
- doCodeLogin,
527
- getTwoFactorLoginCode,
528
- doTwoFactorLogin,
529
- doWechatQrLogin,
530
- doCaLogin,
531
- doAssistanceQrLogin
532
- } from 'eoss-ui/src/config/api.js';
533
- const ceshi = util.getParams('ceshi');
534
- import { dayImg, nightImg } from 'eoss-ui/src/config/image';
535
- export default {
536
- name: 'EsLogin',
537
- inheritAttrs: false,
538
- components: {
539
- resetPassword
540
- },
541
- props: {
542
- //初始登录配置接口地址
543
- initLogin: {
544
- type: String,
545
- default: initLogin
546
- },
547
- size: String,
548
- mode: {
549
- type: String,
550
- default: 'default'
551
- },
552
- switchs: {
553
- type: Array,
554
- default() {
555
- return [
556
- {
557
- type: '0',
558
- icon: 'es-icon-zhuomian'
559
- },
560
- {
561
- type: '3',
562
- name: '手机扫码登录',
563
- icon: 'es-icon-qrcode',
564
- tips: '扫码登录在这里',
565
- background:
566
- 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAAAoCAYAAAA2cfJIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDA2IDc5LmRhYmFjYmIsIDIwMjEvMDQvMTQtMDA6Mzk6NDQgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCAyMi40IChNYWNpbnRvc2gpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjZFRTVERTUxQzRDMzExRUY4NkFGQ0U2RDY3NEFERkI0IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjZFRTVERTUyQzRDMzExRUY4NkFGQ0U2RDY3NEFERkI0Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NkVFNURFNEZDNEMzMTFFRjg2QUZDRTZENjc0QURGQjQiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NkVFNURFNTBDNEMzMTFFRjg2QUZDRTZENjc0QURGQjQiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz64XoEfAAAB/UlEQVR42uycOUsDQRiG99vdHJ4JHhFN1EhEQkBsRVACghBbKytBf4OiNrZipQHtRLASsbJIQDQGBVHBysIDAxIvPBCCGpO4ZvwWrCT+gZ33gWV2mam+95mZPWDpcGZYCYQjY4oQs0Y+lxDF4qcCLAFpWrVud/QqRJOpZHy55Jjn3dUODv/oJXU+krm9vkPZrIXL29JU2x5aIaIeluDyb7/KxyDP/C2Eb00yd+l7znfHzLlUvymAk5f9LEplXYRhPHHT8J8AQGIgAAQAEABAAAABAAQAEABAAAABAAQAEABYAiGKBW66A+FIGQSQkIfTk3UjnzM/+G2zBDUQQDK+C3kjfZic+cp+XPHlPkvQCgGk2waESB/vRfNvmdivBJ0QQEJuTw7Wsq/PS7/bQRgCSEjh4/2GlwTNXAAggGS4m9uaXT7/vEI0mkrGExBAIqoafZ6ato5FIprg8DdxDyAR5bUed317KEqqusDhr+ApQCLsFZXOhlDXPGnaBoc/h/cAkuEJdg2pmp7i0+m/fRBAAnjPt3FzxrNfQAAAAQAEABAAQAAAASAAgAAAAgAIAGQVIEeqWo5SWBfSdQ83j/8JENMdzgGXz+9FqayH+ZMozrefT+Ol+nXzz1GBcGS8LhBcdvv8iaJhPKJsFlnebTavbnf0KURTnPNFqTE/AgwAPZCY5D/YjJ4AAAAASUVORK5CYII='
567
- }
568
- ];
569
- }
570
- },
571
- switchsActive: {
572
- type: String,
573
- default: '0'
574
- },
575
- launch: Boolean,
576
- param: {
577
- type: Object,
578
- default() {
579
- return {};
580
- }
581
- },
582
- loginBackground: [String, Array, Object],
583
- loginImage: [String, Array, Object],
584
- loginLogo: String,
585
- loginTitle: String,
586
- loginName: String,
587
- type: {
588
- type: String,
589
- default: '0'
590
- },
591
- firstLoginModel: String,
592
- //是否加密传输
593
- isEncrypt: {
594
- type: Boolean,
595
- default: true
596
- },
597
- modelTips: Boolean,
598
- model: {
599
- type: Object,
600
- default() {
601
- return {};
602
- }
603
- },
604
- username: {
605
- type: Object,
606
- default: () => {
607
- return {
608
- placeholder: '请输入账号',
609
- rules: [
610
- { required: true, message: '账号不能为空', trigger: 'change' }
611
- ]
612
- };
613
- }
614
- },
615
- phone: {
616
- type: Object,
617
- default: () => {
618
- return {
619
- placeholder: '请输入手机号',
620
- rules: [
621
- { required: true, message: '手机号不能为空', trigger: 'change' },
622
- {
623
- ...rules.phone,
624
- trigger: 'change'
625
- }
626
- ]
627
- };
628
- }
629
- },
630
- email: {
631
- type: Object,
632
- default: () => {
633
- return {
634
- placeholder: '请输入邮箱地址',
635
- rules: [
636
- {
637
- required: true,
638
- message: '请输入邮箱地址',
639
- trigger: 'change'
640
- },
641
- {
642
- type: 'email',
643
- message: '请输入正确的邮箱地址',
644
- trigger: 'blur'
645
- }
646
- ]
647
- };
648
- }
649
- },
650
- password: {
651
- type: Object,
652
- default: () => {
653
- return {
654
- placeholder: '请输入密码',
655
- rules: [
656
- { required: true, message: '密码不能为空', trigger: 'change' }
657
- ]
658
- };
659
- }
660
- },
661
- toUrl: String,
662
- //账号登录接口地址
663
- action: {
664
- type: String,
665
- default: doUserLogin
666
- },
667
- //ca登录地址
668
- caAction: {
669
- type: String,
670
- default: doCaLogin
671
- },
672
- //扫码登录接口地址
673
- scanAction: {
674
- type: String,
675
- default: doQrLogin
676
- },
677
- //图片验证码接口地址
678
- codeAction: {
679
- type: String,
680
- default: changeImg
681
- },
682
- getLoginCode: {
683
- type: String,
684
- default: getLoginCode
685
- },
686
- doCodeLogin: {
687
- type: String,
688
- default: doCodeLogin
689
- },
690
- getTwoFactorLoginCode: {
691
- type: String,
692
- default: getTwoFactorLoginCode
693
- },
694
- doTwoFactorLogin: {
695
- type: String,
696
- default: doTwoFactorLogin
697
- },
698
- doWechatQrLogin: {
699
- type: String,
700
- default: doWechatQrLogin
701
- },
702
- imgCode: {
703
- type: [Boolean, Object],
704
- default: true
705
- },
706
- onLogin: Function,
707
- onSuccess: Function,
708
- onError: {
709
- type: Function,
710
- default: () => {}
711
- },
712
- doorIndex: {
713
- type: Boolean,
714
- default: true
715
- },
716
- storage: String,
717
- warning: String,
718
- copyrightStyle: {
719
- type: Object,
720
- default() {
721
- return {
722
- color: '#fff'
723
- };
724
- }
725
- },
726
- appName: String,
727
- qrImage: String,
728
- forget: {
729
- type: [Boolean, String],
730
- default: true
731
- },
732
- remember: {
733
- type: Boolean,
734
- default: true
735
- },
736
- downloadApp: String,
737
- downLoadUrls: {
738
- type: Object,
739
- default() {
740
- return {};
741
- }
742
- },
743
- onDownLoadApp: [Function, Boolean],
744
- redirect_uri: String,
745
- position: {
746
- type: String,
747
- default: 'center'
748
- },
749
- translate: String,
750
- useResults: {
751
- type: Boolean,
752
- default: true
753
- },
754
- scanIntervalTime: {
755
- type: Number,
756
- default: 1500
757
- },
758
- isScale: Boolean,
759
- isFixed: Boolean,
760
- showIosTips: Boolean,
761
- safe: Boolean,
762
- launchImage: {
763
- type: [String, Object],
764
- default() {
765
- return {
766
- day: dayImg,
767
- night: nightImg
768
- };
769
- }
770
- },
771
- loginDownloadApps: Boolean,
772
- copyrights: {
773
- type: Array,
774
- default() {
775
- return [];
776
- }
777
- },
778
- caModel: String,
779
- caInstallPath: String,
780
- showKeySelect: Boolean
781
- },
782
- computed: {
783
- transform() {
784
- let translate = this.translate
785
- ? this.translate
786
- : this.align === 'center'
787
- ? '-50%, -51%'
788
- : '-51%';
789
- if (this.align.indexOf('%') > -1) {
790
- return {
791
- left: this.align,
792
- top: '50%',
793
- transform: `translateY(${translate})`
794
- };
795
- }
796
- if (this.align === 'left') {
797
- return {
798
- left: '30%',
799
- top: '50%',
800
- transform: `translateY(${translate})`
801
- };
802
- }
803
- if (this.align === 'right') {
804
- return {
805
- left: '70%',
806
- top: '50%',
807
- transform: `translateY(${translate})`
808
- };
809
- }
810
- return {
811
- left: '50%',
812
- top: '50%',
813
- transform: `translate(${translate})`
814
- };
815
- },
816
- redirectUri() {
817
- if (this.redirect_uri) {
818
- return this.redirect_uri;
819
- } else {
820
- return window.location.href || window.href;
821
- }
822
- },
823
- showWarnInfo() {
824
- return this.$slots.warning || this.$scopedSlots.warning
825
- ? false
826
- : this.warningText
827
- ? true
828
- : false;
829
- },
830
- modelLength() {
831
- return Array.isArray(this.loginModel)
832
- ? this.loginModel.length
833
- : this.loginModel.split(',').length;
834
- },
835
- iconfonts() {
836
- const types = this.loginModel.split(',');
837
- return types.length > 2
838
- ? {
839
- 0: {
840
- type: '0',
841
- icon: 'es-icon-shuru',
842
- icon2: '',
843
- name: '账号登录'
844
- },
845
- 1: { type: '1', icon: 'es-icon-usb-key', name: '证书登录' },
846
- 3: {
847
- type: '3',
848
- icon: 'es-icon-saoma',
849
- icon2: '',
850
- name: '扫码登录'
851
- },
852
- 6: { type: '6', icon: 'es-icon-duanxin', name: '短信登录' },
853
- 7: { type: '7', icon: 'es-icon-dingding', name: '钉钉扫码登录' },
854
- 9: { type: '9', icon: 'es-icon-weixin', name: '微信扫码登录' },
855
- 11: { type: '11', icon: 'es-icon-youxiang', name: '邮箱登录' },
856
- 12: { type: '12', icon: 'es-icon-shuru', name: '账号登录' } //双因素
857
- }
858
- : {
859
- 0: { type: '0', icon: 'es-icon-zhanghaodenglu', name: '账号登录' },
860
- 1: { type: '1', icon: 'es-icon-ca', name: '证书登录' },
861
- 3: { type: '3', icon: 'es-icon-saomadenglu', name: '扫码登录' },
862
- 6: { type: '6', icon: 'es-icon-duanxindenglu', name: '短信登录' },
863
- 7: { type: '7', icon: 'es-icon-dingding', name: '钉钉扫码登录' },
864
- 9: { type: '9', icon: 'es-icon-weixin', name: '微信扫码登录' },
865
- 11: {
866
- type: '11',
867
- icon: 'es-icon-youxiangdenglu',
868
- name: '邮箱登录'
869
- },
870
- 12: { type: '12', icon: 'es-icon-zhanghaodenglu', name: '账号登录' } //双因素
871
- };
872
- },
873
- icons() {
874
- let icon = [];
875
- const types = this.loginModel.split(',');
876
- types.forEach((item) => {
877
- icon.push(this.iconfonts[item]);
878
- });
879
- return icon;
880
- },
881
- isCaLogin() {
882
- return this.loginModel.indexOf('1') > -1;
883
- },
884
- showVerifyCode() {
885
- return (
886
- this.passModifyModel &&
887
- (this.passModifyModel.indexOf('6') > -1 ||
888
- this.passModifyModel.indexOf('11') > -1)
889
- );
890
- },
891
- _launchImage() {
892
- let img = util.isObject(this.launchImages)
893
- ? this.launchImages[this.launchKey]
894
- : this.launchImages;
895
- return { 'background-image': `url(${img})` };
896
- },
897
- showForget() {
898
- return this.forgetUrl && typeof this.forgetUrl === 'string'
899
- ? true
900
- : this.forgetUrl === true && this.loginModel.indexOf('0') > -1;
901
- }
902
- },
903
- watch: {
904
- loginModel: {
905
- immediate: true,
906
- handler(val) {
907
- this.active = val.split(',')[0];
908
- this.title = this.iconfonts[this.active].name;
909
- this.switchs.forEach((item) => {
910
- if (item.type == this.active) {
911
- this.switchActive = item.type;
912
- return;
913
- }
914
- });
915
- }
916
- },
917
- active: {
918
- immediate: true,
919
- handler(val) {
920
- this.loginInfo(val == 3);
921
- }
922
- },
923
- identifyingId(val) {
924
- if (val) {
925
- this.loginInfo(this.active == 3);
926
- }
927
- },
928
- appName: {
929
- immediate: true,
930
- handler(val) {
931
- if (val) {
932
- this.app = val;
933
- }
934
- }
935
- },
936
- qrImage: {
937
- immediate: true,
938
- handler(val) {
939
- if (val) {
940
- this.qrimg = val;
941
- }
942
- }
943
- },
944
- checked(val) {
945
- if (!val) {
946
- localStorage.removeItem('unpd');
947
- //localStorage.removeItem('remember');
948
- }
949
- }
950
- // secret: {
951
- // immediate: true,
952
- // handler(val) {
953
- // if (val) {
954
- // if (this.storage) {
955
- // localStorage.setItem('secret', val);
956
- // } else {
957
- // sessionStorage.setItem('secret', val);
958
- // }
959
- // }
960
- // }
961
- // }
962
- },
963
- data() {
964
- return {
965
- title: '',
966
- align: this.position,
967
- loginBackgroundImg: this.loginBackground,
968
- loginMainImg: this.loginImage,
969
- loginNameImg: this.loginName,
970
- loginTitleImg: this.loginTitle,
971
- loginLogoImg: this.loginLogo,
972
- loginModel: this.type,
973
- caLoginModel: this.caModel,
974
- passModifyModel: null,
975
- active: 0,
976
- submit: false,
977
- checked: false,
978
- formData: this.model,
979
- focusShow: false,
980
- users: [],
981
- imageCode: '',
982
- secret: null,
983
- identifyingId: undefined,
984
- download: {},
985
- setup: '',
986
- sysName: '',
987
- copyright: this.copyrights,
988
- forgetUrl: this.forget,
989
- actionUrl: this.action,
990
- downloadSetup: '',
991
- app: '',
992
- qrimg: '',
993
- interval: null,
994
- showResetPassword: false,
995
- operationCheckCode: '',
996
- showDownLoadApp: false,
997
- wechatAppid: null,
998
- wechatScope: null,
999
- disabled: false,
1000
- btnText: '获取验证码',
1001
- timer: null,
1002
- countdown: 0,
1003
- code: null,
1004
- defaultModel: JSON.parse(JSON.stringify(this.model)),
1005
- checkCode: '',
1006
- showAssistance: false,
1007
- doAssistance: null,
1008
- warningText: this.warning,
1009
- safes: {
1010
- paste: (event) => {
1011
- event.preventDefault();
1012
- return false;
1013
- },
1014
- contextmenu: (event) => {
1015
- event.preventDefault();
1016
- return false;
1017
- },
1018
- copy: (event) => {
1019
- event.preventDefault();
1020
- return false;
1021
- },
1022
- cut: (event) => {
1023
- event.preventDefault();
1024
- return false;
1025
- }
1026
- },
1027
- userName: '',
1028
- launchShow: this.launch,
1029
- showLaunch: false,
1030
- launchImages: this.launchImage,
1031
- launchKey: 'day',
1032
- launchTime: 2000,
1033
- switchActive: this.switchsActive,
1034
- loginDownloadApp: this.loginDownloadApps,
1035
- installPath: this.caInstallPath
1036
- };
1037
- },
1038
- beforeCreate() {
1039
- this.setScale = debounce(300, () => {
1040
- util.setScale();
1041
- });
1042
- util.removeStorage([
1043
- 'remind',
1044
- 'ssId',
1045
- 'token',
1046
- 'Authorization',
1047
- 'deviceUnique',
1048
- 'userId',
1049
- 'userName',
1050
- 'useCaseCodes'
1051
- ]);
1052
- },
1053
- created() {
1054
- this.launchKey = 5 < new Date().getHours() < 18 ? 'day' : 'night';
1055
- if (ceshi) {
1056
- this.loginModel = ceshi == 'true' || ceshi == true ? '0' : ceshi;
1057
- }
1058
- if (this.isScale || util.getParams('scale')) {
1059
- util.setScale();
1060
- window.addEventListener('resize', this.setScale);
1061
- }
1062
- this.code = util.getParams('code');
1063
- if (this.code) {
1064
- this.doWechatLogin(this.code);
1065
- } else {
1066
- this.getLogin();
1067
- document.addEventListener('keyup', this.doLogin);
1068
- document.addEventListener('keydown', this.forbiddenTab);
1069
- }
1070
- this.init();
1071
- },
1072
- mounted() {
1073
- this.getRemember();
1074
- //delete util.win.websocket;
1075
- },
1076
- methods: {
1077
- init() {
1078
- let loginBoxAlign = localStorage.getItem('loginBoxAlign');
1079
- loginBoxAlign && (this.align = loginBoxAlign);
1080
- },
1081
- doWechatLogin(code) {
1082
- util
1083
- .ajax({
1084
- method: 'post',
1085
- url: this.doWechatQrLogin,
1086
- data: { code: code }
1087
- })
1088
- .then((res) => {
1089
- if (res.rCode == 0) {
1090
- const results = res.results;
1091
- this.handleResults(results);
1092
- } else {
1093
- const msg =
1094
- res.results && res.results.msg ? res.results.msg : res.msg;
1095
- this.$message({
1096
- message: msg || '系统错误,请联系管理员!',
1097
- type: 'error',
1098
- onClose: () => {
1099
- window.location.href = util.delUrlParam({ key: 'code' });
1100
- if (window.location.hash) {
1101
- location.reload();
1102
- }
1103
- }
1104
- });
1105
- }
1106
- })
1107
- .catch((err) => {
1108
- if (err.message && err.message !== 'canceled') {
1109
- this.$message.error(err.message);
1110
- }
1111
- });
1112
- },
1113
- getBackground(res) {
1114
- let style = {};
1115
- if (!res || (Array.isArray(res) && !res.length)) {
1116
- return style;
1117
- }
1118
- if (Array.isArray(res)) {
1119
- let url = [];
1120
- let image = [];
1121
- res.forEach((item) => {
1122
- if (item.indexOf('url(') > -1) {
1123
- url.push(item);
1124
- } else {
1125
- image.push(`url(${item})`);
1126
- }
1127
- });
1128
- if (url.length == res.length) {
1129
- style = { background: url.join(',') };
1130
- } else if (image.length == res.length) {
1131
- style = { 'background-image': image.join(',') };
1132
- } else {
1133
- console.error('设置的样式不一致!');
1134
- }
1135
- } else if (util.isObject(res)) {
1136
- style = res;
1137
- } else if (res.indexOf('url(') > -1) {
1138
- style = { background: res };
1139
- } else {
1140
- style = { 'background-image': `url(${res})` };
1141
- }
1142
- return style;
1143
- },
1144
- getRemember(user) {
1145
- let values = localStorage.getItem('unpd');
1146
- let value = {};
1147
- if (values) {
1148
- try {
1149
- values = JSON.parse(values);
1150
- let users = [];
1151
- for (let i in values) {
1152
- let k = util.esDecode(i);
1153
- value[k] = util.esDecode(values[i]);
1154
- users.push({ value: k });
1155
- }
1156
- this.users = users;
1157
- let keys = Object.keys(value);
1158
- if (keys.length) {
1159
- this.checked = true;
1160
- }
1161
- if (!user && keys.length == 1) {
1162
- user = keys[0];
1163
- // user = localStorage.getItem('remember');
1164
- // if (user) {
1165
- // user = util.esDecode(user);
1166
- // } else {
1167
- // user = keys[0];
1168
- // }
1169
- }
1170
- if (keys.length > 1) {
1171
- this.focusShow = true;
1172
- }
1173
- if (user) {
1174
- this.$set(this.formData, 'username', user);
1175
- this.$set(this.formData, 'password', value[user]);
1176
- }
1177
- } catch (error) {
1178
- localStorage.removeItem('unpd');
1179
- }
1180
- }
1181
- },
1182
- handleBlur(res) {
1183
- this.getRemember(res.value);
1184
- },
1185
- handleRemember() {
1186
- let values = localStorage.getItem('unpd');
1187
- let value = {};
1188
- if (values) {
1189
- values = JSON.parse(values);
1190
- for (let i in values) {
1191
- value[util.esDecode(i)] = util.esDecode(values[i]);
1192
- }
1193
- }
1194
- if (this.checked) {
1195
- //localStorage.setItem('remember', util.esEncode(this.formData.username));
1196
- value[this.formData.username] = this.formData.password;
1197
- let data = {};
1198
- for (let i in value) {
1199
- data[util.esEncode(i)] = util.esEncode(value[i]);
1200
- }
1201
- localStorage.setItem('unpd', JSON.stringify(data));
1202
- } else {
1203
- delete value[this.formData.username];
1204
- if (Object.keys(value)) {
1205
- let data = {};
1206
- for (let i in value) {
1207
- data[util.esEncode(i)] = util.esEncode(value[i]);
1208
- }
1209
- localStorage.setItem('unpd', JSON.stringify(data));
1210
- } else {
1211
- localStorage.removeItem('unpd');
1212
- }
1213
- //localStorage.removeItem('remember');
1214
- }
1215
- },
1216
- // 下载app的弹窗
1217
- handleDownLoadApp() {
1218
- if (this.onDownLoadApp) {
1219
- if (typeof this.onDownLoadApp === 'function') {
1220
- this.onDownLoadApp();
1221
- } else {
1222
- this.$emit('handleDownLoadApp');
1223
- this.$emit('handle-down-load-app');
1224
- }
1225
- } else {
1226
- this.showDownLoadApp = true;
1227
- }
1228
- },
1229
- handleDownLoadApps() {
1230
- if (this.downloadApp) {
1231
- window.open(this.downloadApp);
1232
- } else {
1233
- this.handleDownLoadApp();
1234
- }
1235
- },
1236
- switchLogin(res) {
1237
- if (res.type != '1') {
1238
- this.active = res.type;
1239
- this.title = res.name;
1240
- Object.keys(this.defaultModel).length &&
1241
- (this.formData = JSON.parse(JSON.stringify(this.defaultModel)));
1242
- this.$emit('change-type', res, this.identifyingId);
1243
- this.$nextTick(() => {
1244
- let ref = 'login' + this.active;
1245
- this.$refs[ref] && this.$refs[ref].clearValidate();
1246
- });
1247
- } else {
1248
- this.submit = true;
1249
- this.$refs.calogin && this.$refs.calogin.getCertificate();
1250
- }
1251
- this.countdown = 0;
1252
- },
1253
- switchLoginType(res) {
1254
- this.countdown = 0;
1255
- if (res) {
1256
- this.switchActive = res.type;
1257
- this.title = res.name || '';
1258
- if (this.loginModel.indexOf(res.type) > -1) {
1259
- this.active = res.type;
1260
- } else {
1261
- let other = this.switchs.filter((item) => {
1262
- return item.type != res.type;
1263
- })[0];
1264
- let model = this.loginModel.split(',').filter((item) => {
1265
- return item != res.type && item != other.type;
1266
- })[0];
1267
- if (model) {
1268
- this.active = model;
1269
- this.title = this.iconfonts[model].name;
1270
- } else {
1271
- console.error('complex风格的登录方式,loginModel配置错误!');
1272
- }
1273
- }
1274
- } else {
1275
- this.active = this.switchs[0].type;
1276
- this.title = '';
1277
- this.switchActive = this.switchs[0].type;
1278
- }
1279
- this.$emit('change-type', res, this.identifyingId);
1280
- this.$nextTick(() => {
1281
- let ref = 'login' + this.active;
1282
- this.$refs[ref] && this.$refs[ref].clearValidate();
1283
- });
1284
- },
1285
- isShow(res) {
1286
- return this.loginModel.indexOf(res) > -1;
1287
- },
1288
- async getLogin() {
1289
- const config = util.getStorage('initLogin');
1290
- if (config) {
1291
- this.setConfig(JSON.parse(config));
1292
- }
1293
- await util
1294
- .ajax({ url: this.initLogin })
1295
- .then((res) => {
1296
- if (res && res.rCode === 0) {
1297
- store.set('initLogin', res.results);
1298
- util.setStorage({
1299
- type: 'localStorage',
1300
- key: 'initLogin',
1301
- value: JSON.stringify(res.results)
1302
- });
1303
- this.$emit('initLogin', res.results);
1304
- this.setConfig(res.results);
1305
- } else {
1306
- this.$message({
1307
- message: res.msg || '系统错误,请联系管理员!',
1308
- type: 'error'
1309
- });
1310
- }
1311
- })
1312
- .catch((err) => {
1313
- if (err.message && err.message !== 'canceled') {
1314
- this.$message.error(err.message);
1315
- }
1316
- });
1317
- },
1318
- setConfig(res) {
1319
- const isLogined = localStorage.getItem('isLogined');
1320
- this.identifyingId = res.identifyingId || '';
1321
- this.getImgCode();
1322
- let downloads = {};
1323
- if (res.androidDownloadUrl) {
1324
- downloads['android'] = res.androidDownloadUrl;
1325
- }
1326
- if (res.iosDownloadUrl) {
1327
- downloads['ios'] = res.iosDownloadUrl;
1328
- }
1329
- if (res.iosDownloadUrl2) {
1330
- downloads['pad'] = res.iosDownloadUrl2;
1331
- }
1332
- if (res.macDownloadUrl) {
1333
- downloads['mac'] = res.macDownloadUrl;
1334
- }
1335
- if (res.winDownloadUrl) {
1336
- downloads['win'] = res.winDownloadUrl;
1337
- }
1338
- if (res.linuxDownloadUrl) {
1339
- downloads['linux'] = res.linuxDownloadUrl;
1340
- }
1341
- if (res.harmonyDownloadUrl) {
1342
- downloads['harmony'] = res.harmonyDownloadUrl;
1343
- }
1344
- this.sysName = res.subsystemName;
1345
- this.secret = res.secret;
1346
- this.setup = res.setup;
1347
- this.downloadSetup = res.downloadSetup;
1348
- if (res.subsystemName) {
1349
- document.title = res.subsystemName;
1350
- }
1351
- this.app = res.appName || res.subsystemName;
1352
- if (res.loginModel && !ceshi) {
1353
- this.loginModel =
1354
- (res.firstLoginModel || this.firstLoginModel) && !isLogined
1355
- ? res.firstLoginModel || this.firstLoginModel
1356
- : res.loginModel;
1357
- }
1358
-
1359
- if (res.loginBackgroundUrl) {
1360
- this.loginBackgroundImg = res.loginBackgroundUrl.split(',');
1361
- }
1362
- if (res.loginLogoUrl) {
1363
- this.loginLogoImg = res.loginLogoUrl;
1364
- }
1365
- if (res.caModel) {
1366
- this.caLoginModel = res.caModel;
1367
- }
1368
- res.loginPage && sessionStorage.setItem('loginPage', res.loginPage);
1369
- if (res.subsystemExtend && Object.keys(res.subsystemExtend).length) {
1370
- if (
1371
- res.subsystemExtend.copyright &&
1372
- res.subsystemExtend.copyright.length
1373
- ) {
1374
- this.copyright = JSON.parse(res.subsystemExtend.copyright);
1375
- }
1376
- if (res.subsystemExtend.qrimg || res.subsystemExtend.qrImg) {
1377
- this.qrimg = res.subsystemExtend.qrimg || res.subsystemExtend.qrImg;
1378
- }
1379
- //忘记密码地址
1380
- if (
1381
- res.subsystemExtend.forgetPassUrl ||
1382
- res.subsystemExtend.look_pass_url
1383
- ) {
1384
- this.forgetUrl =
1385
- res.subsystemExtend.forgetPassUrl ||
1386
- res.subsystemExtend.look_pass_url;
1387
- }
1388
- res.subsystemExtend.loginPage &&
1389
- sessionStorage.setItem('loginPage', res.subsystemExtend.loginPage);
1390
- if (res.subsystemExtend.login_url) {
1391
- this.actionUrl = res.subsystemExtend.login_url;
1392
- }
1393
- if (res.subsystemExtend.loginModel) {
1394
- this.loginModel = res.subsystemExtend.loginModel;
1395
- }
1396
- if (res.subsystemExtend.firstLoginModel && !isLogined) {
1397
- this.loginModel = res.subsystemExtend.firstLoginModel;
1398
- }
1399
- if (res.subsystemExtend.caModel) {
1400
- this.caLoginModel = res.subsystemExtend.caModel;
1401
- }
1402
- if (res.subsystemExtend.applicationName) {
1403
- localStorage.setItem('appcode', res.subsystemExtend.applicationName);
1404
- }
1405
- if (res.subsystemExtend.loginBoxBackgroun) {
1406
- this.loginMainImg = res.subsystemExtend.loginBoxBackground.split(',');
1407
- }
1408
- if (res.subsystemExtend.loginBoxTitle) {
1409
- this.loginTitleImg = res.subsystemExtend.loginBoxTitle;
1410
- }
1411
- if (res.subsystemExtend.loginBoxName) {
1412
- this.loginNameImg = res.subsystemExtend.loginBoxName;
1413
- }
1414
- if (res.subsystemExtend.loginBoxAlign && this.useResults) {
1415
- localStorage.setItem(
1416
- 'loginBoxAlign',
1417
- res.subsystemExtend.loginBoxAlign
1418
- );
1419
- this.align = res.subsystemExtend.loginBoxAlign;
1420
- }
1421
- if (res.subsystemExtend.themeColor) {
1422
- util.updateTheme(res.subsystemExtend.themeColor);
1423
- localStorage.setItem('theme', res.subsystemExtend.themeColor);
1424
- }
1425
- if (res.subsystemExtend.macDownloadUrl) {
1426
- downloads.mac = res.subsystemExtend.macDownloadUrl;
1427
- }
1428
- if (res.subsystemExtend.winDownloadUrl) {
1429
- downloads.win = res.subsystemExtend.winDownloadUrl;
1430
- }
1431
- if (res.subsystemExtend.linuxDownloadUrl) {
1432
- downloads.linux = res.subsystemExtend.linuxDownloadUrl;
1433
- }
1434
- if (res.subsystemExtend.uosDownloadUrl) {
1435
- downloads.uos = res.subsystemExtend.uosDownloadUrl;
1436
- }
1437
-
1438
- if (res.subsystemExtend.harmonyDownloadUrl) {
1439
- downloads.harmony = res.subsystemExtend.harmonyDownloadUrl;
1440
- }
1441
- if (res.subsystemExtend.warningText) {
1442
- this.warningText = res.subsystemExtend.warningText;
1443
- }
1444
- if (res.subsystemExtend.launchTime) {
1445
- this.launchTime = parseInt(res.subsystemExtend.launchTime, 10);
1446
- }
1447
- if (res.subsystemExtend.launchImage) {
1448
- if (!this.launchShow) {
1449
- this.launchShow = true;
1450
- }
1451
- if (
1452
- res.subsystemExtend.launchImage != 'true' &&
1453
- res.subsystemExtend.launchImage != true
1454
- ) {
1455
- this.launchImages =
1456
- res.subsystemExtend.launchImage.indexOf('{') > -1 &&
1457
- res.subsystemExtend.launchImage.indexOf('}') > -1
1458
- ? JSON.parse(res.subsystemExtend.launchImage)
1459
- : res.subsystemExtend.launchImage;
1460
- }
1461
- }
1462
- if (res.subsystemExtend.loginDownloadApp) {
1463
- this.loginDownloadApp = res.subsystemExtend.loginDownloadApp;
1464
- }
1465
- if (res.subsystemExtend.caInstallPath) {
1466
- this.installPath = res.subsystemExtend.caInstallPath;
1467
- }
1468
- }
1469
- this.passModifyModel = res.passModifyModel;
1470
- this.wechatAppid = res.wechatAppid;
1471
- this.wechatScope = res.wechatScope;
1472
- this.download = { ...this.downLoadUrls, ...downloads };
1473
- if (res.sysLogoIco) {
1474
- localStorage.setItem('sysLogoIco', res.sysLogoIco);
1475
- util.setFavicon(res.sysLogoIco);
1476
- }
1477
- },
1478
-
1479
- getImgCode() {
1480
- if (this.identifyingId === '') {
1481
- return;
1482
- }
1483
- this.imageCode =
1484
- util.getStorage('host') +
1485
- this.codeAction +
1486
- '?identifyingId=' +
1487
- this.identifyingId +
1488
- (this.imgCode && typeof this.imgCode == 'object'
1489
- ? '&' + util.queryParams(this.imgCode)
1490
- : '') +
1491
- '&heightflag=' +
1492
- Math.random().toString().split('.')[1];
1493
- delete this.formData.identifyingCode;
1494
- delete this.formData.verificationCode;
1495
- return this.imageCode;
1496
- },
1497
- getCode() {
1498
- if (this.countdown) {
1499
- return false;
1500
- }
1501
- let data = {};
1502
- let flag = false;
1503
- let ref = 'login' + this.active;
1504
- if (this.active == 12) {
1505
- if (!this.formData.username) {
1506
- this.$refs[ref].validateField('username');
1507
- return false;
1508
- }
1509
- this.$refs[ref].validateField('username', (res) => {
1510
- flag = res != '';
1511
- });
1512
- if (flag) {
1513
- return false;
1514
- }
1515
- data = {
1516
- username: this.formData.username,
1517
- targetType: this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS'
1518
- // targetType: 'SMS'
1519
- };
1520
- } else {
1521
- if (!this.formData.target) {
1522
- this.$refs[ref].validateField('target');
1523
- return false;
1524
- }
1525
- this.$refs[ref].validateField('target', (res) => {
1526
- flag = res != '';
1527
- });
1528
- if (flag) {
1529
- return false;
1530
- }
1531
- data = {
1532
- target: this.formData.target,
1533
- targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1534
- };
1535
- }
1536
- this.countdown = 60;
1537
- this.timer = setInterval(() => {
1538
- if (this.countdown > 0) {
1539
- this.countdown--;
1540
- this.disabled = true;
1541
- this.btnText = '重新获取' + this.countdown + 's';
1542
- } else {
1543
- this.btnText = '重新获取';
1544
- this.disabled = false;
1545
- this.submit = false;
1546
- }
1547
- }, 1000);
1548
- util
1549
- .ajax({
1550
- method: 'post',
1551
- url:
1552
- this.active == 12 ? this.getTwoFactorLoginCode : this.getLoginCode,
1553
- data: data
1554
- })
1555
- .then((res) => {
1556
- this.$message({
1557
- message: res.msg,
1558
- duration: res.rCode == 0 ? 2000 : 3000,
1559
- type: res.rCode == 0 ? 'success' : 'error'
1560
- });
1561
-
1562
- if (res.rCode === 2) {
1563
- this.btnText = '获取验证码';
1564
- this.disabled = false;
1565
- this.countdown = 0;
1566
- clearInterval(this.timer);
1567
- }
1568
- })
1569
- .catch((err) => {
1570
- if (err.message && err.message !== 'canceled') {
1571
- this.$message.error(err.message);
1572
- }
1573
- });
1574
- },
1575
- handleLogin() {
1576
- if (this.submit) {
1577
- return false;
1578
- }
1579
- let ref = 'login' + this.active;
1580
- this.$refs[ref].validate((valid) => {
1581
- if (valid) {
1582
- this.submit = true;
1583
- let param = util.getParams() || {};
1584
- const data =
1585
- this.active == '0'
1586
- ? {
1587
- username: this.formData.username,
1588
- password:
1589
- this.secret && this.isEncrypt
1590
- ? util.esmEncrypt({
1591
- data: this.formData.password,
1592
- key: this.secret
1593
- })
1594
- : this.formData.password,
1595
- identifyingCode: this.formData.identifyingCode,
1596
- identifyingId: this.identifyingId
1597
- }
1598
- : this.active == '12'
1599
- ? {
1600
- username: this.formData.username,
1601
- password:
1602
- this.secret && this.isEncrypt
1603
- ? util.esmEncrypt({
1604
- data: this.formData.password,
1605
- key: this.secret
1606
- })
1607
- : this.formData.password,
1608
- targetType:
1609
- this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS',
1610
- verificationCode: this.formData.identifyingCode
1611
- }
1612
- : {
1613
- target: this.formData.target,
1614
- verificationCode: this.formData.verificationCode,
1615
- targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1616
- };
1617
- if (this.onLogin) {
1618
- if (this.active == '0') {
1619
- this.onLogin(
1620
- { ...param, ...data },
1621
- this.getImgCode,
1622
- this.handleRemember
1623
- );
1624
- } else {
1625
- this.onLogin({ ...param, ...data });
1626
- }
1627
- } else {
1628
- this.handleUserLogin({ ...param, ...this.param, ...data });
1629
- }
1630
- } else {
1631
- this.submit = false;
1632
- return false;
1633
- }
1634
- });
1635
- },
1636
- doLogin(e) {
1637
- if (util.win.event == undefined) {
1638
- var key = e.keyCode;
1639
- } else {
1640
- var key = util.win.event.keyCode;
1641
- }
1642
- if (key == 13) {
1643
- this.handleLogin();
1644
- }
1645
- },
1646
- handleUserLogin(data) {
1647
- let extUserBindHandleId = sessionStorage.getItem('extUserBindHandleId');
1648
- util
1649
- .ajax({
1650
- method: 'post',
1651
- url:
1652
- this.active == '0'
1653
- ? this.actionUrl
1654
- : this.active == '12'
1655
- ? this.doTwoFactorLogin
1656
- : this.doCodeLogin,
1657
- data: extUserBindHandleId
1658
- ? { ...data, extUserBindHandleId: extUserBindHandleId }
1659
- : data
1660
- })
1661
- .then((res) => {
1662
- this.submit = false;
1663
- if (res.rCode == 0) {
1664
- util.removeStorage('extUserBindHandleId');
1665
- this.handleRemember();
1666
- const results = res.results;
1667
- this.handleResults(results);
1668
- if (this.onSuccess) {
1669
- this.onSuccess(res);
1670
- }
1671
- } else {
1672
- const msg =
1673
- res.results && res.results.msg ? res.results.msg : res.msg;
1674
- this.$message({
1675
- message: msg || '系统错误,请联系管理员!',
1676
- type: 'error',
1677
- onClose: () => {
1678
- this.btnText = '获取验证码';
1679
- this.disabled = false;
1680
- this.countdown = 0;
1681
- clearInterval(this.timer);
1682
- this.getImgCode();
1683
- }
1684
- });
1685
- this.onError(res);
1686
- }
1687
- })
1688
- .catch((err) => {
1689
- this.submit = false;
1690
- if (err.message && err.message !== 'canceled') {
1691
- this.$message.error(err.message);
1692
- }
1693
- });
1694
- },
1695
- caLogin(signedData) {
1696
- this.loginInfo(false);
1697
- util
1698
- .ajax({
1699
- method: 'post',
1700
- url: this.caAction,
1701
- data:
1702
- typeof signedData === 'string'
1703
- ? { identifyingId: this.identifyingId, signedData: signedData }
1704
- : signedData
1705
- })
1706
- .then((res) => {
1707
- this.submit = false;
1708
- if (res.rCode == 0) {
1709
- const results = res.results;
1710
- this.handleResults(results);
1711
- if (this.onSuccess) {
1712
- this.onSuccess(res);
1713
- }
1714
- } else {
1715
- const msg =
1716
- res.results && res.results.msg ? res.results.msg : res.msg;
1717
- this.$message({
1718
- message: msg || '系统错误,请联系管理员!',
1719
- type: 'error',
1720
- onClose: () => {
1721
- this.getImgCode();
1722
- this.loginInfo(this.active == 3);
1723
- }
1724
- });
1725
- this.onError(res);
1726
- }
1727
- })
1728
- .catch((err) => {
1729
- this.submit = false;
1730
- if (err.message && err.message !== 'canceled') {
1731
- this.$message.error(err.message);
1732
- }
1733
- });
1734
- },
1735
- handleForget() {
1736
- if (typeof this.forgetUrl === 'string') {
1737
- util.win.open(this.forgetUrl);
1738
- } else {
1739
- this.showResetPassword = true;
1740
- }
1741
- },
1742
- downloadExe() {
1743
- util.win.open(this.downloadSetup);
1744
- },
1745
- //获取app登录信息
1746
- loginInfo(res) {
1747
- clearTimeout(this.interval);
1748
- if (res) {
1749
- this.interval = setTimeout(() => {
1750
- this.initRequestLoginInfo();
1751
- }, this.scanIntervalTime);
1752
- }
1753
- },
1754
- initRequestLoginInfo() {
1755
- if (this.identifyingId == '') {
1756
- return false;
1757
- }
1758
- util
1759
- .ajax({
1760
- method: 'post',
1761
- url: this.scanAction,
1762
- data: {
1763
- identifyingId: this.identifyingId
1764
- }
1765
- })
1766
- .then((res) => {
1767
- if (res.rCode === 0) {
1768
- const results = res.results;
1769
- if (results.statusCode === 0 || results.statusCode === 2) {
1770
- // statusCode为2时 代表密码过期,也应执行handleResults
1771
- clearTimeout(this.interval);
1772
- this.handleResults(results, 3);
1773
- } else {
1774
- this.loginInfo(true);
1775
- }
1776
- }
1777
- })
1778
- .catch((err) => {
1779
- clearTimeout(this.interval);
1780
- if (err.message && err.message !== 'canceled') {
1781
- this.$message.error(err.message);
1782
- }
1783
- });
1784
- },
1785
- handleResults(results, type) {
1786
- switch (results.statusCode) {
1787
- case 0:
1788
- this.userName = results.userName;
1789
- util.setStorage({
1790
- type: this.storage,
1791
- key: {
1792
- ssId: results.ssId,
1793
- token: results.token,
1794
- Authorization: results.token,
1795
- deviceUnique: results.deviceUnique,
1796
- userId: results.userId,
1797
- userName: results.userName,
1798
- useCaseCodes: results.resourceCodes
1799
- }
1800
- });
1801
- if (this.launchShow) {
1802
- this.$message({
1803
- message: '登录成功!',
1804
- type: 'success',
1805
- duration: 1000
1806
- });
1807
- this.showLaunch = true;
1808
- setTimeout(() => {
1809
- if (this.toUrl) {
1810
- window.location.href = this.toUrl;
1811
- } else if (results.doorIndex && this.doorIndex) {
1812
- sessionStorage.setItem('doorIndex', results.doorIndex);
1813
- localStorage.setItem('isLogined', true);
1814
- window.location.href = results.doorIndex;
1815
- } else {
1816
- if (window.location.href.indexOf('login.html') > -1) {
1817
- window.location.href = './main.html';
1818
- } else {
1819
- this.$router.push({ name: 'main' });
1820
- this.$nextTick(() => {
1821
- this.showLaunch = false;
1822
- });
1823
- }
1824
- }
1825
- }, this.launchTime);
1826
- } else {
1827
- this.$message({
1828
- message: '登录成功!',
1829
- type: 'success',
1830
- duration: 1500,
1831
- onClose: () => {
1832
- if (this.toUrl) {
1833
- window.location.href = this.toUrl;
1834
- } else if (results.doorIndex && this.doorIndex) {
1835
- sessionStorage.setItem('doorIndex', results.doorIndex);
1836
- localStorage.setItem('isLogined', true);
1837
- window.location.href = results.doorIndex;
1838
- } else {
1839
- if (window.location.href.indexOf('login.html') > -1) {
1840
- window.location.href = './main.html';
1841
- } else {
1842
- this.$router.push({ name: 'main' });
1843
- }
1844
- }
1845
- }
1846
- });
1847
- }
1848
- break;
1849
- case 2:
1850
- this.$confirm(
1851
- results.msg ? results.msg : '密码太简单了, 请修改密码?',
1852
- '提示',
1853
- {
1854
- confirmButtonText: '确定',
1855
- //cancelButtonText: '取消',
1856
- type: 'warning'
1857
- }
1858
- )
1859
- .then(() => {
1860
- this.operationCheckCode = results.checkCode;
1861
- if (typeof this.forgetUrl === 'string') {
1862
- util.win.open(this.forgetUrl);
1863
- } else {
1864
- this.showResetPassword = true;
1865
- }
1866
- })
1867
- .catch((e) => {});
1868
- break;
1869
- case 3:
1870
- let url =
1871
- results.doorIndex && this.doorIndex
1872
- ? results.doorIndex
1873
- : window.location.href.indexOf('main.html') > -1
1874
- ? './login.html'
1875
- : window.location.hash
1876
- ? window.location.href.replace('login', 'main')
1877
- : window.location.href;
1878
- const href = results.authorizeUrl.replace(
1879
- '{redirectUri}',
1880
- encodeURIComponent(url)
1881
- );
1882
- window.location.href = href;
1883
- // window.location.href =
1884
- // results.authorizeUrl.indexOf('?') > -1
1885
- // ? results.authorizeUrl + '&token=' + results.token
1886
- // : results.authorizeUrl + '?token=' + results.token;
1887
- break;
1888
- case 4:
1889
- this.$alert(
1890
- results.msg ? results.msg : '账号未绑定,账号密码登录后自动绑定!',
1891
- '提示',
1892
- {
1893
- confirmButtonText: '确定',
1894
- type: 'error'
1895
- }
1896
- )
1897
- .then(() => {
1898
- sessionStorage.setItem(
1899
- 'extUserBindHandleId',
1900
- results.extUserBindHandleId
1901
- );
1902
- window.location.href = util.delUrlParam({ key: 'code' });
1903
- if (window.location.hash) {
1904
- location.reload();
1905
- }
1906
- })
1907
- .catch((e) => {});
1908
- break;
1909
- case 102:
1910
- this.checkCode = results.checkCode;
1911
- this.showAssistance = true;
1912
- let { operationCheckCode } = JSON.parse(results.checkCode);
1913
- this.handleAssistance({ operationCheckCode });
1914
- break;
1915
- default:
1916
- if (type !== 3) {
1917
- this.$message({
1918
- message: results.msg,
1919
- type: 'error',
1920
- onClose: () => {
1921
- if (this.code) {
1922
- window.location.href = util.delUrlParam({ key: 'code' });
1923
- if (window.location.hash) {
1924
- location.reload();
1925
- }
1926
- } else {
1927
- this.getImgCode();
1928
- }
1929
- }
1930
- });
1931
- } else if (this.active == 3) {
1932
- this.loginInfo(true);
1933
- }
1934
- }
1935
- },
1936
- handleAssistance(data) {
1937
- clearTimeout(this.doAssistance);
1938
- this.doAssistance = setTimeout(() => {
1939
- this.doAssistanceLogin(data);
1940
- }, this.scanIntervalTime);
1941
- },
1942
- doAssistanceLogin(data) {
1943
- util
1944
- .ajax({
1945
- method: 'post',
1946
- url: doAssistanceQrLogin,
1947
- data: data
1948
- })
1949
- .then((res) => {
1950
- if (res.rCode === 0) {
1951
- const results = res.results;
1952
- if (results.statusCode === 0) {
1953
- clearTimeout(this.doAssistance);
1954
- this.handleResults(results, 3);
1955
- } else {
1956
- this.handleAssistance(data);
1957
- }
1958
- } else {
1959
- clearTimeout(this.doAssistance);
1960
- this.$message.error(res.msg);
1961
- }
1962
- })
1963
- .catch((err) => {
1964
- clearTimeout(this.doAssistance);
1965
- if (err.message && err.message !== 'canceled') {
1966
- this.$message.error(err.message);
1967
- }
1968
- });
1969
- },
1970
- closeAssistance() {
1971
- clearTimeout(this.doAssistance);
1972
- },
1973
- handleSuccess() {
1974
- this.showResetPassword = false;
1975
- },
1976
- forbiddenTab(e) {
1977
- if (e.keyCode == 9) {
1978
- return false;
1979
- }
1980
- },
1981
- handlePaste(event) {
1982
- this.safe && event.preventDefault();
1983
- },
1984
- handleError() {
1985
- this.submit = false;
1986
- }
1987
- },
1988
- beforeDestroy() {
1989
- window.removeEventListener('resize', this.setScale);
1990
- document.removeEventListener('keyup', this.doLogin);
1991
- document.removeEventListener('keydown', this.forbiddenTab);
1992
- }
1993
- };
1994
- </script>
1
+ <template>
2
+ <div
3
+ v-if="!code"
4
+ class="es-login-screen"
5
+ :class="{
6
+ 'es-login-medium': size == 'medium',
7
+ 'es-login-small': size == 'small',
8
+ 'es-login-mini': size == 'mini'
9
+ }"
10
+ :style="getBackground(loginBackgroundImg)"
11
+ >
12
+ <div
13
+ v-if="loginDownloadApp"
14
+ class="es-download-app"
15
+ @click="handleDownLoadApps"
16
+ >
17
+ <i class="el-icon-mobile-phone"></i>下载APP
18
+ </div>
19
+ <img v-if="loginLogoImg" class="es-login-logo" :src="loginLogoImg" />
20
+ <slot></slot>
21
+ <slot name="warning" :contents="warningText"></slot>
22
+ <div
23
+ class="es-login"
24
+ v-loading.fullscreen.lock="submit"
25
+ element-loading-text="登录中..."
26
+ element-loading-spinner="el-icon-loading"
27
+ element-loading-background="rgba(0, 0, 0, 0.65)"
28
+ :class="{
29
+ 'es-simple': mode == 'simple',
30
+ 'es-adaptive': !isScale && !isFixed
31
+ }"
32
+ :style="transform"
33
+ >
34
+ <img v-if="loginNameImg" class="es-login-name" :src="loginNameImg" />
35
+ <div
36
+ class="es-login-main"
37
+ :style="getBackground(loginMainImg)"
38
+ :class="{
39
+ 'es-models': modelLength > 2 && mode !== 'complex',
40
+ 'es-complex': mode == 'complex'
41
+ }"
42
+ >
43
+ <div class="es-login-complex-title" v-if="mode == 'complex'">
44
+ 欢迎登录
45
+ </div>
46
+ <div
47
+ v-if="modelLength > 1 || mode == 'complex'"
48
+ :class="{
49
+ 'es-login-models': modelLength > 2 && mode !== 'complex',
50
+ 'es-login-model': modelLength == 2 || mode == 'complex'
51
+ }"
52
+ >
53
+ <template v-if="this.mode == 'complex'">
54
+ <template v-if="loginModel.indexOf('3') > -1">
55
+ <template v-for="item in switchs">
56
+ <div
57
+ v-if="item.tips"
58
+ v-show="switchActive != item.type"
59
+ class="es-login-model-tips"
60
+ :key="item.type + '_0'"
61
+ :style="getBackground(item.background)"
62
+ >
63
+ {{ item.tips }}
64
+ </div>
65
+ <span
66
+ v-show="switchActive != item.type"
67
+ class="es-icon-box"
68
+ @click="switchLoginType(item)"
69
+ :title="modelLength > 2 ? item.name : ''"
70
+ :key="item.type + '_1'"
71
+ >
72
+ <i :class="[item.icon, 'es-icon']"></i>
73
+ </span>
74
+ </template>
75
+ </template>
76
+ </template>
77
+ <template v-else>
78
+ <template v-for="item in icons">
79
+ <div
80
+ class="es-login-model-item-tips"
81
+ v-if="modelLength == 2"
82
+ v-show="active != item.type && modelTips"
83
+ :key="item.type"
84
+ >
85
+ {{ item.name }}点这里<i class="es-icon-zhixiangyou"></i>
86
+ </div>
87
+ <span
88
+ v-show="modelLength > 2 || active != item.type"
89
+ class="es-icon-box"
90
+ @click="switchLogin(item)"
91
+ :title="item.name"
92
+ :key="item.name"
93
+ :class="[{ 'es-icon-active': active == item.type }]"
94
+ >
95
+ <i :class="[item.icon, 'es-icon']"></i>
96
+ </span>
97
+ </template>
98
+ </template>
99
+ </div>
100
+ <div v-if="loginTitleImg" class="es-login-title-image">
101
+ <img class="es-login-title-img" :src="loginTitleImg" />
102
+ </div>
103
+ <template v-else-if="mode !== 'complex'">
104
+ <slot name="login-title" :type="active">
105
+ <div class="es-login-title">
106
+ <span class="es-login-title-content">{{ title }}</span>
107
+ </div>
108
+ </slot>
109
+ </template>
110
+ <div class="es-login-form-box">
111
+ <div
112
+ v-if="mode == 'complex'"
113
+ class="es-login-complex-models"
114
+ :class="{ 'es-complex-title': active == '3' }"
115
+ >
116
+ <template v-if="active == '3'">
117
+ <div class="es-login-complex-models-item es-active">
118
+ {{ title }}
119
+ </div>
120
+ </template>
121
+ <template v-else>
122
+ <template v-for="item in icons">
123
+ <div
124
+ v-if="item.type !== '3'"
125
+ class="es-login-complex-models-item"
126
+ :class="{ 'es-active': active == item.type }"
127
+ :key="item.type"
128
+ @click="switchLogin(item)"
129
+ >
130
+ {{ item.name }}
131
+ </div>
132
+ </template>
133
+ </template>
134
+ </div>
135
+ <template v-if="isShow(active) && (active == 0 || active == 12)">
136
+ <el-form
137
+ :ref="'login' + active"
138
+ class="es-login-form"
139
+ :model="formData"
140
+ >
141
+ <el-form-item prop="username" :rules="username.rules">
142
+ <es-input
143
+ v-model="formData.username"
144
+ type="text"
145
+ name="username"
146
+ tabindex="1"
147
+ exclude
148
+ :placeholder="username.placeholder"
149
+ :focusShow="focusShow"
150
+ :data="users"
151
+ @select="handleBlur"
152
+ >
153
+ <template slot="prefix">
154
+ <i class="es-icon-zhanghao es-label-user"></i>
155
+ </template>
156
+ </es-input>
157
+ </el-form-item>
158
+ <el-form-item prop="password" :rules="password.rules">
159
+ <el-input
160
+ v-model="formData.password"
161
+ name="password"
162
+ tabindex="2"
163
+ type="password"
164
+ :placeholder="password.placeholder"
165
+ autocomplete="off"
166
+ show-password
167
+ @paste.native.capture="handlePaste"
168
+ @copy.native.capture="handlePaste"
169
+ >
170
+ <template slot="prefix">
171
+ <i class="es-icon-mima es-label-password"></i>
172
+ </template>
173
+ </el-input>
174
+ </el-form-item>
175
+ <el-form-item
176
+ prop="identifyingCode"
177
+ :rules="[
178
+ {
179
+ required: true,
180
+ message: '验证码不能为空',
181
+ trigger: 'change'
182
+ }
183
+ ]"
184
+ v-if="imgCode || showVerifyCode"
185
+ >
186
+ <el-input
187
+ name="identifyingCode"
188
+ tabindex="3"
189
+ type="text"
190
+ v-model="formData.identifyingCode"
191
+ placeholder="请输入验证码"
192
+ autocomplete="off"
193
+ class="es-label-image-code"
194
+ >
195
+ <template slot="prefix">
196
+ <i class="es-icon-yanzheng es-label-code-image"></i>
197
+ </template>
198
+ <template slot="suffix">
199
+ <img
200
+ v-show="imgCode && (active == '0' || active == '12')"
201
+ class="es-img-code"
202
+ :src="imageCode"
203
+ @click.stop="getImgCode"
204
+ />
205
+ </template>
206
+ </el-input>
207
+ </el-form-item>
208
+ <div>
209
+ <div class="es-password-handle">
210
+ <el-checkbox
211
+ v-show="remember && (active == '0' || active == '12')"
212
+ v-model="checked"
213
+ >记住密码</el-checkbox
214
+ >
215
+ <div v-show="showForget" class="es-password-forget">
216
+ <span @click="handleForget">忘记密码</span>
217
+ </div>
218
+ </div>
219
+ <el-button
220
+ class="es-button-submit"
221
+ type="primary"
222
+ @click="handleLogin"
223
+ >登录</el-button
224
+ >
225
+ </div>
226
+ </el-form>
227
+ </template>
228
+ <template
229
+ v-if="isShow(active) && (active == 3 || active == 7 || active == 9)"
230
+ >
231
+ <div
232
+ class="es-login-qrcode"
233
+ :class="{ 'es-login-qrcode-complex': mode == 'complex' }"
234
+ >
235
+ <div class="es-login-down-app" v-if="mode !== 'complex'">
236
+ 打开
237
+ <template v-if="active == 3">
238
+ <a
239
+ class="es-login-app-name es-pointer"
240
+ target="_blank"
241
+ :href="downloadApp"
242
+ v-if="downloadApp"
243
+ >{{ app }}app</a
244
+ >
245
+ <span
246
+ class="es-login-app-name es-pointer"
247
+ v-else
248
+ @click="handleDownLoadApp"
249
+ >{{ app }}app
250
+ </span>
251
+ </template>
252
+ <span class="es-login-app-name" v-else
253
+ >{{ active == 7 ? '钉钉' : '微信' }}app </span
254
+ >,扫描二维码
255
+ </div>
256
+ <div class="es-login-qrcode-box">
257
+ <es-qr-code
258
+ :content="identifyingId"
259
+ :logo="qrimg"
260
+ auto
261
+ v-if="active == 3 && identifyingId"
262
+ ></es-qr-code>
263
+ <div class="es-wx-qrcode-box" v-if="active == 9">
264
+ <es-wxlogin
265
+ href="data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7CiAgICB3aWR0aDogMTAwJSAhaW1wb3J0YW50OwogICAgYm94LXNpemluZzogYm9yZGVyLWJveCAhaW1wb3J0YW50OwogICAgbWFyZ2luOiAwICFpbXBvcnRhbnQ7Cn0KCi5pbXBvd2VyQm94IC5pbmZvLAouaW1wb3dlckJveCAudGl0bGUgewogICAgZGlzcGxheTogbm9uZSAhaW1wb3J0YW50Owp9"
266
+ auto
267
+ :appid="wechatAppid"
268
+ :scope="wechatScope"
269
+ :redirect_uri="redirectUri"
270
+ ></es-wxlogin>
271
+ </div>
272
+ </div>
273
+ <div
274
+ v-if="active == 3 && mode == 'complex'"
275
+ class="es-login-complex-app"
276
+ >
277
+ <div class="es-login-complex-scan">
278
+ <i class="es-icon-scan"></i>
279
+ <span class="es-login-complex-scan-tips"
280
+ >打开app<br />扫一扫登录</span
281
+ >
282
+ </div>
283
+ <div class="es-login-complex-download">
284
+ <a
285
+ class="es-login-app-name es-pointer"
286
+ target="_blank"
287
+ :href="downloadApp"
288
+ v-if="downloadApp"
289
+ >下载app</a
290
+ >
291
+ <span
292
+ class="es-login-app-name es-pointer"
293
+ v-else
294
+ @click="handleDownLoadApp"
295
+ >下载app
296
+ </span>
297
+ </div>
298
+ </div>
299
+ <div
300
+ v-if="
301
+ active == 3 &&
302
+ loginModel.indexOf('0') > -1 &&
303
+ mode == 'complex'
304
+ "
305
+ class="es-to-login"
306
+ >
307
+ <span class="es-pointer" @click="switchLoginType()"
308
+ >账号登录<i class="es-icon-youbian"></i
309
+ ></span>
310
+ </div>
311
+ </div>
312
+ </template>
313
+ <template v-if="isShow(active) && (active == 6 || active == 11)">
314
+ <el-form
315
+ :ref="'login' + active"
316
+ class="es-login-form es-login-verify"
317
+ :model="formData"
318
+ >
319
+ <el-form-item
320
+ prop="target"
321
+ :rules="active == 6 ? phone.rules : email.rules"
322
+ >
323
+ <el-input
324
+ v-model="formData.target"
325
+ type="text"
326
+ name="target"
327
+ tabindex="4"
328
+ :placeholder="
329
+ active == 6 ? phone.placeholder : email.placeholder
330
+ "
331
+ autocomplete="off"
332
+ >
333
+ <template slot="prefix">
334
+ <i class="es-icon-zhanghao es-label-user"></i>
335
+ </template>
336
+ </el-input>
337
+ </el-form-item>
338
+ <el-form-item
339
+ prop="verificationCode"
340
+ :rules="[{ required: true, message: '验证码不能为空' }]"
341
+ >
342
+ <el-input
343
+ name="verificationCode"
344
+ type="text"
345
+ v-model="formData.verificationCode"
346
+ placeholder="请输入验证码"
347
+ autocomplete="off"
348
+ class="es-label-image-code es-label-get-code"
349
+ tabindex="5"
350
+ >
351
+ <template slot="prefix">
352
+ <i class="es-icon-yanzheng es-label-code-image"></i>
353
+ </template>
354
+ <template slot="suffix">
355
+ <el-button
356
+ class="es-get-code"
357
+ type="primary"
358
+ :disabled="disabled"
359
+ @click.stop="getCode"
360
+ >{{ btnText }}</el-button
361
+ >
362
+ </template>
363
+ </el-input>
364
+ </el-form-item>
365
+ <div>
366
+ <div class="es-password-handle">
367
+ <el-checkbox
368
+ v-show="remember && active == '0'"
369
+ v-model="checked"
370
+ >记住密码</el-checkbox
371
+ >
372
+ <div
373
+ v-show="showForget"
374
+ class="es-password-forget"
375
+ @click="handleForget"
376
+ >
377
+ 忘记密码
378
+ </div>
379
+ </div>
380
+ <el-button
381
+ class="es-button-submit"
382
+ type="primary"
383
+ @click="handleLogin"
384
+ >登录</el-button
385
+ >
386
+ </div>
387
+ </el-form>
388
+ </template>
389
+ <div class="es-downloadSetup" v-if="downloadSetup || $slots.button">
390
+ <slot name="button"></slot>
391
+ <span class="es-setup" @click="downloadExe"
392
+ >初次使用请下载一键安装包</span
393
+ >
394
+ </div>
395
+ <div class="es-warning" v-if="showWarnInfo">
396
+ {{ warningText }}
397
+ </div>
398
+ </div>
399
+ </div>
400
+ </div>
401
+ <slot name="footer" :copyright="copyright">
402
+ <div class="es-login-icp">
403
+ <template v-for="item in copyright">
404
+ <a
405
+ v-if="item.url || item.open"
406
+ class="es-login-icp-item"
407
+ :target="item.open ? '_blank' : '_self'"
408
+ :style="{
409
+ color: '#63c2ff',
410
+ ...item.style
411
+ }"
412
+ :key="item.title"
413
+ :href="item.url || item.open"
414
+ >
415
+ {{ item.title }}
416
+ </a>
417
+ <span
418
+ v-else
419
+ class="es-login-icp-item"
420
+ :style="item.style || copyrightStyle"
421
+ :key="item.title"
422
+ >
423
+ {{ item.title }}
424
+ </span>
425
+ <template v-if="item.children && item.children.length">
426
+ <template v-for="child in item.children">
427
+ <a
428
+ v-if="child.url || child.open"
429
+ class="es-login-icp-child-item"
430
+ :target="child.open ? '_blank' : '_self'"
431
+ :style="{
432
+ color: '#63c2ff',
433
+ ...child.style
434
+ }"
435
+ :key="child.title"
436
+ :href="child.url || child.open"
437
+ >
438
+ {{ child.title }}
439
+ </a>
440
+ <span
441
+ v-else
442
+ class="es-login-icp-child-item"
443
+ :style="child.style || copyrightStyle"
444
+ :key="child.title"
445
+ >
446
+ {{ child.title }}
447
+ </span>
448
+ </template>
449
+ </template>
450
+ </template>
451
+ </div>
452
+ </slot>
453
+ <es-dialog
454
+ :title="operationCheckCode ? '修改密码' : '密码重置'"
455
+ width="680px"
456
+ height="auto"
457
+ :visible.sync="showResetPassword"
458
+ >
459
+ <slot
460
+ name="resetPassword"
461
+ :secret="secret"
462
+ :is-encrypt="isEncrypt"
463
+ v-if="showResetPassword"
464
+ >
465
+ <reset-password
466
+ :secret="secret"
467
+ :is-encrypt="isEncrypt"
468
+ :type="passModifyModel"
469
+ :username="formData.username"
470
+ :operationCheckCode="operationCheckCode"
471
+ @success="handleSuccess"
472
+ ></reset-password>
473
+ </slot>
474
+ </es-dialog>
475
+ <es-dialog
476
+ title="客户端下载"
477
+ width="80%"
478
+ height="80%"
479
+ custom-class="es-clients-dialog"
480
+ :visible.sync="showDownLoadApp"
481
+ >
482
+ <es-clients :downloads="download" :showTips="showIosTips"></es-clients>
483
+ </es-dialog>
484
+ <es-dialog
485
+ title="请进行身份效验"
486
+ width="420px"
487
+ height="380px"
488
+ :show-scale="false"
489
+ :visible.sync="showAssistance"
490
+ @close="closeAssistance"
491
+ >
492
+ <es-qr-code :content="checkCode" v-if="checkCode"></es-qr-code>
493
+ </es-dialog>
494
+ <transition name="launch-fade">
495
+ <div class="es-launch-image" :style="_launchImage" v-show="showLaunch">
496
+ <p class="es-launch-text es-launch-user-name">{{ userName }},您好!</p>
497
+ <p class="es-launch-text es-launch-system-name">
498
+ 欢迎进入{{ sysName }}
499
+ </p>
500
+ </div>
501
+ </transition>
502
+ <es-ca-login
503
+ v-if="isCaLogin"
504
+ ref="calogin"
505
+ :showSelect="showKeySelect"
506
+ :install-path="installPath"
507
+ :ca-model="caLoginModel"
508
+ :identifyingId="identifyingId"
509
+ :success="caLogin"
510
+ @error="handleError"
511
+ ></es-ca-login>
512
+ </div>
513
+ </template>
514
+ <script>
515
+ import { debounce } from 'throttle-debounce';
516
+ import resetPassword from './resetPassword.vue';
517
+ import store from 'eoss-ui/src/utils/store';
518
+ import util from 'eoss-ui/src/utils/util';
519
+ import rules from 'eoss-ui/src/utils/rules.js';
520
+ import {
521
+ initLogin,
522
+ changeImg,
523
+ doUserLogin,
524
+ doQrLogin,
525
+ getLoginCode,
526
+ doCodeLogin,
527
+ getTwoFactorLoginCode,
528
+ doTwoFactorLogin,
529
+ doWechatQrLogin,
530
+ doCaLogin,
531
+ doAssistanceQrLogin
532
+ } from 'eoss-ui/src/config/api.js';
533
+ const params = util.getParams();
534
+ import { dayImg, nightImg } from 'eoss-ui/src/config/image';
535
+ export default {
536
+ name: 'EsLogin',
537
+ inheritAttrs: false,
538
+ components: {
539
+ resetPassword
540
+ },
541
+ props: {
542
+ ceshi: String,
543
+ //初始登录配置接口地址
544
+ initLogin: {
545
+ type: String,
546
+ default: initLogin
547
+ },
548
+ size: String,
549
+ mode: {
550
+ type: String,
551
+ default: 'default'
552
+ },
553
+ switchs: {
554
+ type: Array,
555
+ default() {
556
+ return [
557
+ {
558
+ type: '0',
559
+ icon: 'es-icon-zhuomian'
560
+ },
561
+ {
562
+ type: '3',
563
+ name: '手机扫码登录',
564
+ icon: 'es-icon-qrcode',
565
+ tips: '扫码登录在这里',
566
+ background:
567
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAAAoCAYAAAA2cfJIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDA2IDc5LmRhYmFjYmIsIDIwMjEvMDQvMTQtMDA6Mzk6NDQgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCAyMi40IChNYWNpbnRvc2gpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjZFRTVERTUxQzRDMzExRUY4NkFGQ0U2RDY3NEFERkI0IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjZFRTVERTUyQzRDMzExRUY4NkFGQ0U2RDY3NEFERkI0Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NkVFNURFNEZDNEMzMTFFRjg2QUZDRTZENjc0QURGQjQiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NkVFNURFNTBDNEMzMTFFRjg2QUZDRTZENjc0QURGQjQiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz64XoEfAAAB/UlEQVR42uycOUsDQRiG99vdHJ4JHhFN1EhEQkBsRVACghBbKytBf4OiNrZipQHtRLASsbJIQDQGBVHBysIDAxIvPBCCGpO4ZvwWrCT+gZ33gWV2mam+95mZPWDpcGZYCYQjY4oQs0Y+lxDF4qcCLAFpWrVud/QqRJOpZHy55Jjn3dUODv/oJXU+krm9vkPZrIXL29JU2x5aIaIeluDyb7/KxyDP/C2Eb00yd+l7znfHzLlUvymAk5f9LEplXYRhPHHT8J8AQGIgAAQAEABAAAABAAQAEABAAAABAAQAEABYAiGKBW66A+FIGQSQkIfTk3UjnzM/+G2zBDUQQDK+C3kjfZic+cp+XPHlPkvQCgGk2waESB/vRfNvmdivBJ0QQEJuTw7Wsq/PS7/bQRgCSEjh4/2GlwTNXAAggGS4m9uaXT7/vEI0mkrGExBAIqoafZ6ato5FIprg8DdxDyAR5bUed317KEqqusDhr+ApQCLsFZXOhlDXPGnaBoc/h/cAkuEJdg2pmp7i0+m/fRBAAnjPt3FzxrNfQAAAAQAEABAAQAAAASAAgAAAAgAIAGQVIEeqWo5SWBfSdQ83j/8JENMdzgGXz+9FqayH+ZMozrefT+Ol+nXzz1GBcGS8LhBcdvv8iaJhPKJsFlnebTavbnf0KURTnPNFqTE/AgwAPZCY5D/YjJ4AAAAASUVORK5CYII='
568
+ }
569
+ ];
570
+ }
571
+ },
572
+ switchsActive: {
573
+ type: String,
574
+ default: '0'
575
+ },
576
+ launch: Boolean,
577
+ param: {
578
+ type: Object,
579
+ default() {
580
+ return {};
581
+ }
582
+ },
583
+ loginBackground: [String, Array, Object],
584
+ loginImage: [String, Array, Object],
585
+ loginLogo: String,
586
+ loginTitle: String,
587
+ loginName: String,
588
+ type: {
589
+ type: String,
590
+ default: '0'
591
+ },
592
+ firstLoginModel: String,
593
+ //是否加密传输
594
+ isEncrypt: {
595
+ type: Boolean,
596
+ default: true
597
+ },
598
+ modelTips: Boolean,
599
+ model: {
600
+ type: Object,
601
+ default() {
602
+ return {};
603
+ }
604
+ },
605
+ username: {
606
+ type: Object,
607
+ default: () => {
608
+ return {
609
+ placeholder: '请输入账号',
610
+ rules: [
611
+ { required: true, message: '账号不能为空', trigger: 'change' }
612
+ ]
613
+ };
614
+ }
615
+ },
616
+ phone: {
617
+ type: Object,
618
+ default: () => {
619
+ return {
620
+ placeholder: '请输入手机号',
621
+ rules: [
622
+ { required: true, message: '手机号不能为空', trigger: 'change' },
623
+ {
624
+ ...rules.phone,
625
+ trigger: 'change'
626
+ }
627
+ ]
628
+ };
629
+ }
630
+ },
631
+ email: {
632
+ type: Object,
633
+ default: () => {
634
+ return {
635
+ placeholder: '请输入邮箱地址',
636
+ rules: [
637
+ {
638
+ required: true,
639
+ message: '请输入邮箱地址',
640
+ trigger: 'change'
641
+ },
642
+ {
643
+ type: 'email',
644
+ message: '请输入正确的邮箱地址',
645
+ trigger: 'blur'
646
+ }
647
+ ]
648
+ };
649
+ }
650
+ },
651
+ password: {
652
+ type: Object,
653
+ default: () => {
654
+ return {
655
+ placeholder: '请输入密码',
656
+ rules: [
657
+ { required: true, message: '密码不能为空', trigger: 'change' }
658
+ ]
659
+ };
660
+ }
661
+ },
662
+ toUrl: String,
663
+ //账号登录接口地址
664
+ action: {
665
+ type: String,
666
+ default: doUserLogin
667
+ },
668
+ //ca登录地址
669
+ caAction: {
670
+ type: String,
671
+ default: doCaLogin
672
+ },
673
+ //扫码登录接口地址
674
+ scanAction: {
675
+ type: String,
676
+ default: doQrLogin
677
+ },
678
+ //图片验证码接口地址
679
+ codeAction: {
680
+ type: String,
681
+ default: changeImg
682
+ },
683
+ getLoginCode: {
684
+ type: String,
685
+ default: getLoginCode
686
+ },
687
+ doCodeLogin: {
688
+ type: String,
689
+ default: doCodeLogin
690
+ },
691
+ getTwoFactorLoginCode: {
692
+ type: String,
693
+ default: getTwoFactorLoginCode
694
+ },
695
+ doTwoFactorLogin: {
696
+ type: String,
697
+ default: doTwoFactorLogin
698
+ },
699
+ doWechatQrLogin: {
700
+ type: String,
701
+ default: doWechatQrLogin
702
+ },
703
+ imgCode: {
704
+ type: [Boolean, Object],
705
+ default: true
706
+ },
707
+ onLogin: Function,
708
+ onSuccess: Function,
709
+ onError: {
710
+ type: Function,
711
+ default: () => {}
712
+ },
713
+ doorIndex: {
714
+ type: Boolean,
715
+ default: true
716
+ },
717
+ storage: String,
718
+ warning: String,
719
+ copyrightStyle: {
720
+ type: Object,
721
+ default() {
722
+ return {
723
+ color: '#fff'
724
+ };
725
+ }
726
+ },
727
+ appName: String,
728
+ qrImage: String,
729
+ forget: {
730
+ type: [Boolean, String],
731
+ default: true
732
+ },
733
+ remember: {
734
+ type: Boolean,
735
+ default: true
736
+ },
737
+ downloadApp: String,
738
+ downLoadUrls: {
739
+ type: Object,
740
+ default() {
741
+ return {};
742
+ }
743
+ },
744
+ onDownLoadApp: [Function, Boolean],
745
+ redirect_uri: String,
746
+ position: {
747
+ type: String,
748
+ default: 'center'
749
+ },
750
+ translate: String,
751
+ useResults: {
752
+ type: Boolean,
753
+ default: true
754
+ },
755
+ scanIntervalTime: {
756
+ type: Number,
757
+ default: 1500
758
+ },
759
+ isScale: Boolean,
760
+ isFixed: Boolean,
761
+ showIosTips: Boolean,
762
+ safe: Boolean,
763
+ launchImage: {
764
+ type: [String, Object],
765
+ default() {
766
+ return {
767
+ day: dayImg,
768
+ night: nightImg
769
+ };
770
+ }
771
+ },
772
+ loginDownloadApps: Boolean,
773
+ copyrights: {
774
+ type: Array,
775
+ default() {
776
+ return [];
777
+ }
778
+ },
779
+ caModel: String,
780
+ caInstallPath: String,
781
+ showKeySelect: Boolean
782
+ },
783
+ computed: {
784
+ transform() {
785
+ let translate = this.translate
786
+ ? this.translate
787
+ : this.align === 'center'
788
+ ? '-50%, -51%'
789
+ : '-51%';
790
+ if (this.align.indexOf('%') > -1) {
791
+ return {
792
+ left: this.align,
793
+ top: '50%',
794
+ transform: `translateY(${translate})`
795
+ };
796
+ }
797
+ if (this.align === 'left') {
798
+ return {
799
+ left: '30%',
800
+ top: '50%',
801
+ transform: `translateY(${translate})`
802
+ };
803
+ }
804
+ if (this.align === 'right') {
805
+ return {
806
+ left: '70%',
807
+ top: '50%',
808
+ transform: `translateY(${translate})`
809
+ };
810
+ }
811
+ return {
812
+ left: '50%',
813
+ top: '50%',
814
+ transform: `translate(${translate})`
815
+ };
816
+ },
817
+ redirectUri() {
818
+ if (this.redirect_uri) {
819
+ return this.redirect_uri;
820
+ } else {
821
+ return window.location.href || window.href;
822
+ }
823
+ },
824
+ showWarnInfo() {
825
+ return this.$slots.warning || this.$scopedSlots.warning
826
+ ? false
827
+ : this.warningText
828
+ ? true
829
+ : false;
830
+ },
831
+ modelLength() {
832
+ return Array.isArray(this.loginModel)
833
+ ? this.loginModel.length
834
+ : this.loginModel.split(',').length;
835
+ },
836
+ iconfonts() {
837
+ const types = this.loginModel.split(',');
838
+ return types.length > 2
839
+ ? {
840
+ 0: {
841
+ type: '0',
842
+ icon: 'es-icon-shuru',
843
+ icon2: '',
844
+ name: '账号登录'
845
+ },
846
+ 1: { type: '1', icon: 'es-icon-usb-key', name: '证书登录' },
847
+ 3: {
848
+ type: '3',
849
+ icon: 'es-icon-saoma',
850
+ icon2: '',
851
+ name: '扫码登录'
852
+ },
853
+ 6: { type: '6', icon: 'es-icon-duanxin', name: '短信登录' },
854
+ 7: { type: '7', icon: 'es-icon-dingding', name: '钉钉扫码登录' },
855
+ 9: { type: '9', icon: 'es-icon-weixin', name: '微信扫码登录' },
856
+ 11: { type: '11', icon: 'es-icon-youxiang', name: '邮箱登录' },
857
+ 12: { type: '12', icon: 'es-icon-shuru', name: '账号登录' } //双因素
858
+ }
859
+ : {
860
+ 0: { type: '0', icon: 'es-icon-zhanghaodenglu', name: '账号登录' },
861
+ 1: { type: '1', icon: 'es-icon-ca', name: '证书登录' },
862
+ 3: { type: '3', icon: 'es-icon-saomadenglu', name: '扫码登录' },
863
+ 6: { type: '6', icon: 'es-icon-duanxindenglu', name: '短信登录' },
864
+ 7: { type: '7', icon: 'es-icon-dingding', name: '钉钉扫码登录' },
865
+ 9: { type: '9', icon: 'es-icon-weixin', name: '微信扫码登录' },
866
+ 11: {
867
+ type: '11',
868
+ icon: 'es-icon-youxiangdenglu',
869
+ name: '邮箱登录'
870
+ },
871
+ 12: { type: '12', icon: 'es-icon-zhanghaodenglu', name: '账号登录' } //双因素
872
+ };
873
+ },
874
+ icons() {
875
+ let icon = [];
876
+ const types = this.loginModel.split(',');
877
+ types.forEach((item) => {
878
+ icon.push(this.iconfonts[item]);
879
+ });
880
+ return icon;
881
+ },
882
+ isCaLogin() {
883
+ return this.loginModel.indexOf('1') > -1;
884
+ },
885
+ showVerifyCode() {
886
+ return (
887
+ this.passModifyModel &&
888
+ (this.passModifyModel.indexOf('6') > -1 ||
889
+ this.passModifyModel.indexOf('11') > -1)
890
+ );
891
+ },
892
+ _launchImage() {
893
+ let img = util.isObject(this.launchImages)
894
+ ? this.launchImages[this.launchKey]
895
+ : this.launchImages;
896
+ return { 'background-image': `url(${img})` };
897
+ },
898
+ showForget() {
899
+ return this.forgetUrl && typeof this.forgetUrl === 'string'
900
+ ? true
901
+ : this.forgetUrl === true && this.loginModel.indexOf('0') > -1;
902
+ },
903
+ isCeshi() {
904
+ return this.ceshi ? params[this.ceshi] : false;
905
+ }
906
+ },
907
+ watch: {
908
+ loginModel: {
909
+ immediate: true,
910
+ handler(val) {
911
+ this.active = val.split(',')[0];
912
+ this.title = this.iconfonts[this.active].name;
913
+ this.switchs.forEach((item) => {
914
+ if (item.type == this.active) {
915
+ this.switchActive = item.type;
916
+ return;
917
+ }
918
+ });
919
+ }
920
+ },
921
+ active: {
922
+ immediate: true,
923
+ handler(val) {
924
+ this.loginInfo(val == 3);
925
+ }
926
+ },
927
+ identifyingId(val) {
928
+ if (val) {
929
+ this.loginInfo(this.active == 3);
930
+ }
931
+ },
932
+ appName: {
933
+ immediate: true,
934
+ handler(val) {
935
+ if (val) {
936
+ this.app = val;
937
+ }
938
+ }
939
+ },
940
+ qrImage: {
941
+ immediate: true,
942
+ handler(val) {
943
+ if (val) {
944
+ this.qrimg = val;
945
+ }
946
+ }
947
+ },
948
+ checked(val) {
949
+ if (!val) {
950
+ localStorage.removeItem('unpd');
951
+ //localStorage.removeItem('remember');
952
+ }
953
+ }
954
+ // secret: {
955
+ // immediate: true,
956
+ // handler(val) {
957
+ // if (val) {
958
+ // if (this.storage) {
959
+ // localStorage.setItem('secret', val);
960
+ // } else {
961
+ // sessionStorage.setItem('secret', val);
962
+ // }
963
+ // }
964
+ // }
965
+ // }
966
+ },
967
+ data() {
968
+ return {
969
+ title: '',
970
+ align: this.position,
971
+ loginBackgroundImg: this.loginBackground,
972
+ loginMainImg: this.loginImage,
973
+ loginNameImg: this.loginName,
974
+ loginTitleImg: this.loginTitle,
975
+ loginLogoImg: this.loginLogo,
976
+ loginModel: this.type,
977
+ caLoginModel: this.caModel,
978
+ passModifyModel: null,
979
+ active: 0,
980
+ submit: false,
981
+ checked: false,
982
+ formData: this.model,
983
+ focusShow: false,
984
+ users: [],
985
+ imageCode: '',
986
+ secret: null,
987
+ identifyingId: undefined,
988
+ download: {},
989
+ setup: '',
990
+ sysName: '',
991
+ copyright: this.copyrights,
992
+ forgetUrl: this.forget,
993
+ actionUrl: this.action,
994
+ downloadSetup: '',
995
+ app: '',
996
+ qrimg: '',
997
+ interval: null,
998
+ showResetPassword: false,
999
+ operationCheckCode: '',
1000
+ showDownLoadApp: false,
1001
+ wechatAppid: null,
1002
+ wechatScope: null,
1003
+ disabled: false,
1004
+ btnText: '获取验证码',
1005
+ timer: null,
1006
+ countdown: 0,
1007
+ code: null,
1008
+ defaultModel: JSON.parse(JSON.stringify(this.model)),
1009
+ checkCode: '',
1010
+ showAssistance: false,
1011
+ doAssistance: null,
1012
+ warningText: this.warning,
1013
+ safes: {
1014
+ paste: (event) => {
1015
+ event.preventDefault();
1016
+ return false;
1017
+ },
1018
+ contextmenu: (event) => {
1019
+ event.preventDefault();
1020
+ return false;
1021
+ },
1022
+ copy: (event) => {
1023
+ event.preventDefault();
1024
+ return false;
1025
+ },
1026
+ cut: (event) => {
1027
+ event.preventDefault();
1028
+ return false;
1029
+ }
1030
+ },
1031
+ userName: '',
1032
+ launchShow: this.launch,
1033
+ showLaunch: false,
1034
+ launchImages: this.launchImage,
1035
+ launchKey: 'day',
1036
+ launchTime: 2000,
1037
+ switchActive: this.switchsActive,
1038
+ loginDownloadApp: this.loginDownloadApps,
1039
+ installPath: this.caInstallPath,
1040
+ storageType: this.storage
1041
+ };
1042
+ },
1043
+ beforeCreate() {
1044
+ this.setScale = debounce(300, () => {
1045
+ util.setScale();
1046
+ });
1047
+ util.removeStorage([
1048
+ 'remind',
1049
+ 'ssId',
1050
+ 'token',
1051
+ 'Authorization',
1052
+ 'deviceUnique',
1053
+ 'userId',
1054
+ 'userName',
1055
+ 'useCaseCodes'
1056
+ ]);
1057
+ },
1058
+ created() {
1059
+ this.launchKey = 5 < new Date().getHours() < 18 ? 'day' : 'night';
1060
+ if (this.isCeshi) {
1061
+ this.loginModel =
1062
+ this.isCeshi == 'true' || this.isCeshi == true ? '0' : this.isCeshi;
1063
+ }
1064
+ if (this.isScale || util.getParams('scale')) {
1065
+ util.setScale();
1066
+ window.addEventListener('resize', this.setScale);
1067
+ }
1068
+ this.code = util.getParams('code');
1069
+ if (this.code) {
1070
+ this.doWechatLogin(this.code);
1071
+ } else {
1072
+ this.getLogin();
1073
+ document.addEventListener('keyup', this.doLogin);
1074
+ document.addEventListener('keydown', this.forbiddenTab);
1075
+ }
1076
+ this.init();
1077
+ },
1078
+ mounted() {
1079
+ this.getRemember();
1080
+ //delete util.win.websocket;
1081
+ },
1082
+ methods: {
1083
+ init() {
1084
+ let loginBoxAlign = localStorage.getItem('loginBoxAlign');
1085
+ loginBoxAlign && (this.align = loginBoxAlign);
1086
+ },
1087
+ doWechatLogin(code) {
1088
+ util
1089
+ .ajax({
1090
+ method: 'post',
1091
+ url: this.doWechatQrLogin,
1092
+ data: { code: code }
1093
+ })
1094
+ .then((res) => {
1095
+ if (res.rCode == 0) {
1096
+ const results = res.results;
1097
+ this.handleResults(results);
1098
+ } else {
1099
+ const msg =
1100
+ res.results && res.results.msg ? res.results.msg : res.msg;
1101
+ this.$message({
1102
+ message: msg || '系统错误,请联系管理员!',
1103
+ type: 'error',
1104
+ onClose: () => {
1105
+ window.location.href = util.delUrlParam({ key: 'code' });
1106
+ if (window.location.hash) {
1107
+ location.reload();
1108
+ }
1109
+ }
1110
+ });
1111
+ }
1112
+ })
1113
+ .catch((err) => {
1114
+ if (err.message && err.message !== 'canceled') {
1115
+ this.$message.error(err.message);
1116
+ }
1117
+ });
1118
+ },
1119
+ getBackground(res) {
1120
+ let style = {};
1121
+ if (!res || (Array.isArray(res) && !res.length)) {
1122
+ return style;
1123
+ }
1124
+ if (Array.isArray(res)) {
1125
+ let url = [];
1126
+ let image = [];
1127
+ res.forEach((item) => {
1128
+ if (item.indexOf('url(') > -1) {
1129
+ url.push(item);
1130
+ } else {
1131
+ image.push(`url(${item})`);
1132
+ }
1133
+ });
1134
+ if (url.length == res.length) {
1135
+ style = { background: url.join(',') };
1136
+ } else if (image.length == res.length) {
1137
+ style = { 'background-image': image.join(',') };
1138
+ } else {
1139
+ console.error('设置的样式不一致!');
1140
+ }
1141
+ } else if (util.isObject(res)) {
1142
+ style = res;
1143
+ } else if (res.indexOf('url(') > -1) {
1144
+ style = { background: res };
1145
+ } else {
1146
+ style = { 'background-image': `url(${res})` };
1147
+ }
1148
+ return style;
1149
+ },
1150
+ getRemember(user) {
1151
+ let values = localStorage.getItem('unpd');
1152
+ let value = {};
1153
+ if (values) {
1154
+ try {
1155
+ values = JSON.parse(values);
1156
+ let users = [];
1157
+ for (let i in values) {
1158
+ let k = util.esDecode(i);
1159
+ value[k] = util.esDecode(values[i]);
1160
+ users.push({ value: k });
1161
+ }
1162
+ this.users = users;
1163
+ let keys = Object.keys(value);
1164
+ if (keys.length) {
1165
+ this.checked = true;
1166
+ }
1167
+ if (!user && keys.length == 1) {
1168
+ user = keys[0];
1169
+ // user = localStorage.getItem('remember');
1170
+ // if (user) {
1171
+ // user = util.esDecode(user);
1172
+ // } else {
1173
+ // user = keys[0];
1174
+ // }
1175
+ }
1176
+ if (keys.length > 1) {
1177
+ this.focusShow = true;
1178
+ }
1179
+ if (user) {
1180
+ this.$set(this.formData, 'username', user);
1181
+ this.$set(this.formData, 'password', value[user]);
1182
+ }
1183
+ } catch (error) {
1184
+ localStorage.removeItem('unpd');
1185
+ }
1186
+ }
1187
+ },
1188
+ handleBlur(res) {
1189
+ this.getRemember(res.value);
1190
+ },
1191
+ handleRemember() {
1192
+ let values = localStorage.getItem('unpd');
1193
+ let value = {};
1194
+ if (values) {
1195
+ values = JSON.parse(values);
1196
+ for (let i in values) {
1197
+ value[util.esDecode(i)] = util.esDecode(values[i]);
1198
+ }
1199
+ }
1200
+ if (this.checked) {
1201
+ //localStorage.setItem('remember', util.esEncode(this.formData.username));
1202
+ value[this.formData.username] = this.formData.password;
1203
+ let data = {};
1204
+ for (let i in value) {
1205
+ data[util.esEncode(i)] = util.esEncode(value[i]);
1206
+ }
1207
+ localStorage.setItem('unpd', JSON.stringify(data));
1208
+ } else {
1209
+ delete value[this.formData.username];
1210
+ if (Object.keys(value)) {
1211
+ let data = {};
1212
+ for (let i in value) {
1213
+ data[util.esEncode(i)] = util.esEncode(value[i]);
1214
+ }
1215
+ localStorage.setItem('unpd', JSON.stringify(data));
1216
+ } else {
1217
+ localStorage.removeItem('unpd');
1218
+ }
1219
+ //localStorage.removeItem('remember');
1220
+ }
1221
+ },
1222
+ // 下载app的弹窗
1223
+ handleDownLoadApp() {
1224
+ if (this.onDownLoadApp) {
1225
+ if (typeof this.onDownLoadApp === 'function') {
1226
+ this.onDownLoadApp();
1227
+ } else {
1228
+ this.$emit('handleDownLoadApp');
1229
+ this.$emit('handle-down-load-app');
1230
+ }
1231
+ } else {
1232
+ this.showDownLoadApp = true;
1233
+ }
1234
+ },
1235
+ handleDownLoadApps() {
1236
+ if (this.downloadApp) {
1237
+ window.open(this.downloadApp);
1238
+ } else {
1239
+ this.handleDownLoadApp();
1240
+ }
1241
+ },
1242
+ switchLogin(res) {
1243
+ if (res.type != '1') {
1244
+ this.active = res.type;
1245
+ this.title = res.name;
1246
+ Object.keys(this.defaultModel).length &&
1247
+ (this.formData = JSON.parse(JSON.stringify(this.defaultModel)));
1248
+ this.$emit('change-type', res, this.identifyingId);
1249
+ this.$nextTick(() => {
1250
+ let ref = 'login' + this.active;
1251
+ this.$refs[ref] && this.$refs[ref].clearValidate();
1252
+ });
1253
+ } else {
1254
+ this.submit = true;
1255
+ this.$refs.calogin && this.$refs.calogin.getCertificate();
1256
+ }
1257
+ this.countdown = 0;
1258
+ },
1259
+ switchLoginType(res) {
1260
+ this.countdown = 0;
1261
+ if (res) {
1262
+ this.switchActive = res.type;
1263
+ this.title = res.name || '';
1264
+ if (this.loginModel.indexOf(res.type) > -1) {
1265
+ this.active = res.type;
1266
+ } else {
1267
+ let other = this.switchs.filter((item) => {
1268
+ return item.type != res.type;
1269
+ })[0];
1270
+ let model = this.loginModel.split(',').filter((item) => {
1271
+ return item != res.type && item != other.type;
1272
+ })[0];
1273
+ if (model) {
1274
+ this.active = model;
1275
+ this.title = this.iconfonts[model].name;
1276
+ } else {
1277
+ console.error('complex风格的登录方式,loginModel配置错误!');
1278
+ }
1279
+ }
1280
+ } else {
1281
+ this.active = this.switchs[0].type;
1282
+ this.title = '';
1283
+ this.switchActive = this.switchs[0].type;
1284
+ }
1285
+ this.$emit('change-type', res, this.identifyingId);
1286
+ this.$nextTick(() => {
1287
+ let ref = 'login' + this.active;
1288
+ this.$refs[ref] && this.$refs[ref].clearValidate();
1289
+ });
1290
+ },
1291
+ isShow(res) {
1292
+ return this.loginModel.indexOf(res) > -1;
1293
+ },
1294
+ async getLogin() {
1295
+ const config = util.getStorage('initLogin');
1296
+ if (config) {
1297
+ this.setConfig(JSON.parse(config));
1298
+ }
1299
+ await util
1300
+ .ajax({ url: this.initLogin })
1301
+ .then((res) => {
1302
+ if (res && res.rCode === 0) {
1303
+ store.set('initLogin', res.results);
1304
+ util.setStorage({
1305
+ type: 'localStorage',
1306
+ key: 'initLogin',
1307
+ value: JSON.stringify(res.results)
1308
+ });
1309
+ this.$emit('initLogin', res.results);
1310
+ this.setConfig(res.results);
1311
+ } else {
1312
+ this.$message({
1313
+ message: res.msg || '系统错误,请联系管理员!',
1314
+ type: 'error'
1315
+ });
1316
+ }
1317
+ })
1318
+ .catch((err) => {
1319
+ if (err.message && err.message !== 'canceled') {
1320
+ this.$message.error(err.message);
1321
+ }
1322
+ });
1323
+ },
1324
+ setConfig(res) {
1325
+ const isLogined = localStorage.getItem('isLogined');
1326
+ this.identifyingId = res.identifyingId || '';
1327
+ this.getImgCode();
1328
+ let downloads = {};
1329
+ if (res.androidDownloadUrl) {
1330
+ downloads['android'] = res.androidDownloadUrl;
1331
+ }
1332
+ if (res.iosDownloadUrl) {
1333
+ downloads['ios'] = res.iosDownloadUrl;
1334
+ }
1335
+ if (res.iosDownloadUrl2) {
1336
+ downloads['pad'] = res.iosDownloadUrl2;
1337
+ }
1338
+ if (res.macDownloadUrl) {
1339
+ downloads['mac'] = res.macDownloadUrl;
1340
+ }
1341
+ if (res.winDownloadUrl) {
1342
+ downloads['win'] = res.winDownloadUrl;
1343
+ }
1344
+ if (res.linuxDownloadUrl) {
1345
+ downloads['linux'] = res.linuxDownloadUrl;
1346
+ }
1347
+ if (res.harmonyDownloadUrl) {
1348
+ downloads['harmony'] = res.harmonyDownloadUrl;
1349
+ }
1350
+ this.sysName = res.subsystemName;
1351
+ this.secret = res.secret;
1352
+ this.setup = res.setup;
1353
+ this.downloadSetup = res.downloadSetup;
1354
+ if (res.subsystemName) {
1355
+ document.title = res.subsystemName;
1356
+ }
1357
+ this.app = res.appName || res.subsystemName;
1358
+ if (res.loginModel && !this.isCeshi) {
1359
+ this.loginModel =
1360
+ (res.firstLoginModel || this.firstLoginModel) && !isLogined
1361
+ ? res.firstLoginModel || this.firstLoginModel
1362
+ : res.loginModel;
1363
+ }
1364
+
1365
+ if (res.loginBackgroundUrl) {
1366
+ this.loginBackgroundImg = res.loginBackgroundUrl.split(',');
1367
+ }
1368
+ if (res.loginLogoUrl) {
1369
+ this.loginLogoImg = res.loginLogoUrl;
1370
+ }
1371
+ if (res.caModel) {
1372
+ this.caLoginModel = res.caModel;
1373
+ }
1374
+ res.loginPage && sessionStorage.setItem('loginPage', res.loginPage);
1375
+ if (res.subsystemExtend && Object.keys(res.subsystemExtend).length) {
1376
+ if (
1377
+ res.subsystemExtend.copyright &&
1378
+ res.subsystemExtend.copyright.length
1379
+ ) {
1380
+ this.copyright = JSON.parse(res.subsystemExtend.copyright);
1381
+ }
1382
+ if (res.subsystemExtend.qrimg || res.subsystemExtend.qrImg) {
1383
+ this.qrimg = res.subsystemExtend.qrimg || res.subsystemExtend.qrImg;
1384
+ }
1385
+ //忘记密码地址
1386
+ if (
1387
+ res.subsystemExtend.forgetPassUrl ||
1388
+ res.subsystemExtend.look_pass_url
1389
+ ) {
1390
+ this.forgetUrl =
1391
+ res.subsystemExtend.forgetPassUrl ||
1392
+ res.subsystemExtend.look_pass_url;
1393
+ }
1394
+ res.subsystemExtend.loginPage &&
1395
+ sessionStorage.setItem('loginPage', res.subsystemExtend.loginPage);
1396
+ if (res.subsystemExtend.login_url) {
1397
+ this.actionUrl = res.subsystemExtend.login_url;
1398
+ }
1399
+ if (res.subsystemExtend.loginModel) {
1400
+ this.loginModel = res.subsystemExtend.loginModel;
1401
+ }
1402
+ if (res.subsystemExtend.firstLoginModel && !isLogined) {
1403
+ this.loginModel = res.subsystemExtend.firstLoginModel;
1404
+ }
1405
+ if (res.subsystemExtend.caModel) {
1406
+ this.caLoginModel = res.subsystemExtend.caModel;
1407
+ }
1408
+ if (res.subsystemExtend.applicationName) {
1409
+ localStorage.setItem('appcode', res.subsystemExtend.applicationName);
1410
+ }
1411
+ if (res.subsystemExtend.loginBoxBackgroun) {
1412
+ this.loginMainImg = res.subsystemExtend.loginBoxBackground.split(',');
1413
+ }
1414
+ if (res.subsystemExtend.loginBoxTitle) {
1415
+ this.loginTitleImg = res.subsystemExtend.loginBoxTitle;
1416
+ }
1417
+ if (res.subsystemExtend.loginBoxName) {
1418
+ this.loginNameImg = res.subsystemExtend.loginBoxName;
1419
+ }
1420
+ if (res.subsystemExtend.loginBoxAlign && this.useResults) {
1421
+ localStorage.setItem(
1422
+ 'loginBoxAlign',
1423
+ res.subsystemExtend.loginBoxAlign
1424
+ );
1425
+ this.align = res.subsystemExtend.loginBoxAlign;
1426
+ }
1427
+ if (res.subsystemExtend.themeColor) {
1428
+ util.updateTheme(res.subsystemExtend.themeColor);
1429
+ localStorage.setItem('theme', res.subsystemExtend.themeColor);
1430
+ }
1431
+ if (res.subsystemExtend.macDownloadUrl) {
1432
+ downloads.mac = res.subsystemExtend.macDownloadUrl;
1433
+ }
1434
+ if (res.subsystemExtend.winDownloadUrl) {
1435
+ downloads.win = res.subsystemExtend.winDownloadUrl;
1436
+ }
1437
+ if (res.subsystemExtend.linuxDownloadUrl) {
1438
+ downloads.linux = res.subsystemExtend.linuxDownloadUrl;
1439
+ }
1440
+ if (res.subsystemExtend.uosDownloadUrl) {
1441
+ downloads.uos = res.subsystemExtend.uosDownloadUrl;
1442
+ }
1443
+
1444
+ if (res.subsystemExtend.harmonyDownloadUrl) {
1445
+ downloads.harmony = res.subsystemExtend.harmonyDownloadUrl;
1446
+ }
1447
+ if (res.subsystemExtend.warningText) {
1448
+ this.warningText = res.subsystemExtend.warningText;
1449
+ }
1450
+ if (res.subsystemExtend.launchTime) {
1451
+ this.launchTime = parseInt(res.subsystemExtend.launchTime, 10);
1452
+ }
1453
+ if (res.subsystemExtend.launchImage) {
1454
+ if (!this.launchShow) {
1455
+ this.launchShow = true;
1456
+ }
1457
+ if (
1458
+ res.subsystemExtend.launchImage != 'true' &&
1459
+ res.subsystemExtend.launchImage != true
1460
+ ) {
1461
+ this.launchImages =
1462
+ res.subsystemExtend.launchImage.indexOf('{') > -1 &&
1463
+ res.subsystemExtend.launchImage.indexOf('}') > -1
1464
+ ? JSON.parse(res.subsystemExtend.launchImage)
1465
+ : res.subsystemExtend.launchImage;
1466
+ }
1467
+ }
1468
+ if (res.subsystemExtend.loginDownloadApp) {
1469
+ this.loginDownloadApp = res.subsystemExtend.loginDownloadApp;
1470
+ }
1471
+ if (res.subsystemExtend.caInstallPath) {
1472
+ this.installPath = res.subsystemExtend.caInstallPath;
1473
+ }
1474
+ if (res.subsystemExtend.storageType) {
1475
+ this.storageType = res.subsystemExtend.storageType;
1476
+ }
1477
+ }
1478
+ this.passModifyModel = res.passModifyModel;
1479
+ this.wechatAppid = res.wechatAppid;
1480
+ this.wechatScope = res.wechatScope;
1481
+ this.download = { ...this.downLoadUrls, ...downloads };
1482
+ if (res.sysLogoIco) {
1483
+ localStorage.setItem('sysLogoIco', res.sysLogoIco);
1484
+ util.setFavicon(res.sysLogoIco);
1485
+ }
1486
+ },
1487
+
1488
+ getImgCode() {
1489
+ if (this.identifyingId === '') {
1490
+ return;
1491
+ }
1492
+ this.imageCode =
1493
+ util.getStorage('host') +
1494
+ this.codeAction +
1495
+ '?identifyingId=' +
1496
+ this.identifyingId +
1497
+ (this.imgCode && typeof this.imgCode == 'object'
1498
+ ? '&' + util.queryParams(this.imgCode)
1499
+ : '') +
1500
+ '&heightflag=' +
1501
+ Math.random().toString().split('.')[1];
1502
+ delete this.formData.identifyingCode;
1503
+ delete this.formData.verificationCode;
1504
+ return this.imageCode;
1505
+ },
1506
+ getCode() {
1507
+ if (this.countdown) {
1508
+ return false;
1509
+ }
1510
+ let data = {};
1511
+ let flag = false;
1512
+ let ref = 'login' + this.active;
1513
+ if (this.active == 12) {
1514
+ if (!this.formData.username) {
1515
+ this.$refs[ref].validateField('username');
1516
+ return false;
1517
+ }
1518
+ this.$refs[ref].validateField('username', (res) => {
1519
+ flag = res != '';
1520
+ });
1521
+ if (flag) {
1522
+ return false;
1523
+ }
1524
+ data = {
1525
+ username: this.formData.username,
1526
+ targetType: this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS'
1527
+ // targetType: 'SMS'
1528
+ };
1529
+ } else {
1530
+ if (!this.formData.target) {
1531
+ this.$refs[ref].validateField('target');
1532
+ return false;
1533
+ }
1534
+ this.$refs[ref].validateField('target', (res) => {
1535
+ flag = res != '';
1536
+ });
1537
+ if (flag) {
1538
+ return false;
1539
+ }
1540
+ data = {
1541
+ target: this.formData.target,
1542
+ targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1543
+ };
1544
+ }
1545
+ this.countdown = 60;
1546
+ this.timer = setInterval(() => {
1547
+ if (this.countdown > 0) {
1548
+ this.countdown--;
1549
+ this.disabled = true;
1550
+ this.btnText = '重新获取' + this.countdown + 's';
1551
+ } else {
1552
+ this.btnText = '重新获取';
1553
+ this.disabled = false;
1554
+ this.submit = false;
1555
+ }
1556
+ }, 1000);
1557
+ util
1558
+ .ajax({
1559
+ method: 'post',
1560
+ url:
1561
+ this.active == 12 ? this.getTwoFactorLoginCode : this.getLoginCode,
1562
+ data: data
1563
+ })
1564
+ .then((res) => {
1565
+ this.$message({
1566
+ message: res.msg,
1567
+ duration: res.rCode == 0 ? 2000 : 3000,
1568
+ type: res.rCode == 0 ? 'success' : 'error'
1569
+ });
1570
+
1571
+ if (res.rCode === 2) {
1572
+ this.btnText = '获取验证码';
1573
+ this.disabled = false;
1574
+ this.countdown = 0;
1575
+ clearInterval(this.timer);
1576
+ }
1577
+ })
1578
+ .catch((err) => {
1579
+ if (err.message && err.message !== 'canceled') {
1580
+ this.$message.error(err.message);
1581
+ }
1582
+ });
1583
+ },
1584
+ handleLogin() {
1585
+ if (this.submit) {
1586
+ return false;
1587
+ }
1588
+ let ref = 'login' + this.active;
1589
+ this.$refs[ref].validate((valid) => {
1590
+ if (valid) {
1591
+ this.submit = true;
1592
+ let param = util.getParams() || {};
1593
+ const data =
1594
+ this.active == '0'
1595
+ ? {
1596
+ username: this.formData.username,
1597
+ password:
1598
+ this.secret && this.isEncrypt
1599
+ ? util.esmEncrypt({
1600
+ data: this.formData.password,
1601
+ key: this.secret
1602
+ })
1603
+ : this.formData.password,
1604
+ identifyingCode: this.formData.identifyingCode,
1605
+ identifyingId: this.identifyingId
1606
+ }
1607
+ : this.active == '12'
1608
+ ? {
1609
+ username: this.formData.username,
1610
+ password:
1611
+ this.secret && this.isEncrypt
1612
+ ? util.esmEncrypt({
1613
+ data: this.formData.password,
1614
+ key: this.secret
1615
+ })
1616
+ : this.formData.password,
1617
+ targetType:
1618
+ this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS',
1619
+ verificationCode: this.formData.identifyingCode
1620
+ }
1621
+ : {
1622
+ target: this.formData.target,
1623
+ verificationCode: this.formData.verificationCode,
1624
+ targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1625
+ };
1626
+ if (this.onLogin) {
1627
+ if (this.active == '0') {
1628
+ this.onLogin(
1629
+ { ...param, ...data },
1630
+ this.getImgCode,
1631
+ this.handleRemember
1632
+ );
1633
+ } else {
1634
+ this.onLogin({ ...param, ...data });
1635
+ }
1636
+ } else {
1637
+ this.handleUserLogin({ ...param, ...this.param, ...data });
1638
+ }
1639
+ } else {
1640
+ this.submit = false;
1641
+ return false;
1642
+ }
1643
+ });
1644
+ },
1645
+ doLogin(e) {
1646
+ if (util.win.event == undefined) {
1647
+ var key = e.keyCode;
1648
+ } else {
1649
+ var key = util.win.event.keyCode;
1650
+ }
1651
+ if (key == 13) {
1652
+ this.handleLogin();
1653
+ }
1654
+ },
1655
+ handleUserLogin(data) {
1656
+ let extUserBindHandleId = sessionStorage.getItem('extUserBindHandleId');
1657
+ util
1658
+ .ajax({
1659
+ method: 'post',
1660
+ url:
1661
+ this.active == '0'
1662
+ ? this.actionUrl
1663
+ : this.active == '12'
1664
+ ? this.doTwoFactorLogin
1665
+ : this.doCodeLogin,
1666
+ data: extUserBindHandleId
1667
+ ? { ...data, extUserBindHandleId: extUserBindHandleId }
1668
+ : data
1669
+ })
1670
+ .then((res) => {
1671
+ this.submit = false;
1672
+ if (res.rCode == 0) {
1673
+ util.removeStorage('extUserBindHandleId');
1674
+ this.handleRemember();
1675
+ const results = res.results;
1676
+ this.handleResults(results);
1677
+ if (this.onSuccess) {
1678
+ this.onSuccess(res);
1679
+ }
1680
+ } else {
1681
+ const msg =
1682
+ res.results && res.results.msg ? res.results.msg : res.msg;
1683
+ this.$message({
1684
+ message: msg || '系统错误,请联系管理员!',
1685
+ type: 'error',
1686
+ onClose: () => {
1687
+ this.btnText = '获取验证码';
1688
+ this.disabled = false;
1689
+ this.countdown = 0;
1690
+ clearInterval(this.timer);
1691
+ this.getImgCode();
1692
+ }
1693
+ });
1694
+ this.onError(res);
1695
+ }
1696
+ })
1697
+ .catch((err) => {
1698
+ this.submit = false;
1699
+ if (err.message && err.message !== 'canceled') {
1700
+ this.$message.error(err.message);
1701
+ }
1702
+ });
1703
+ },
1704
+ caLogin(signedData) {
1705
+ this.loginInfo(false);
1706
+ util
1707
+ .ajax({
1708
+ method: 'post',
1709
+ url: this.caAction,
1710
+ data:
1711
+ typeof signedData === 'string'
1712
+ ? { identifyingId: this.identifyingId, signedData: signedData }
1713
+ : signedData
1714
+ })
1715
+ .then((res) => {
1716
+ this.submit = false;
1717
+ if (res.rCode == 0) {
1718
+ const results = res.results;
1719
+ this.handleResults(results);
1720
+ if (this.onSuccess) {
1721
+ this.onSuccess(res);
1722
+ }
1723
+ } else {
1724
+ const msg =
1725
+ res.results && res.results.msg ? res.results.msg : res.msg;
1726
+ this.$message({
1727
+ message: msg || '系统错误,请联系管理员!',
1728
+ type: 'error',
1729
+ onClose: () => {
1730
+ this.getImgCode();
1731
+ this.loginInfo(this.active == 3);
1732
+ }
1733
+ });
1734
+ this.onError(res);
1735
+ }
1736
+ })
1737
+ .catch((err) => {
1738
+ this.submit = false;
1739
+ if (err.message && err.message !== 'canceled') {
1740
+ this.$message.error(err.message);
1741
+ }
1742
+ });
1743
+ },
1744
+ handleForget() {
1745
+ if (typeof this.forgetUrl === 'string') {
1746
+ util.win.open(this.forgetUrl);
1747
+ } else {
1748
+ this.showResetPassword = true;
1749
+ }
1750
+ },
1751
+ downloadExe() {
1752
+ util.win.open(this.downloadSetup);
1753
+ },
1754
+ //获取app登录信息
1755
+ loginInfo(res) {
1756
+ clearTimeout(this.interval);
1757
+ if (res) {
1758
+ this.interval = setTimeout(() => {
1759
+ this.initRequestLoginInfo();
1760
+ }, this.scanIntervalTime);
1761
+ }
1762
+ },
1763
+ initRequestLoginInfo() {
1764
+ if (this.identifyingId == '') {
1765
+ return false;
1766
+ }
1767
+ util
1768
+ .ajax({
1769
+ method: 'post',
1770
+ url: this.scanAction,
1771
+ data: {
1772
+ identifyingId: this.identifyingId
1773
+ }
1774
+ })
1775
+ .then((res) => {
1776
+ if (res.rCode === 0) {
1777
+ const results = res.results;
1778
+ if (results.statusCode === 0 || results.statusCode === 2) {
1779
+ // statusCode为2时 代表密码过期,也应执行handleResults
1780
+ clearTimeout(this.interval);
1781
+ if (results.statusCode === 2) {
1782
+ this.$alert(
1783
+ results.msg
1784
+ ? results.msg
1785
+ : '您的初始密码已过期,请及时修改!',
1786
+ '提示',
1787
+ {
1788
+ confirmButtonText: '确定',
1789
+ type: 'warning'
1790
+ }
1791
+ )
1792
+ .then(() => {
1793
+ this.handleResults(results, 3);
1794
+ })
1795
+ .catch((e) => {});
1796
+ } else {
1797
+ this.handleResults(results, 3);
1798
+ }
1799
+ } else {
1800
+ this.loginInfo(true);
1801
+ }
1802
+ }
1803
+ })
1804
+ .catch((err) => {
1805
+ clearTimeout(this.interval);
1806
+ if (err.message && err.message !== 'canceled') {
1807
+ this.$message.error(err.message);
1808
+ }
1809
+ });
1810
+ },
1811
+ handleResults(results, type) {
1812
+ switch (results.statusCode) {
1813
+ case 0:
1814
+ this.userName = results.userName;
1815
+ util.setStorage({
1816
+ type: this.storageType,
1817
+ key: {
1818
+ ssId: results.ssId,
1819
+ token: results.token,
1820
+ Authorization: results.token,
1821
+ deviceUnique: results.deviceUnique,
1822
+ userId: results.userId,
1823
+ userName: results.userName,
1824
+ useCaseCodes: results.resourceCodes
1825
+ }
1826
+ });
1827
+ if (this.launchShow) {
1828
+ this.$message({
1829
+ message: '登录成功!',
1830
+ type: 'success',
1831
+ duration: 1000
1832
+ });
1833
+ this.showLaunch = true;
1834
+ setTimeout(() => {
1835
+ if (this.toUrl) {
1836
+ window.location.href = this.toUrl;
1837
+ } else if (results.doorIndex && this.doorIndex) {
1838
+ sessionStorage.setItem('doorIndex', results.doorIndex);
1839
+ localStorage.setItem('isLogined', true);
1840
+ window.location.href = results.doorIndex;
1841
+ } else {
1842
+ if (window.location.href.indexOf('login.html') > -1) {
1843
+ window.location.href = './main.html';
1844
+ } else {
1845
+ this.$router.push({ name: 'main' });
1846
+ this.$nextTick(() => {
1847
+ this.showLaunch = false;
1848
+ });
1849
+ }
1850
+ }
1851
+ }, this.launchTime);
1852
+ } else {
1853
+ this.$message({
1854
+ message: '登录成功!',
1855
+ type: 'success',
1856
+ duration: 1500,
1857
+ onClose: () => {
1858
+ if (this.toUrl) {
1859
+ window.location.href = this.toUrl;
1860
+ } else if (results.doorIndex && this.doorIndex) {
1861
+ sessionStorage.setItem('doorIndex', results.doorIndex);
1862
+ localStorage.setItem('isLogined', true);
1863
+ window.location.href = results.doorIndex;
1864
+ } else {
1865
+ if (window.location.href.indexOf('login.html') > -1) {
1866
+ window.location.href = './main.html';
1867
+ } else {
1868
+ this.$router.push({ name: 'main' });
1869
+ }
1870
+ }
1871
+ }
1872
+ });
1873
+ }
1874
+ break;
1875
+ case 2:
1876
+ this.$confirm(
1877
+ results.msg ? results.msg : '密码太简单了, 请修改密码?',
1878
+ '提示',
1879
+ {
1880
+ confirmButtonText: '确定',
1881
+ //cancelButtonText: '取消',
1882
+ type: 'warning'
1883
+ }
1884
+ )
1885
+ .then(() => {
1886
+ this.operationCheckCode = results.checkCode;
1887
+ if (typeof this.forgetUrl === 'string') {
1888
+ util.win.open(this.forgetUrl);
1889
+ } else {
1890
+ this.showResetPassword = true;
1891
+ }
1892
+ })
1893
+ .catch((e) => {});
1894
+ break;
1895
+ case 3:
1896
+ let url =
1897
+ results.doorIndex && this.doorIndex
1898
+ ? results.doorIndex
1899
+ : window.location.href.indexOf('main.html') > -1
1900
+ ? './login.html'
1901
+ : window.location.hash
1902
+ ? window.location.href.replace('login', 'main')
1903
+ : window.location.href;
1904
+ const href = results.authorizeUrl.replace(
1905
+ '{redirectUri}',
1906
+ encodeURIComponent(url)
1907
+ );
1908
+ window.location.href = href;
1909
+ // window.location.href =
1910
+ // results.authorizeUrl.indexOf('?') > -1
1911
+ // ? results.authorizeUrl + '&token=' + results.token
1912
+ // : results.authorizeUrl + '?token=' + results.token;
1913
+ break;
1914
+ case 4:
1915
+ this.$alert(
1916
+ results.msg ? results.msg : '账号未绑定,账号密码登录后自动绑定!',
1917
+ '提示',
1918
+ {
1919
+ confirmButtonText: '确定',
1920
+ type: 'error'
1921
+ }
1922
+ )
1923
+ .then(() => {
1924
+ sessionStorage.setItem(
1925
+ 'extUserBindHandleId',
1926
+ results.extUserBindHandleId
1927
+ );
1928
+ window.location.href = util.delUrlParam({ key: 'code' });
1929
+ if (window.location.hash) {
1930
+ location.reload();
1931
+ }
1932
+ })
1933
+ .catch((e) => {});
1934
+ break;
1935
+ case 102:
1936
+ this.checkCode = results.checkCode;
1937
+ this.showAssistance = true;
1938
+ let { operationCheckCode } = JSON.parse(results.checkCode);
1939
+ this.handleAssistance({ operationCheckCode });
1940
+ break;
1941
+ default:
1942
+ if (type !== 3) {
1943
+ this.$message({
1944
+ message: results.msg,
1945
+ type: 'error',
1946
+ onClose: () => {
1947
+ if (this.code) {
1948
+ window.location.href = util.delUrlParam({ key: 'code' });
1949
+ if (window.location.hash) {
1950
+ location.reload();
1951
+ }
1952
+ } else {
1953
+ this.getImgCode();
1954
+ }
1955
+ }
1956
+ });
1957
+ } else if (this.active == 3) {
1958
+ this.loginInfo(true);
1959
+ }
1960
+ }
1961
+ },
1962
+ handleAssistance(data) {
1963
+ clearTimeout(this.doAssistance);
1964
+ this.doAssistance = setTimeout(() => {
1965
+ this.doAssistanceLogin(data);
1966
+ }, this.scanIntervalTime);
1967
+ },
1968
+ doAssistanceLogin(data) {
1969
+ util
1970
+ .ajax({
1971
+ method: 'post',
1972
+ url: doAssistanceQrLogin,
1973
+ data: data
1974
+ })
1975
+ .then((res) => {
1976
+ if (res.rCode === 0) {
1977
+ const results = res.results;
1978
+ if (results.statusCode === 0) {
1979
+ clearTimeout(this.doAssistance);
1980
+ this.handleResults(results, 3);
1981
+ } else {
1982
+ this.handleAssistance(data);
1983
+ }
1984
+ } else {
1985
+ clearTimeout(this.doAssistance);
1986
+ this.$message.error(res.msg);
1987
+ }
1988
+ })
1989
+ .catch((err) => {
1990
+ clearTimeout(this.doAssistance);
1991
+ if (err.message && err.message !== 'canceled') {
1992
+ this.$message.error(err.message);
1993
+ }
1994
+ });
1995
+ },
1996
+ closeAssistance() {
1997
+ clearTimeout(this.doAssistance);
1998
+ },
1999
+ handleSuccess() {
2000
+ this.showResetPassword = false;
2001
+ },
2002
+ forbiddenTab(e) {
2003
+ if (e.keyCode == 9) {
2004
+ return false;
2005
+ }
2006
+ },
2007
+ handlePaste(event) {
2008
+ this.safe && event.preventDefault();
2009
+ },
2010
+ handleError() {
2011
+ this.submit = false;
2012
+ }
2013
+ },
2014
+ beforeDestroy() {
2015
+ window.removeEventListener('resize', this.setScale);
2016
+ document.removeEventListener('keyup', this.doLogin);
2017
+ document.removeEventListener('keydown', this.forbiddenTab);
2018
+ }
2019
+ };
2020
+ </script>