system-clients 3.2.96 → 3.2.97-temp

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 (217) hide show
  1. package/.eslintrc.js +16 -16
  2. package/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
  5. package/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
  6. package/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  7. package/.gradle/7.4/fileChanges/last-build.bin +0 -0
  8. package/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
  9. package/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  10. package/.gradle/7.4/gc.properties +0 -0
  11. package/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/.gradle/buildOutputCleanup/cache.properties +2 -0
  13. package/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  14. package/.gradle/file-system.probe +0 -0
  15. package/.gradle/vcs-1/gc.properties +0 -0
  16. package/SystemClient.iml +8 -8
  17. package/build/webpack.base.conf.js +85 -85
  18. package/build.gradle +6 -6
  19. package/examples/LoginPage/App.vue +21 -21
  20. package/examples/LoginPage/index.html +11 -11
  21. package/examples/LoginPage/main.js +15 -15
  22. package/index.html +21 -21
  23. package/package.json +105 -105
  24. package/src/components/Main.vue +961 -937
  25. package/src/components/TabButton.vue +201 -201
  26. package/src/components/Tabs.vue +67 -67
  27. package/src/components/Util.js +343 -343
  28. package/src/components/addressManage/AddressCascadingMenu.vue +145 -145
  29. package/src/components/common/ProgressBase.vue +83 -83
  30. package/src/components/equipment/EquipmentManage.vue +83 -83
  31. package/src/components/equipment/PcAdd.vue +115 -115
  32. package/src/components/equipment/PcList.vue +119 -119
  33. package/src/components/equipment/PcManage.vue +61 -61
  34. package/src/components/equipment/PhoneAdd.vue +118 -118
  35. package/src/components/equipment/PhoneList.vue +113 -113
  36. package/src/components/equipment/PhoneManage.vue +61 -61
  37. package/src/components/equipment/PosAdd.vue +323 -319
  38. package/src/components/equipment/PosList.vue +294 -292
  39. package/src/components/equipment/PosManage.vue +138 -138
  40. package/src/components/equipment/PosManageBoth.vue +125 -125
  41. package/src/components/equipment/PosParamAdd.vue +236 -236
  42. package/src/components/equipment/PosParamList.vue +121 -121
  43. package/src/components/equipment/PosParamManage.vue +51 -51
  44. package/src/components/materialManage/materialData.vue +44 -44
  45. package/src/components/materialManage/materialList.vue +255 -255
  46. package/src/components/parammanage/ParamManage.vue +42 -42
  47. package/src/components/parammanage/ParamPage.vue +337 -337
  48. package/src/components/parammanage/ParamPages.vue +222 -222
  49. package/src/components/parammanage/SinglePage.vue +235 -235
  50. package/src/components/parammanage/SinglePages.vue +167 -167
  51. package/src/components/server/AddChangeMsg.vue +66 -66
  52. package/src/components/server/ChangeDeclare.vue +45 -45
  53. package/src/components/server/ImageVieweTest.vue +56 -56
  54. package/src/components/server/ImageViewer.vue +350 -350
  55. package/src/components/server/LeftTree.vue +111 -111
  56. package/src/components/server/LoadData.vue +55 -55
  57. package/src/components/server/Login.vue +571 -548
  58. package/src/components/server/LoginPage.vue +235 -235
  59. package/src/components/server/LoginView.vue +128 -128
  60. package/src/components/server/Menu.vue +188 -188
  61. package/src/components/server/ModifyPw.vue +125 -126
  62. package/src/components/server/PcdBuildingSelect.vue +241 -243
  63. package/src/components/server/ResSelect.vue +175 -169
  64. package/src/components/server/ResSelectGroup.vue +211 -211
  65. package/src/components/server/RightTree.vue +348 -348
  66. package/src/components/server/RoleSelector.vue +89 -90
  67. package/src/components/server/TestResSelect.vue +58 -58
  68. package/src/components/server/TestResSelectGroup.vue +388 -388
  69. package/src/filiale/baole/Login.vue +568 -570
  70. package/src/filiale/baole/system.js +5 -5
  71. package/src/filiale/bayan/PosAdd.vue +369 -0
  72. package/src/filiale/bayan/PosList.vue +349 -0
  73. package/src/filiale/bayan/PosManage.vue +138 -0
  74. package/src/filiale/bayan/system.js +6 -0
  75. package/src/filiale/chengtou/Login.vue +537 -539
  76. package/src/filiale/chengtou/system.js +5 -5
  77. package/src/filiale/dongguan/Login.vue +900 -902
  78. package/src/filiale/dongguan/Main.vue +715 -717
  79. package/src/filiale/dongguan/system.js +6 -6
  80. package/src/filiale/furuike/Login.vue +583 -587
  81. package/src/filiale/furuike/Main.vue +827 -840
  82. package/src/filiale/furuike/system.js +7 -7
  83. package/src/filiale/gehua/Main.vue +807 -809
  84. package/src/filiale/gehua/system.js +6 -6
  85. package/src/filiale/konggang/Login.vue +470 -472
  86. package/src/filiale/konggang/system.js +7 -7
  87. package/src/filiale/qianneng/Login.vue +582 -584
  88. package/src/filiale/qianneng/Main.vue +816 -818
  89. package/src/filiale/qianneng/ModifyPw.vue +107 -108
  90. package/src/filiale/qianneng/system.js +11 -11
  91. package/src/filiale/rizhao/LeftTree.vue +111 -111
  92. package/src/filiale/rizhao/Login.vue +791 -793
  93. package/src/filiale/rizhao/Main.vue +611 -611
  94. package/src/filiale/rizhao/system.js +14 -14
  95. package/src/filiale/shiquan/Login.vue +564 -566
  96. package/src/filiale/shiquan/system.js +8 -8
  97. package/src/filiale/tianyi/Login.vue +571 -573
  98. package/src/filiale/tianyi/system.js +5 -5
  99. package/src/filiale/tongchuan/Login.vue +561 -563
  100. package/src/filiale/tongchuan/Main.vue +1019 -1021
  101. package/src/filiale/tongchuan/system.js +7 -7
  102. package/src/filiale/weinan/Main.vue +923 -924
  103. package/src/filiale/weinan/system.js +7 -7
  104. package/src/filiale/wenxi/Login.vue +535 -537
  105. package/src/filiale/wenxi/Main.vue +785 -787
  106. package/src/filiale/wenxi/system.js +10 -10
  107. package/src/filiale/wuhai/LeftTree.vue +141 -141
  108. package/src/filiale/wuhai/Main.vue +807 -810
  109. package/src/filiale/wuhai/system.js +10 -10
  110. package/src/filiale/yuchuan/Login.vue +889 -891
  111. package/src/filiale/yuchuan/Main.vue +864 -866
  112. package/src/filiale/yuchuan/system.js +10 -10
  113. package/src/filiale/zhoukou/Main.vue +807 -809
  114. package/src/filiale/zhoukou/system.js +6 -6
  115. package/src/plugins/EncryptUtil.js +53 -53
  116. package/src/plugins/GetLoginInfoService.js +581 -474
  117. package/src/plugins/HeatGetLoginInfoService.js +491 -491
  118. package/src/plugins/validation.js +15 -15
  119. package/src/stores/AppData.js +38 -38
  120. package/src/stores/HeatAppData.js +38 -38
  121. package/src/styles/fonts/glyphicons-halflings-regular.svg +288 -288
  122. package/src/styles/less/.csscomb.json +304 -304
  123. package/src/styles/less/.csslintrc +19 -19
  124. package/src/styles/less/alerts.less +73 -73
  125. package/src/styles/less/aofeng/animate.min.css +10 -10
  126. package/src/styles/less/aofeng/expandcss.less +569 -569
  127. package/src/styles/less/aofeng/login.less +367 -367
  128. package/src/styles/less/aofeng/standard.less +2507 -2507
  129. package/src/styles/less/aofeng/themeOne/BinaryTemplate.less +690 -690
  130. package/src/styles/less/aofeng/themeOne/loginStyle.less +1586 -1586
  131. package/src/styles/less/aofeng/themeOne/systemStyle.less +2650 -2650
  132. package/src/styles/less/aofeng/themeOne.less +17 -17
  133. package/src/styles/less/aofeng/themeTwo/newStyle1.less +415 -415
  134. package/src/styles/less/aofeng/themeTwo.less +3 -3
  135. package/src/styles/less/badges.less +66 -66
  136. package/src/styles/less/bootstrap.less +66 -66
  137. package/src/styles/less/breadcrumbs.less +26 -26
  138. package/src/styles/less/button-groups.less +247 -247
  139. package/src/styles/less/buttons.less +172 -172
  140. package/src/styles/less/carousel.less +269 -269
  141. package/src/styles/less/close.less +34 -34
  142. package/src/styles/less/code.less +69 -69
  143. package/src/styles/less/component-animations.less +33 -33
  144. package/src/styles/less/dropdowns.less +216 -216
  145. package/src/styles/less/fonts-list.less +25 -25
  146. package/src/styles/less/forms.less +626 -626
  147. package/src/styles/less/glyphicons.less +305 -305
  148. package/src/styles/less/grid.less +84 -84
  149. package/src/styles/less/input-groups.less +167 -167
  150. package/src/styles/less/jumbotron.less +52 -52
  151. package/src/styles/less/labels.less +64 -64
  152. package/src/styles/less/list-group.less +141 -141
  153. package/src/styles/less/manageStyle/manageChile.less +180 -180
  154. package/src/styles/less/manageStyle/manageStyle/manageChile.less +180 -180
  155. package/src/styles/less/manageStyle/manageStyle/manageStyle.less +1102 -1102
  156. package/src/styles/less/manageStyle/manageStyle/safeStyle.less +498 -498
  157. package/src/styles/less/manageStyle/manageStyle.less +1102 -1102
  158. package/src/styles/less/manageStyle/safeStyle.less +498 -498
  159. package/src/styles/less/media.less +66 -66
  160. package/src/styles/less/mixins/alerts.less +14 -14
  161. package/src/styles/less/mixins/background-variant.less +9 -9
  162. package/src/styles/less/mixins/border-radius.less +18 -18
  163. package/src/styles/less/mixins/buttons.less +69 -69
  164. package/src/styles/less/mixins/center-block.less +7 -7
  165. package/src/styles/less/mixins/clearfix.less +22 -22
  166. package/src/styles/less/mixins/forms.less +90 -90
  167. package/src/styles/less/mixins/gradients.less +59 -59
  168. package/src/styles/less/mixins/grid-framework.less +92 -92
  169. package/src/styles/less/mixins/grid.less +122 -122
  170. package/src/styles/less/mixins/hide-text.less +21 -21
  171. package/src/styles/less/mixins/image.less +33 -33
  172. package/src/styles/less/mixins/labels.less +12 -12
  173. package/src/styles/less/mixins/list-group.less +30 -30
  174. package/src/styles/less/mixins/nav-divider.less +10 -10
  175. package/src/styles/less/mixins/nav-vertical-align.less +9 -9
  176. package/src/styles/less/mixins/opacity.less +8 -8
  177. package/src/styles/less/mixins/pagination.less +24 -24
  178. package/src/styles/less/mixins/panels.less +24 -24
  179. package/src/styles/less/mixins/progress-bar.less +10 -10
  180. package/src/styles/less/mixins/reset-filter.less +8 -8
  181. package/src/styles/less/mixins/reset-text.less +18 -18
  182. package/src/styles/less/mixins/resize.less +6 -6
  183. package/src/styles/less/mixins/responsive-visibility.less +15 -15
  184. package/src/styles/less/mixins/size.less +10 -10
  185. package/src/styles/less/mixins/tab-focus.less +9 -9
  186. package/src/styles/less/mixins/table-row.less +44 -44
  187. package/src/styles/less/mixins/text-emphasis.less +9 -9
  188. package/src/styles/less/mixins/text-overflow.less +8 -8
  189. package/src/styles/less/mixins/vendor-prefixes.less +227 -227
  190. package/src/styles/less/mixins.less +40 -40
  191. package/src/styles/less/modals.less +151 -151
  192. package/src/styles/less/navbar.less +660 -660
  193. package/src/styles/less/navs.less +285 -285
  194. package/src/styles/less/normalize.less +424 -424
  195. package/src/styles/less/pager.less +76 -76
  196. package/src/styles/less/pagination.less +89 -89
  197. package/src/styles/less/panels.less +275 -275
  198. package/src/styles/less/popovers.less +131 -131
  199. package/src/styles/less/print.less +101 -101
  200. package/src/styles/less/progress-bars.less +87 -87
  201. package/src/styles/less/responsive-embed.less +35 -35
  202. package/src/styles/less/responsive-utilities.less +194 -194
  203. package/src/styles/less/scaffolding.less +161 -161
  204. package/src/styles/less/stand.less +207 -207
  205. package/src/styles/less/tables.less +312 -312
  206. package/src/styles/less/theme.less +291 -291
  207. package/src/styles/less/thumbnails.less +36 -36
  208. package/src/styles/less/tooltip.less +102 -102
  209. package/src/styles/less/type.less +316 -316
  210. package/src/styles/less/utilities.less +55 -55
  211. package/src/styles/less/variables.less +899 -899
  212. package/src/styles/less/wells.less +29 -29
  213. package/src/system.js +125 -121
  214. package/src/util/Daiban.json +12 -12
  215. package/yarn-error.log +6896 -6896
  216. package/src/filiale/ruihua/Login.vue +0 -549
  217. package/src/filiale/ruihua/system.js +0 -5
@@ -1,474 +1,581 @@
1
- import Vue from 'vue'
2
- import {HttpResetClass} from 'vue-client'
3
- import cryptJS from './EncryptUtil'
4
-
5
- let loginGen = async function (username, password, cue) {
6
- let data = {username, password,resourceName:'客服系统'}
7
- const getLogin = await Vue.resetpost('/api/af-auth/login', data,
8
- {resolveMsg: null, rejectMsg: null,headerConfig:{'Content-type': "application/json"}
9
- })
10
- if (getLogin.data) {
11
- //获取jwt
12
- Vue.$login.jwt = getLogin.data.resources.data.id
13
- Vue.$login.jwtNew = getLogin.data.access_token
14
- // 调用远程登录服务,获取所有有权访问的功能
15
- Vue.$login.f = getLogin.data.resources.data
16
- // 把登录用户添加到cookie里
17
- Vue.cookie.set('loginId', Vue.$login.f.id)
18
- try {
19
- //获取有权限的功能树
20
- let hasRight = await Vue.resetpost(`/rs/search`, {
21
- source: "tool.getFullTree(this.getRights().where(row.getType() == $function$))",
22
- userid: Vue.$login.f.id
23
- }, { resolveMsg: null, rejectMsg: null })
24
- //准备替换功能树
25
- var fun = []
26
- hasRight.data[0].children[0].children.forEach((item) => {
27
- if (item.name === '客服系统') {
28
- item.children.forEach((item1) => {
29
- fun.push(item1)
30
- })
31
- }
32
- })
33
- Vue.$login.f.functions = fun
34
- } catch (error) {
35
- }
36
- if (Vue.$login.f.id !== '11') {
37
- try {
38
- let getAllArea = await Vue.resetpost('/rs/search', {
39
- source: 'this.getParentByType($organization$).getChildByName($片区$).getChildren()',
40
- userid: Vue.$login.f.id
41
- }, {resolveMsg: null, rejectMsg: null})
42
-
43
- let areaTemp = []
44
- for (let i = 0; i < getAllArea.data.length; i++) {
45
- areaTemp.push({label: getAllArea.data[i].name, value: getAllArea.data[i]})
46
- }
47
- Vue.$login.f.f_allArea = areaTemp
48
- } catch (error) {
49
- Vue.$login.f.f_allArea = []
50
- console.log('获取区县', error)
51
- }
52
- // 获取抄表员
53
- try {
54
- let getGasman = await Vue.resetpost('/rs/search', {
55
- source: 'this.getParentByType($organization$).getChildByName($抄表员$).getUsers()',
56
- userid: Vue.$login.f.id
57
- }, {resolveMsg: null, rejectMsg: null})
58
- let gasman = []
59
- for (let i = 0; i < getGasman.data.length; i++) {
60
- gasman.push(getGasman.data[i])
61
- }
62
- Vue.$login.f.f_gasman = gasman
63
- } catch (error) {
64
- Vue.$login.f.f_gasman = []
65
- console.log('抄表员模块', error)
66
- }
67
- // 获取安装人
68
- try {
69
- let getInstallman = await Vue.resetpost('/rs/search', {
70
- source: 'this.getParentByType($organization$).getChildByName($安装员$).getUsers()',
71
- userid: Vue.$login.f.id
72
- }, {resolveMsg: null, rejectMsg: null})
73
- console.log('获取安装员', getInstallman)
74
- let installman = []
75
- for (let i = 0; i < getInstallman.data.length; i++) {
76
- installman.push(getInstallman.data[i])
77
- }
78
- Vue.$login.f.f_installman = installman
79
- } catch (error) {
80
- Vue.$login.f.f_installman = []
81
- console.log('安装人模块', error)
82
- }
83
- // 获取资源服务权限
84
- try {
85
- let getLic = await Vue.resetpost('/rs/search', {
86
- data: {
87
- source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($资源操作$) != -1)',
88
- userid: Vue.$login.f.id
89
- }
90
- }, {resolveMsg: null, rejectMsg: null})
91
- let arry = []
92
- getLic.data.forEach((item) => {
93
- arry.push(item.name)
94
- })
95
- Vue.$login.f.lics = arry
96
- } catch (error) {
97
- Vue.$login.f.f_gasman = []
98
- console.log('资源服务权限', error)
99
- }
100
- // TODO 处理界面细节
101
- try {
102
- let viewDetails = await Vue.resetpost('rs/search', {
103
- source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($功能权限$) != -1)',
104
- userid: Vue.$login.f.id
105
- }, {resolveMsg: null, rejectMsg: null})
106
- let r = viewDetails.data
107
- Vue.$login.r = []
108
- r.forEach(x => Vue.$login.r.push(x.name))
109
- } catch (error) {
110
- Vue.$login.r = []
111
- console.log('加载模块失败', error)
112
- }
113
- // 调用登录后处理
114
- for (let proc of Vue.$login.afterLogin) {
115
- await proc(Vue.$login.f)
116
- }
117
- // 定时发送心跳
118
- if (cue) {
119
- setInterval(() => {
120
- let http = new HttpResetClass()
121
- //暂时不出现不出现异地登录校验
122
- http.load('POST', `rs/user/access/${Vue.$login.f.id}`, {}, {
123
- resolveMsg: null,
124
- rejectMsg: null
125
- }).then((req) => {
126
- if (req.data.forcestate && req.data.forcestate == 1) {
127
- Vue.showMessage("您被强制下线!", ['confirm']).then((res) => {
128
- location.reload()
129
- })
130
- } else if (req.data.status == 710) {
131
- Vue.showMessage(req.data.msg + ",您将被强制退出系统", ['confirm']).then((res) => {
132
- if (res === 'confirm') {
133
- location.reload()
134
- }
135
- })
136
- }
137
- })
138
- }, 2 * 60 * 1000)
139
- }
140
- }
141
-
142
- } else {
143
- let error = {status: 401, data: "登录失败,请稍后重试"}
144
- if (getLogin.data.code !== 500) {
145
- error = {status: getLogin.data.code, data: getLogin.data.msg}
146
- }
147
- // 抛出错误
148
- throw error
149
- }
150
- }
151
-
152
- let GetLoginInfoService = {
153
- // 登录后要处理的异步对象
154
- afterLogin: [],
155
- //验证码开关
156
- Verification: true,
157
- //构建时间开关
158
- versionTime: true,
159
- //
160
- SinglePageToken : {},
161
- //登录信息展示开关
162
- depPrompt: true,
163
- install(Vue, options) {
164
- // 给vue增添对话框显示方法
165
- Vue.$login = Vue.prototype.$login = GetLoginInfoService
166
- },
167
-
168
- f: {},
169
-
170
- /**
171
- * 登录
172
- * @param name
173
- * @param password
174
- * @param cue true/false 是/否显示异地登录
175
- */
176
- login(name, password, cue) {
177
- if (cue === undefined || cue === null || cue === '') {
178
- cue = true
179
- }
180
- Vue.$login.SinglePageToken = cryptJS.AESEncrypt(JSON.stringify({name,password}), "3KMKqvgwR8ULbR8Z")
181
- return loginGen(name, password, cue)
182
- },
183
-
184
- convertToIn(val) {
185
- let temp = ''
186
- if (val instanceof Array) {
187
- if (val.length >= 1) {
188
- temp = '('
189
- val.forEach((res) => {
190
- temp += `'${res}',`
191
- })
192
- temp = temp.substr(0, temp.length - 1) + ')'
193
- }
194
- }
195
- return temp
196
- },
197
-
198
- toStandardYearMonth() {
199
- let dt = new Date()
200
- let month = dt.getMonth() + 1
201
- return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month)
202
- },
203
-
204
- toStandardYearMonth1() {
205
- let dt = new Date()
206
- let month = dt.getMonth() + 1
207
- return dt.getFullYear() + (month < 10 ? '0' + month : month)
208
- },
209
-
210
- toStandardDateString() {
211
- let dt = new Date()
212
- let month = dt.getMonth() + 1
213
- let date = dt.getDate()
214
- return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
215
- },
216
-
217
- toStartAndEndDateString() {
218
- let dt = new Date()
219
- let month = dt.getMonth() + 1
220
- // let date = dt.getDate()
221
- return [dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-01',
222
- dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (new Date(dt.getFullYear(), month, 0).getDate())]
223
- // return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
224
- },
225
-
226
- toStandardTimeString() {
227
- let dt = new Date()
228
- let month = dt.getMonth() + 1
229
- let date = dt.getDate()
230
- let hour = dt.getHours()
231
- let min = dt.getMinutes()
232
- let sec = dt.getSeconds()
233
- return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date) +
234
- ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
235
- },
236
-
237
- guid() {
238
- let buf = new Uint16Array(8)
239
- window.crypto.getRandomValues(buf)
240
- let S4 = function (num) {
241
- let ret = num.toString(16)
242
- while (ret.length < 4) {
243
- ret = '0' + ret
244
- }
245
- return ret
246
- }
247
- return (S4(buf[0]) + S4(buf[1]) + S4(buf[2]) + S4(buf[3]) + S4(buf[4]) + S4(buf[5]) + S4(buf[6]) + S4(buf[7]))
248
- },
249
-
250
- choices(role, param, hasBlank = false, blankHint = '请选择') {
251
- if (role == 'view') {
252
- Vue.getParams(param, [null])
253
- } else {
254
- let result = []
255
- if (hasBlank)
256
- result.push({label: blankHint, value: null})
257
- if (!Vue.param || !Vue.param[param])
258
- result.push({label: '请在系统设置里更新参数', value: '请在系统设置里更新参数'})
259
- else {
260
- let p = Vue.param[param]
261
- p.forEach(function (item) {
262
- result.push({label: item.name, value: item.name})
263
- })
264
- }
265
- return result
266
- }
267
- },
268
-
269
- required(param) {
270
- if (typeof param === 'number' && param == 0)
271
- return false
272
- if (!param)
273
- return true
274
- param = param + ''
275
- param = param.trim()
276
- if (!param)
277
- return true
278
- return false
279
- },
280
-
281
- isInt(n) {
282
- return !window.isNaN(n) && n % 1 === 0
283
- },
284
-
285
- isFloat(n) {
286
- return !window.isNaN(n)
287
- },
288
-
289
- // this will convert all true/false to boolean
290
- booleanFilter(paper) {
291
- for (let key in paper) {
292
- if (!paper.hasOwnProperty(key))
293
- continue
294
- if (typeof paper[key] == 'object' && paper[key] != null) {
295
- booleanFilter(paper[key])
296
- } else {
297
- if (paper[key] === 'true' || paper[key] == 'false')
298
- paper[key] = (paper[key] === 'true')
299
- }
300
- }
301
- },
302
- // recursively traverse through each path
303
- ratifyPics(paper) {
304
- for (let key in paper) {
305
- if (key.endsWith('_path')) {
306
- if (!paper[key]) {
307
- paper[key] = 'rs/db/file/nopic.png'
308
- } else {
309
- paper[key] = 'rs/db/file/' + paper[key]
310
- }
311
- } else if (paper[key] !== null && typeof (paper[key]) == 'object') {
312
- ratifyPics(paper[key])
313
- }
314
- }
315
- },
316
-
317
- // load script and other stuff
318
- loadscript(type, fileName) {
319
- return new Promise((resolve, reject) => {
320
- let element
321
- if (type == 'css') {
322
- element = document.createElement('link')
323
- element.setAttribute('rel', 'stylesheet')
324
- element.setAttribute('type', 'text/css')
325
- element.setAttribute('href', fileName)
326
- } else if (type == 'js') {
327
- element = document.createElement('script')
328
- element.setAttribute('type', 'text/javascript')
329
- element.setAttribute('src', fileName)
330
- }
331
- if (element) {
332
- element.setAttribute('async', '')
333
- element.setAttribute('defer', '')
334
- element.addEventListener('load', function () {
335
- resolve(element)
336
- }, false)
337
- element.addEventListener('error', function () {
338
- reject(element)
339
- }, false)
340
- document.body.appendChild(element)
341
- }
342
- })
343
- },
344
- // 不能选择器中截取掉多余的字符
345
- orgName(name) {
346
- return name.substring(10)
347
- },
348
-
349
- getNowDate(name) {
350
- // 求取当前时间的工具
351
- let myweekday = ''
352
- let year = ''
353
- let mydate = new Date()
354
- myweekday = mydate.getDay()
355
- let mymonth = mydate.getMonth() + 1
356
- let myday = mydate.getDate()
357
- let myyear = mydate.getYear()
358
- year = (myyear > 200) ? myyear : 1900 + myyear
359
- let week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期日', '星期六']
360
- // document.write("<font color=#ffffff>今天是 "+year+"年"+mymonth+"月"+myday+"日 "+weekday+"</font>");
361
- return year + '年' + mymonth + '月' + myday + '日 ' + week[myweekday]
362
- },
363
-
364
- addDate(date, days) {
365
- // 求取当前时间的工具
366
- let endDate = new Date(date)
367
- endDate = endDate.valueOf()
368
- endDate = endDate + days * 24 * 60 * 60 * 1000
369
- endDate = new Date(endDate)
370
- let month = endDate.getMonth() + 1
371
- let day = endDate.getDate()
372
- let hour = endDate.getHours()
373
- let min = endDate.getMinutes()
374
- let sec = endDate.getSeconds()
375
- return endDate.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day) +
376
- ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
377
- // return a
378
- },
379
-
380
- // 通过地址栏的参数获取参数内容
381
- getUrlParames(param) {
382
- var query = window.location.search
383
- var iLen = param.length
384
- var iStart = query.indexOf(param)
385
- if (iStart === -1) {
386
- return ''
387
- }
388
- iStart += iLen + 1
389
- var iEnd = query.indexOf('&', iStart)
390
- if (iEnd === -1) {
391
- return query.substring(iStart)
392
- }
393
- return query.substring(iStart, iEnd)
394
- },
395
-
396
- // 从地址栏获取加密的参数
397
- getUrlCompileParames(param) {
398
- let code = unescape(window.location.search.slice(1, window.location.search.length))
399
- let query = String.fromCharCode(code.charCodeAt(0) - code.length)
400
- for (var i = 1; i < code.length; i++) {
401
- query += String.fromCharCode(code.charCodeAt(i) - query.charCodeAt(i - 1))
402
- }
403
- let iLen = param.length
404
- let iStart = query.indexOf(param)
405
- if (iStart === -1) {
406
- return ''
407
- }
408
- iStart += iLen + 1
409
- let iEnd = query.indexOf('&', iStart)
410
- if (iEnd === -1) {
411
- return query.substring(iStart)
412
- }
413
- return query.substring(iStart, iEnd)
414
- },
415
-
416
- // 对字符串进行加密
417
- compileStr(code) {
418
- let c = String.fromCharCode(code.charCodeAt(0) + code.length)
419
- for (let i = 1; i < code.length; i++) {
420
- c += String.fromCharCode(code.charCodeAt(i) + code.charCodeAt(i - 1))
421
- }
422
- return escape(c)
423
- },
424
- // 字符串进行解密
425
- uncompileStr(code) {
426
- code = unescape(code)
427
- let c = String.fromCharCode(code.charCodeAt(0) - code.length)
428
- for (var i = 1; i < code.length; i++) {
429
- c += String.fromCharCode(code.charCodeAt(i) - c.charCodeAt(i - 1))
430
- }
431
- return c
432
- },
433
-
434
- dateDescripte(date) {
435
- let nowTime = new Date().getTime()
436
- let oldTime = new Date(date).getTime()
437
- let timeDiff = nowTime - oldTime
438
- // 规则说明
439
- // 小于等于2分钟为刚刚
440
- // 大于2分钟小于等于1小时为取整的分钟前(例如:35分钟前)
441
- // 大于1小时小于等于24小时为取整的小时前(例如:15小时前)
442
- // 大于24小时小于等于30天为取整的天前(例如:12天前)
443
- // 大于30天小于等于12月为取整的月前,月份统一为30天一月,不做额外处理(例如:3个月前)
444
- // 大于365取整的年前,(例如:2年前)
445
- let minute = 1000 * 60
446
- let hour = minute * 60
447
- let day = hour * 24
448
- let month = day * 30
449
- let year = month * 12
450
- let des = ''
451
- if (timeDiff <= minute * 2) {
452
- des = '刚刚'
453
- } else if (minute * 2 < timeDiff && timeDiff < hour) {
454
- des = `${Math.floor(timeDiff / minute)}分钟前`
455
- } else if (hour < timeDiff && timeDiff <= day) {
456
- des = `${Math.floor(timeDiff / hour)}小时前`
457
- } else if (day < timeDiff && timeDiff <= month) {
458
- des = `${Math.floor(timeDiff / day)}天前`
459
- } else if (month < timeDiff && timeDiff <= year) {
460
- des = `${Math.floor(timeDiff / month)}个月前`
461
- } else if (year < timeDiff) {
462
- des = `${Math.floor(timeDiff / year)}年前`
463
- }
464
- return des
465
- },
466
-
467
- nextMonth20(date) {
468
- let ds = date.split('-')
469
- let nextMonth = ds[1] - 0 + 1
470
- return ds[0] + '-' + (nextMonth < 10 ? '0' + nextMonth : nextMonth) + '-20 00:00:00'
471
- }
472
- }
473
-
474
- export default GetLoginInfoService
1
+ import Vue from 'vue'
2
+ import {HttpResetClass} from 'vue-client'
3
+ import cryptJS from './EncryptUtil'
4
+
5
+ let loginGen = async function (name, password, cue) {
6
+ let data = {name: name, password: password}
7
+ data = '$' + cryptJS.RSAEncrypt(JSON.stringify(data))
8
+ const getLogin = await Vue.resetpost('/rs/logic/getLogin', data, {resolveMsg: null, rejectMsg: null})
9
+ if (getLogin.data.states === '登录成功') {
10
+ //获取jwt
11
+ Vue.$login.jwt = getLogin.data.jwt
12
+ Vue.$login.jwtNew = getLogin.data.jwtNew
13
+ // 调用远程登录服务,获取所有有权访问的功能
14
+ data = {username: name, password: password}
15
+ data = cryptJS.RSAEncrypt(JSON.stringify(data))
16
+ const resource = await Vue.resetpost(`/rs/user/userLogin/客服系统`, data, {
17
+ resolveMsg: null,
18
+ rejectMsg: null
19
+ })
20
+ // 兼容旧版ldao
21
+ if ((JSON.stringify(resource.data).startsWith("{") || JSON.stringify(resource.data).startsWith("[")) && resource.data.code && resource.data.msg && resource.data.code !== 200) {
22
+ throw {status: 555, data: resource.data.msg}
23
+ }
24
+ console.log('登陆获取Util', JSON.stringify(resource.data))
25
+
26
+ // 兼容旧版ldao,旧版不返回code
27
+ if ((JSON.stringify(resource.data).startsWith("{") || JSON.stringify(resource.data).startsWith("[")) && resource.data.code && resource.data.msg) {
28
+ Vue.$login.f = resource.data.data
29
+ } else {
30
+ Vue.$login.f = resource.data
31
+ }
32
+ // 把登录用户添加到cookie里
33
+ Vue.cookie.set('loginId', Vue.$login.f.id)
34
+ try {
35
+ //获取有权限的功能树
36
+ let hasRight = await Vue.resetpost(`/rs/search`, {
37
+ source: "tool.getFullTree(this.getRights().where(row.getType() == $function$))",
38
+ userid: Vue.$login.f.id
39
+ }, { resolveMsg: null, rejectMsg: null })
40
+ console.log('有权限功能返回数据', JSON.stringify(hasRight.data))
41
+ //准备替换功能树
42
+ var fun = []
43
+ hasRight.data[0].children[0].children.forEach((item) => {
44
+ if (item.name === '客服系统') {
45
+ item.children.forEach((item1) => {
46
+ fun.push(item1)
47
+ })
48
+ }
49
+ })
50
+ // console.log('替换前', JSON.stringify(Vue.$login.f.functions))
51
+ // console.log('替换后', JSON.stringify(fun))
52
+ Vue.$login.f.functions = fun
53
+ } catch (error) {
54
+ }
55
+ if (Vue.$login.f.id !== '11') {
56
+ try {
57
+ let getAllArea = await Vue.resetpost('/rs/search', {
58
+ source: 'this.getParentByType($organization$).getChildByName($片区$).getChildren()',
59
+ userid: Vue.$login.f.id
60
+ }, {resolveMsg: null, rejectMsg: null})
61
+
62
+ let areaTemp = []
63
+ for (let i = 0; i < getAllArea.data.length; i++) {
64
+ areaTemp.push({label: getAllArea.data[i].name, value: getAllArea.data[i]})
65
+ }
66
+ Vue.$login.f.f_allArea = areaTemp
67
+ } catch (error) {
68
+ Vue.$login.f.f_allArea = []
69
+ console.log('获取区县', error)
70
+ }
71
+ // 获取抄表员
72
+ try {
73
+ let getGasman = await Vue.resetpost('/rs/search', {
74
+ source: 'this.getParentByType($organization$).getChildByName($抄表员$).getUsers()',
75
+ userid: Vue.$login.f.id
76
+ }, {resolveMsg: null, rejectMsg: null})
77
+ let gasman = []
78
+ for (let i = 0; i < getGasman.data.length; i++) {
79
+ gasman.push(getGasman.data[i])
80
+ }
81
+ Vue.$login.f.f_gasman = gasman
82
+ } catch (error) {
83
+ Vue.$login.f.f_gasman = []
84
+ console.log('抄表员模块', error)
85
+ }
86
+ // 获取安装人
87
+ try {
88
+ let getInstallman = await Vue.resetpost('/rs/search', {
89
+ source: 'this.getParentByType($organization$).getChildByName($安装员$).getUsers()',
90
+ userid: Vue.$login.f.id
91
+ }, {resolveMsg: null, rejectMsg: null})
92
+ console.log('获取安装员', getInstallman)
93
+ let installman = []
94
+ for (let i = 0; i < getInstallman.data.length; i++) {
95
+ installman.push(getInstallman.data[i])
96
+ }
97
+ Vue.$login.f.f_installman = installman
98
+ } catch (error) {
99
+ Vue.$login.f.f_installman = []
100
+ console.log('安装人模块', error)
101
+ }
102
+ // 获取换表员
103
+ // try {
104
+ // let getChangeMeterman = await Vue.resetpost('/rs/search', {
105
+ // source: 'this.getParentByType($organization$).getChildByName($换表员$).getUsers()',
106
+ // userid: Vue.$login.f.id
107
+ // }, {resolveMsg: null, rejectMsg: null})
108
+ // let changemeterman = []
109
+ // for (let i = 0; i < getChangeMeterman.data.length; i++) {
110
+ // changemeterman.push(getChangeMeterman.data[i])
111
+ // }
112
+ // Vue.$login.f.f_changemeterman = changemeterman
113
+ // }catch (error) {
114
+ // Vue.$login.f.f_changemeterman = []
115
+ // console.log('换表员模块',error)
116
+ // }
117
+ // 获取资源服务权限
118
+ try {
119
+ let getLic = await Vue.resetpost('/rs/search', {
120
+ data: {
121
+ source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($资源操作$) != -1)',
122
+ userid: Vue.$login.f.id
123
+ }
124
+ }, {resolveMsg: null, rejectMsg: null})
125
+ let arry = []
126
+ getLic.data.forEach((item) => {
127
+ arry.push(item.name)
128
+ })
129
+ Vue.$login.f.lics = arry
130
+ } catch (error) {
131
+ Vue.$login.f.f_gasman = []
132
+ console.log('资源服务权限', error)
133
+ }
134
+ // // 票据使用人
135
+ // try {
136
+ // let getPaperUseman = await Vue.resetpost('/rs/search', {
137
+ // source: 'this.getParentByType($organization$).getChildByName($票据使用人$).getUsers()',
138
+ // userid: Vue.$login.f.id
139
+ // }, {resolveMsg: null, rejectMsg: null})
140
+ // let perperuseman = []
141
+ // for (let i = 0; i < getPaperUseman.data.length; i++) {
142
+ // perperuseman.push(getPaperUseman.data[i])
143
+ // }
144
+ // Vue.$login.f.f_paperUseman = perperuseman
145
+ // }catch (error) {
146
+ // Vue.$login.f.f_paperUseman = []
147
+ // console.log('票据使用人模块',error)
148
+ //
149
+ // }
150
+ // // 票据分配人
151
+ // try {
152
+ // let getPaperAllotman = await Vue.resetpost('/rs/search', {
153
+ // source: 'this.getParentByType($organization$).getChildByName($票据分配人$).getUsers()',
154
+ // userid: Vue.$login.f.id
155
+ // }, {resolveMsg: null, rejectMsg: null})
156
+ // let paperallotman = []
157
+ // for (let i = 0; i < getPaperAllotman.data.length; i++) {
158
+ // paperallotman.push(getPaperAllotman.data[i])
159
+ // }
160
+ // Vue.$login.f.f_paperAllotman = paperallotman
161
+ // }catch (error) {
162
+ // Vue.$login.f.f_paperAllotman = []
163
+ // console.log('票据分配人模块',error)
164
+ // }
165
+ // TODO 处理界面细节
166
+ try {
167
+ let viewDetails = await Vue.resetpost('rs/search', {
168
+ source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($功能权限$) != -1)',
169
+ userid: Vue.$login.f.id
170
+ }, {resolveMsg: null, rejectMsg: null})
171
+ let r = viewDetails.data
172
+ Vue.$login.r = []
173
+ r.forEach(x => Vue.$login.r.push(x.name))
174
+ } catch (error) {
175
+ Vue.$login.r = []
176
+ console.log('加载模块失败', error)
177
+ }
178
+ // 调用登录后处理
179
+ for (let proc of Vue.$login.afterLogin) {
180
+ await proc(Vue.$login.f)
181
+ }
182
+ // 启动未操作下线计时器(30分钟)
183
+ if(Vue.$login.autoLoginout){
184
+ Vue.$login.startInactivityTimer(Vue.$login.autoLoginTimeOut)
185
+ }
186
+
187
+ // 定时发送心跳
188
+ if (cue) {
189
+ setInterval(() => {
190
+ let http = new HttpResetClass()
191
+ //暂时不出现不出现异地登录校验
192
+ http.load('POST', `rs/user/access/${Vue.$login.f.id}`, {}, {
193
+ resolveMsg: null,
194
+ rejectMsg: null
195
+ }).then((req) => {
196
+ if (req.data.forcestate && req.data.forcestate == 1) {
197
+ Vue.showMessage("您被强制下线!", ['confirm']).then((res) => {
198
+ location.reload()
199
+ })
200
+ } else if (req.data.status == 710) {
201
+ Vue.showMessage(req.data.msg + ",您将被强制退出系统", ['confirm']).then((res) => {
202
+ if (res === 'confirm') {
203
+ location.reload()
204
+ }
205
+ })
206
+ }
207
+ })
208
+ }, 2 * 60 * 1000)
209
+ }
210
+ }
211
+
212
+ } else {
213
+ if(getLogin.data.states.includes('您的密码已经使用超过')){
214
+ throw {status: 789, data: getLogin.data.states}
215
+ }else{
216
+ let error = {status: 401, data: getLogin.data.states}
217
+ // 抛出错误
218
+ throw error
219
+ }
220
+ }
221
+ }
222
+
223
+ let GetLoginInfoService = {
224
+ // 登录后要处理的异步对象
225
+ afterLogin: [],
226
+ //验证码开关
227
+ Verification: true,
228
+ //构建时间开关
229
+ versionTime: true,
230
+ //长时间未操作退出开关
231
+ autoLoginout: false,
232
+ autoLoginTimeOut:30*60*1000,
233
+ //
234
+ SinglePageToken : {},
235
+ //登录信息展示开关
236
+ depPrompt: true,
237
+ install(Vue, options) {
238
+ // 给vue增添对话框显示方法
239
+ Vue.$login = Vue.prototype.$login = GetLoginInfoService
240
+ },
241
+
242
+ f: {},
243
+
244
+ /**
245
+ * 登录
246
+ * @param name
247
+ * @param password
248
+ * @param cue true/false 是/否显示异地登录
249
+ */
250
+ login(name, password, cue) {
251
+ if (cue === undefined || cue === null || cue === '') {
252
+ cue = true
253
+ }
254
+ Vue.$login.SinglePageToken = cryptJS.AESEncrypt(JSON.stringify({name,password}), "3KMKqvgwR8ULbR8Z")
255
+ return loginGen(name, password, cue)
256
+ },
257
+
258
+ convertToIn(val) {
259
+ let temp = ''
260
+ if (val instanceof Array) {
261
+ if (val.length >= 1) {
262
+ temp = '('
263
+ val.forEach((res) => {
264
+ temp += `'${res}',`
265
+ })
266
+ temp = temp.substr(0, temp.length - 1) + ')'
267
+ }
268
+ }
269
+ return temp
270
+ },
271
+
272
+ toStandardYearMonth() {
273
+ let dt = new Date()
274
+ let month = dt.getMonth() + 1
275
+ return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month)
276
+ },
277
+
278
+ toStandardYearMonth1() {
279
+ let dt = new Date()
280
+ let month = dt.getMonth() + 1
281
+ return dt.getFullYear() + (month < 10 ? '0' + month : month)
282
+ },
283
+
284
+ toStandardDateString() {
285
+ let dt = new Date()
286
+ let month = dt.getMonth() + 1
287
+ let date = dt.getDate()
288
+ return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
289
+ },
290
+
291
+ toStartAndEndDateString() {
292
+ let dt = new Date()
293
+ let month = dt.getMonth() + 1
294
+ // let date = dt.getDate()
295
+ return [dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-01',
296
+ dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (new Date(dt.getFullYear(), month, 0).getDate())]
297
+ // return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date)
298
+ },
299
+
300
+ toStandardTimeString() {
301
+ let dt = new Date()
302
+ let month = dt.getMonth() + 1
303
+ let date = dt.getDate()
304
+ let hour = dt.getHours()
305
+ let min = dt.getMinutes()
306
+ let sec = dt.getSeconds()
307
+ return dt.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date) +
308
+ ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
309
+ },
310
+
311
+ guid() {
312
+ let buf = new Uint16Array(8)
313
+ window.crypto.getRandomValues(buf)
314
+ let S4 = function (num) {
315
+ let ret = num.toString(16)
316
+ while (ret.length < 4) {
317
+ ret = '0' + ret
318
+ }
319
+ return ret
320
+ }
321
+ return (S4(buf[0]) + S4(buf[1]) + S4(buf[2]) + S4(buf[3]) + S4(buf[4]) + S4(buf[5]) + S4(buf[6]) + S4(buf[7]))
322
+ },
323
+
324
+ choices(role, param, hasBlank = false, blankHint = '请选择') {
325
+ if (role == 'view') {
326
+ Vue.getParams(param, [null])
327
+ } else {
328
+ let result = []
329
+ if (hasBlank)
330
+ result.push({label: blankHint, value: null})
331
+ if (!Vue.param || !Vue.param[param])
332
+ result.push({label: '请在系统设置里更新参数', value: '请在系统设置里更新参数'})
333
+ else {
334
+ let p = Vue.param[param]
335
+ p.forEach(function (item) {
336
+ result.push({label: item.name, value: item.name})
337
+ })
338
+ }
339
+ return result
340
+ }
341
+ },
342
+
343
+ required(param) {
344
+ if (typeof param === 'number' && param == 0)
345
+ return false
346
+ if (!param)
347
+ return true
348
+ param = param + ''
349
+ param = param.trim()
350
+ if (!param)
351
+ return true
352
+ return false
353
+ },
354
+
355
+ isInt(n) {
356
+ return !window.isNaN(n) && n % 1 === 0
357
+ },
358
+
359
+ isFloat(n) {
360
+ return !window.isNaN(n)
361
+ },
362
+
363
+ // this will convert all true/false to boolean
364
+ booleanFilter(paper) {
365
+ for (let key in paper) {
366
+ if (!paper.hasOwnProperty(key))
367
+ continue
368
+ if (typeof paper[key] == 'object' && paper[key] != null) {
369
+ booleanFilter(paper[key])
370
+ } else {
371
+ if (paper[key] === 'true' || paper[key] == 'false')
372
+ paper[key] = (paper[key] === 'true')
373
+ }
374
+ }
375
+ },
376
+ // recursively traverse through each path
377
+ ratifyPics(paper) {
378
+ for (let key in paper) {
379
+ if (key.endsWith('_path')) {
380
+ if (!paper[key]) {
381
+ paper[key] = 'rs/db/file/nopic.png'
382
+ } else {
383
+ paper[key] = 'rs/db/file/' + paper[key]
384
+ }
385
+ } else if (paper[key] !== null && typeof (paper[key]) == 'object') {
386
+ ratifyPics(paper[key])
387
+ }
388
+ }
389
+ },
390
+
391
+ // load script and other stuff
392
+ loadscript(type, fileName) {
393
+ return new Promise((resolve, reject) => {
394
+ let element
395
+ if (type == 'css') {
396
+ element = document.createElement('link')
397
+ element.setAttribute('rel', 'stylesheet')
398
+ element.setAttribute('type', 'text/css')
399
+ element.setAttribute('href', fileName)
400
+ } else if (type == 'js') {
401
+ element = document.createElement('script')
402
+ element.setAttribute('type', 'text/javascript')
403
+ element.setAttribute('src', fileName)
404
+ }
405
+ if (element) {
406
+ element.setAttribute('async', '')
407
+ element.setAttribute('defer', '')
408
+ element.addEventListener('load', function () {
409
+ resolve(element)
410
+ }, false)
411
+ element.addEventListener('error', function () {
412
+ reject(element)
413
+ }, false)
414
+ document.body.appendChild(element)
415
+ }
416
+ })
417
+ },
418
+ // 不能选择器中截取掉多余的字符
419
+ orgName(name) {
420
+ return name.substring(10)
421
+ },
422
+
423
+ getNowDate(name) {
424
+ // 求取当前时间的工具
425
+ let myweekday = ''
426
+ let year = ''
427
+ let mydate = new Date()
428
+ myweekday = mydate.getDay()
429
+ let mymonth = mydate.getMonth() + 1
430
+ let myday = mydate.getDate()
431
+ let myyear = mydate.getYear()
432
+ year = (myyear > 200) ? myyear : 1900 + myyear
433
+ let week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期日', '星期六']
434
+ // document.write("<font color=#ffffff>今天是 "+year+"年"+mymonth+"月"+myday+"日 "+weekday+"</font>");
435
+ return year + '年' + mymonth + '月' + myday + '日 ' + week[myweekday]
436
+ },
437
+
438
+ addDate(date, days) {
439
+ // 求取当前时间的工具
440
+ let endDate = new Date(date)
441
+ endDate = endDate.valueOf()
442
+ endDate = endDate + days * 24 * 60 * 60 * 1000
443
+ endDate = new Date(endDate)
444
+ let month = endDate.getMonth() + 1
445
+ let day = endDate.getDate()
446
+ let hour = endDate.getHours()
447
+ let min = endDate.getMinutes()
448
+ let sec = endDate.getSeconds()
449
+ return endDate.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day) +
450
+ ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)
451
+ // return a
452
+ },
453
+
454
+ // 通过地址栏的参数获取参数内容
455
+ getUrlParames(param) {
456
+ var query = window.location.search
457
+ var iLen = param.length
458
+ var iStart = query.indexOf(param)
459
+ if (iStart === -1) {
460
+ return ''
461
+ }
462
+ iStart += iLen + 1
463
+ var iEnd = query.indexOf('&', iStart)
464
+ if (iEnd === -1) {
465
+ return query.substring(iStart)
466
+ }
467
+ return query.substring(iStart, iEnd)
468
+ },
469
+
470
+ // 从地址栏获取加密的参数
471
+ getUrlCompileParames(param) {
472
+ let code = unescape(window.location.search.slice(1, window.location.search.length))
473
+ let query = String.fromCharCode(code.charCodeAt(0) - code.length)
474
+ for (var i = 1; i < code.length; i++) {
475
+ query += String.fromCharCode(code.charCodeAt(i) - query.charCodeAt(i - 1))
476
+ }
477
+ let iLen = param.length
478
+ let iStart = query.indexOf(param)
479
+ if (iStart === -1) {
480
+ return ''
481
+ }
482
+ iStart += iLen + 1
483
+ let iEnd = query.indexOf('&', iStart)
484
+ if (iEnd === -1) {
485
+ return query.substring(iStart)
486
+ }
487
+ return query.substring(iStart, iEnd)
488
+ },
489
+
490
+ // 对字符串进行加密
491
+ compileStr(code) {
492
+ let c = String.fromCharCode(code.charCodeAt(0) + code.length)
493
+ for (let i = 1; i < code.length; i++) {
494
+ c += String.fromCharCode(code.charCodeAt(i) + code.charCodeAt(i - 1))
495
+ }
496
+ return escape(c)
497
+ },
498
+ // 字符串进行解密
499
+ uncompileStr(code) {
500
+ code = unescape(code)
501
+ let c = String.fromCharCode(code.charCodeAt(0) - code.length)
502
+ for (var i = 1; i < code.length; i++) {
503
+ c += String.fromCharCode(code.charCodeAt(i) - c.charCodeAt(i - 1))
504
+ }
505
+ return c
506
+ },
507
+
508
+ dateDescripte(date) {
509
+ let nowTime = new Date().getTime()
510
+ let oldTime = new Date(date).getTime()
511
+ let timeDiff = nowTime - oldTime
512
+ // 规则说明
513
+ // 小于等于2分钟为刚刚
514
+ // 大于2分钟小于等于1小时为取整的分钟前(例如:35分钟前)
515
+ // 大于1小时小于等于24小时为取整的小时前(例如:15小时前)
516
+ // 大于24小时小于等于30天为取整的天前(例如:12天前)
517
+ // 大于30天小于等于12月为取整的月前,月份统一为30天一月,不做额外处理(例如:3个月前)
518
+ // 大于365取整的年前,(例如:2年前)
519
+ let minute = 1000 * 60
520
+ let hour = minute * 60
521
+ let day = hour * 24
522
+ let month = day * 30
523
+ let year = month * 12
524
+ let des = ''
525
+ if (timeDiff <= minute * 2) {
526
+ des = '刚刚'
527
+ } else if (minute * 2 < timeDiff && timeDiff < hour) {
528
+ des = `${Math.floor(timeDiff / minute)}分钟前`
529
+ } else if (hour < timeDiff && timeDiff <= day) {
530
+ des = `${Math.floor(timeDiff / hour)}小时前`
531
+ } else if (day < timeDiff && timeDiff <= month) {
532
+ des = `${Math.floor(timeDiff / day)}天前`
533
+ } else if (month < timeDiff && timeDiff <= year) {
534
+ des = `${Math.floor(timeDiff / month)}个月前`
535
+ } else if (year < timeDiff) {
536
+ des = `${Math.floor(timeDiff / year)}年前`
537
+ }
538
+ return des
539
+ },
540
+
541
+ nextMonth20(date) {
542
+ let ds = date.split('-')
543
+ let nextMonth = ds[1] - 0 + 1
544
+ return ds[0] + '-' + (nextMonth < 10 ? '0' + nextMonth : nextMonth) + '-20 00:00:00'
545
+ },
546
+ /**
547
+ * 启动未操作强制下线计时器
548
+ * @param timeout 超时时间(毫秒),默认30分钟
549
+ */
550
+ startInactivityTimer(timeout) {
551
+ // 清除已有的定时器
552
+ if (this._inactivityTimer) {
553
+ clearTimeout(this._inactivityTimer);
554
+ }
555
+ // 事件处理函数
556
+ const resetTimer = () => {
557
+ clearTimeout(this._inactivityTimer);
558
+ this._inactivityTimer = setTimeout(() => {
559
+ // 强制下线逻辑
560
+ // Vue.cookie.delete('loginId');
561
+ Vue.$login.f = {};
562
+ Vue.showMessage("长时间未操作,您已被强制下线", ['confirm']).then(() => {
563
+ location.reload();
564
+ });
565
+ }, timeout);
566
+ };
567
+ // 需要监听的事件
568
+ const events = ['mousemove', 'keydown', 'mousedown', 'scroll', 'touchstart'];
569
+ // 只绑定一次
570
+ if (!this._inactivityListenerAdded) {
571
+ events.forEach(event => {
572
+ window.addEventListener(event, resetTimer, true);
573
+ });
574
+ this._inactivityListenerAdded = true;
575
+ }
576
+ // 初始化计时器
577
+ resetTimer();
578
+ }
579
+ }
580
+
581
+ export default GetLoginInfoService