eoss-ui 0.7.89 → 0.7.91

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 (162) hide show
  1. package/lib/button-group.js +16 -0
  2. package/lib/button.js +18 -2
  3. package/lib/calogin.js +16 -0
  4. package/lib/checkbox-group.js +16 -0
  5. package/lib/data-table-form.js +16 -0
  6. package/lib/data-table.js +32 -19
  7. package/lib/date-picker.js +16 -0
  8. package/lib/dialog.js +27 -6
  9. package/lib/eoss-ui.common.js +769 -757
  10. package/lib/flow-group.js +30 -15
  11. package/lib/flow-list.js +112 -96
  12. package/lib/flow.js +178 -162
  13. package/lib/form.js +16 -0
  14. package/lib/handle-user.js +19 -3
  15. package/lib/handler.js +26 -10
  16. package/lib/icon.js +16 -0
  17. package/lib/index.js +1 -1
  18. package/lib/input-number.js +16 -0
  19. package/lib/input.js +16 -0
  20. package/lib/login.js +16 -0
  21. package/lib/main.js +397 -386
  22. package/lib/nav.js +16 -0
  23. package/lib/page.js +16 -0
  24. package/lib/pagination.js +19 -3
  25. package/lib/player.js +16 -0
  26. package/lib/qr-code.js +16 -0
  27. package/lib/radio-group.js +16 -0
  28. package/lib/retrial-auth.js +22 -6
  29. package/lib/select-ganged.js +16 -0
  30. package/lib/select.js +18 -2
  31. package/lib/selector-panel.js +16 -0
  32. package/lib/selector.js +16 -0
  33. package/lib/sizer.js +16 -0
  34. package/lib/steps.js +16 -0
  35. package/lib/switch.js +16 -0
  36. package/lib/table-form.js +16 -0
  37. package/lib/tabs.js +16 -0
  38. package/lib/theme-chalk/index.css +1 -1
  39. package/lib/theme-chalk/login.css +1 -1
  40. package/lib/tips.js +16 -0
  41. package/lib/tree-group.js +19 -3
  42. package/lib/tree.js +16 -0
  43. package/lib/upload.js +16 -0
  44. package/lib/utils/util.js +16 -0
  45. package/lib/wujie.js +16 -0
  46. package/lib/wxlogin.js +16 -0
  47. package/package.json +1 -1
  48. package/packages/.DS_Store +0 -0
  49. package/packages/button/src/main.vue +2 -2
  50. package/packages/button-group/src/main.vue +346 -346
  51. package/packages/calogin/.DS_Store +0 -0
  52. package/packages/calogin/src/main.vue +412 -412
  53. package/packages/clients/src/main.vue +151 -151
  54. package/packages/data-table/src/column.vue +2 -5
  55. package/packages/data-table/src/main.vue +4 -3
  56. package/packages/date-picker/.DS_Store +0 -0
  57. package/packages/date-picker/src/.DS_Store +0 -0
  58. package/packages/dialog/.DS_Store +0 -0
  59. package/packages/dialog/src/main.vue +11 -4
  60. package/packages/flow/.DS_Store +0 -0
  61. package/packages/flow/src/.DS_Store +0 -0
  62. package/packages/flow/src/component/Circulate.vue +417 -417
  63. package/packages/flow/src/component/CommonOpinions.vue +376 -376
  64. package/packages/flow/src/component/CustomPreset.vue +324 -324
  65. package/packages/flow/src/component/FileList.vue +97 -97
  66. package/packages/flow/src/component/FreeCirculation.vue +244 -244
  67. package/packages/flow/src/component/Preset.vue +257 -257
  68. package/packages/flow/src/component/SendMsg.vue +242 -242
  69. package/packages/flow/src/component/SortFlow.vue +110 -110
  70. package/packages/flow/src/component/taskUnionExamine.vue +761 -761
  71. package/packages/flow/src/form.vue +123 -123
  72. package/packages/flow/src/freeStartFlow.vue +2855 -2855
  73. package/packages/flow/src/processForm.vue +1680 -1680
  74. package/packages/flow/src/processReject.vue +309 -309
  75. package/packages/flow/src/reset.vue +946 -946
  76. package/packages/flow/src/startTaskRead.vue +695 -695
  77. package/packages/flow/src/supervise.vue +159 -159
  78. package/packages/flow/src/table.vue +58 -58
  79. package/packages/flow-group/src/main.vue +728 -727
  80. package/packages/flow-list/.DS_Store +0 -0
  81. package/packages/flow-list/src/main.vue +2337 -2337
  82. package/packages/form/.DS_Store +0 -0
  83. package/packages/form/src/main.vue +3901 -3901
  84. package/packages/form/src/table.vue +1512 -1512
  85. package/packages/handle-user/src/main.vue +137 -137
  86. package/packages/handler/src/main.vue +10 -8
  87. package/packages/icon/.DS_Store +0 -0
  88. package/packages/icon/src/main.vue +104 -104
  89. package/packages/login/.DS_Store +0 -0
  90. package/packages/login/src/main.vue +2087 -2087
  91. package/packages/login/src/resetPassword.vue +557 -557
  92. package/packages/main/.DS_Store +0 -0
  93. package/packages/main/src/.DS_Store +0 -0
  94. package/packages/main/src/default/userinfo.vue +505 -503
  95. package/packages/main/src/main.vue +10 -15
  96. package/packages/main/src/public/online.vue +89 -89
  97. package/packages/main/src/public/search.vue +464 -464
  98. package/packages/main/src/public/settings.vue +273 -273
  99. package/packages/main/src/simplicity/apps.vue +388 -388
  100. package/packages/main/src/simplicity/avatar.vue +82 -82
  101. package/packages/main/src/simplicity/handler.vue +158 -158
  102. package/packages/main/src/simplicity/index.vue +2330 -2328
  103. package/packages/main/src/simplicity/menu-list.vue +135 -135
  104. package/packages/main/src/simplicity/message.vue +293 -293
  105. package/packages/main/src/simplicity/notice.vue +222 -222
  106. package/packages/main/src/simplicity/sub-menu.vue +276 -276
  107. package/packages/main/src/simplicity/user.vue +259 -259
  108. package/packages/main/src/simplicity/userinfo.vue +403 -401
  109. package/packages/main/src/simplicityTop/apps.vue +388 -388
  110. package/packages/main/src/simplicityTop/avatar.vue +82 -82
  111. package/packages/main/src/simplicityTop/handler.vue +215 -215
  112. package/packages/main/src/simplicityTop/index.vue +2620 -2618
  113. package/packages/main/src/simplicityTop/lists.vue +84 -84
  114. package/packages/main/src/simplicityTop/menu-list.vue +135 -135
  115. package/packages/main/src/simplicityTop/message.vue +293 -293
  116. package/packages/main/src/simplicityTop/notice.vue +222 -222
  117. package/packages/main/src/simplicityTop/router-page.vue +45 -45
  118. package/packages/main/src/simplicityTop/sub-menu.vue +274 -274
  119. package/packages/main/src/simplicityTop/user.vue +259 -259
  120. package/packages/main/src/simplicityTop/userinfo.vue +403 -401
  121. package/packages/menu/.DS_Store +0 -0
  122. package/packages/menu/src/main.vue +595 -595
  123. package/packages/nav/src/main.vue +351 -351
  124. package/packages/pagination/src/main.vue +1 -1
  125. package/packages/retrial-auth/src/main.vue +4 -4
  126. package/packages/select/.DS_Store +0 -0
  127. package/packages/select/src/main.vue +2 -2
  128. package/packages/selector/.DS_Store +0 -0
  129. package/packages/selector/src/main.vue +761 -761
  130. package/packages/selector-panel/.DS_Store +0 -0
  131. package/packages/selector-panel/src/main.vue +1036 -1036
  132. package/packages/selector-panel/src/selection.vue +174 -174
  133. package/packages/switch/src/main.vue +170 -170
  134. package/packages/theme-chalk/lib/index.css +1 -1
  135. package/packages/theme-chalk/lib/login.css +1 -1
  136. package/packages/theme-chalk/src/.DS_Store +0 -0
  137. package/packages/theme-chalk/src/data-table.scss +297 -297
  138. package/packages/theme-chalk/src/flow-list.scss +55 -55
  139. package/packages/theme-chalk/src/flow.scss +373 -373
  140. package/packages/theme-chalk/src/form.scss +501 -501
  141. package/packages/theme-chalk/src/handler.scss +148 -148
  142. package/packages/theme-chalk/src/icon.scss +3452 -3452
  143. package/packages/theme-chalk/src/login.scss +1006 -1006
  144. package/packages/theme-chalk/src/main.scss +664 -664
  145. package/packages/theme-chalk/src/menu.scss +224 -224
  146. package/packages/theme-chalk/src/selector.scss +114 -114
  147. package/packages/theme-chalk/src/simplicity-top.scss +1845 -1845
  148. package/packages/theme-chalk/src/simplicity.scss +1403 -1403
  149. package/packages/theme-chalk/src/tree.scss +165 -165
  150. package/packages/theme-chalk/src/upload.scss +172 -172
  151. package/packages/tips/src/main.vue +141 -141
  152. package/packages/toolbar/src/main.vue +430 -430
  153. package/packages/tree-group/src/main.vue +2 -1
  154. package/packages/upload/.DS_Store +0 -0
  155. package/packages/upload/src/main.vue +1344 -1344
  156. package/packages/wujie/src/main.vue +146 -146
  157. package/src/.DS_Store +0 -0
  158. package/src/config/api.js +348 -348
  159. package/src/index.js +163 -163
  160. package/src/utils/.DS_Store +0 -0
  161. package/src/utils/rules.js +18 -18
  162. package/src/utils/util.js +16 -0
@@ -1,2087 +1,2087 @@
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-shoushiyou"></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-yonghu 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-yanzhengma 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-saoma"></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-shoushiyou"></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="downloadLength == 1 ? '450px' : '80%'"
478
- :height="downloadLength == 1 ? '500px' : '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
- alertCallback: {
783
- type: Function,
784
- default: () => {}
785
- }
786
- },
787
- computed: {
788
- downloadLength() {
789
- return this.download ? Object.keys(this.download).length : 0;
790
- },
791
- transform() {
792
- let translate = this.translate
793
- ? this.translate
794
- : this.align === 'center'
795
- ? '-50%, -51%'
796
- : '-51%';
797
- if (this.align.indexOf('%') > -1) {
798
- return {
799
- left: this.align,
800
- top: '50%',
801
- transform: `translateY(${translate})`
802
- };
803
- }
804
- if (this.align === 'left') {
805
- return {
806
- left: '30%',
807
- top: '50%',
808
- transform: `translateY(${translate})`
809
- };
810
- }
811
- if (this.align === 'right') {
812
- return {
813
- left: '70%',
814
- top: '50%',
815
- transform: `translateY(${translate})`
816
- };
817
- }
818
- return {
819
- left: '50%',
820
- top: '50%',
821
- transform: `translate(${translate})`
822
- };
823
- },
824
- redirectUri() {
825
- if (this.redirect_uri) {
826
- return this.redirect_uri;
827
- } else {
828
- return window.location.href || window.href;
829
- }
830
- },
831
- showWarnInfo() {
832
- return this.$slots.warning || this.$scopedSlots.warning
833
- ? false
834
- : this.warningText
835
- ? true
836
- : false;
837
- },
838
- modelLength() {
839
- return Array.isArray(this.loginModel)
840
- ? this.loginModel.length
841
- : this.loginModel.split(',').length;
842
- },
843
- iconfonts() {
844
- const types = this.loginModel.split(',');
845
- return types.length > 2
846
- ? {
847
- 0: {
848
- type: '0',
849
- icon: 'es-icon-jianpan',
850
- icon2: '',
851
- name: '账号登录'
852
- },
853
- 1: { type: '1', icon: 'es-icon-upan', name: '证书登录' },
854
- 3: {
855
- type: '3',
856
- icon: 'es-icon-saoma1',
857
- icon2: '',
858
- name: '扫码登录'
859
- },
860
- 6: { type: '6', icon: 'es-icon-solid-duanxin', name: '短信登录' },
861
- 7: { type: '7', icon: 'es-icon-dingding1', name: '钉钉扫码登录' },
862
- 9: { type: '9', icon: 'es-icon-weixin1', name: '微信扫码登录' },
863
- 11: { type: '11', icon: 'es-icon-youjian', name: '邮箱登录' },
864
- 12: { type: '12', icon: 'es-icon-jianpan', name: '账号登录' } //双因素
865
- }
866
- : {
867
- 0: { type: '0', icon: 'es-icon-solid-monitor', name: '账号登录' },
868
- 1: {
869
- type: '1',
870
- icon: 'es-icon-solid-cashenfenrenzheng',
871
- name: '证书登录'
872
- },
873
- 3: { type: '3', icon: 'es-icon-qrcode', name: '扫码登录' },
874
- 6: { type: '6', icon: 'es-icon-solid-duanxin', name: '短信登录' },
875
- 7: { type: '7', icon: 'es-icon-dingding', name: '钉钉扫码登录' },
876
- 9: { type: '9', icon: 'es-icon-weixin', name: '微信扫码登录' },
877
- 11: {
878
- type: '11',
879
- icon: 'es-icon-youjian',
880
- name: '邮箱登录'
881
- },
882
- 12: { type: '12', icon: 'es-icon-solid-monitor', name: '账号登录' } //双因素
883
- };
884
- },
885
- icons() {
886
- let icon = [];
887
- const types = this.loginModel.split(',');
888
- types.forEach((item) => {
889
- icon.push(this.iconfonts[item]);
890
- });
891
- return icon;
892
- },
893
- isCaLogin() {
894
- return this.loginModel.indexOf('1') > -1;
895
- },
896
- showVerifyCode() {
897
- return (
898
- this.passModifyModel &&
899
- (this.passModifyModel.indexOf('6') > -1 ||
900
- this.passModifyModel.indexOf('11') > -1)
901
- );
902
- },
903
- _launchImage() {
904
- let img = util.isObject(this.launchImages)
905
- ? this.launchImages[this.launchKey]
906
- : this.launchImages;
907
- return { 'background-image': `url(${img})` };
908
- },
909
- showForget() {
910
- return this.forgetUrl && typeof this.forgetUrl === 'string'
911
- ? true
912
- : this.forgetUrl === true &&
913
- this.loginModel.indexOf('0') > -1 &&
914
- this.showVerifyCode;
915
- },
916
- isCeshi() {
917
- return this.ceshi ? params[this.ceshi] : false;
918
- }
919
- },
920
- watch: {
921
- loginModel: {
922
- immediate: true,
923
- handler(val) {
924
- this.active = val.split(',')[0];
925
- this.title = this.iconfonts[this.active].name;
926
- this.switchs.forEach((item) => {
927
- if (item.type == this.active) {
928
- this.switchActive = item.type;
929
- return;
930
- }
931
- });
932
- }
933
- },
934
- active: {
935
- immediate: true,
936
- handler(val) {
937
- this.loginInfo(val == 3);
938
- }
939
- },
940
- identifyingId(val) {
941
- if (val) {
942
- this.loginInfo(this.active == 3);
943
- }
944
- },
945
- appName: {
946
- immediate: true,
947
- handler(val) {
948
- if (val) {
949
- this.app = val;
950
- }
951
- }
952
- },
953
- qrImage: {
954
- immediate: true,
955
- handler(val) {
956
- if (val) {
957
- this.qrimg = val;
958
- }
959
- }
960
- },
961
- checked(val) {
962
- if (!val) {
963
- localStorage.removeItem('unpd');
964
- //localStorage.removeItem('remember');
965
- }
966
- }
967
- // secret: {
968
- // immediate: true,
969
- // handler(val) {
970
- // if (val) {
971
- // if (this.storage) {
972
- // localStorage.setItem('secret', val);
973
- // } else {
974
- // sessionStorage.setItem('secret', val);
975
- // }
976
- // }
977
- // }
978
- // }
979
- },
980
- data() {
981
- return {
982
- title: '',
983
- align: this.position,
984
- loginBackgroundImg: this.loginBackground,
985
- loginMainImg: this.loginImage,
986
- loginNameImg: this.loginName,
987
- loginTitleImg: this.loginTitle,
988
- loginLogoImg: this.loginLogo,
989
- loginModel: this.type,
990
- caLoginModel: this.caModel,
991
- passModifyModel: null,
992
- active: 0,
993
- submit: false,
994
- checked: false,
995
- formData: this.model,
996
- focusShow: false,
997
- users: [],
998
- imageCode: '',
999
- secret: null,
1000
- identifyingId: undefined,
1001
- download: {},
1002
- setup: '',
1003
- sysName: '',
1004
- copyright: this.copyrights,
1005
- forgetUrl: this.forget,
1006
- actionUrl: this.action,
1007
- downloadSetup: '',
1008
- app: '',
1009
- qrimg: '',
1010
- interval: null,
1011
- showResetPassword: false,
1012
- operationCheckCode: '',
1013
- showDownLoadApp: false,
1014
- wechatAppid: null,
1015
- wechatScope: null,
1016
- disabled: false,
1017
- btnText: '获取验证码',
1018
- timer: null,
1019
- countdown: 0,
1020
- code: null,
1021
- defaultModel: JSON.parse(JSON.stringify(this.model)),
1022
- checkCode: '',
1023
- showAssistance: false,
1024
- doAssistance: null,
1025
- warningText: this.warning,
1026
- safes: {
1027
- paste: (event) => {
1028
- event.preventDefault();
1029
- return false;
1030
- },
1031
- contextmenu: (event) => {
1032
- event.preventDefault();
1033
- return false;
1034
- },
1035
- copy: (event) => {
1036
- event.preventDefault();
1037
- return false;
1038
- },
1039
- cut: (event) => {
1040
- event.preventDefault();
1041
- return false;
1042
- }
1043
- },
1044
- userName: '',
1045
- launchShow: this.launch,
1046
- showLaunch: false,
1047
- launchImages: this.launchImage,
1048
- launchKey: 'day',
1049
- launchTime: 2000,
1050
- switchActive: this.switchsActive,
1051
- loginDownloadApp: this.loginDownloadApps,
1052
- installPath: this.caInstallPath,
1053
- storageType: this.storage
1054
- };
1055
- },
1056
- beforeCreate() {
1057
- this.setScale = debounce(300, () => {
1058
- util.setScale();
1059
- });
1060
- util.removeStorage([
1061
- 'remind',
1062
- 'ssId',
1063
- 'token',
1064
- 'Authorization',
1065
- 'deviceUnique',
1066
- 'userId',
1067
- 'userName',
1068
- 'useCaseCodes'
1069
- ]);
1070
- },
1071
- created() {
1072
- this.launchKey = 5 < new Date().getHours() < 18 ? 'day' : 'night';
1073
- if (this.isCeshi) {
1074
- this.loginModel =
1075
- this.isCeshi == 'true' || this.isCeshi == true ? '0' : this.isCeshi;
1076
- }
1077
- if (this.isScale || util.getParams('scale')) {
1078
- util.setScale();
1079
- window.addEventListener('resize', this.setScale);
1080
- }
1081
- this.code = util.getParams('code');
1082
- if (this.code) {
1083
- this.doWechatLogin(this.code);
1084
- } else {
1085
- this.getLogin();
1086
- document.addEventListener('keyup', this.doLogin);
1087
- document.addEventListener('keydown', this.forbiddenTab);
1088
- }
1089
- this.init();
1090
- },
1091
- mounted() {
1092
- this.getRemember();
1093
- //delete util.win.websocket;
1094
- },
1095
- methods: {
1096
- init() {
1097
- let loginBoxAlign = localStorage.getItem('loginBoxAlign');
1098
- loginBoxAlign && (this.align = loginBoxAlign);
1099
- },
1100
- doWechatLogin(code) {
1101
- util
1102
- .ajax({
1103
- method: 'post',
1104
- url: this.doWechatQrLogin,
1105
- data: { code: code }
1106
- })
1107
- .then((res) => {
1108
- if (res.rCode == 0) {
1109
- const results = res.results;
1110
- this.handleResults(results);
1111
- } else {
1112
- const msg =
1113
- res.results && res.results.msg ? res.results.msg : res.msg;
1114
- this.$message({
1115
- message: msg || '系统错误,请联系管理员!',
1116
- type: 'error',
1117
- onClose: () => {
1118
- window.location.href = util.delUrlParam({ key: 'code' });
1119
- if (window.location.hash) {
1120
- location.reload();
1121
- }
1122
- }
1123
- });
1124
- }
1125
- })
1126
- .catch((err) => {
1127
- if (err.message && err.message !== 'canceled') {
1128
- this.$message.error(err.message);
1129
- }
1130
- });
1131
- },
1132
- getBackground(res) {
1133
- let style = {};
1134
- if (!res || (Array.isArray(res) && !res.length)) {
1135
- return style;
1136
- }
1137
- if (Array.isArray(res)) {
1138
- let url = [];
1139
- let image = [];
1140
- res.forEach((item) => {
1141
- if (item.indexOf('url(') > -1) {
1142
- url.push(item);
1143
- } else {
1144
- image.push(`url(${item})`);
1145
- }
1146
- });
1147
- if (url.length == res.length) {
1148
- style = { background: url.join(',') };
1149
- } else if (image.length == res.length) {
1150
- style = { 'background-image': image.join(',') };
1151
- } else {
1152
- console.error('设置的样式不一致!');
1153
- }
1154
- } else if (util.isObject(res)) {
1155
- style = res;
1156
- } else if (res.indexOf('url(') > -1) {
1157
- style = { background: res };
1158
- } else {
1159
- style = { 'background-image': `url(${res})` };
1160
- }
1161
- return style;
1162
- },
1163
- getRemember(user) {
1164
- let values = localStorage.getItem('unpd');
1165
- let value = {};
1166
- if (values) {
1167
- try {
1168
- values = JSON.parse(values);
1169
- let users = [];
1170
- for (let i in values) {
1171
- let k = util.esDecode(i);
1172
- value[k] = util.esDecode(values[i]);
1173
- users.push({ value: k });
1174
- }
1175
- this.users = users;
1176
- let keys = Object.keys(value);
1177
- if (keys.length) {
1178
- this.checked = true;
1179
- }
1180
- if (!user && keys.length == 1) {
1181
- user = keys[0];
1182
- // user = localStorage.getItem('remember');
1183
- // if (user) {
1184
- // user = util.esDecode(user);
1185
- // } else {
1186
- // user = keys[0];
1187
- // }
1188
- }
1189
- if (keys.length > 1) {
1190
- this.focusShow = true;
1191
- }
1192
- if (user) {
1193
- this.$set(this.formData, 'username', user);
1194
- this.$set(this.formData, 'password', value[user]);
1195
- }
1196
- } catch (error) {
1197
- localStorage.removeItem('unpd');
1198
- }
1199
- }
1200
- },
1201
- handleBlur(res) {
1202
- this.getRemember(res.value);
1203
- },
1204
- handleRemember() {
1205
- let values = localStorage.getItem('unpd');
1206
- let value = {};
1207
- if (values) {
1208
- values = JSON.parse(values);
1209
- for (let i in values) {
1210
- value[util.esDecode(i)] = util.esDecode(values[i]);
1211
- }
1212
- }
1213
- if (this.checked) {
1214
- //localStorage.setItem('remember', util.esEncode(this.formData.username));
1215
- value[this.formData.username] = this.formData.password;
1216
- let data = {};
1217
- for (let i in value) {
1218
- data[util.esEncode(i)] = util.esEncode(value[i]);
1219
- }
1220
- localStorage.setItem('unpd', JSON.stringify(data));
1221
- } else {
1222
- delete value[this.formData.username];
1223
- if (Object.keys(value)) {
1224
- let data = {};
1225
- for (let i in value) {
1226
- data[util.esEncode(i)] = util.esEncode(value[i]);
1227
- }
1228
- localStorage.setItem('unpd', JSON.stringify(data));
1229
- } else {
1230
- localStorage.removeItem('unpd');
1231
- }
1232
- //localStorage.removeItem('remember');
1233
- }
1234
- },
1235
- // 下载app的弹窗
1236
- handleDownLoadApp() {
1237
- if (this.onDownLoadApp) {
1238
- if (typeof this.onDownLoadApp === 'function') {
1239
- this.onDownLoadApp();
1240
- } else {
1241
- this.$emit('handleDownLoadApp');
1242
- this.$emit('handle-down-load-app');
1243
- }
1244
- } else {
1245
- this.showDownLoadApp = true;
1246
- }
1247
- },
1248
- handleDownLoadApps() {
1249
- if (this.downloadApp) {
1250
- window.open(this.downloadApp);
1251
- } else {
1252
- this.handleDownLoadApp();
1253
- }
1254
- },
1255
- switchLogin(res) {
1256
- if (res.type != '1') {
1257
- this.active = res.type;
1258
- this.title = res.name;
1259
- Object.keys(this.defaultModel).length &&
1260
- (this.formData = JSON.parse(JSON.stringify(this.defaultModel)));
1261
- this.$emit('change-type', res, this.identifyingId);
1262
- this.$nextTick(() => {
1263
- let ref = 'login' + this.active;
1264
- this.$refs[ref] && this.$refs[ref].clearValidate();
1265
- });
1266
- } else {
1267
- this.submit = true;
1268
- this.$refs.calogin && this.$refs.calogin.getCertificate();
1269
- }
1270
- this.countdown = 0;
1271
- },
1272
- switchLoginType(res) {
1273
- this.countdown = 0;
1274
- if (res) {
1275
- this.switchActive = res.type;
1276
- this.title = res.name || '';
1277
- if (this.loginModel.indexOf(res.type) > -1) {
1278
- this.active = res.type;
1279
- } else {
1280
- let other = this.switchs.filter((item) => {
1281
- return item.type != res.type;
1282
- })[0];
1283
- let model = this.loginModel.split(',').filter((item) => {
1284
- return item != res.type && item != other.type;
1285
- })[0];
1286
- if (model) {
1287
- this.active = model;
1288
- this.title = this.iconfonts[model].name;
1289
- } else {
1290
- console.error('complex风格的登录方式,loginModel配置错误!');
1291
- }
1292
- }
1293
- } else {
1294
- this.active = this.switchs[0].type;
1295
- this.title = '';
1296
- this.switchActive = this.switchs[0].type;
1297
- }
1298
- this.$emit('change-type', res, this.identifyingId);
1299
- this.$nextTick(() => {
1300
- let ref = 'login' + this.active;
1301
- this.$refs[ref] && this.$refs[ref].clearValidate();
1302
- });
1303
- },
1304
- isShow(res) {
1305
- return this.loginModel.indexOf(res) > -1;
1306
- },
1307
- async getLogin() {
1308
- const config = util.getStorage('initLogin');
1309
- if (config) {
1310
- this.setConfig(JSON.parse(config));
1311
- }
1312
- await util
1313
- .ajax({ url: this.initLogin })
1314
- .then((res) => {
1315
- if (res && res.rCode === 0) {
1316
- store.set('initLogin', res.results);
1317
- util.setStorage({
1318
- type: 'localStorage',
1319
- key: 'initLogin',
1320
- value: JSON.stringify(res.results)
1321
- });
1322
- this.$emit('initLogin', res.results);
1323
- this.setConfig(res.results, true);
1324
- } else {
1325
- this.$message({
1326
- message: res.msg || '系统错误,请联系管理员!',
1327
- type: 'error'
1328
- });
1329
- }
1330
- })
1331
- .catch((err) => {
1332
- if (err.message && err.message !== 'canceled') {
1333
- this.$message.error(err.message);
1334
- }
1335
- });
1336
- },
1337
- setConfig(res, ajax) {
1338
- const isLogined = localStorage.getItem('isLogined');
1339
- this.identifyingId = res.identifyingId || '';
1340
- this.getImgCode();
1341
- let downloads = {};
1342
- if (res.androidDownloadUrl) {
1343
- downloads['android'] = res.androidDownloadUrl;
1344
- }
1345
- if (res.iosDownloadUrl) {
1346
- downloads['ios'] = res.iosDownloadUrl;
1347
- }
1348
- if (res.iosDownloadUrl2) {
1349
- downloads['pad'] = res.iosDownloadUrl2;
1350
- }
1351
- if (res.macDownloadUrl) {
1352
- downloads['mac'] = res.macDownloadUrl;
1353
- }
1354
- if (res.winDownloadUrl) {
1355
- downloads['win'] = res.winDownloadUrl;
1356
- }
1357
- if (res.linuxDownloadUrl) {
1358
- downloads['linux'] = res.linuxDownloadUrl;
1359
- }
1360
- if (res.harmonyDownloadUrl) {
1361
- downloads['harmony'] = res.harmonyDownloadUrl;
1362
- }
1363
- this.sysName = res.subsystemName;
1364
- this.secret = res.secret;
1365
- this.setup = res.setup;
1366
- this.downloadSetup = res.downloadSetup;
1367
- if (res.subsystemName) {
1368
- document.title = res.subsystemName;
1369
- }
1370
- this.app = res.appName || res.subsystemName;
1371
- if (res.loginModel && !this.isCeshi) {
1372
- this.loginModel =
1373
- (res.firstLoginModel || this.firstLoginModel) && !isLogined
1374
- ? res.firstLoginModel || this.firstLoginModel
1375
- : res.loginModel;
1376
- }
1377
-
1378
- if (res.loginBackgroundUrl) {
1379
- this.loginBackgroundImg = res.loginBackgroundUrl.split(',');
1380
- }
1381
- if (res.loginLogoUrl) {
1382
- this.loginLogoImg = res.loginLogoUrl;
1383
- }
1384
- if (res.caModel) {
1385
- this.caLoginModel = res.caModel;
1386
- }
1387
- res.loginPage && sessionStorage.setItem('loginPage', res.loginPage);
1388
- if (res.subsystemExtend && Object.keys(res.subsystemExtend).length) {
1389
- if (
1390
- res.subsystemExtend.copyright &&
1391
- res.subsystemExtend.copyright.length
1392
- ) {
1393
- this.copyright = JSON.parse(res.subsystemExtend.copyright);
1394
- }
1395
- if (res.subsystemExtend.qrimg || res.subsystemExtend.qrImg) {
1396
- this.qrimg = res.subsystemExtend.qrimg || res.subsystemExtend.qrImg;
1397
- }
1398
- //忘记密码地址
1399
- if (
1400
- res.subsystemExtend.forgetPassUrl ||
1401
- res.subsystemExtend.look_pass_url
1402
- ) {
1403
- this.forgetUrl =
1404
- res.subsystemExtend.forgetPassUrl ||
1405
- res.subsystemExtend.look_pass_url;
1406
- }
1407
- res.subsystemExtend.loginPage &&
1408
- sessionStorage.setItem('loginPage', res.subsystemExtend.loginPage);
1409
- if (res.subsystemExtend.login_url) {
1410
- this.actionUrl = res.subsystemExtend.login_url;
1411
- }
1412
- if (res.subsystemExtend.loginModel) {
1413
- this.loginModel = res.subsystemExtend.loginModel;
1414
- }
1415
- if (res.subsystemExtend.firstLoginModel && !isLogined) {
1416
- this.loginModel = res.subsystemExtend.firstLoginModel;
1417
- }
1418
- if (res.subsystemExtend.caModel) {
1419
- this.caLoginModel = res.subsystemExtend.caModel;
1420
- }
1421
- if (res.subsystemExtend.applicationName) {
1422
- localStorage.setItem('appcode', res.subsystemExtend.applicationName);
1423
- }
1424
- if (res.subsystemExtend.loginBoxBackgroun) {
1425
- this.loginMainImg = res.subsystemExtend.loginBoxBackground.split(',');
1426
- }
1427
- if (res.subsystemExtend.loginBoxTitle) {
1428
- this.loginTitleImg = res.subsystemExtend.loginBoxTitle;
1429
- }
1430
- if (res.subsystemExtend.loginBoxName) {
1431
- this.loginNameImg = res.subsystemExtend.loginBoxName;
1432
- }
1433
- if (res.subsystemExtend.loginBoxAlign && this.useResults) {
1434
- localStorage.setItem(
1435
- 'loginBoxAlign',
1436
- res.subsystemExtend.loginBoxAlign
1437
- );
1438
- this.align = res.subsystemExtend.loginBoxAlign;
1439
- }
1440
- if (res.subsystemExtend.themeColor) {
1441
- util.updateTheme(res.subsystemExtend.themeColor);
1442
- localStorage.setItem('theme', res.subsystemExtend.themeColor);
1443
- }
1444
- if (res.subsystemExtend.macDownloadUrl) {
1445
- downloads.mac = res.subsystemExtend.macDownloadUrl;
1446
- }
1447
- if (res.subsystemExtend.winDownloadUrl) {
1448
- downloads.win = res.subsystemExtend.winDownloadUrl;
1449
- }
1450
- if (res.subsystemExtend.linuxDownloadUrl) {
1451
- downloads.linux = res.subsystemExtend.linuxDownloadUrl;
1452
- }
1453
- if (res.subsystemExtend.uosDownloadUrl) {
1454
- downloads.uos = res.subsystemExtend.uosDownloadUrl;
1455
- }
1456
-
1457
- if (res.subsystemExtend.harmonyDownloadUrl) {
1458
- downloads.harmony = res.subsystemExtend.harmonyDownloadUrl;
1459
- }
1460
- if (res.subsystemExtend.warningText) {
1461
- this.warningText = res.subsystemExtend.warningText;
1462
- }
1463
- if (res.subsystemExtend.launchTime) {
1464
- this.launchTime = parseInt(res.subsystemExtend.launchTime, 10);
1465
- }
1466
- if (res.subsystemExtend.launchImage) {
1467
- if (!this.launchShow) {
1468
- this.launchShow = true;
1469
- }
1470
- if (
1471
- res.subsystemExtend.launchImage != 'true' &&
1472
- res.subsystemExtend.launchImage != true
1473
- ) {
1474
- this.launchImages =
1475
- res.subsystemExtend.launchImage.indexOf('{') > -1 &&
1476
- res.subsystemExtend.launchImage.indexOf('}') > -1
1477
- ? JSON.parse(res.subsystemExtend.launchImage)
1478
- : res.subsystemExtend.launchImage;
1479
- }
1480
- }
1481
- if (res.subsystemExtend.loginDownloadApp) {
1482
- this.loginDownloadApp = res.subsystemExtend.loginDownloadApp;
1483
- }
1484
- if (res.subsystemExtend.caInstallPath) {
1485
- this.installPath = res.subsystemExtend.caInstallPath;
1486
- }
1487
- if (res.subsystemExtend.storageType) {
1488
- this.storageType = res.subsystemExtend.storageType;
1489
- }
1490
- if (res.subsystemExtend.alertContent) {
1491
- ajax && this.alertContent(res.subsystemExtend.alertContent);
1492
- }
1493
- }
1494
- this.passModifyModel = res.passModifyModel;
1495
- this.wechatAppid = res.wechatAppid;
1496
- this.wechatScope = res.wechatScope;
1497
- this.download = { ...this.downLoadUrls, ...downloads };
1498
- if (res.sysLogoIco) {
1499
- localStorage.setItem('sysLogoIco', res.sysLogoIco);
1500
- util.setFavicon(res.sysLogoIco);
1501
- }
1502
- },
1503
- async alertContent(contents) {
1504
- let { content, title, ...config } = JSON.parse(contents);
1505
- const regex = /\.md$/;
1506
- let isMarkdown = regex.test(content);
1507
- if (isMarkdown) {
1508
- content = await util.ajax({ url: content });
1509
- content = this.renderMarkdown(content);
1510
- }
1511
- this.$alert(content, title, {
1512
- dangerouslyUseHTMLString: isMarkdown,
1513
- setHeight: isMarkdown,
1514
- customClass: 'es-login-alert',
1515
- ...config
1516
- })
1517
- .then(() => {
1518
- this.alertCallback(1, { content, title, ...config });
1519
- })
1520
- .catch(() => {
1521
- this.alertCallback(0, { content, title, ...config });
1522
- });
1523
- },
1524
- async downloadMdFile(url) {
1525
- try {
1526
- const response = await fetch(url);
1527
- if (!response.ok) {
1528
- throw new Error(`下载失败: ${response.statusText}`);
1529
- }
1530
- return await response.text();
1531
- } catch (error) {
1532
- console.error('MD文件下载出错:', error);
1533
- throw error; // 抛出错错误供调用者处理
1534
- }
1535
- },
1536
- renderMarkdown(content) {
1537
- // 这里使用简单的正则替换示例,实际项目建议使用成熟库如marked、markdown-it等
1538
- // 生产环境推荐: npm install marked 后引入使用
1539
- let html = content
1540
- // 处理标题
1541
- .replace(/^#{1,6}\s+(.*?)$/gm, (match, text, level) => {
1542
- const hLevel = match.indexOf('#');
1543
- return `<h${hLevel}>${text}</h${hLevel}>`;
1544
- })
1545
- // 处理粗体
1546
- .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
1547
- // 处理斜体
1548
- .replace(/\*(.*?)\*/g, '<em>$1</em>')
1549
- // 处理链接
1550
- .replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2" target="_blank">$1</a>')
1551
- // 处理换行
1552
- .replace(/\n/g, '<br>');
1553
- return html;
1554
- },
1555
- getImgCode() {
1556
- if (this.identifyingId === '') {
1557
- return;
1558
- }
1559
- this.imageCode =
1560
- util.getStorage('host') +
1561
- this.codeAction +
1562
- '?identifyingId=' +
1563
- this.identifyingId +
1564
- (this.imgCode && typeof this.imgCode == 'object'
1565
- ? '&' + util.queryParams(this.imgCode)
1566
- : '') +
1567
- '&heightflag=' +
1568
- Math.random().toString().split('.')[1];
1569
- delete this.formData.identifyingCode;
1570
- delete this.formData.verificationCode;
1571
- return this.imageCode;
1572
- },
1573
- getCode() {
1574
- if (this.countdown) {
1575
- return false;
1576
- }
1577
- let data = {};
1578
- let flag = false;
1579
- let ref = 'login' + this.active;
1580
- if (this.active == 12) {
1581
- if (!this.formData.username) {
1582
- this.$refs[ref].validateField('username');
1583
- return false;
1584
- }
1585
- this.$refs[ref].validateField('username', (res) => {
1586
- flag = res != '';
1587
- });
1588
- if (flag) {
1589
- return false;
1590
- }
1591
- data = {
1592
- username: this.formData.username,
1593
- targetType: this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS'
1594
- // targetType: 'SMS'
1595
- };
1596
- } else {
1597
- if (!this.formData.target) {
1598
- this.$refs[ref].validateField('target');
1599
- return false;
1600
- }
1601
- this.$refs[ref].validateField('target', (res) => {
1602
- flag = res != '';
1603
- });
1604
- if (flag) {
1605
- return false;
1606
- }
1607
- data = {
1608
- target: this.formData.target,
1609
- targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1610
- };
1611
- }
1612
- this.countdown = 60;
1613
- this.timer = setInterval(() => {
1614
- if (this.countdown > 0) {
1615
- this.countdown--;
1616
- this.disabled = true;
1617
- this.btnText = '重新获取' + this.countdown + 's';
1618
- } else {
1619
- this.btnText = '重新获取';
1620
- this.disabled = false;
1621
- this.submit = false;
1622
- }
1623
- }, 1000);
1624
- util
1625
- .ajax({
1626
- method: 'post',
1627
- url:
1628
- this.active == 12 ? this.getTwoFactorLoginCode : this.getLoginCode,
1629
- data: data
1630
- })
1631
- .then((res) => {
1632
- this.$message({
1633
- message: res.msg,
1634
- duration: res.rCode == 0 ? 2000 : 3000,
1635
- type: res.rCode == 0 ? 'success' : 'error'
1636
- });
1637
-
1638
- if (res.rCode === 2) {
1639
- this.btnText = '获取验证码';
1640
- this.disabled = false;
1641
- this.countdown = 0;
1642
- clearInterval(this.timer);
1643
- }
1644
- })
1645
- .catch((err) => {
1646
- if (err.message && err.message !== 'canceled') {
1647
- this.$message.error(err.message);
1648
- }
1649
- });
1650
- },
1651
- handleLogin() {
1652
- if (this.submit) {
1653
- return false;
1654
- }
1655
- let ref = 'login' + this.active;
1656
- this.$refs[ref].validate((valid) => {
1657
- if (valid) {
1658
- this.submit = true;
1659
- let param = util.getParams() || {};
1660
- const data =
1661
- this.active == '0'
1662
- ? {
1663
- username: this.formData.username,
1664
- password:
1665
- this.secret && this.isEncrypt
1666
- ? util.esmEncrypt({
1667
- data: this.formData.password,
1668
- key: this.secret
1669
- })
1670
- : this.formData.password,
1671
- identifyingCode: this.formData.identifyingCode,
1672
- identifyingId: this.identifyingId
1673
- }
1674
- : this.active == '12'
1675
- ? {
1676
- username: this.formData.username,
1677
- password:
1678
- this.secret && this.isEncrypt
1679
- ? util.esmEncrypt({
1680
- data: this.formData.password,
1681
- key: this.secret
1682
- })
1683
- : this.formData.password,
1684
- targetType:
1685
- this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS',
1686
- verificationCode: this.formData.identifyingCode
1687
- }
1688
- : {
1689
- target: this.formData.target,
1690
- verificationCode: this.formData.verificationCode,
1691
- targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1692
- };
1693
- if (this.onLogin) {
1694
- if (this.active == '0') {
1695
- this.onLogin(
1696
- { ...param, ...data },
1697
- this.getImgCode,
1698
- this.handleRemember
1699
- );
1700
- } else {
1701
- this.onLogin({ ...param, ...data });
1702
- }
1703
- } else {
1704
- this.handleUserLogin({ ...param, ...this.param, ...data });
1705
- }
1706
- } else {
1707
- this.submit = false;
1708
- return false;
1709
- }
1710
- });
1711
- },
1712
- doLogin(e) {
1713
- if (util.win.event == undefined) {
1714
- var key = e.keyCode;
1715
- } else {
1716
- var key = util.win.event.keyCode;
1717
- }
1718
- if (key == 13) {
1719
- this.handleLogin();
1720
- }
1721
- },
1722
- handleUserLogin(data) {
1723
- let extUserBindHandleId = sessionStorage.getItem('extUserBindHandleId');
1724
- util
1725
- .ajax({
1726
- method: 'post',
1727
- url:
1728
- this.active == '0'
1729
- ? this.actionUrl
1730
- : this.active == '12'
1731
- ? this.doTwoFactorLogin
1732
- : this.doCodeLogin,
1733
- data: extUserBindHandleId
1734
- ? { ...data, extUserBindHandleId: extUserBindHandleId }
1735
- : data
1736
- })
1737
- .then((res) => {
1738
- this.submit = false;
1739
- if (res.rCode == 0) {
1740
- util.removeStorage('extUserBindHandleId');
1741
- this.handleRemember();
1742
- const results = res.results;
1743
- this.handleResults(results);
1744
- if (this.onSuccess) {
1745
- this.onSuccess(res);
1746
- }
1747
- } else {
1748
- const msg =
1749
- res.results && res.results.msg ? res.results.msg : res.msg;
1750
- this.$message({
1751
- message: msg || '系统错误,请联系管理员!',
1752
- type: 'error',
1753
- onClose: () => {
1754
- this.btnText = '获取验证码';
1755
- this.disabled = false;
1756
- this.countdown = 0;
1757
- clearInterval(this.timer);
1758
- this.getImgCode();
1759
- }
1760
- });
1761
- this.onError(res);
1762
- }
1763
- })
1764
- .catch((err) => {
1765
- this.submit = false;
1766
- if (err.message && err.message !== 'canceled') {
1767
- this.$message.error(err.message);
1768
- }
1769
- });
1770
- },
1771
- caLogin(signedData) {
1772
- this.loginInfo(false);
1773
- util
1774
- .ajax({
1775
- method: 'post',
1776
- url: this.caAction,
1777
- data:
1778
- typeof signedData === 'string'
1779
- ? { identifyingId: this.identifyingId, signedData: signedData }
1780
- : signedData
1781
- })
1782
- .then((res) => {
1783
- this.submit = false;
1784
- if (res.rCode == 0) {
1785
- const results = res.results;
1786
- this.handleResults(results);
1787
- if (this.onSuccess) {
1788
- this.onSuccess(res);
1789
- }
1790
- } else {
1791
- const msg =
1792
- res.results && res.results.msg ? res.results.msg : res.msg;
1793
- this.$message({
1794
- message: msg || '系统错误,请联系管理员!',
1795
- type: 'error',
1796
- onClose: () => {
1797
- this.getImgCode();
1798
- this.loginInfo(this.active == 3);
1799
- }
1800
- });
1801
- this.onError(res);
1802
- }
1803
- })
1804
- .catch((err) => {
1805
- this.submit = false;
1806
- if (err.message && err.message !== 'canceled') {
1807
- this.$message.error(err.message);
1808
- }
1809
- });
1810
- },
1811
- handleForget() {
1812
- if (typeof this.forgetUrl === 'string') {
1813
- util.win.open(this.forgetUrl);
1814
- } else {
1815
- this.showResetPassword = true;
1816
- }
1817
- },
1818
- downloadExe() {
1819
- util.win.open(this.downloadSetup);
1820
- },
1821
- //获取app登录信息
1822
- loginInfo(res) {
1823
- clearTimeout(this.interval);
1824
- if (res) {
1825
- this.interval = setTimeout(() => {
1826
- this.initRequestLoginInfo();
1827
- }, this.scanIntervalTime);
1828
- }
1829
- },
1830
- initRequestLoginInfo() {
1831
- if (this.identifyingId == '') {
1832
- return false;
1833
- }
1834
- util
1835
- .ajax({
1836
- method: 'post',
1837
- url: this.scanAction,
1838
- data: {
1839
- identifyingId: this.identifyingId
1840
- }
1841
- })
1842
- .then((res) => {
1843
- if (res.rCode === 0) {
1844
- const results = res.results;
1845
- if (results.statusCode === 0 || results.statusCode === 2) {
1846
- // statusCode为2时 代表密码过期,也应执行handleResults
1847
- clearTimeout(this.interval);
1848
- if (results.statusCode === 2) {
1849
- this.$alert(
1850
- results.msg
1851
- ? results.msg
1852
- : '您的初始密码已过期,请及时修改!',
1853
- '提示',
1854
- {
1855
- confirmButtonText: '确定',
1856
- type: 'warning'
1857
- }
1858
- )
1859
- .then(() => {
1860
- this.handleResults(results, 3);
1861
- })
1862
- .catch((e) => {});
1863
- } else {
1864
- this.handleResults(results, 3);
1865
- }
1866
- } else {
1867
- this.loginInfo(true);
1868
- }
1869
- }
1870
- })
1871
- .catch((err) => {
1872
- clearTimeout(this.interval);
1873
- if (err.message && err.message !== 'canceled') {
1874
- this.$message.error(err.message);
1875
- }
1876
- });
1877
- },
1878
- handleResults(results, type) {
1879
- switch (results.statusCode) {
1880
- case 0:
1881
- this.userName = results.userName;
1882
- util.setStorage({
1883
- type: this.storageType,
1884
- key: {
1885
- ssId: results.ssId,
1886
- token: results.token,
1887
- Authorization: results.token,
1888
- deviceUnique: results.deviceUnique,
1889
- userId: results.userId,
1890
- userName: results.userName,
1891
- useCaseCodes: results.resourceCodes
1892
- }
1893
- });
1894
- if (this.launchShow) {
1895
- this.$message({
1896
- message: '登录成功!',
1897
- type: 'success',
1898
- duration: 1000
1899
- });
1900
- this.showLaunch = true;
1901
- setTimeout(() => {
1902
- if (this.toUrl) {
1903
- window.location.href = this.toUrl;
1904
- } else if (results.doorIndex && this.doorIndex) {
1905
- sessionStorage.setItem('doorIndex', results.doorIndex);
1906
- localStorage.setItem('isLogined', true);
1907
- window.location.href = results.doorIndex;
1908
- } else {
1909
- if (window.location.href.indexOf('login.html') > -1) {
1910
- window.location.href = './main.html';
1911
- } else {
1912
- this.$router.push({ name: 'main' });
1913
- this.$nextTick(() => {
1914
- this.showLaunch = false;
1915
- });
1916
- }
1917
- }
1918
- }, this.launchTime);
1919
- } else {
1920
- this.$message({
1921
- message: '登录成功!',
1922
- type: 'success',
1923
- duration: 1500,
1924
- onClose: () => {
1925
- if (this.toUrl) {
1926
- window.location.href = this.toUrl;
1927
- } else if (results.doorIndex && this.doorIndex) {
1928
- sessionStorage.setItem('doorIndex', results.doorIndex);
1929
- localStorage.setItem('isLogined', true);
1930
- window.location.href = results.doorIndex;
1931
- } else {
1932
- if (window.location.href.indexOf('login.html') > -1) {
1933
- window.location.href = './main.html';
1934
- } else {
1935
- this.$router.push({ name: 'main' });
1936
- }
1937
- }
1938
- }
1939
- });
1940
- }
1941
- break;
1942
- case 2:
1943
- this.$confirm(
1944
- results.msg ? results.msg : '密码太简单了, 请修改密码?',
1945
- '提示',
1946
- {
1947
- confirmButtonText: '确定',
1948
- //cancelButtonText: '取消',
1949
- type: 'warning'
1950
- }
1951
- )
1952
- .then(() => {
1953
- this.operationCheckCode = results.checkCode;
1954
- if (typeof this.forgetUrl === 'string') {
1955
- util.win.open(this.forgetUrl);
1956
- } else {
1957
- this.showResetPassword = true;
1958
- }
1959
- })
1960
- .catch((e) => {});
1961
- break;
1962
- case 3:
1963
- let url =
1964
- results.doorIndex && this.doorIndex
1965
- ? results.doorIndex
1966
- : window.location.href.indexOf('main.html') > -1
1967
- ? './login.html'
1968
- : window.location.hash
1969
- ? window.location.href.replace('login', 'main')
1970
- : window.location.href;
1971
- const href = results.authorizeUrl.replace(
1972
- '{redirectUri}',
1973
- encodeURIComponent(url)
1974
- );
1975
- window.location.href = href;
1976
- // window.location.href =
1977
- // results.authorizeUrl.indexOf('?') > -1
1978
- // ? results.authorizeUrl + '&token=' + results.token
1979
- // : results.authorizeUrl + '?token=' + results.token;
1980
- break;
1981
- case 4:
1982
- this.$alert(
1983
- results.msg ? results.msg : '账号未绑定,账号密码登录后自动绑定!',
1984
- '提示',
1985
- {
1986
- confirmButtonText: '确定',
1987
- type: 'error'
1988
- }
1989
- )
1990
- .then(() => {
1991
- sessionStorage.setItem(
1992
- 'extUserBindHandleId',
1993
- results.extUserBindHandleId
1994
- );
1995
- window.location.href = util.delUrlParam({ key: 'code' });
1996
- if (window.location.hash) {
1997
- location.reload();
1998
- }
1999
- })
2000
- .catch((e) => {});
2001
- break;
2002
- case 102:
2003
- this.checkCode = results.checkCode;
2004
- this.showAssistance = true;
2005
- let { operationCheckCode } = JSON.parse(results.checkCode);
2006
- this.handleAssistance({ operationCheckCode });
2007
- break;
2008
- default:
2009
- if (type !== 3) {
2010
- this.$message({
2011
- message: results.msg,
2012
- type: 'error',
2013
- onClose: () => {
2014
- if (this.code) {
2015
- window.location.href = util.delUrlParam({ key: 'code' });
2016
- if (window.location.hash) {
2017
- location.reload();
2018
- }
2019
- } else {
2020
- this.getImgCode();
2021
- }
2022
- }
2023
- });
2024
- } else if (this.active == 3) {
2025
- this.loginInfo(true);
2026
- }
2027
- }
2028
- },
2029
- handleAssistance(data) {
2030
- clearTimeout(this.doAssistance);
2031
- this.doAssistance = setTimeout(() => {
2032
- this.doAssistanceLogin(data);
2033
- }, this.scanIntervalTime);
2034
- },
2035
- doAssistanceLogin(data) {
2036
- util
2037
- .ajax({
2038
- method: 'post',
2039
- url: doAssistanceQrLogin,
2040
- data: data
2041
- })
2042
- .then((res) => {
2043
- if (res.rCode === 0) {
2044
- const results = res.results;
2045
- if (results.statusCode === 0) {
2046
- clearTimeout(this.doAssistance);
2047
- this.handleResults(results, 3);
2048
- } else {
2049
- this.handleAssistance(data);
2050
- }
2051
- } else {
2052
- clearTimeout(this.doAssistance);
2053
- this.$message.error(res.msg);
2054
- }
2055
- })
2056
- .catch((err) => {
2057
- clearTimeout(this.doAssistance);
2058
- if (err.message && err.message !== 'canceled') {
2059
- this.$message.error(err.message);
2060
- }
2061
- });
2062
- },
2063
- closeAssistance() {
2064
- clearTimeout(this.doAssistance);
2065
- },
2066
- handleSuccess() {
2067
- this.showResetPassword = false;
2068
- },
2069
- forbiddenTab(e) {
2070
- if (e.keyCode == 9) {
2071
- return false;
2072
- }
2073
- },
2074
- handlePaste(event) {
2075
- this.safe && event.preventDefault();
2076
- },
2077
- handleError() {
2078
- this.submit = false;
2079
- }
2080
- },
2081
- beforeDestroy() {
2082
- window.removeEventListener('resize', this.setScale);
2083
- document.removeEventListener('keyup', this.doLogin);
2084
- document.removeEventListener('keydown', this.forbiddenTab);
2085
- }
2086
- };
2087
- </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-shoushiyou"></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-yonghu 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-yanzhengma 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-saoma"></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-shoushiyou"></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="downloadLength == 1 ? '450px' : '80%'"
478
+ :height="downloadLength == 1 ? '500px' : '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
+ alertCallback: {
783
+ type: Function,
784
+ default: () => {}
785
+ }
786
+ },
787
+ computed: {
788
+ downloadLength() {
789
+ return this.download ? Object.keys(this.download).length : 0;
790
+ },
791
+ transform() {
792
+ let translate = this.translate
793
+ ? this.translate
794
+ : this.align === 'center'
795
+ ? '-50%, -51%'
796
+ : '-51%';
797
+ if (this.align.indexOf('%') > -1) {
798
+ return {
799
+ left: this.align,
800
+ top: '50%',
801
+ transform: `translateY(${translate})`
802
+ };
803
+ }
804
+ if (this.align === 'left') {
805
+ return {
806
+ left: '30%',
807
+ top: '50%',
808
+ transform: `translateY(${translate})`
809
+ };
810
+ }
811
+ if (this.align === 'right') {
812
+ return {
813
+ left: '70%',
814
+ top: '50%',
815
+ transform: `translateY(${translate})`
816
+ };
817
+ }
818
+ return {
819
+ left: '50%',
820
+ top: '50%',
821
+ transform: `translate(${translate})`
822
+ };
823
+ },
824
+ redirectUri() {
825
+ if (this.redirect_uri) {
826
+ return this.redirect_uri;
827
+ } else {
828
+ return window.location.href || window.href;
829
+ }
830
+ },
831
+ showWarnInfo() {
832
+ return this.$slots.warning || this.$scopedSlots.warning
833
+ ? false
834
+ : this.warningText
835
+ ? true
836
+ : false;
837
+ },
838
+ modelLength() {
839
+ return Array.isArray(this.loginModel)
840
+ ? this.loginModel.length
841
+ : this.loginModel.split(',').length;
842
+ },
843
+ iconfonts() {
844
+ const types = this.loginModel.split(',');
845
+ return types.length > 2
846
+ ? {
847
+ 0: {
848
+ type: '0',
849
+ icon: 'es-icon-jianpan',
850
+ icon2: '',
851
+ name: '账号登录'
852
+ },
853
+ 1: { type: '1', icon: 'es-icon-upan', name: '证书登录' },
854
+ 3: {
855
+ type: '3',
856
+ icon: 'es-icon-saoma1',
857
+ icon2: '',
858
+ name: '扫码登录'
859
+ },
860
+ 6: { type: '6', icon: 'es-icon-solid-duanxin', name: '短信登录' },
861
+ 7: { type: '7', icon: 'es-icon-dingding1', name: '钉钉扫码登录' },
862
+ 9: { type: '9', icon: 'es-icon-weixin1', name: '微信扫码登录' },
863
+ 11: { type: '11', icon: 'es-icon-youjian', name: '邮箱登录' },
864
+ 12: { type: '12', icon: 'es-icon-jianpan', name: '账号登录' } //双因素
865
+ }
866
+ : {
867
+ 0: { type: '0', icon: 'es-icon-solid-monitor', name: '账号登录' },
868
+ 1: {
869
+ type: '1',
870
+ icon: 'es-icon-solid-cashenfenrenzheng',
871
+ name: '证书登录'
872
+ },
873
+ 3: { type: '3', icon: 'es-icon-qrcode', name: '扫码登录' },
874
+ 6: { type: '6', icon: 'es-icon-solid-duanxin', name: '短信登录' },
875
+ 7: { type: '7', icon: 'es-icon-dingding', name: '钉钉扫码登录' },
876
+ 9: { type: '9', icon: 'es-icon-weixin', name: '微信扫码登录' },
877
+ 11: {
878
+ type: '11',
879
+ icon: 'es-icon-youjian',
880
+ name: '邮箱登录'
881
+ },
882
+ 12: { type: '12', icon: 'es-icon-solid-monitor', name: '账号登录' } //双因素
883
+ };
884
+ },
885
+ icons() {
886
+ let icon = [];
887
+ const types = this.loginModel.split(',');
888
+ types.forEach((item) => {
889
+ icon.push(this.iconfonts[item]);
890
+ });
891
+ return icon;
892
+ },
893
+ isCaLogin() {
894
+ return this.loginModel.indexOf('1') > -1;
895
+ },
896
+ showVerifyCode() {
897
+ return (
898
+ this.passModifyModel &&
899
+ (this.passModifyModel.indexOf('6') > -1 ||
900
+ this.passModifyModel.indexOf('11') > -1)
901
+ );
902
+ },
903
+ _launchImage() {
904
+ let img = util.isObject(this.launchImages)
905
+ ? this.launchImages[this.launchKey]
906
+ : this.launchImages;
907
+ return { 'background-image': `url(${img})` };
908
+ },
909
+ showForget() {
910
+ return this.forgetUrl && typeof this.forgetUrl === 'string'
911
+ ? true
912
+ : this.forgetUrl === true &&
913
+ this.loginModel.indexOf('0') > -1 &&
914
+ this.showVerifyCode;
915
+ },
916
+ isCeshi() {
917
+ return this.ceshi ? params[this.ceshi] : false;
918
+ }
919
+ },
920
+ watch: {
921
+ loginModel: {
922
+ immediate: true,
923
+ handler(val) {
924
+ this.active = val.split(',')[0];
925
+ this.title = this.iconfonts[this.active].name;
926
+ this.switchs.forEach((item) => {
927
+ if (item.type == this.active) {
928
+ this.switchActive = item.type;
929
+ return;
930
+ }
931
+ });
932
+ }
933
+ },
934
+ active: {
935
+ immediate: true,
936
+ handler(val) {
937
+ this.loginInfo(val == 3);
938
+ }
939
+ },
940
+ identifyingId(val) {
941
+ if (val) {
942
+ this.loginInfo(this.active == 3);
943
+ }
944
+ },
945
+ appName: {
946
+ immediate: true,
947
+ handler(val) {
948
+ if (val) {
949
+ this.app = val;
950
+ }
951
+ }
952
+ },
953
+ qrImage: {
954
+ immediate: true,
955
+ handler(val) {
956
+ if (val) {
957
+ this.qrimg = val;
958
+ }
959
+ }
960
+ },
961
+ checked(val) {
962
+ if (!val) {
963
+ localStorage.removeItem('unpd');
964
+ //localStorage.removeItem('remember');
965
+ }
966
+ }
967
+ // secret: {
968
+ // immediate: true,
969
+ // handler(val) {
970
+ // if (val) {
971
+ // if (this.storage) {
972
+ // localStorage.setItem('secret', val);
973
+ // } else {
974
+ // sessionStorage.setItem('secret', val);
975
+ // }
976
+ // }
977
+ // }
978
+ // }
979
+ },
980
+ data() {
981
+ return {
982
+ title: '',
983
+ align: this.position,
984
+ loginBackgroundImg: this.loginBackground,
985
+ loginMainImg: this.loginImage,
986
+ loginNameImg: this.loginName,
987
+ loginTitleImg: this.loginTitle,
988
+ loginLogoImg: this.loginLogo,
989
+ loginModel: this.type,
990
+ caLoginModel: this.caModel,
991
+ passModifyModel: null,
992
+ active: 0,
993
+ submit: false,
994
+ checked: false,
995
+ formData: this.model,
996
+ focusShow: false,
997
+ users: [],
998
+ imageCode: '',
999
+ secret: null,
1000
+ identifyingId: undefined,
1001
+ download: {},
1002
+ setup: '',
1003
+ sysName: '',
1004
+ copyright: this.copyrights,
1005
+ forgetUrl: this.forget,
1006
+ actionUrl: this.action,
1007
+ downloadSetup: '',
1008
+ app: '',
1009
+ qrimg: '',
1010
+ interval: null,
1011
+ showResetPassword: false,
1012
+ operationCheckCode: '',
1013
+ showDownLoadApp: false,
1014
+ wechatAppid: null,
1015
+ wechatScope: null,
1016
+ disabled: false,
1017
+ btnText: '获取验证码',
1018
+ timer: null,
1019
+ countdown: 0,
1020
+ code: null,
1021
+ defaultModel: JSON.parse(JSON.stringify(this.model)),
1022
+ checkCode: '',
1023
+ showAssistance: false,
1024
+ doAssistance: null,
1025
+ warningText: this.warning,
1026
+ safes: {
1027
+ paste: (event) => {
1028
+ event.preventDefault();
1029
+ return false;
1030
+ },
1031
+ contextmenu: (event) => {
1032
+ event.preventDefault();
1033
+ return false;
1034
+ },
1035
+ copy: (event) => {
1036
+ event.preventDefault();
1037
+ return false;
1038
+ },
1039
+ cut: (event) => {
1040
+ event.preventDefault();
1041
+ return false;
1042
+ }
1043
+ },
1044
+ userName: '',
1045
+ launchShow: this.launch,
1046
+ showLaunch: false,
1047
+ launchImages: this.launchImage,
1048
+ launchKey: 'day',
1049
+ launchTime: 2000,
1050
+ switchActive: this.switchsActive,
1051
+ loginDownloadApp: this.loginDownloadApps,
1052
+ installPath: this.caInstallPath,
1053
+ storageType: this.storage
1054
+ };
1055
+ },
1056
+ beforeCreate() {
1057
+ this.setScale = debounce(300, () => {
1058
+ util.setScale();
1059
+ });
1060
+ util.removeStorage([
1061
+ 'remind',
1062
+ 'ssId',
1063
+ 'token',
1064
+ 'Authorization',
1065
+ 'deviceUnique',
1066
+ 'userId',
1067
+ 'userName',
1068
+ 'useCaseCodes'
1069
+ ]);
1070
+ },
1071
+ created() {
1072
+ this.launchKey = 5 < new Date().getHours() < 18 ? 'day' : 'night';
1073
+ if (this.isCeshi) {
1074
+ this.loginModel =
1075
+ this.isCeshi == 'true' || this.isCeshi == true ? '0' : this.isCeshi;
1076
+ }
1077
+ if (this.isScale || util.getParams('scale')) {
1078
+ util.setScale();
1079
+ window.addEventListener('resize', this.setScale);
1080
+ }
1081
+ this.code = util.getParams('code');
1082
+ if (this.code) {
1083
+ this.doWechatLogin(this.code);
1084
+ } else {
1085
+ this.getLogin();
1086
+ document.addEventListener('keyup', this.doLogin);
1087
+ document.addEventListener('keydown', this.forbiddenTab);
1088
+ }
1089
+ this.init();
1090
+ },
1091
+ mounted() {
1092
+ this.getRemember();
1093
+ //delete util.win.websocket;
1094
+ },
1095
+ methods: {
1096
+ init() {
1097
+ let loginBoxAlign = localStorage.getItem('loginBoxAlign');
1098
+ loginBoxAlign && (this.align = loginBoxAlign);
1099
+ },
1100
+ doWechatLogin(code) {
1101
+ util
1102
+ .ajax({
1103
+ method: 'post',
1104
+ url: this.doWechatQrLogin,
1105
+ data: { code: code }
1106
+ })
1107
+ .then((res) => {
1108
+ if (res.rCode == 0) {
1109
+ const results = res.results;
1110
+ this.handleResults(results);
1111
+ } else {
1112
+ const msg =
1113
+ res.results && res.results.msg ? res.results.msg : res.msg;
1114
+ this.$message({
1115
+ message: msg || '系统错误,请联系管理员!',
1116
+ type: 'error',
1117
+ onClose: () => {
1118
+ window.location.href = util.delUrlParam({ key: 'code' });
1119
+ if (window.location.hash) {
1120
+ location.reload();
1121
+ }
1122
+ }
1123
+ });
1124
+ }
1125
+ })
1126
+ .catch((err) => {
1127
+ if (err.message && err.message !== 'canceled') {
1128
+ this.$message.error(err.message);
1129
+ }
1130
+ });
1131
+ },
1132
+ getBackground(res) {
1133
+ let style = {};
1134
+ if (!res || (Array.isArray(res) && !res.length)) {
1135
+ return style;
1136
+ }
1137
+ if (Array.isArray(res)) {
1138
+ let url = [];
1139
+ let image = [];
1140
+ res.forEach((item) => {
1141
+ if (item.indexOf('url(') > -1) {
1142
+ url.push(item);
1143
+ } else {
1144
+ image.push(`url(${item})`);
1145
+ }
1146
+ });
1147
+ if (url.length == res.length) {
1148
+ style = { background: url.join(',') };
1149
+ } else if (image.length == res.length) {
1150
+ style = { 'background-image': image.join(',') };
1151
+ } else {
1152
+ console.error('设置的样式不一致!');
1153
+ }
1154
+ } else if (util.isObject(res)) {
1155
+ style = res;
1156
+ } else if (res.indexOf('url(') > -1) {
1157
+ style = { background: res };
1158
+ } else {
1159
+ style = { 'background-image': `url(${res})` };
1160
+ }
1161
+ return style;
1162
+ },
1163
+ getRemember(user) {
1164
+ let values = localStorage.getItem('unpd');
1165
+ let value = {};
1166
+ if (values) {
1167
+ try {
1168
+ values = JSON.parse(values);
1169
+ let users = [];
1170
+ for (let i in values) {
1171
+ let k = util.esDecode(i);
1172
+ value[k] = util.esDecode(values[i]);
1173
+ users.push({ value: k });
1174
+ }
1175
+ this.users = users;
1176
+ let keys = Object.keys(value);
1177
+ if (keys.length) {
1178
+ this.checked = true;
1179
+ }
1180
+ if (!user && keys.length == 1) {
1181
+ user = keys[0];
1182
+ // user = localStorage.getItem('remember');
1183
+ // if (user) {
1184
+ // user = util.esDecode(user);
1185
+ // } else {
1186
+ // user = keys[0];
1187
+ // }
1188
+ }
1189
+ if (keys.length > 1) {
1190
+ this.focusShow = true;
1191
+ }
1192
+ if (user) {
1193
+ this.$set(this.formData, 'username', user);
1194
+ this.$set(this.formData, 'password', value[user]);
1195
+ }
1196
+ } catch (error) {
1197
+ localStorage.removeItem('unpd');
1198
+ }
1199
+ }
1200
+ },
1201
+ handleBlur(res) {
1202
+ this.getRemember(res.value);
1203
+ },
1204
+ handleRemember() {
1205
+ let values = localStorage.getItem('unpd');
1206
+ let value = {};
1207
+ if (values) {
1208
+ values = JSON.parse(values);
1209
+ for (let i in values) {
1210
+ value[util.esDecode(i)] = util.esDecode(values[i]);
1211
+ }
1212
+ }
1213
+ if (this.checked) {
1214
+ //localStorage.setItem('remember', util.esEncode(this.formData.username));
1215
+ value[this.formData.username] = this.formData.password;
1216
+ let data = {};
1217
+ for (let i in value) {
1218
+ data[util.esEncode(i)] = util.esEncode(value[i]);
1219
+ }
1220
+ localStorage.setItem('unpd', JSON.stringify(data));
1221
+ } else {
1222
+ delete value[this.formData.username];
1223
+ if (Object.keys(value)) {
1224
+ let data = {};
1225
+ for (let i in value) {
1226
+ data[util.esEncode(i)] = util.esEncode(value[i]);
1227
+ }
1228
+ localStorage.setItem('unpd', JSON.stringify(data));
1229
+ } else {
1230
+ localStorage.removeItem('unpd');
1231
+ }
1232
+ //localStorage.removeItem('remember');
1233
+ }
1234
+ },
1235
+ // 下载app的弹窗
1236
+ handleDownLoadApp() {
1237
+ if (this.onDownLoadApp) {
1238
+ if (typeof this.onDownLoadApp === 'function') {
1239
+ this.onDownLoadApp();
1240
+ } else {
1241
+ this.$emit('handleDownLoadApp');
1242
+ this.$emit('handle-down-load-app');
1243
+ }
1244
+ } else {
1245
+ this.showDownLoadApp = true;
1246
+ }
1247
+ },
1248
+ handleDownLoadApps() {
1249
+ if (this.downloadApp) {
1250
+ window.open(this.downloadApp);
1251
+ } else {
1252
+ this.handleDownLoadApp();
1253
+ }
1254
+ },
1255
+ switchLogin(res) {
1256
+ if (res.type != '1') {
1257
+ this.active = res.type;
1258
+ this.title = res.name;
1259
+ Object.keys(this.defaultModel).length &&
1260
+ (this.formData = JSON.parse(JSON.stringify(this.defaultModel)));
1261
+ this.$emit('change-type', res, this.identifyingId);
1262
+ this.$nextTick(() => {
1263
+ let ref = 'login' + this.active;
1264
+ this.$refs[ref] && this.$refs[ref].clearValidate();
1265
+ });
1266
+ } else {
1267
+ this.submit = true;
1268
+ this.$refs.calogin && this.$refs.calogin.getCertificate();
1269
+ }
1270
+ this.countdown = 0;
1271
+ },
1272
+ switchLoginType(res) {
1273
+ this.countdown = 0;
1274
+ if (res) {
1275
+ this.switchActive = res.type;
1276
+ this.title = res.name || '';
1277
+ if (this.loginModel.indexOf(res.type) > -1) {
1278
+ this.active = res.type;
1279
+ } else {
1280
+ let other = this.switchs.filter((item) => {
1281
+ return item.type != res.type;
1282
+ })[0];
1283
+ let model = this.loginModel.split(',').filter((item) => {
1284
+ return item != res.type && item != other.type;
1285
+ })[0];
1286
+ if (model) {
1287
+ this.active = model;
1288
+ this.title = this.iconfonts[model].name;
1289
+ } else {
1290
+ console.error('complex风格的登录方式,loginModel配置错误!');
1291
+ }
1292
+ }
1293
+ } else {
1294
+ this.active = this.switchs[0].type;
1295
+ this.title = '';
1296
+ this.switchActive = this.switchs[0].type;
1297
+ }
1298
+ this.$emit('change-type', res, this.identifyingId);
1299
+ this.$nextTick(() => {
1300
+ let ref = 'login' + this.active;
1301
+ this.$refs[ref] && this.$refs[ref].clearValidate();
1302
+ });
1303
+ },
1304
+ isShow(res) {
1305
+ return this.loginModel.indexOf(res) > -1;
1306
+ },
1307
+ async getLogin() {
1308
+ const config = util.getStorage('initLogin');
1309
+ if (config) {
1310
+ this.setConfig(JSON.parse(config));
1311
+ }
1312
+ await util
1313
+ .ajax({ url: this.initLogin })
1314
+ .then((res) => {
1315
+ if (res && res.rCode === 0) {
1316
+ store.set('initLogin', res.results);
1317
+ util.setStorage({
1318
+ type: 'localStorage',
1319
+ key: 'initLogin',
1320
+ value: JSON.stringify(res.results)
1321
+ });
1322
+ this.$emit('initLogin', res.results);
1323
+ this.setConfig(res.results, true);
1324
+ } else {
1325
+ this.$message({
1326
+ message: res.msg || '系统错误,请联系管理员!',
1327
+ type: 'error'
1328
+ });
1329
+ }
1330
+ })
1331
+ .catch((err) => {
1332
+ if (err.message && err.message !== 'canceled') {
1333
+ this.$message.error(err.message);
1334
+ }
1335
+ });
1336
+ },
1337
+ setConfig(res, ajax) {
1338
+ const isLogined = localStorage.getItem('isLogined');
1339
+ this.identifyingId = res.identifyingId || '';
1340
+ this.getImgCode();
1341
+ let downloads = {};
1342
+ if (res.androidDownloadUrl) {
1343
+ downloads['android'] = res.androidDownloadUrl;
1344
+ }
1345
+ if (res.iosDownloadUrl) {
1346
+ downloads['ios'] = res.iosDownloadUrl;
1347
+ }
1348
+ if (res.iosDownloadUrl2) {
1349
+ downloads['pad'] = res.iosDownloadUrl2;
1350
+ }
1351
+ if (res.macDownloadUrl) {
1352
+ downloads['mac'] = res.macDownloadUrl;
1353
+ }
1354
+ if (res.winDownloadUrl) {
1355
+ downloads['win'] = res.winDownloadUrl;
1356
+ }
1357
+ if (res.linuxDownloadUrl) {
1358
+ downloads['linux'] = res.linuxDownloadUrl;
1359
+ }
1360
+ if (res.harmonyDownloadUrl) {
1361
+ downloads['harmony'] = res.harmonyDownloadUrl;
1362
+ }
1363
+ this.sysName = res.subsystemName;
1364
+ this.secret = res.secret;
1365
+ this.setup = res.setup;
1366
+ this.downloadSetup = res.downloadSetup;
1367
+ if (res.subsystemName) {
1368
+ document.title = res.subsystemName;
1369
+ }
1370
+ this.app = res.appName || res.subsystemName;
1371
+ if (res.loginModel && !this.isCeshi) {
1372
+ this.loginModel =
1373
+ (res.firstLoginModel || this.firstLoginModel) && !isLogined
1374
+ ? res.firstLoginModel || this.firstLoginModel
1375
+ : res.loginModel;
1376
+ }
1377
+
1378
+ if (res.loginBackgroundUrl) {
1379
+ this.loginBackgroundImg = res.loginBackgroundUrl.split(',');
1380
+ }
1381
+ if (res.loginLogoUrl) {
1382
+ this.loginLogoImg = res.loginLogoUrl;
1383
+ }
1384
+ if (res.caModel) {
1385
+ this.caLoginModel = res.caModel;
1386
+ }
1387
+ res.loginPage && sessionStorage.setItem('loginPage', res.loginPage);
1388
+ if (res.subsystemExtend && Object.keys(res.subsystemExtend).length) {
1389
+ if (
1390
+ res.subsystemExtend.copyright &&
1391
+ res.subsystemExtend.copyright.length
1392
+ ) {
1393
+ this.copyright = JSON.parse(res.subsystemExtend.copyright);
1394
+ }
1395
+ if (res.subsystemExtend.qrimg || res.subsystemExtend.qrImg) {
1396
+ this.qrimg = res.subsystemExtend.qrimg || res.subsystemExtend.qrImg;
1397
+ }
1398
+ //忘记密码地址
1399
+ if (
1400
+ res.subsystemExtend.forgetPassUrl ||
1401
+ res.subsystemExtend.look_pass_url
1402
+ ) {
1403
+ this.forgetUrl =
1404
+ res.subsystemExtend.forgetPassUrl ||
1405
+ res.subsystemExtend.look_pass_url;
1406
+ }
1407
+ res.subsystemExtend.loginPage &&
1408
+ sessionStorage.setItem('loginPage', res.subsystemExtend.loginPage);
1409
+ if (res.subsystemExtend.login_url) {
1410
+ this.actionUrl = res.subsystemExtend.login_url;
1411
+ }
1412
+ if (res.subsystemExtend.loginModel) {
1413
+ this.loginModel = res.subsystemExtend.loginModel;
1414
+ }
1415
+ if (res.subsystemExtend.firstLoginModel && !isLogined) {
1416
+ this.loginModel = res.subsystemExtend.firstLoginModel;
1417
+ }
1418
+ if (res.subsystemExtend.caModel) {
1419
+ this.caLoginModel = res.subsystemExtend.caModel;
1420
+ }
1421
+ if (res.subsystemExtend.applicationName) {
1422
+ localStorage.setItem('appcode', res.subsystemExtend.applicationName);
1423
+ }
1424
+ if (res.subsystemExtend.loginBoxBackgroun) {
1425
+ this.loginMainImg = res.subsystemExtend.loginBoxBackground.split(',');
1426
+ }
1427
+ if (res.subsystemExtend.loginBoxTitle) {
1428
+ this.loginTitleImg = res.subsystemExtend.loginBoxTitle;
1429
+ }
1430
+ if (res.subsystemExtend.loginBoxName) {
1431
+ this.loginNameImg = res.subsystemExtend.loginBoxName;
1432
+ }
1433
+ if (res.subsystemExtend.loginBoxAlign && this.useResults) {
1434
+ localStorage.setItem(
1435
+ 'loginBoxAlign',
1436
+ res.subsystemExtend.loginBoxAlign
1437
+ );
1438
+ this.align = res.subsystemExtend.loginBoxAlign;
1439
+ }
1440
+ if (res.subsystemExtend.themeColor) {
1441
+ util.updateTheme(res.subsystemExtend.themeColor);
1442
+ localStorage.setItem('theme', res.subsystemExtend.themeColor);
1443
+ }
1444
+ if (res.subsystemExtend.macDownloadUrl) {
1445
+ downloads.mac = res.subsystemExtend.macDownloadUrl;
1446
+ }
1447
+ if (res.subsystemExtend.winDownloadUrl) {
1448
+ downloads.win = res.subsystemExtend.winDownloadUrl;
1449
+ }
1450
+ if (res.subsystemExtend.linuxDownloadUrl) {
1451
+ downloads.linux = res.subsystemExtend.linuxDownloadUrl;
1452
+ }
1453
+ if (res.subsystemExtend.uosDownloadUrl) {
1454
+ downloads.uos = res.subsystemExtend.uosDownloadUrl;
1455
+ }
1456
+
1457
+ if (res.subsystemExtend.harmonyDownloadUrl) {
1458
+ downloads.harmony = res.subsystemExtend.harmonyDownloadUrl;
1459
+ }
1460
+ if (res.subsystemExtend.warningText) {
1461
+ this.warningText = res.subsystemExtend.warningText;
1462
+ }
1463
+ if (res.subsystemExtend.launchTime) {
1464
+ this.launchTime = parseInt(res.subsystemExtend.launchTime, 10);
1465
+ }
1466
+ if (res.subsystemExtend.launchImage) {
1467
+ if (!this.launchShow) {
1468
+ this.launchShow = true;
1469
+ }
1470
+ if (
1471
+ res.subsystemExtend.launchImage != 'true' &&
1472
+ res.subsystemExtend.launchImage != true
1473
+ ) {
1474
+ this.launchImages =
1475
+ res.subsystemExtend.launchImage.indexOf('{') > -1 &&
1476
+ res.subsystemExtend.launchImage.indexOf('}') > -1
1477
+ ? JSON.parse(res.subsystemExtend.launchImage)
1478
+ : res.subsystemExtend.launchImage;
1479
+ }
1480
+ }
1481
+ if (res.subsystemExtend.loginDownloadApp) {
1482
+ this.loginDownloadApp = res.subsystemExtend.loginDownloadApp;
1483
+ }
1484
+ if (res.subsystemExtend.caInstallPath) {
1485
+ this.installPath = res.subsystemExtend.caInstallPath;
1486
+ }
1487
+ if (res.subsystemExtend.storageType) {
1488
+ this.storageType = res.subsystemExtend.storageType;
1489
+ }
1490
+ if (res.subsystemExtend.alertContent) {
1491
+ ajax && this.alertContent(res.subsystemExtend.alertContent);
1492
+ }
1493
+ }
1494
+ this.passModifyModel = res.passModifyModel;
1495
+ this.wechatAppid = res.wechatAppid;
1496
+ this.wechatScope = res.wechatScope;
1497
+ this.download = { ...this.downLoadUrls, ...downloads };
1498
+ if (res.sysLogoIco) {
1499
+ localStorage.setItem('sysLogoIco', res.sysLogoIco);
1500
+ util.setFavicon(res.sysLogoIco);
1501
+ }
1502
+ },
1503
+ async alertContent(contents) {
1504
+ let { content, title, ...config } = JSON.parse(contents);
1505
+ const regex = /\.md$/;
1506
+ let isMarkdown = regex.test(content);
1507
+ if (isMarkdown) {
1508
+ content = await util.ajax({ url: content });
1509
+ content = this.renderMarkdown(content);
1510
+ }
1511
+ this.$alert(content, title, {
1512
+ dangerouslyUseHTMLString: isMarkdown,
1513
+ setHeight: isMarkdown,
1514
+ customClass: 'es-login-alert',
1515
+ ...config
1516
+ })
1517
+ .then(() => {
1518
+ this.alertCallback(1, { content, title, ...config });
1519
+ })
1520
+ .catch(() => {
1521
+ this.alertCallback(0, { content, title, ...config });
1522
+ });
1523
+ },
1524
+ async downloadMdFile(url) {
1525
+ try {
1526
+ const response = await fetch(url);
1527
+ if (!response.ok) {
1528
+ throw new Error(`下载失败: ${response.statusText}`);
1529
+ }
1530
+ return await response.text();
1531
+ } catch (error) {
1532
+ console.error('MD文件下载出错:', error);
1533
+ throw error; // 抛出错错误供调用者处理
1534
+ }
1535
+ },
1536
+ renderMarkdown(content) {
1537
+ // 这里使用简单的正则替换示例,实际项目建议使用成熟库如marked、markdown-it等
1538
+ // 生产环境推荐: npm install marked 后引入使用
1539
+ let html = content
1540
+ // 处理标题
1541
+ .replace(/^#{1,6}\s+(.*?)$/gm, (match, text, level) => {
1542
+ const hLevel = match.indexOf('#');
1543
+ return `<h${hLevel}>${text}</h${hLevel}>`;
1544
+ })
1545
+ // 处理粗体
1546
+ .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
1547
+ // 处理斜体
1548
+ .replace(/\*(.*?)\*/g, '<em>$1</em>')
1549
+ // 处理链接
1550
+ .replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2" target="_blank">$1</a>')
1551
+ // 处理换行
1552
+ .replace(/\n/g, '<br>');
1553
+ return html;
1554
+ },
1555
+ getImgCode() {
1556
+ if (this.identifyingId === '') {
1557
+ return;
1558
+ }
1559
+ this.imageCode =
1560
+ util.getStorage('host') +
1561
+ this.codeAction +
1562
+ '?identifyingId=' +
1563
+ this.identifyingId +
1564
+ (this.imgCode && typeof this.imgCode == 'object'
1565
+ ? '&' + util.queryParams(this.imgCode)
1566
+ : '') +
1567
+ '&heightflag=' +
1568
+ Math.random().toString().split('.')[1];
1569
+ delete this.formData.identifyingCode;
1570
+ delete this.formData.verificationCode;
1571
+ return this.imageCode;
1572
+ },
1573
+ getCode() {
1574
+ if (this.countdown) {
1575
+ return false;
1576
+ }
1577
+ let data = {};
1578
+ let flag = false;
1579
+ let ref = 'login' + this.active;
1580
+ if (this.active == 12) {
1581
+ if (!this.formData.username) {
1582
+ this.$refs[ref].validateField('username');
1583
+ return false;
1584
+ }
1585
+ this.$refs[ref].validateField('username', (res) => {
1586
+ flag = res != '';
1587
+ });
1588
+ if (flag) {
1589
+ return false;
1590
+ }
1591
+ data = {
1592
+ username: this.formData.username,
1593
+ targetType: this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS'
1594
+ // targetType: 'SMS'
1595
+ };
1596
+ } else {
1597
+ if (!this.formData.target) {
1598
+ this.$refs[ref].validateField('target');
1599
+ return false;
1600
+ }
1601
+ this.$refs[ref].validateField('target', (res) => {
1602
+ flag = res != '';
1603
+ });
1604
+ if (flag) {
1605
+ return false;
1606
+ }
1607
+ data = {
1608
+ target: this.formData.target,
1609
+ targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1610
+ };
1611
+ }
1612
+ this.countdown = 60;
1613
+ this.timer = setInterval(() => {
1614
+ if (this.countdown > 0) {
1615
+ this.countdown--;
1616
+ this.disabled = true;
1617
+ this.btnText = '重新获取' + this.countdown + 's';
1618
+ } else {
1619
+ this.btnText = '重新获取';
1620
+ this.disabled = false;
1621
+ this.submit = false;
1622
+ }
1623
+ }, 1000);
1624
+ util
1625
+ .ajax({
1626
+ method: 'post',
1627
+ url:
1628
+ this.active == 12 ? this.getTwoFactorLoginCode : this.getLoginCode,
1629
+ data: data
1630
+ })
1631
+ .then((res) => {
1632
+ this.$message({
1633
+ message: res.msg,
1634
+ duration: res.rCode == 0 ? 2000 : 3000,
1635
+ type: res.rCode == 0 ? 'success' : 'error'
1636
+ });
1637
+
1638
+ if (res.rCode === 2) {
1639
+ this.btnText = '获取验证码';
1640
+ this.disabled = false;
1641
+ this.countdown = 0;
1642
+ clearInterval(this.timer);
1643
+ }
1644
+ })
1645
+ .catch((err) => {
1646
+ if (err.message && err.message !== 'canceled') {
1647
+ this.$message.error(err.message);
1648
+ }
1649
+ });
1650
+ },
1651
+ handleLogin() {
1652
+ if (this.submit) {
1653
+ return false;
1654
+ }
1655
+ let ref = 'login' + this.active;
1656
+ this.$refs[ref].validate((valid) => {
1657
+ if (valid) {
1658
+ this.submit = true;
1659
+ let param = util.getParams() || {};
1660
+ const data =
1661
+ this.active == '0'
1662
+ ? {
1663
+ username: this.formData.username,
1664
+ password:
1665
+ this.secret && this.isEncrypt
1666
+ ? util.esmEncrypt({
1667
+ data: this.formData.password,
1668
+ key: this.secret
1669
+ })
1670
+ : this.formData.password,
1671
+ identifyingCode: this.formData.identifyingCode,
1672
+ identifyingId: this.identifyingId
1673
+ }
1674
+ : this.active == '12'
1675
+ ? {
1676
+ username: this.formData.username,
1677
+ password:
1678
+ this.secret && this.isEncrypt
1679
+ ? util.esmEncrypt({
1680
+ data: this.formData.password,
1681
+ key: this.secret
1682
+ })
1683
+ : this.formData.password,
1684
+ targetType:
1685
+ this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS',
1686
+ verificationCode: this.formData.identifyingCode
1687
+ }
1688
+ : {
1689
+ target: this.formData.target,
1690
+ verificationCode: this.formData.verificationCode,
1691
+ targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1692
+ };
1693
+ if (this.onLogin) {
1694
+ if (this.active == '0') {
1695
+ this.onLogin(
1696
+ { ...param, ...data },
1697
+ this.getImgCode,
1698
+ this.handleRemember
1699
+ );
1700
+ } else {
1701
+ this.onLogin({ ...param, ...data });
1702
+ }
1703
+ } else {
1704
+ this.handleUserLogin({ ...param, ...this.param, ...data });
1705
+ }
1706
+ } else {
1707
+ this.submit = false;
1708
+ return false;
1709
+ }
1710
+ });
1711
+ },
1712
+ doLogin(e) {
1713
+ if (util.win.event == undefined) {
1714
+ var key = e.keyCode;
1715
+ } else {
1716
+ var key = util.win.event.keyCode;
1717
+ }
1718
+ if (key == 13) {
1719
+ this.handleLogin();
1720
+ }
1721
+ },
1722
+ handleUserLogin(data) {
1723
+ let extUserBindHandleId = sessionStorage.getItem('extUserBindHandleId');
1724
+ util
1725
+ .ajax({
1726
+ method: 'post',
1727
+ url:
1728
+ this.active == '0'
1729
+ ? this.actionUrl
1730
+ : this.active == '12'
1731
+ ? this.doTwoFactorLogin
1732
+ : this.doCodeLogin,
1733
+ data: extUserBindHandleId
1734
+ ? { ...data, extUserBindHandleId: extUserBindHandleId }
1735
+ : data
1736
+ })
1737
+ .then((res) => {
1738
+ this.submit = false;
1739
+ if (res.rCode == 0) {
1740
+ util.removeStorage('extUserBindHandleId');
1741
+ this.handleRemember();
1742
+ const results = res.results;
1743
+ this.handleResults(results);
1744
+ if (this.onSuccess) {
1745
+ this.onSuccess(res);
1746
+ }
1747
+ } else {
1748
+ const msg =
1749
+ res.results && res.results.msg ? res.results.msg : res.msg;
1750
+ this.$message({
1751
+ message: msg || '系统错误,请联系管理员!',
1752
+ type: 'error',
1753
+ onClose: () => {
1754
+ this.btnText = '获取验证码';
1755
+ this.disabled = false;
1756
+ this.countdown = 0;
1757
+ clearInterval(this.timer);
1758
+ this.getImgCode();
1759
+ }
1760
+ });
1761
+ this.onError(res);
1762
+ }
1763
+ })
1764
+ .catch((err) => {
1765
+ this.submit = false;
1766
+ if (err.message && err.message !== 'canceled') {
1767
+ this.$message.error(err.message);
1768
+ }
1769
+ });
1770
+ },
1771
+ caLogin(signedData) {
1772
+ this.loginInfo(false);
1773
+ util
1774
+ .ajax({
1775
+ method: 'post',
1776
+ url: this.caAction,
1777
+ data:
1778
+ typeof signedData === 'string'
1779
+ ? { identifyingId: this.identifyingId, signedData: signedData }
1780
+ : signedData
1781
+ })
1782
+ .then((res) => {
1783
+ this.submit = false;
1784
+ if (res.rCode == 0) {
1785
+ const results = res.results;
1786
+ this.handleResults(results);
1787
+ if (this.onSuccess) {
1788
+ this.onSuccess(res);
1789
+ }
1790
+ } else {
1791
+ const msg =
1792
+ res.results && res.results.msg ? res.results.msg : res.msg;
1793
+ this.$message({
1794
+ message: msg || '系统错误,请联系管理员!',
1795
+ type: 'error',
1796
+ onClose: () => {
1797
+ this.getImgCode();
1798
+ this.loginInfo(this.active == 3);
1799
+ }
1800
+ });
1801
+ this.onError(res);
1802
+ }
1803
+ })
1804
+ .catch((err) => {
1805
+ this.submit = false;
1806
+ if (err.message && err.message !== 'canceled') {
1807
+ this.$message.error(err.message);
1808
+ }
1809
+ });
1810
+ },
1811
+ handleForget() {
1812
+ if (typeof this.forgetUrl === 'string') {
1813
+ util.win.open(this.forgetUrl);
1814
+ } else {
1815
+ this.showResetPassword = true;
1816
+ }
1817
+ },
1818
+ downloadExe() {
1819
+ util.win.open(this.downloadSetup);
1820
+ },
1821
+ //获取app登录信息
1822
+ loginInfo(res) {
1823
+ clearTimeout(this.interval);
1824
+ if (res) {
1825
+ this.interval = setTimeout(() => {
1826
+ this.initRequestLoginInfo();
1827
+ }, this.scanIntervalTime);
1828
+ }
1829
+ },
1830
+ initRequestLoginInfo() {
1831
+ if (this.identifyingId == '') {
1832
+ return false;
1833
+ }
1834
+ util
1835
+ .ajax({
1836
+ method: 'post',
1837
+ url: this.scanAction,
1838
+ data: {
1839
+ identifyingId: this.identifyingId
1840
+ }
1841
+ })
1842
+ .then((res) => {
1843
+ if (res.rCode === 0) {
1844
+ const results = res.results;
1845
+ if (results.statusCode === 0 || results.statusCode === 2) {
1846
+ // statusCode为2时 代表密码过期,也应执行handleResults
1847
+ clearTimeout(this.interval);
1848
+ if (results.statusCode === 2) {
1849
+ this.$alert(
1850
+ results.msg
1851
+ ? results.msg
1852
+ : '您的初始密码已过期,请及时修改!',
1853
+ '提示',
1854
+ {
1855
+ confirmButtonText: '确定',
1856
+ type: 'warning'
1857
+ }
1858
+ )
1859
+ .then(() => {
1860
+ this.handleResults(results, 3);
1861
+ })
1862
+ .catch((e) => {});
1863
+ } else {
1864
+ this.handleResults(results, 3);
1865
+ }
1866
+ } else {
1867
+ this.loginInfo(true);
1868
+ }
1869
+ }
1870
+ })
1871
+ .catch((err) => {
1872
+ clearTimeout(this.interval);
1873
+ if (err.message && err.message !== 'canceled') {
1874
+ this.$message.error(err.message);
1875
+ }
1876
+ });
1877
+ },
1878
+ handleResults(results, type) {
1879
+ switch (results.statusCode) {
1880
+ case 0:
1881
+ this.userName = results.userName;
1882
+ util.setStorage({
1883
+ type: this.storageType,
1884
+ key: {
1885
+ ssId: results.ssId,
1886
+ token: results.token,
1887
+ Authorization: results.token,
1888
+ deviceUnique: results.deviceUnique,
1889
+ userId: results.userId,
1890
+ userName: results.userName,
1891
+ useCaseCodes: results.resourceCodes
1892
+ }
1893
+ });
1894
+ if (this.launchShow) {
1895
+ this.$message({
1896
+ message: '登录成功!',
1897
+ type: 'success',
1898
+ duration: 1000
1899
+ });
1900
+ this.showLaunch = true;
1901
+ setTimeout(() => {
1902
+ if (this.toUrl) {
1903
+ window.location.href = this.toUrl;
1904
+ } else if (results.doorIndex && this.doorIndex) {
1905
+ sessionStorage.setItem('doorIndex', results.doorIndex);
1906
+ localStorage.setItem('isLogined', true);
1907
+ window.location.href = results.doorIndex;
1908
+ } else {
1909
+ if (window.location.href.indexOf('login.html') > -1) {
1910
+ window.location.href = './main.html';
1911
+ } else {
1912
+ this.$router.push({ name: 'main' });
1913
+ this.$nextTick(() => {
1914
+ this.showLaunch = false;
1915
+ });
1916
+ }
1917
+ }
1918
+ }, this.launchTime);
1919
+ } else {
1920
+ this.$message({
1921
+ message: '登录成功!',
1922
+ type: 'success',
1923
+ duration: 1500,
1924
+ onClose: () => {
1925
+ if (this.toUrl) {
1926
+ window.location.href = this.toUrl;
1927
+ } else if (results.doorIndex && this.doorIndex) {
1928
+ sessionStorage.setItem('doorIndex', results.doorIndex);
1929
+ localStorage.setItem('isLogined', true);
1930
+ window.location.href = results.doorIndex;
1931
+ } else {
1932
+ if (window.location.href.indexOf('login.html') > -1) {
1933
+ window.location.href = './main.html';
1934
+ } else {
1935
+ this.$router.push({ name: 'main' });
1936
+ }
1937
+ }
1938
+ }
1939
+ });
1940
+ }
1941
+ break;
1942
+ case 2:
1943
+ this.$confirm(
1944
+ results.msg ? results.msg : '密码太简单了, 请修改密码?',
1945
+ '提示',
1946
+ {
1947
+ confirmButtonText: '确定',
1948
+ //cancelButtonText: '取消',
1949
+ type: 'warning'
1950
+ }
1951
+ )
1952
+ .then(() => {
1953
+ this.operationCheckCode = results.checkCode;
1954
+ if (typeof this.forgetUrl === 'string') {
1955
+ util.win.open(this.forgetUrl);
1956
+ } else {
1957
+ this.showResetPassword = true;
1958
+ }
1959
+ })
1960
+ .catch((e) => {});
1961
+ break;
1962
+ case 3:
1963
+ let url =
1964
+ results.doorIndex && this.doorIndex
1965
+ ? results.doorIndex
1966
+ : window.location.href.indexOf('main.html') > -1
1967
+ ? './login.html'
1968
+ : window.location.hash
1969
+ ? window.location.href.replace('login', 'main')
1970
+ : window.location.href;
1971
+ const href = results.authorizeUrl.replace(
1972
+ '{redirectUri}',
1973
+ encodeURIComponent(url)
1974
+ );
1975
+ window.location.href = href;
1976
+ // window.location.href =
1977
+ // results.authorizeUrl.indexOf('?') > -1
1978
+ // ? results.authorizeUrl + '&token=' + results.token
1979
+ // : results.authorizeUrl + '?token=' + results.token;
1980
+ break;
1981
+ case 4:
1982
+ this.$alert(
1983
+ results.msg ? results.msg : '账号未绑定,账号密码登录后自动绑定!',
1984
+ '提示',
1985
+ {
1986
+ confirmButtonText: '确定',
1987
+ type: 'error'
1988
+ }
1989
+ )
1990
+ .then(() => {
1991
+ sessionStorage.setItem(
1992
+ 'extUserBindHandleId',
1993
+ results.extUserBindHandleId
1994
+ );
1995
+ window.location.href = util.delUrlParam({ key: 'code' });
1996
+ if (window.location.hash) {
1997
+ location.reload();
1998
+ }
1999
+ })
2000
+ .catch((e) => {});
2001
+ break;
2002
+ case 102:
2003
+ this.checkCode = results.checkCode;
2004
+ this.showAssistance = true;
2005
+ let { operationCheckCode } = JSON.parse(results.checkCode);
2006
+ this.handleAssistance({ operationCheckCode });
2007
+ break;
2008
+ default:
2009
+ if (type !== 3) {
2010
+ this.$message({
2011
+ message: results.msg,
2012
+ type: 'error',
2013
+ onClose: () => {
2014
+ if (this.code) {
2015
+ window.location.href = util.delUrlParam({ key: 'code' });
2016
+ if (window.location.hash) {
2017
+ location.reload();
2018
+ }
2019
+ } else {
2020
+ this.getImgCode();
2021
+ }
2022
+ }
2023
+ });
2024
+ } else if (this.active == 3) {
2025
+ this.loginInfo(true);
2026
+ }
2027
+ }
2028
+ },
2029
+ handleAssistance(data) {
2030
+ clearTimeout(this.doAssistance);
2031
+ this.doAssistance = setTimeout(() => {
2032
+ this.doAssistanceLogin(data);
2033
+ }, this.scanIntervalTime);
2034
+ },
2035
+ doAssistanceLogin(data) {
2036
+ util
2037
+ .ajax({
2038
+ method: 'post',
2039
+ url: doAssistanceQrLogin,
2040
+ data: data
2041
+ })
2042
+ .then((res) => {
2043
+ if (res.rCode === 0) {
2044
+ const results = res.results;
2045
+ if (results.statusCode === 0) {
2046
+ clearTimeout(this.doAssistance);
2047
+ this.handleResults(results, 3);
2048
+ } else {
2049
+ this.handleAssistance(data);
2050
+ }
2051
+ } else {
2052
+ clearTimeout(this.doAssistance);
2053
+ this.$message.error(res.msg);
2054
+ }
2055
+ })
2056
+ .catch((err) => {
2057
+ clearTimeout(this.doAssistance);
2058
+ if (err.message && err.message !== 'canceled') {
2059
+ this.$message.error(err.message);
2060
+ }
2061
+ });
2062
+ },
2063
+ closeAssistance() {
2064
+ clearTimeout(this.doAssistance);
2065
+ },
2066
+ handleSuccess() {
2067
+ this.showResetPassword = false;
2068
+ },
2069
+ forbiddenTab(e) {
2070
+ if (e.keyCode == 9) {
2071
+ return false;
2072
+ }
2073
+ },
2074
+ handlePaste(event) {
2075
+ this.safe && event.preventDefault();
2076
+ },
2077
+ handleError() {
2078
+ this.submit = false;
2079
+ }
2080
+ },
2081
+ beforeDestroy() {
2082
+ window.removeEventListener('resize', this.setScale);
2083
+ document.removeEventListener('keyup', this.doLogin);
2084
+ document.removeEventListener('keydown', this.forbiddenTab);
2085
+ }
2086
+ };
2087
+ </script>