eoss-ui 0.7.99 → 0.8.0

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 (231) hide show
  1. package/lib/calogin.js +233 -233
  2. package/lib/eoss-ui.common.js +660 -655
  3. package/lib/flow.js +118 -118
  4. package/lib/index.js +1 -1
  5. package/lib/main.js +283 -283
  6. package/lib/qr-code.js +13 -13
  7. package/lib/select.js +12 -7
  8. package/lib/theme-chalk/index.css +1 -1
  9. package/lib/theme-chalk/login.css +1 -1
  10. package/package.json +1 -1
  11. package/packages/button/index.js +5 -5
  12. package/packages/button/src/main.vue +418 -418
  13. package/packages/button-group/index.js +5 -5
  14. package/packages/calendar/index.js +5 -5
  15. package/packages/calogin/index.js +5 -5
  16. package/packages/calogin/src/plugin.js +915 -915
  17. package/packages/card/index.js +5 -5
  18. package/packages/card/src/main.vue +156 -156
  19. package/packages/cascader/index.js +5 -5
  20. package/packages/cascader/src/main.vue +168 -168
  21. package/packages/checkbox-group/index.js +5 -5
  22. package/packages/checkbox-group/src/main.vue +333 -333
  23. package/packages/clients/index.js +5 -5
  24. package/packages/data-table/index.js +5 -5
  25. package/packages/data-table/src/children.vue +39 -39
  26. package/packages/data-table/src/main.vue +1847 -1847
  27. package/packages/data-table/src/sizer.vue +195 -195
  28. package/packages/data-table-form/index.js +5 -5
  29. package/packages/data-table-form/src/checkbox.vue +101 -101
  30. package/packages/data-table-form/src/colgroup.vue +17 -17
  31. package/packages/data-table-form/src/main.vue +181 -181
  32. package/packages/data-table-form/src/radio.vue +65 -65
  33. package/packages/data-table-form/src/table.vue +233 -233
  34. package/packages/data-table-form/src/tbody.vue +336 -336
  35. package/packages/data-table-form/src/thead.vue +68 -68
  36. package/packages/date-picker/index.js +5 -5
  37. package/packages/date-picker/src/main.vue +236 -236
  38. package/packages/dialog/index.js +5 -5
  39. package/packages/enable-drag/index.js +5 -5
  40. package/packages/enterprise/index.js +5 -5
  41. package/packages/enterprise/src/main.vue +66 -66
  42. package/packages/error-page/index.js +5 -5
  43. package/packages/error-page/src/main.vue +44 -44
  44. package/packages/flow/index.js +5 -5
  45. package/packages/flow/src/component/FreeCirculation.vue +245 -245
  46. package/packages/flow/src/component/TimeLimit.vue +190 -190
  47. package/packages/flow/src/main.vue +4145 -4145
  48. package/packages/flow-group/index.js +5 -5
  49. package/packages/flow-group/src/main.vue +750 -750
  50. package/packages/flow-list/index.js +5 -5
  51. package/packages/form/index.js +5 -5
  52. package/packages/handle-user/index.js +5 -5
  53. package/packages/handle-user/src/main.vue +137 -137
  54. package/packages/handler/index.js +5 -5
  55. package/packages/handler/src/main.vue +499 -499
  56. package/packages/icon/index.js +5 -5
  57. package/packages/icons/index.js +5 -5
  58. package/packages/icons/src/main.vue +81 -81
  59. package/packages/input/index.js +5 -5
  60. package/packages/input/src/main.vue +356 -356
  61. package/packages/input-number/index.js +5 -5
  62. package/packages/input-number/src/main.vue +106 -106
  63. package/packages/label/index.js +5 -5
  64. package/packages/label/src/main.vue +457 -457
  65. package/packages/layout/index.js +5 -5
  66. package/packages/layout/src/item.vue +152 -152
  67. package/packages/layout/src/main.vue +31 -31
  68. package/packages/login/index.js +5 -5
  69. package/packages/login/src/main.vue +2088 -2088
  70. package/packages/main/index.js +5 -5
  71. package/packages/main/src/default/message.vue +249 -249
  72. package/packages/main/src/default/notice.vue +157 -157
  73. package/packages/main/src/default/userinfo.vue +513 -513
  74. package/packages/main/src/simplicity/index.vue +2335 -2335
  75. package/packages/main/src/simplicity/lists.vue +84 -84
  76. package/packages/main/src/simplicity/router-page.vue +45 -45
  77. package/packages/main/src/simplicity/userinfo.vue +408 -408
  78. package/packages/main/src/simplicityTop/index.vue +2625 -2625
  79. package/packages/main/src/simplicityTop/userinfo.vue +408 -408
  80. package/packages/menu/index.js +5 -5
  81. package/packages/nav/index.js +5 -5
  82. package/packages/notify/index.js +5 -5
  83. package/packages/notify/src/main.vue +538 -538
  84. package/packages/page/index.js +5 -5
  85. package/packages/page/src/main.vue +167 -167
  86. package/packages/pagination/index.js +5 -5
  87. package/packages/pagination/src/main.vue +96 -96
  88. package/packages/player/index.js +5 -5
  89. package/packages/player/src/main.vue +194 -194
  90. package/packages/qr-code/index.js +5 -5
  91. package/packages/qr-code/src/main.vue +170 -170
  92. package/packages/radio-group/index.js +6 -6
  93. package/packages/radio-group/src/main.vue +319 -319
  94. package/packages/retrial-auth/index.js +5 -5
  95. package/packages/retrial-auth/src/main.vue +299 -299
  96. package/packages/select/index.js +5 -5
  97. package/packages/select/src/main.vue +14 -9
  98. package/packages/select-ganged/index.js +5 -5
  99. package/packages/select-ganged/src/main.vue +724 -724
  100. package/packages/selector/index.js +5 -5
  101. package/packages/selector-panel/index.js +5 -5
  102. package/packages/selector-panel/src/tree.vue +129 -129
  103. package/packages/sizer/index.js +5 -5
  104. package/packages/sizer/src/main.vue +254 -254
  105. package/packages/steps/index.js +5 -5
  106. package/packages/steps/src/main.vue +181 -181
  107. package/packages/switch/index.js +5 -5
  108. package/packages/table-form/index.js +5 -5
  109. package/packages/tabs/index.js +5 -5
  110. package/packages/tabs/src/main.vue +788 -788
  111. package/packages/tabs-panel/index.js +5 -5
  112. package/packages/tabs-panel/src/main.vue +29 -29
  113. package/packages/theme-chalk/gulpfile.js +25 -0
  114. package/packages/theme-chalk/src/base.scss +261 -261
  115. package/packages/theme-chalk/src/button-group.scss +176 -176
  116. package/packages/theme-chalk/src/button.scss +24 -24
  117. package/packages/theme-chalk/src/calendar.scss +113 -113
  118. package/packages/theme-chalk/src/card.scss +99 -99
  119. package/packages/theme-chalk/src/checkbox-group.scss +8 -8
  120. package/packages/theme-chalk/src/clients.scss +87 -87
  121. package/packages/theme-chalk/src/data-table-form.scss +67 -67
  122. package/packages/theme-chalk/src/date-picker.scss +7 -7
  123. package/packages/theme-chalk/src/dialog.scss +77 -77
  124. package/packages/theme-chalk/src/enable-drag.scss +181 -181
  125. package/packages/theme-chalk/src/enterprise.scss +5 -5
  126. package/packages/theme-chalk/src/error-page.scss +18 -18
  127. package/packages/theme-chalk/src/flow-group.scss +110 -110
  128. package/packages/theme-chalk/src/handle-user.scss +40 -40
  129. package/packages/theme-chalk/src/icons.scss +99 -99
  130. package/packages/theme-chalk/src/input.scss +9 -9
  131. package/packages/theme-chalk/src/label.scss +24 -24
  132. package/packages/theme-chalk/src/layout.scss +46 -46
  133. package/packages/theme-chalk/src/mixins/color.scss +117 -117
  134. package/packages/theme-chalk/src/nav.scss +111 -111
  135. package/packages/theme-chalk/src/page.scss +3 -3
  136. package/packages/theme-chalk/src/pagination.scss +29 -29
  137. package/packages/theme-chalk/src/player.scss +9 -9
  138. package/packages/theme-chalk/src/qr-code.scss +17 -17
  139. package/packages/theme-chalk/src/radio-group.scss +9 -9
  140. package/packages/theme-chalk/src/retrial-auth.scss +38 -38
  141. package/packages/theme-chalk/src/select-ganged.scss +8 -8
  142. package/packages/theme-chalk/src/select.scss +8 -8
  143. package/packages/theme-chalk/src/selector-panel.scss +204 -204
  144. package/packages/theme-chalk/src/sizer.scss +36 -36
  145. package/packages/theme-chalk/src/steps.scss +88 -88
  146. package/packages/theme-chalk/src/switch.scss +3 -3
  147. package/packages/theme-chalk/src/table-form.scss +1 -1
  148. package/packages/theme-chalk/src/tabs.scss +87 -87
  149. package/packages/theme-chalk/src/tips.scss +7 -7
  150. package/packages/theme-chalk/src/toolbar.scss +179 -179
  151. package/packages/theme-chalk/src/tree-group.scss +72 -72
  152. package/packages/theme-chalk/src/wxlogin.scss +3 -3
  153. package/packages/tips/index.js +5 -5
  154. package/packages/toolbar/index.js +5 -5
  155. package/packages/tree/index.js +5 -5
  156. package/packages/tree-group/index.js +5 -5
  157. package/packages/upload/index.js +5 -5
  158. package/packages/upload/src/main.vue +1344 -1344
  159. package/packages/upload/src/picture.js +15 -15
  160. package/packages/wujie/index.js +5 -5
  161. package/packages/wxlogin/index.js +5 -5
  162. package/packages/wxlogin/src/main.vue +128 -128
  163. package/src/config/image.js +2 -2
  164. package/src/index.js +1 -1
  165. package/src/utils/bus.js +3 -3
  166. package/src/utils/date-util.js +312 -312
  167. package/src/utils/http.js +50 -50
  168. package/src/utils/store.js +21 -21
  169. package/src/utils/webSocket.js +107 -107
  170. package/packages/theme-chalk/lib/base.css +0 -1
  171. package/packages/theme-chalk/lib/button-group.css +0 -1
  172. package/packages/theme-chalk/lib/button.css +0 -1
  173. package/packages/theme-chalk/lib/calendar.css +0 -1
  174. package/packages/theme-chalk/lib/calogin.css +0 -0
  175. package/packages/theme-chalk/lib/card.css +0 -1
  176. package/packages/theme-chalk/lib/cascader.css +0 -0
  177. package/packages/theme-chalk/lib/checkbox-group.css +0 -1
  178. package/packages/theme-chalk/lib/clients.css +0 -1
  179. package/packages/theme-chalk/lib/data-table-form.css +0 -1
  180. package/packages/theme-chalk/lib/data-table.css +0 -1
  181. package/packages/theme-chalk/lib/date-picker.css +0 -1
  182. package/packages/theme-chalk/lib/dialog.css +0 -1
  183. package/packages/theme-chalk/lib/enable-drag.css +0 -1
  184. package/packages/theme-chalk/lib/enterprise.css +0 -1
  185. package/packages/theme-chalk/lib/error-page.css +0 -1
  186. package/packages/theme-chalk/lib/flow-chart.css +0 -0
  187. package/packages/theme-chalk/lib/flow-group.css +0 -1
  188. package/packages/theme-chalk/lib/flow-list.css +0 -1
  189. package/packages/theme-chalk/lib/flow.css +0 -1
  190. package/packages/theme-chalk/lib/fonts/iconfont.ttf +0 -0
  191. package/packages/theme-chalk/lib/fonts/iconfont.woff +0 -0
  192. package/packages/theme-chalk/lib/form.css +0 -1
  193. package/packages/theme-chalk/lib/handle-user.css +0 -1
  194. package/packages/theme-chalk/lib/handler.css +0 -1
  195. package/packages/theme-chalk/lib/icon.css +0 -1
  196. package/packages/theme-chalk/lib/icons.css +0 -1
  197. package/packages/theme-chalk/lib/index.css +0 -1
  198. package/packages/theme-chalk/lib/input-number.css +0 -0
  199. package/packages/theme-chalk/lib/input.css +0 -1
  200. package/packages/theme-chalk/lib/label.css +0 -1
  201. package/packages/theme-chalk/lib/layout.css +0 -1
  202. package/packages/theme-chalk/lib/login.css +0 -1
  203. package/packages/theme-chalk/lib/main.css +0 -1
  204. package/packages/theme-chalk/lib/menu.css +0 -1
  205. package/packages/theme-chalk/lib/nav.css +0 -1
  206. package/packages/theme-chalk/lib/notify.css +0 -0
  207. package/packages/theme-chalk/lib/page.css +0 -1
  208. package/packages/theme-chalk/lib/pagination.css +0 -1
  209. package/packages/theme-chalk/lib/player.css +0 -1
  210. package/packages/theme-chalk/lib/qr-code.css +0 -1
  211. package/packages/theme-chalk/lib/radio-group.css +0 -1
  212. package/packages/theme-chalk/lib/retrial-auth.css +0 -1
  213. package/packages/theme-chalk/lib/select-ganged.css +0 -1
  214. package/packages/theme-chalk/lib/select.css +0 -1
  215. package/packages/theme-chalk/lib/selector-panel.css +0 -1
  216. package/packages/theme-chalk/lib/selector.css +0 -1
  217. package/packages/theme-chalk/lib/simplicity-top.css +0 -1
  218. package/packages/theme-chalk/lib/simplicity.css +0 -1
  219. package/packages/theme-chalk/lib/sizer.css +0 -1
  220. package/packages/theme-chalk/lib/steps.css +0 -1
  221. package/packages/theme-chalk/lib/switch.css +0 -1
  222. package/packages/theme-chalk/lib/table-form.css +0 -0
  223. package/packages/theme-chalk/lib/tabs-panel.css +0 -0
  224. package/packages/theme-chalk/lib/tabs.css +0 -1
  225. package/packages/theme-chalk/lib/tips.css +0 -1
  226. package/packages/theme-chalk/lib/toolbar.css +0 -1
  227. package/packages/theme-chalk/lib/tree-group.css +0 -1
  228. package/packages/theme-chalk/lib/tree.css +0 -1
  229. package/packages/theme-chalk/lib/upload.css +0 -1
  230. package/packages/theme-chalk/lib/wujie.css +0 -0
  231. package/packages/theme-chalk/lib/wxlogin.css +0 -1
@@ -1,2088 +1,2088 @@
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
- console.log(content);
1510
- content = content ? this.renderMarkdown(content) : content;
1511
- }
1512
- this.$alert(content, title, {
1513
- dangerouslyUseHTMLString: isMarkdown,
1514
- setHeight: isMarkdown,
1515
- customClass: 'es-login-alert',
1516
- ...config
1517
- })
1518
- .then(() => {
1519
- this.alertCallback(1, { content, title, ...config });
1520
- })
1521
- .catch(() => {
1522
- this.alertCallback(0, { content, title, ...config });
1523
- });
1524
- },
1525
- async downloadMdFile(url) {
1526
- try {
1527
- const response = await fetch(url);
1528
- if (!response.ok) {
1529
- throw new Error(`下载失败: ${response.statusText}`);
1530
- }
1531
- return await response.text();
1532
- } catch (error) {
1533
- console.error('MD文件下载出错:', error);
1534
- throw error; // 抛出错错误供调用者处理
1535
- }
1536
- },
1537
- renderMarkdown(content) {
1538
- // 这里使用简单的正则替换示例,实际项目建议使用成熟库如marked、markdown-it等
1539
- // 生产环境推荐: npm install marked 后引入使用
1540
- let html = content
1541
- // 处理标题
1542
- .replace(/^#{1,6}\s+(.*?)$/gm, (match, text, level) => {
1543
- const hLevel = match.indexOf('#');
1544
- return `<h${hLevel}>${text}</h${hLevel}>`;
1545
- })
1546
- // 处理粗体
1547
- .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
1548
- // 处理斜体
1549
- .replace(/\*(.*?)\*/g, '<em>$1</em>')
1550
- // 处理链接
1551
- .replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2" target="_blank">$1</a>')
1552
- // 处理换行
1553
- .replace(/\n/g, '<br>');
1554
- return html;
1555
- },
1556
- getImgCode() {
1557
- if (this.identifyingId === '') {
1558
- return;
1559
- }
1560
- this.imageCode =
1561
- util.getStorage('host') +
1562
- this.codeAction +
1563
- '?identifyingId=' +
1564
- this.identifyingId +
1565
- (this.imgCode && typeof this.imgCode == 'object'
1566
- ? '&' + util.queryParams(this.imgCode)
1567
- : '') +
1568
- '&heightflag=' +
1569
- Math.random().toString().split('.')[1];
1570
- delete this.formData.identifyingCode;
1571
- delete this.formData.verificationCode;
1572
- return this.imageCode;
1573
- },
1574
- getCode() {
1575
- if (this.countdown) {
1576
- return false;
1577
- }
1578
- let data = {};
1579
- let flag = false;
1580
- let ref = 'login' + this.active;
1581
- if (this.active == 12) {
1582
- if (!this.formData.username) {
1583
- this.$refs[ref].validateField('username');
1584
- return false;
1585
- }
1586
- this.$refs[ref].validateField('username', (res) => {
1587
- flag = res != '';
1588
- });
1589
- if (flag) {
1590
- return false;
1591
- }
1592
- data = {
1593
- username: this.formData.username,
1594
- targetType: this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS'
1595
- // targetType: 'SMS'
1596
- };
1597
- } else {
1598
- if (!this.formData.target) {
1599
- this.$refs[ref].validateField('target');
1600
- return false;
1601
- }
1602
- this.$refs[ref].validateField('target', (res) => {
1603
- flag = res != '';
1604
- });
1605
- if (flag) {
1606
- return false;
1607
- }
1608
- data = {
1609
- target: this.formData.target,
1610
- targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1611
- };
1612
- }
1613
- this.countdown = 60;
1614
- this.timer = setInterval(() => {
1615
- if (this.countdown > 0) {
1616
- this.countdown--;
1617
- this.disabled = true;
1618
- this.btnText = '重新获取' + this.countdown + 's';
1619
- } else {
1620
- this.btnText = '重新获取';
1621
- this.disabled = false;
1622
- this.submit = false;
1623
- }
1624
- }, 1000);
1625
- util
1626
- .ajax({
1627
- method: 'post',
1628
- url:
1629
- this.active == 12 ? this.getTwoFactorLoginCode : this.getLoginCode,
1630
- data: data
1631
- })
1632
- .then((res) => {
1633
- this.$message({
1634
- message: res.msg,
1635
- duration: res.rCode == 0 ? 2000 : 3000,
1636
- type: res.rCode == 0 ? 'success' : 'error'
1637
- });
1638
-
1639
- if (res.rCode === 2) {
1640
- this.btnText = '获取验证码';
1641
- this.disabled = false;
1642
- this.countdown = 0;
1643
- clearInterval(this.timer);
1644
- }
1645
- })
1646
- .catch((err) => {
1647
- if (err.message && err.message !== 'canceled') {
1648
- this.$message.error(err.message);
1649
- }
1650
- });
1651
- },
1652
- handleLogin() {
1653
- if (this.submit) {
1654
- return false;
1655
- }
1656
- let ref = 'login' + this.active;
1657
- this.$refs[ref].validate((valid) => {
1658
- if (valid) {
1659
- this.submit = true;
1660
- let param = util.getParams() || {};
1661
- const data =
1662
- this.active == '0'
1663
- ? {
1664
- username: this.formData.username,
1665
- password:
1666
- this.secret && this.isEncrypt
1667
- ? util.esmEncrypt({
1668
- data: this.formData.password,
1669
- key: this.secret
1670
- })
1671
- : this.formData.password,
1672
- identifyingCode: this.formData.identifyingCode,
1673
- identifyingId: this.identifyingId
1674
- }
1675
- : this.active == '12'
1676
- ? {
1677
- username: this.formData.username,
1678
- password:
1679
- this.secret && this.isEncrypt
1680
- ? util.esmEncrypt({
1681
- data: this.formData.password,
1682
- key: this.secret
1683
- })
1684
- : this.formData.password,
1685
- targetType:
1686
- this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS',
1687
- verificationCode: this.formData.identifyingCode
1688
- }
1689
- : {
1690
- target: this.formData.target,
1691
- verificationCode: this.formData.verificationCode,
1692
- targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1693
- };
1694
- if (this.onLogin) {
1695
- if (this.active == '0') {
1696
- this.onLogin(
1697
- { ...param, ...data },
1698
- this.getImgCode,
1699
- this.handleRemember
1700
- );
1701
- } else {
1702
- this.onLogin({ ...param, ...data });
1703
- }
1704
- } else {
1705
- this.handleUserLogin({ ...param, ...this.param, ...data });
1706
- }
1707
- } else {
1708
- this.submit = false;
1709
- return false;
1710
- }
1711
- });
1712
- },
1713
- doLogin(e) {
1714
- if (util.win.event == undefined) {
1715
- var key = e.keyCode;
1716
- } else {
1717
- var key = util.win.event.keyCode;
1718
- }
1719
- if (key == 13) {
1720
- this.handleLogin();
1721
- }
1722
- },
1723
- handleUserLogin(data) {
1724
- let extUserBindHandleId = sessionStorage.getItem('extUserBindHandleId');
1725
- util
1726
- .ajax({
1727
- method: 'post',
1728
- url:
1729
- this.active == '0'
1730
- ? this.actionUrl
1731
- : this.active == '12'
1732
- ? this.doTwoFactorLogin
1733
- : this.doCodeLogin,
1734
- data: extUserBindHandleId
1735
- ? { ...data, extUserBindHandleId: extUserBindHandleId }
1736
- : data
1737
- })
1738
- .then((res) => {
1739
- this.submit = false;
1740
- if (res.rCode == 0) {
1741
- util.removeStorage('extUserBindHandleId');
1742
- this.handleRemember();
1743
- const results = res.results;
1744
- this.handleResults(results);
1745
- if (this.onSuccess) {
1746
- this.onSuccess(res);
1747
- }
1748
- } else {
1749
- const msg =
1750
- res.results && res.results.msg ? res.results.msg : res.msg;
1751
- this.$message({
1752
- message: msg || '系统错误,请联系管理员!',
1753
- type: 'error',
1754
- onClose: () => {
1755
- this.btnText = '获取验证码';
1756
- this.disabled = false;
1757
- this.countdown = 0;
1758
- clearInterval(this.timer);
1759
- this.getImgCode();
1760
- }
1761
- });
1762
- this.onError(res);
1763
- }
1764
- })
1765
- .catch((err) => {
1766
- this.submit = false;
1767
- if (err.message && err.message !== 'canceled') {
1768
- this.$message.error(err.message);
1769
- }
1770
- });
1771
- },
1772
- caLogin(signedData) {
1773
- this.loginInfo(false);
1774
- util
1775
- .ajax({
1776
- method: 'post',
1777
- url: this.caAction,
1778
- data:
1779
- typeof signedData === 'string'
1780
- ? { identifyingId: this.identifyingId, signedData: signedData }
1781
- : signedData
1782
- })
1783
- .then((res) => {
1784
- this.submit = false;
1785
- if (res.rCode == 0) {
1786
- const results = res.results;
1787
- this.handleResults(results);
1788
- if (this.onSuccess) {
1789
- this.onSuccess(res);
1790
- }
1791
- } else {
1792
- const msg =
1793
- res.results && res.results.msg ? res.results.msg : res.msg;
1794
- this.$message({
1795
- message: msg || '系统错误,请联系管理员!',
1796
- type: 'error',
1797
- onClose: () => {
1798
- this.getImgCode();
1799
- this.loginInfo(this.active == 3);
1800
- }
1801
- });
1802
- this.onError(res);
1803
- }
1804
- })
1805
- .catch((err) => {
1806
- this.submit = false;
1807
- if (err.message && err.message !== 'canceled') {
1808
- this.$message.error(err.message);
1809
- }
1810
- });
1811
- },
1812
- handleForget() {
1813
- if (typeof this.forgetUrl === 'string') {
1814
- util.win.open(this.forgetUrl);
1815
- } else {
1816
- this.showResetPassword = true;
1817
- }
1818
- },
1819
- downloadExe() {
1820
- util.win.open(this.downloadSetup);
1821
- },
1822
- //获取app登录信息
1823
- loginInfo(res) {
1824
- clearTimeout(this.interval);
1825
- if (res) {
1826
- this.interval = setTimeout(() => {
1827
- this.initRequestLoginInfo();
1828
- }, this.scanIntervalTime);
1829
- }
1830
- },
1831
- initRequestLoginInfo() {
1832
- if (this.identifyingId == '') {
1833
- return false;
1834
- }
1835
- util
1836
- .ajax({
1837
- method: 'post',
1838
- url: this.scanAction,
1839
- data: {
1840
- identifyingId: this.identifyingId
1841
- }
1842
- })
1843
- .then((res) => {
1844
- if (res.rCode === 0) {
1845
- const results = res.results;
1846
- if (results.statusCode === 0 || results.statusCode === 2) {
1847
- // statusCode为2时 代表密码过期,也应执行handleResults
1848
- clearTimeout(this.interval);
1849
- if (results.statusCode === 2) {
1850
- this.$alert(
1851
- results.msg
1852
- ? results.msg
1853
- : '您的初始密码已过期,请及时修改!',
1854
- '提示',
1855
- {
1856
- confirmButtonText: '确定',
1857
- type: 'warning'
1858
- }
1859
- )
1860
- .then(() => {
1861
- this.handleResults(results, 3);
1862
- })
1863
- .catch((e) => {});
1864
- } else {
1865
- this.handleResults(results, 3);
1866
- }
1867
- } else {
1868
- this.loginInfo(true);
1869
- }
1870
- }
1871
- })
1872
- .catch((err) => {
1873
- clearTimeout(this.interval);
1874
- if (err.message && err.message !== 'canceled') {
1875
- this.$message.error(err.message);
1876
- }
1877
- });
1878
- },
1879
- handleResults(results, type) {
1880
- switch (results.statusCode) {
1881
- case 0:
1882
- this.userName = results.userName;
1883
- util.setStorage({
1884
- type: this.storageType,
1885
- key: {
1886
- ssId: results.ssId,
1887
- token: results.token,
1888
- Authorization: results.token,
1889
- deviceUnique: results.deviceUnique,
1890
- userId: results.userId,
1891
- userName: results.userName,
1892
- useCaseCodes: results.resourceCodes
1893
- }
1894
- });
1895
- if (this.launchShow) {
1896
- this.$message({
1897
- message: '登录成功!',
1898
- type: 'success',
1899
- duration: 1000
1900
- });
1901
- this.showLaunch = true;
1902
- setTimeout(() => {
1903
- if (this.toUrl) {
1904
- window.location.href = this.toUrl;
1905
- } else if (results.doorIndex && this.doorIndex) {
1906
- sessionStorage.setItem('doorIndex', results.doorIndex);
1907
- localStorage.setItem('isLogined', true);
1908
- window.location.href = results.doorIndex;
1909
- } else {
1910
- if (window.location.href.indexOf('login.html') > -1) {
1911
- window.location.href = './main.html';
1912
- } else {
1913
- this.$router.push({ name: 'main' });
1914
- this.$nextTick(() => {
1915
- this.showLaunch = false;
1916
- });
1917
- }
1918
- }
1919
- }, this.launchTime);
1920
- } else {
1921
- this.$message({
1922
- message: '登录成功!',
1923
- type: 'success',
1924
- duration: 1500,
1925
- onClose: () => {
1926
- if (this.toUrl) {
1927
- window.location.href = this.toUrl;
1928
- } else if (results.doorIndex && this.doorIndex) {
1929
- sessionStorage.setItem('doorIndex', results.doorIndex);
1930
- localStorage.setItem('isLogined', true);
1931
- window.location.href = results.doorIndex;
1932
- } else {
1933
- if (window.location.href.indexOf('login.html') > -1) {
1934
- window.location.href = './main.html';
1935
- } else {
1936
- this.$router.push({ name: 'main' });
1937
- }
1938
- }
1939
- }
1940
- });
1941
- }
1942
- break;
1943
- case 2:
1944
- this.$confirm(
1945
- results.msg ? results.msg : '密码太简单了, 请修改密码?',
1946
- '提示',
1947
- {
1948
- confirmButtonText: '确定',
1949
- //cancelButtonText: '取消',
1950
- type: 'warning'
1951
- }
1952
- )
1953
- .then(() => {
1954
- this.operationCheckCode = results.checkCode;
1955
- if (typeof this.forgetUrl === 'string') {
1956
- util.win.open(this.forgetUrl);
1957
- } else {
1958
- this.showResetPassword = true;
1959
- }
1960
- })
1961
- .catch((e) => {});
1962
- break;
1963
- case 3:
1964
- let url =
1965
- results.doorIndex && this.doorIndex
1966
- ? results.doorIndex
1967
- : window.location.href.indexOf('main.html') > -1
1968
- ? './login.html'
1969
- : window.location.hash
1970
- ? window.location.href.replace('login', 'main')
1971
- : window.location.href;
1972
- const href = results.authorizeUrl.replace(
1973
- '{redirectUri}',
1974
- encodeURIComponent(url)
1975
- );
1976
- window.location.href = href;
1977
- // window.location.href =
1978
- // results.authorizeUrl.indexOf('?') > -1
1979
- // ? results.authorizeUrl + '&token=' + results.token
1980
- // : results.authorizeUrl + '?token=' + results.token;
1981
- break;
1982
- case 4:
1983
- this.$alert(
1984
- results.msg ? results.msg : '账号未绑定,账号密码登录后自动绑定!',
1985
- '提示',
1986
- {
1987
- confirmButtonText: '确定',
1988
- type: 'error'
1989
- }
1990
- )
1991
- .then(() => {
1992
- sessionStorage.setItem(
1993
- 'extUserBindHandleId',
1994
- results.extUserBindHandleId
1995
- );
1996
- window.location.href = util.delUrlParam({ key: 'code' });
1997
- if (window.location.hash) {
1998
- location.reload();
1999
- }
2000
- })
2001
- .catch((e) => {});
2002
- break;
2003
- case 102:
2004
- this.checkCode = results.checkCode;
2005
- this.showAssistance = true;
2006
- let { operationCheckCode } = JSON.parse(results.checkCode);
2007
- this.handleAssistance({ operationCheckCode });
2008
- break;
2009
- default:
2010
- if (type !== 3) {
2011
- this.$message({
2012
- message: results.msg,
2013
- type: 'error',
2014
- onClose: () => {
2015
- if (this.code) {
2016
- window.location.href = util.delUrlParam({ key: 'code' });
2017
- if (window.location.hash) {
2018
- location.reload();
2019
- }
2020
- } else {
2021
- this.getImgCode();
2022
- }
2023
- }
2024
- });
2025
- } else if (this.active == 3) {
2026
- this.loginInfo(true);
2027
- }
2028
- }
2029
- },
2030
- handleAssistance(data) {
2031
- clearTimeout(this.doAssistance);
2032
- this.doAssistance = setTimeout(() => {
2033
- this.doAssistanceLogin(data);
2034
- }, this.scanIntervalTime);
2035
- },
2036
- doAssistanceLogin(data) {
2037
- util
2038
- .ajax({
2039
- method: 'post',
2040
- url: doAssistanceQrLogin,
2041
- data: data
2042
- })
2043
- .then((res) => {
2044
- if (res.rCode === 0) {
2045
- const results = res.results;
2046
- if (results.statusCode === 0) {
2047
- clearTimeout(this.doAssistance);
2048
- this.handleResults(results, 3);
2049
- } else {
2050
- this.handleAssistance(data);
2051
- }
2052
- } else {
2053
- clearTimeout(this.doAssistance);
2054
- this.$message.error(res.msg);
2055
- }
2056
- })
2057
- .catch((err) => {
2058
- clearTimeout(this.doAssistance);
2059
- if (err.message && err.message !== 'canceled') {
2060
- this.$message.error(err.message);
2061
- }
2062
- });
2063
- },
2064
- closeAssistance() {
2065
- clearTimeout(this.doAssistance);
2066
- },
2067
- handleSuccess() {
2068
- this.showResetPassword = false;
2069
- },
2070
- forbiddenTab(e) {
2071
- if (e.keyCode == 9) {
2072
- return false;
2073
- }
2074
- },
2075
- handlePaste(event) {
2076
- this.safe && event.preventDefault();
2077
- },
2078
- handleError() {
2079
- this.submit = false;
2080
- }
2081
- },
2082
- beforeDestroy() {
2083
- window.removeEventListener('resize', this.setScale);
2084
- document.removeEventListener('keyup', this.doLogin);
2085
- document.removeEventListener('keydown', this.forbiddenTab);
2086
- }
2087
- };
2088
- </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
+ console.log(content);
1510
+ content = content ? this.renderMarkdown(content) : content;
1511
+ }
1512
+ this.$alert(content, title, {
1513
+ dangerouslyUseHTMLString: isMarkdown,
1514
+ setHeight: isMarkdown,
1515
+ customClass: 'es-login-alert',
1516
+ ...config
1517
+ })
1518
+ .then(() => {
1519
+ this.alertCallback(1, { content, title, ...config });
1520
+ })
1521
+ .catch(() => {
1522
+ this.alertCallback(0, { content, title, ...config });
1523
+ });
1524
+ },
1525
+ async downloadMdFile(url) {
1526
+ try {
1527
+ const response = await fetch(url);
1528
+ if (!response.ok) {
1529
+ throw new Error(`下载失败: ${response.statusText}`);
1530
+ }
1531
+ return await response.text();
1532
+ } catch (error) {
1533
+ console.error('MD文件下载出错:', error);
1534
+ throw error; // 抛出错错误供调用者处理
1535
+ }
1536
+ },
1537
+ renderMarkdown(content) {
1538
+ // 这里使用简单的正则替换示例,实际项目建议使用成熟库如marked、markdown-it等
1539
+ // 生产环境推荐: npm install marked 后引入使用
1540
+ let html = content
1541
+ // 处理标题
1542
+ .replace(/^#{1,6}\s+(.*?)$/gm, (match, text, level) => {
1543
+ const hLevel = match.indexOf('#');
1544
+ return `<h${hLevel}>${text}</h${hLevel}>`;
1545
+ })
1546
+ // 处理粗体
1547
+ .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
1548
+ // 处理斜体
1549
+ .replace(/\*(.*?)\*/g, '<em>$1</em>')
1550
+ // 处理链接
1551
+ .replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2" target="_blank">$1</a>')
1552
+ // 处理换行
1553
+ .replace(/\n/g, '<br>');
1554
+ return html;
1555
+ },
1556
+ getImgCode() {
1557
+ if (this.identifyingId === '') {
1558
+ return;
1559
+ }
1560
+ this.imageCode =
1561
+ util.getStorage('host') +
1562
+ this.codeAction +
1563
+ '?identifyingId=' +
1564
+ this.identifyingId +
1565
+ (this.imgCode && typeof this.imgCode == 'object'
1566
+ ? '&' + util.queryParams(this.imgCode)
1567
+ : '') +
1568
+ '&heightflag=' +
1569
+ Math.random().toString().split('.')[1];
1570
+ delete this.formData.identifyingCode;
1571
+ delete this.formData.verificationCode;
1572
+ return this.imageCode;
1573
+ },
1574
+ getCode() {
1575
+ if (this.countdown) {
1576
+ return false;
1577
+ }
1578
+ let data = {};
1579
+ let flag = false;
1580
+ let ref = 'login' + this.active;
1581
+ if (this.active == 12) {
1582
+ if (!this.formData.username) {
1583
+ this.$refs[ref].validateField('username');
1584
+ return false;
1585
+ }
1586
+ this.$refs[ref].validateField('username', (res) => {
1587
+ flag = res != '';
1588
+ });
1589
+ if (flag) {
1590
+ return false;
1591
+ }
1592
+ data = {
1593
+ username: this.formData.username,
1594
+ targetType: this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS'
1595
+ // targetType: 'SMS'
1596
+ };
1597
+ } else {
1598
+ if (!this.formData.target) {
1599
+ this.$refs[ref].validateField('target');
1600
+ return false;
1601
+ }
1602
+ this.$refs[ref].validateField('target', (res) => {
1603
+ flag = res != '';
1604
+ });
1605
+ if (flag) {
1606
+ return false;
1607
+ }
1608
+ data = {
1609
+ target: this.formData.target,
1610
+ targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1611
+ };
1612
+ }
1613
+ this.countdown = 60;
1614
+ this.timer = setInterval(() => {
1615
+ if (this.countdown > 0) {
1616
+ this.countdown--;
1617
+ this.disabled = true;
1618
+ this.btnText = '重新获取' + this.countdown + 's';
1619
+ } else {
1620
+ this.btnText = '重新获取';
1621
+ this.disabled = false;
1622
+ this.submit = false;
1623
+ }
1624
+ }, 1000);
1625
+ util
1626
+ .ajax({
1627
+ method: 'post',
1628
+ url:
1629
+ this.active == 12 ? this.getTwoFactorLoginCode : this.getLoginCode,
1630
+ data: data
1631
+ })
1632
+ .then((res) => {
1633
+ this.$message({
1634
+ message: res.msg,
1635
+ duration: res.rCode == 0 ? 2000 : 3000,
1636
+ type: res.rCode == 0 ? 'success' : 'error'
1637
+ });
1638
+
1639
+ if (res.rCode === 2) {
1640
+ this.btnText = '获取验证码';
1641
+ this.disabled = false;
1642
+ this.countdown = 0;
1643
+ clearInterval(this.timer);
1644
+ }
1645
+ })
1646
+ .catch((err) => {
1647
+ if (err.message && err.message !== 'canceled') {
1648
+ this.$message.error(err.message);
1649
+ }
1650
+ });
1651
+ },
1652
+ handleLogin() {
1653
+ if (this.submit) {
1654
+ return false;
1655
+ }
1656
+ let ref = 'login' + this.active;
1657
+ this.$refs[ref].validate((valid) => {
1658
+ if (valid) {
1659
+ this.submit = true;
1660
+ let param = util.getParams() || {};
1661
+ const data =
1662
+ this.active == '0'
1663
+ ? {
1664
+ username: this.formData.username,
1665
+ password:
1666
+ this.secret && this.isEncrypt
1667
+ ? util.esmEncrypt({
1668
+ data: this.formData.password,
1669
+ key: this.secret
1670
+ })
1671
+ : this.formData.password,
1672
+ identifyingCode: this.formData.identifyingCode,
1673
+ identifyingId: this.identifyingId
1674
+ }
1675
+ : this.active == '12'
1676
+ ? {
1677
+ username: this.formData.username,
1678
+ password:
1679
+ this.secret && this.isEncrypt
1680
+ ? util.esmEncrypt({
1681
+ data: this.formData.password,
1682
+ key: this.secret
1683
+ })
1684
+ : this.formData.password,
1685
+ targetType:
1686
+ this.passModifyModel.indexOf('11') > -1 ? 'EMAIL' : 'SMS',
1687
+ verificationCode: this.formData.identifyingCode
1688
+ }
1689
+ : {
1690
+ target: this.formData.target,
1691
+ verificationCode: this.formData.verificationCode,
1692
+ targetType: this.active == '6' ? 'SMS' : 'EMAIL'
1693
+ };
1694
+ if (this.onLogin) {
1695
+ if (this.active == '0') {
1696
+ this.onLogin(
1697
+ { ...param, ...data },
1698
+ this.getImgCode,
1699
+ this.handleRemember
1700
+ );
1701
+ } else {
1702
+ this.onLogin({ ...param, ...data });
1703
+ }
1704
+ } else {
1705
+ this.handleUserLogin({ ...param, ...this.param, ...data });
1706
+ }
1707
+ } else {
1708
+ this.submit = false;
1709
+ return false;
1710
+ }
1711
+ });
1712
+ },
1713
+ doLogin(e) {
1714
+ if (util.win.event == undefined) {
1715
+ var key = e.keyCode;
1716
+ } else {
1717
+ var key = util.win.event.keyCode;
1718
+ }
1719
+ if (key == 13) {
1720
+ this.handleLogin();
1721
+ }
1722
+ },
1723
+ handleUserLogin(data) {
1724
+ let extUserBindHandleId = sessionStorage.getItem('extUserBindHandleId');
1725
+ util
1726
+ .ajax({
1727
+ method: 'post',
1728
+ url:
1729
+ this.active == '0'
1730
+ ? this.actionUrl
1731
+ : this.active == '12'
1732
+ ? this.doTwoFactorLogin
1733
+ : this.doCodeLogin,
1734
+ data: extUserBindHandleId
1735
+ ? { ...data, extUserBindHandleId: extUserBindHandleId }
1736
+ : data
1737
+ })
1738
+ .then((res) => {
1739
+ this.submit = false;
1740
+ if (res.rCode == 0) {
1741
+ util.removeStorage('extUserBindHandleId');
1742
+ this.handleRemember();
1743
+ const results = res.results;
1744
+ this.handleResults(results);
1745
+ if (this.onSuccess) {
1746
+ this.onSuccess(res);
1747
+ }
1748
+ } else {
1749
+ const msg =
1750
+ res.results && res.results.msg ? res.results.msg : res.msg;
1751
+ this.$message({
1752
+ message: msg || '系统错误,请联系管理员!',
1753
+ type: 'error',
1754
+ onClose: () => {
1755
+ this.btnText = '获取验证码';
1756
+ this.disabled = false;
1757
+ this.countdown = 0;
1758
+ clearInterval(this.timer);
1759
+ this.getImgCode();
1760
+ }
1761
+ });
1762
+ this.onError(res);
1763
+ }
1764
+ })
1765
+ .catch((err) => {
1766
+ this.submit = false;
1767
+ if (err.message && err.message !== 'canceled') {
1768
+ this.$message.error(err.message);
1769
+ }
1770
+ });
1771
+ },
1772
+ caLogin(signedData) {
1773
+ this.loginInfo(false);
1774
+ util
1775
+ .ajax({
1776
+ method: 'post',
1777
+ url: this.caAction,
1778
+ data:
1779
+ typeof signedData === 'string'
1780
+ ? { identifyingId: this.identifyingId, signedData: signedData }
1781
+ : signedData
1782
+ })
1783
+ .then((res) => {
1784
+ this.submit = false;
1785
+ if (res.rCode == 0) {
1786
+ const results = res.results;
1787
+ this.handleResults(results);
1788
+ if (this.onSuccess) {
1789
+ this.onSuccess(res);
1790
+ }
1791
+ } else {
1792
+ const msg =
1793
+ res.results && res.results.msg ? res.results.msg : res.msg;
1794
+ this.$message({
1795
+ message: msg || '系统错误,请联系管理员!',
1796
+ type: 'error',
1797
+ onClose: () => {
1798
+ this.getImgCode();
1799
+ this.loginInfo(this.active == 3);
1800
+ }
1801
+ });
1802
+ this.onError(res);
1803
+ }
1804
+ })
1805
+ .catch((err) => {
1806
+ this.submit = false;
1807
+ if (err.message && err.message !== 'canceled') {
1808
+ this.$message.error(err.message);
1809
+ }
1810
+ });
1811
+ },
1812
+ handleForget() {
1813
+ if (typeof this.forgetUrl === 'string') {
1814
+ util.win.open(this.forgetUrl);
1815
+ } else {
1816
+ this.showResetPassword = true;
1817
+ }
1818
+ },
1819
+ downloadExe() {
1820
+ util.win.open(this.downloadSetup);
1821
+ },
1822
+ //获取app登录信息
1823
+ loginInfo(res) {
1824
+ clearTimeout(this.interval);
1825
+ if (res) {
1826
+ this.interval = setTimeout(() => {
1827
+ this.initRequestLoginInfo();
1828
+ }, this.scanIntervalTime);
1829
+ }
1830
+ },
1831
+ initRequestLoginInfo() {
1832
+ if (this.identifyingId == '') {
1833
+ return false;
1834
+ }
1835
+ util
1836
+ .ajax({
1837
+ method: 'post',
1838
+ url: this.scanAction,
1839
+ data: {
1840
+ identifyingId: this.identifyingId
1841
+ }
1842
+ })
1843
+ .then((res) => {
1844
+ if (res.rCode === 0) {
1845
+ const results = res.results;
1846
+ if (results.statusCode === 0 || results.statusCode === 2) {
1847
+ // statusCode为2时 代表密码过期,也应执行handleResults
1848
+ clearTimeout(this.interval);
1849
+ if (results.statusCode === 2) {
1850
+ this.$alert(
1851
+ results.msg
1852
+ ? results.msg
1853
+ : '您的初始密码已过期,请及时修改!',
1854
+ '提示',
1855
+ {
1856
+ confirmButtonText: '确定',
1857
+ type: 'warning'
1858
+ }
1859
+ )
1860
+ .then(() => {
1861
+ this.handleResults(results, 3);
1862
+ })
1863
+ .catch((e) => {});
1864
+ } else {
1865
+ this.handleResults(results, 3);
1866
+ }
1867
+ } else {
1868
+ this.loginInfo(true);
1869
+ }
1870
+ }
1871
+ })
1872
+ .catch((err) => {
1873
+ clearTimeout(this.interval);
1874
+ if (err.message && err.message !== 'canceled') {
1875
+ this.$message.error(err.message);
1876
+ }
1877
+ });
1878
+ },
1879
+ handleResults(results, type) {
1880
+ switch (results.statusCode) {
1881
+ case 0:
1882
+ this.userName = results.userName;
1883
+ util.setStorage({
1884
+ type: this.storageType,
1885
+ key: {
1886
+ ssId: results.ssId,
1887
+ token: results.token,
1888
+ Authorization: results.token,
1889
+ deviceUnique: results.deviceUnique,
1890
+ userId: results.userId,
1891
+ userName: results.userName,
1892
+ useCaseCodes: results.resourceCodes
1893
+ }
1894
+ });
1895
+ if (this.launchShow) {
1896
+ this.$message({
1897
+ message: '登录成功!',
1898
+ type: 'success',
1899
+ duration: 1000
1900
+ });
1901
+ this.showLaunch = true;
1902
+ setTimeout(() => {
1903
+ if (this.toUrl) {
1904
+ window.location.href = this.toUrl;
1905
+ } else if (results.doorIndex && this.doorIndex) {
1906
+ sessionStorage.setItem('doorIndex', results.doorIndex);
1907
+ localStorage.setItem('isLogined', true);
1908
+ window.location.href = results.doorIndex;
1909
+ } else {
1910
+ if (window.location.href.indexOf('login.html') > -1) {
1911
+ window.location.href = './main.html';
1912
+ } else {
1913
+ this.$router.push({ name: 'main' });
1914
+ this.$nextTick(() => {
1915
+ this.showLaunch = false;
1916
+ });
1917
+ }
1918
+ }
1919
+ }, this.launchTime);
1920
+ } else {
1921
+ this.$message({
1922
+ message: '登录成功!',
1923
+ type: 'success',
1924
+ duration: 1500,
1925
+ onClose: () => {
1926
+ if (this.toUrl) {
1927
+ window.location.href = this.toUrl;
1928
+ } else if (results.doorIndex && this.doorIndex) {
1929
+ sessionStorage.setItem('doorIndex', results.doorIndex);
1930
+ localStorage.setItem('isLogined', true);
1931
+ window.location.href = results.doorIndex;
1932
+ } else {
1933
+ if (window.location.href.indexOf('login.html') > -1) {
1934
+ window.location.href = './main.html';
1935
+ } else {
1936
+ this.$router.push({ name: 'main' });
1937
+ }
1938
+ }
1939
+ }
1940
+ });
1941
+ }
1942
+ break;
1943
+ case 2:
1944
+ this.$confirm(
1945
+ results.msg ? results.msg : '密码太简单了, 请修改密码?',
1946
+ '提示',
1947
+ {
1948
+ confirmButtonText: '确定',
1949
+ //cancelButtonText: '取消',
1950
+ type: 'warning'
1951
+ }
1952
+ )
1953
+ .then(() => {
1954
+ this.operationCheckCode = results.checkCode;
1955
+ if (typeof this.forgetUrl === 'string') {
1956
+ util.win.open(this.forgetUrl);
1957
+ } else {
1958
+ this.showResetPassword = true;
1959
+ }
1960
+ })
1961
+ .catch((e) => {});
1962
+ break;
1963
+ case 3:
1964
+ let url =
1965
+ results.doorIndex && this.doorIndex
1966
+ ? results.doorIndex
1967
+ : window.location.href.indexOf('main.html') > -1
1968
+ ? './login.html'
1969
+ : window.location.hash
1970
+ ? window.location.href.replace('login', 'main')
1971
+ : window.location.href;
1972
+ const href = results.authorizeUrl.replace(
1973
+ '{redirectUri}',
1974
+ encodeURIComponent(url)
1975
+ );
1976
+ window.location.href = href;
1977
+ // window.location.href =
1978
+ // results.authorizeUrl.indexOf('?') > -1
1979
+ // ? results.authorizeUrl + '&token=' + results.token
1980
+ // : results.authorizeUrl + '?token=' + results.token;
1981
+ break;
1982
+ case 4:
1983
+ this.$alert(
1984
+ results.msg ? results.msg : '账号未绑定,账号密码登录后自动绑定!',
1985
+ '提示',
1986
+ {
1987
+ confirmButtonText: '确定',
1988
+ type: 'error'
1989
+ }
1990
+ )
1991
+ .then(() => {
1992
+ sessionStorage.setItem(
1993
+ 'extUserBindHandleId',
1994
+ results.extUserBindHandleId
1995
+ );
1996
+ window.location.href = util.delUrlParam({ key: 'code' });
1997
+ if (window.location.hash) {
1998
+ location.reload();
1999
+ }
2000
+ })
2001
+ .catch((e) => {});
2002
+ break;
2003
+ case 102:
2004
+ this.checkCode = results.checkCode;
2005
+ this.showAssistance = true;
2006
+ let { operationCheckCode } = JSON.parse(results.checkCode);
2007
+ this.handleAssistance({ operationCheckCode });
2008
+ break;
2009
+ default:
2010
+ if (type !== 3) {
2011
+ this.$message({
2012
+ message: results.msg,
2013
+ type: 'error',
2014
+ onClose: () => {
2015
+ if (this.code) {
2016
+ window.location.href = util.delUrlParam({ key: 'code' });
2017
+ if (window.location.hash) {
2018
+ location.reload();
2019
+ }
2020
+ } else {
2021
+ this.getImgCode();
2022
+ }
2023
+ }
2024
+ });
2025
+ } else if (this.active == 3) {
2026
+ this.loginInfo(true);
2027
+ }
2028
+ }
2029
+ },
2030
+ handleAssistance(data) {
2031
+ clearTimeout(this.doAssistance);
2032
+ this.doAssistance = setTimeout(() => {
2033
+ this.doAssistanceLogin(data);
2034
+ }, this.scanIntervalTime);
2035
+ },
2036
+ doAssistanceLogin(data) {
2037
+ util
2038
+ .ajax({
2039
+ method: 'post',
2040
+ url: doAssistanceQrLogin,
2041
+ data: data
2042
+ })
2043
+ .then((res) => {
2044
+ if (res.rCode === 0) {
2045
+ const results = res.results;
2046
+ if (results.statusCode === 0) {
2047
+ clearTimeout(this.doAssistance);
2048
+ this.handleResults(results, 3);
2049
+ } else {
2050
+ this.handleAssistance(data);
2051
+ }
2052
+ } else {
2053
+ clearTimeout(this.doAssistance);
2054
+ this.$message.error(res.msg);
2055
+ }
2056
+ })
2057
+ .catch((err) => {
2058
+ clearTimeout(this.doAssistance);
2059
+ if (err.message && err.message !== 'canceled') {
2060
+ this.$message.error(err.message);
2061
+ }
2062
+ });
2063
+ },
2064
+ closeAssistance() {
2065
+ clearTimeout(this.doAssistance);
2066
+ },
2067
+ handleSuccess() {
2068
+ this.showResetPassword = false;
2069
+ },
2070
+ forbiddenTab(e) {
2071
+ if (e.keyCode == 9) {
2072
+ return false;
2073
+ }
2074
+ },
2075
+ handlePaste(event) {
2076
+ this.safe && event.preventDefault();
2077
+ },
2078
+ handleError() {
2079
+ this.submit = false;
2080
+ }
2081
+ },
2082
+ beforeDestroy() {
2083
+ window.removeEventListener('resize', this.setScale);
2084
+ document.removeEventListener('keyup', this.doLogin);
2085
+ document.removeEventListener('keydown', this.forbiddenTab);
2086
+ }
2087
+ };
2088
+ </script>