vue2-client 1.8.166 → 1.8.167

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 (167) hide show
  1. package/.env +19 -19
  2. package/.eslintrc.js +90 -90
  3. package/CHANGELOG.md +824 -824
  4. package/Components.md +60 -60
  5. package/babel.config.js +21 -21
  6. package/docs/index.md +30 -30
  7. package/index.js +31 -31
  8. package/jest-transform-stub.js +8 -8
  9. package/jest.config.js +21 -21
  10. package/jest.setup.js +7 -7
  11. package/package.json +97 -97
  12. package/public/index.html +27 -27
  13. package/src/App.vue +164 -164
  14. package/src/ReportView.js +19 -19
  15. package/src/assets/img/querySlotDemo.svg +15 -15
  16. package/src/assets/svg/badtwo.svg +1 -1
  17. package/src/assets/svg/goodtwo.svg +1 -1
  18. package/src/base-client/components/common/AMisRender/index.js +3 -3
  19. package/src/base-client/components/common/AMisRender/index.vue +263 -263
  20. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +316 -316
  21. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  22. package/src/base-client/components/common/CitySelect/index.js +3 -3
  23. package/src/base-client/components/common/CitySelect/index.md +109 -109
  24. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
  25. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
  26. package/src/base-client/components/common/CreateQuery/index.js +3 -3
  27. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  28. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
  29. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
  30. package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
  31. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  32. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
  33. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  34. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  35. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
  36. package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
  37. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  38. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  39. package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
  40. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  41. package/src/base-client/components/common/Tree/Tree.vue +149 -149
  42. package/src/base-client/components/common/Tree/index.js +2 -2
  43. package/src/base-client/components/common/Upload/Upload.vue +197 -197
  44. package/src/base-client/components/common/Upload/index.js +3 -3
  45. package/src/base-client/components/common/XAddForm/XAddForm.vue +92 -92
  46. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +502 -502
  47. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  48. package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +303 -303
  49. package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
  50. package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
  51. package/src/base-client/components/common/XBadge/XBadge.vue +78 -78
  52. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  53. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  54. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  55. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  56. package/src/base-client/components/common/XDescriptions/XDescriptions.vue +117 -117
  57. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  58. package/src/base-client/components/common/XDescriptions/index.md +83 -83
  59. package/src/base-client/components/common/XForm/XForm.vue +253 -253
  60. package/src/base-client/components/common/XForm/XFormItem.vue +545 -545
  61. package/src/base-client/components/common/XForm/XTreeSelect.vue +191 -191
  62. package/src/base-client/components/common/XForm/index.md +178 -178
  63. package/src/base-client/components/common/XFormCol/XFormCol.vue +38 -38
  64. package/src/base-client/components/common/XFormTable/XFormTable.vue +418 -418
  65. package/src/base-client/components/common/XFormTable/index.md +98 -98
  66. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +131 -131
  67. package/src/base-client/components/common/XReport/XReport.vue +694 -694
  68. package/src/base-client/components/common/XReport/XReportDesign.vue +423 -414
  69. package/src/base-client/components/common/XReport/XReportTrGroup.vue +602 -596
  70. package/src/base-client/components/common/XReport/index.js +3 -3
  71. package/src/base-client/components/common/XReport/index.md +44 -44
  72. package/src/base-client/components/common/XReportSlot/XReportSlot.vue +110 -110
  73. package/src/base-client/components/common/XReportSlot/index.js +3 -3
  74. package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
  75. package/src/base-client/components/common/XStepView/index.js +3 -3
  76. package/src/base-client/components/common/XStepView/index.md +31 -31
  77. package/src/base-client/components/common/XTable/XTable.vue +549 -549
  78. package/src/base-client/components/common/XTable/index.md +255 -255
  79. package/src/base-client/components/common/XTree/XTree.vue +76 -76
  80. package/src/base-client/components/common/XTree/index.js +3 -3
  81. package/src/base-client/components/common/XTree/index.md +36 -36
  82. package/src/base-client/components/index.js +47 -47
  83. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  84. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  85. package/src/base-client/plugins/AppData.js +115 -115
  86. package/src/base-client/plugins/Config.js +19 -19
  87. package/src/base-client/plugins/GetLoginInfoService.js +182 -182
  88. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  89. package/src/bootstrap.js +39 -39
  90. package/src/components/CodeMirror/inedx.vue +118 -118
  91. package/src/components/CodeMirror/setting.js +40 -40
  92. package/src/components/FilePreview/FilePreview.vue +166 -166
  93. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  94. package/src/components/STable/index.js +323 -323
  95. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  96. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  97. package/src/components/menu/SideMenu.vue +75 -75
  98. package/src/components/menu/menu.js +273 -273
  99. package/src/components/tool/AStepItem.vue +60 -60
  100. package/src/config/CreateQueryConfig.js +322 -322
  101. package/src/config/default/antd.config.js +89 -89
  102. package/src/config/default/setting.config.js +53 -53
  103. package/src/font-style/font.css +4 -4
  104. package/src/layouts/CommonLayout.vue +56 -56
  105. package/src/layouts/PageLayout.vue +151 -151
  106. package/src/layouts/SinglePageView.vue +138 -138
  107. package/src/layouts/header/AdminHeader.vue +132 -132
  108. package/src/layouts/header/HeaderNotice.vue +177 -177
  109. package/src/layouts/tabs/TabsHead.vue +189 -189
  110. package/src/layouts/tabs/TabsView.vue +387 -387
  111. package/src/lib.js +1 -1
  112. package/src/main.js +26 -26
  113. package/src/mock/extend/index.js +84 -84
  114. package/src/mock/goods/index.js +108 -108
  115. package/src/pages/AMisDemo/AMisDemo.vue +325 -325
  116. package/src/pages/AMisDemo/AMisDemo2.vue +74 -74
  117. package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
  118. package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
  119. package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
  120. package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
  121. package/src/pages/DynamicStatistics/FavoriteList.vue +51 -51
  122. package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
  123. package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
  124. package/src/pages/DynamicStatistics/index.vue +282 -282
  125. package/src/pages/Example/index.vue +1432 -1305
  126. package/src/pages/ServiceReview/index.vue +284 -284
  127. package/src/pages/XReportView/index.vue +62 -62
  128. package/src/pages/login/Login.vue +378 -378
  129. package/src/pages/login/LoginV3.vue +389 -389
  130. package/src/pages/resourceManage/orgListManage.vue +98 -98
  131. package/src/pages/system/dictionary/index.vue +44 -44
  132. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  133. package/src/pages/system/monitor/operLog/index.vue +37 -37
  134. package/src/pages/system/settings/modifyPassword.vue +117 -117
  135. package/src/pages/system/ticket/index.vue +480 -480
  136. package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
  137. package/src/router/async/config.async.js +32 -32
  138. package/src/router/async/router.map.js +98 -98
  139. package/src/router/guards.js +214 -214
  140. package/src/router/index.js +27 -27
  141. package/src/router.js +18 -18
  142. package/src/services/api/TicketDetailsViewApi.js +46 -46
  143. package/src/services/api/cas.js +79 -79
  144. package/src/services/api/common.js +274 -274
  145. package/src/services/api/entity.js +18 -18
  146. package/src/services/api/index.js +17 -17
  147. package/src/services/api/restTools.js +46 -46
  148. package/src/services/apiService.js +14 -14
  149. package/src/services/user.js +71 -71
  150. package/src/store/modules/setting.js +119 -119
  151. package/src/theme/default/style.less +57 -57
  152. package/src/utils/authority-utils.js +85 -85
  153. package/src/utils/errorCode.js +6 -6
  154. package/src/utils/htmlToPDF.js +108 -108
  155. package/src/utils/htmlToPDFApi.js +5 -5
  156. package/src/utils/indexedDB.js +201 -201
  157. package/src/utils/login.js +141 -141
  158. package/src/utils/map-utils.js +47 -47
  159. package/src/utils/request.js +343 -343
  160. package/src/utils/routerUtil.js +428 -428
  161. package/src/utils/util.js +231 -231
  162. package/src/utils/waterMark.js +31 -31
  163. package/test/Amis.spec.js +163 -163
  164. package/test/Tree.spec.js +167 -167
  165. package/test/myDialog.spec.js +46 -46
  166. package/vue.config.js +166 -166
  167. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
@@ -1,141 +1,141 @@
1
- import { getRoutesConfig, login } from '@vue2-client/services/user'
2
- import { loadRoutes, funcToRouter } from '@vue2-client/utils/routerUtil'
3
- import JSEncrypt from 'jsencrypt'
4
- import { positions } from '@vue2-client/mock/common'
5
- import { timeFix } from '@vue2-client/utils/util'
6
- import { indexedDB } from '@vue2-client/utils/indexedDB'
7
- import Vue from 'vue'
8
- import { message } from 'ant-design-vue'
9
- import {
10
- ACCESS_TOKEN,
11
- V4_ACCESS_TOKEN,
12
- } from '@vue2-client/store/mutation-types'
13
- // 认证类型
14
- const AUTH_TYPE = {
15
- BEARER: 'Bearer',
16
- BASIC: 'basic',
17
- AUTH1: 'auth1',
18
- AUTH2: 'auth2',
19
- }
20
- export function checkSingleAuthorization (authType = AUTH_TYPE.BEARER) {
21
- switch (authType) {
22
- case AUTH_TYPE.BEARER:
23
- if (localStorage.getItem(V4_ACCESS_TOKEN)) {
24
- return true
25
- }
26
- break
27
- case AUTH_TYPE.BASIC:
28
- case AUTH_TYPE.AUTH1:
29
- case AUTH_TYPE.AUTH2:
30
- default:
31
- break
32
- }
33
- return false
34
- }
35
- function setSingleAuthorization (auth, authType = AUTH_TYPE.BEARER) {
36
- switch (authType) {
37
- case AUTH_TYPE.BEARER:
38
- localStorage.setItem(V4_ACCESS_TOKEN, 'Bearer ' + auth.token)
39
- break
40
- case AUTH_TYPE.BASIC:
41
- case AUTH_TYPE.AUTH1:
42
- case AUTH_TYPE.AUTH2:
43
- default:
44
- break
45
- }
46
- }
47
- function setAccessToken (data) {
48
- if (data) {
49
- localStorage.setItem(ACCESS_TOKEN, data)
50
- let timestamp = new Date().getTime() // 当前的时间戳
51
- timestamp = timestamp + 12 * 60 * 60 * 1000
52
- // 格式化时间获取年月日, 登陆过期时间
53
- const dateAfter = new Date(timestamp)
54
- setSingleAuthorization({ token: data, expireAt: dateAfter })
55
- }
56
- }
57
- function afterGeneral (result, options) {
58
- const { password, store } = options
59
- const user = Object.assign(
60
- {
61
- id: result.id,
62
- username: result.ename,
63
- password: password,
64
- name: result.name,
65
- avatar:
66
- 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png',
67
- address: '西安市',
68
- position: positions[0],
69
- },
70
- result
71
- )
72
- const setUser = store._mutations['account/setUser'][0]
73
- const setPermissions = store._mutations['account/setPermissions'][0]
74
- const setRoles = store._mutations['account/setRoles'][0]
75
- setUser(user)
76
- setPermissions([{ id: 'queryForm', operation: ['add', 'edit'] }])
77
- setRoles([{ id: 'admin', operation: ['add', 'edit', 'delete'] }])
78
- loadRoutes(funcToRouter(user.functions))
79
- // 每次重新登录时,清除indexedDB缓存
80
- indexedDB.clear()
81
- message.success(timeFix().CN + `,${result.name} 欢迎回来`, 3)
82
- }
83
- function afterLogin (res, options) {
84
- const { name, password, store, router, pathname } = options
85
- const setting = store.state.setting
86
- const loginRes = res.states
87
- if (loginRes === '登录成功') {
88
- const encrypt = new JSEncrypt()
89
- encrypt.setPublicKey(
90
- 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPvovSfXcwBbW8cKMCgwqNpsYuzF8RPAPFb7LGsnVo44JhM/xxzDyzoYtdfNmtbIuKVi9PzIsyp6rg+09gbuI6UGwBZ5DWBDBMqv5MPdOF5dCQkB2Bbr5yPfURPENypUz+pBFBg41d+BC+rwRiXELwKy7Y9caD/MtJyHydj8OUwIDAQAB'
91
- )
92
- const data = encrypt.encrypt(
93
- JSON.stringify({ username: name, password: password })
94
- )
95
- // 获取路由配置
96
- getRoutesConfig(data, setting.routeName)
97
- .then((result) => {
98
- Vue.$login
99
- .login(result)
100
- .then(() => {
101
- // V3任何情况首位加入资源管理
102
- const resourceManageMain = {
103
- name: '资源管理',
104
- icon: 'api',
105
- position: 1,
106
- link: 'resourceManageMain',
107
- }
108
- result.functions.unshift(resourceManageMain)
109
- afterGeneral(result, options)
110
- setAccessToken(data)
111
- if (result.deps === '用户工单登记') {
112
- router.push(setting.ticketPage).catch(() => {
113
- })
114
- } else {
115
- console.log('去往的页面', pathname)
116
- router.push(pathname).catch(() => {
117
- })
118
- }
119
- })
120
- .finally(() => {
121
- })
122
- })
123
- .catch((res) => {
124
- })
125
- }
126
- }
127
- export function startLogin (options) {
128
- const { name, password, store } = options
129
- const setting = store.state.setting
130
- switch (setting.compatible) {
131
- case 'V2':
132
- case 'V3': {
133
- login(name, password)
134
- .then((res) => {
135
- afterLogin(res, options)
136
- })
137
- .catch((msg) => {})
138
- break
139
- }
140
- }
141
- }
1
+ import { getRoutesConfig, login } from '@vue2-client/services/user'
2
+ import { loadRoutes, funcToRouter } from '@vue2-client/utils/routerUtil'
3
+ import JSEncrypt from 'jsencrypt'
4
+ import { positions } from '@vue2-client/mock/common'
5
+ import { timeFix } from '@vue2-client/utils/util'
6
+ import { indexedDB } from '@vue2-client/utils/indexedDB'
7
+ import Vue from 'vue'
8
+ import { message } from 'ant-design-vue'
9
+ import {
10
+ ACCESS_TOKEN,
11
+ V4_ACCESS_TOKEN,
12
+ } from '@vue2-client/store/mutation-types'
13
+ // 认证类型
14
+ const AUTH_TYPE = {
15
+ BEARER: 'Bearer',
16
+ BASIC: 'basic',
17
+ AUTH1: 'auth1',
18
+ AUTH2: 'auth2',
19
+ }
20
+ export function checkSingleAuthorization (authType = AUTH_TYPE.BEARER) {
21
+ switch (authType) {
22
+ case AUTH_TYPE.BEARER:
23
+ if (localStorage.getItem(V4_ACCESS_TOKEN)) {
24
+ return true
25
+ }
26
+ break
27
+ case AUTH_TYPE.BASIC:
28
+ case AUTH_TYPE.AUTH1:
29
+ case AUTH_TYPE.AUTH2:
30
+ default:
31
+ break
32
+ }
33
+ return false
34
+ }
35
+ function setSingleAuthorization (auth, authType = AUTH_TYPE.BEARER) {
36
+ switch (authType) {
37
+ case AUTH_TYPE.BEARER:
38
+ localStorage.setItem(V4_ACCESS_TOKEN, 'Bearer ' + auth.token)
39
+ break
40
+ case AUTH_TYPE.BASIC:
41
+ case AUTH_TYPE.AUTH1:
42
+ case AUTH_TYPE.AUTH2:
43
+ default:
44
+ break
45
+ }
46
+ }
47
+ function setAccessToken (data) {
48
+ if (data) {
49
+ localStorage.setItem(ACCESS_TOKEN, data)
50
+ let timestamp = new Date().getTime() // 当前的时间戳
51
+ timestamp = timestamp + 12 * 60 * 60 * 1000
52
+ // 格式化时间获取年月日, 登陆过期时间
53
+ const dateAfter = new Date(timestamp)
54
+ setSingleAuthorization({ token: data, expireAt: dateAfter })
55
+ }
56
+ }
57
+ function afterGeneral (result, options) {
58
+ const { password, store } = options
59
+ const user = Object.assign(
60
+ {
61
+ id: result.id,
62
+ username: result.ename,
63
+ password: password,
64
+ name: result.name,
65
+ avatar:
66
+ 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png',
67
+ address: '西安市',
68
+ position: positions[0],
69
+ },
70
+ result
71
+ )
72
+ const setUser = store._mutations['account/setUser'][0]
73
+ const setPermissions = store._mutations['account/setPermissions'][0]
74
+ const setRoles = store._mutations['account/setRoles'][0]
75
+ setUser(user)
76
+ setPermissions([{ id: 'queryForm', operation: ['add', 'edit'] }])
77
+ setRoles([{ id: 'admin', operation: ['add', 'edit', 'delete'] }])
78
+ loadRoutes(funcToRouter(user.functions))
79
+ // 每次重新登录时,清除indexedDB缓存
80
+ indexedDB.clear()
81
+ message.success(timeFix().CN + `,${result.name} 欢迎回来`, 3)
82
+ }
83
+ function afterLogin (res, options) {
84
+ const { name, password, store, router, pathname } = options
85
+ const setting = store.state.setting
86
+ const loginRes = res.states
87
+ if (loginRes === '登录成功') {
88
+ const encrypt = new JSEncrypt()
89
+ encrypt.setPublicKey(
90
+ 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPvovSfXcwBbW8cKMCgwqNpsYuzF8RPAPFb7LGsnVo44JhM/xxzDyzoYtdfNmtbIuKVi9PzIsyp6rg+09gbuI6UGwBZ5DWBDBMqv5MPdOF5dCQkB2Bbr5yPfURPENypUz+pBFBg41d+BC+rwRiXELwKy7Y9caD/MtJyHydj8OUwIDAQAB'
91
+ )
92
+ const data = encrypt.encrypt(
93
+ JSON.stringify({ username: name, password: password })
94
+ )
95
+ // 获取路由配置
96
+ getRoutesConfig(data, setting.routeName)
97
+ .then((result) => {
98
+ Vue.$login
99
+ .login(result)
100
+ .then(() => {
101
+ // V3任何情况首位加入资源管理
102
+ const resourceManageMain = {
103
+ name: '资源管理',
104
+ icon: 'api',
105
+ position: 1,
106
+ link: 'resourceManageMain',
107
+ }
108
+ result.functions.unshift(resourceManageMain)
109
+ afterGeneral(result, options)
110
+ setAccessToken(data)
111
+ if (result.deps === '用户工单登记') {
112
+ router.push(setting.ticketPage).catch(() => {
113
+ })
114
+ } else {
115
+ console.log('去往的页面', pathname)
116
+ router.push(pathname).catch(() => {
117
+ })
118
+ }
119
+ })
120
+ .finally(() => {
121
+ })
122
+ })
123
+ .catch((res) => {
124
+ })
125
+ }
126
+ }
127
+ export function startLogin (options) {
128
+ const { name, password, store } = options
129
+ const setting = store.state.setting
130
+ switch (setting.compatible) {
131
+ case 'V2':
132
+ case 'V3': {
133
+ login(name, password)
134
+ .then((res) => {
135
+ afterLogin(res, options)
136
+ })
137
+ .catch((msg) => {})
138
+ break
139
+ }
140
+ }
141
+ }
@@ -1,47 +1,47 @@
1
- import AMapLoader from '@amap/amap-jsapi-loader'
2
- let Amap
3
- async function GetGDMap (secretKey, key) {
4
- if (!Amap) {
5
- window._AMapSecurityConfig = {
6
- securityJsCode: secretKey
7
- }
8
- // 解决高德地图加载报错 ---> 禁止多种API加载方式混用
9
- AMapLoader.reset()
10
- Amap = await AMapLoader.load({
11
- key: key, // 申请好的Web端开发者Key,首次调用 load 时必填
12
- version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
13
- plugins: ['AMap.IndexCluster', 'AMP.MarkerCluster', 'AMap.InfoWindow', 'AMap.HeatMap', 'AMap.HawkEye', 'AMap.DistrictSearch',
14
- 'AMap.ToolBar', 'AMap.Geolocation', 'AMap.MouseTool',
15
- 'AMap.Geocoder', 'AMap.MarkerClusterer', 'AMap.AutoComplete'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
16
- AMapUI: {
17
- version: '1.1', // AMapUI 缺省 1.1
18
- plugins: ['misc/PositionPicker'] // 需要加载的 AMapUI ui插件
19
- }
20
- })
21
- }
22
- return Amap
23
- }
24
-
25
- async function getGDMap (address) {
26
- new (await GetGDMap()).Geocoder({
27
- radius: 500 // 范围,默认:500
28
- }).getLocation(address, function (status, result) {
29
- if (status === 'complete' && result.geocodes.length) {
30
- return ({ lng: result.geocodes[0].location.lng, lat: result.geocodes[0].location.lat })
31
- } else {
32
- // eslint-disable-next-line prefer-promise-reject-errors
33
- throw new Error('根据经纬度查询地址失败')
34
- }
35
- })
36
- }
37
-
38
- async function GetLocation (address) {
39
- return new Promise((resolve, reject) => {
40
- try {
41
- resolve(getGDMap(address))
42
- } catch (e) {
43
- reject(e)
44
- }
45
- })
46
- }
47
- export { GetGDMap, GetLocation }
1
+ import AMapLoader from '@amap/amap-jsapi-loader'
2
+ let Amap
3
+ async function GetGDMap (secretKey, key) {
4
+ if (!Amap) {
5
+ window._AMapSecurityConfig = {
6
+ securityJsCode: secretKey
7
+ }
8
+ // 解决高德地图加载报错 ---> 禁止多种API加载方式混用
9
+ AMapLoader.reset()
10
+ Amap = await AMapLoader.load({
11
+ key: key, // 申请好的Web端开发者Key,首次调用 load 时必填
12
+ version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
13
+ plugins: ['AMap.IndexCluster', 'AMP.MarkerCluster', 'AMap.InfoWindow', 'AMap.HeatMap', 'AMap.HawkEye', 'AMap.DistrictSearch',
14
+ 'AMap.ToolBar', 'AMap.Geolocation', 'AMap.MouseTool',
15
+ 'AMap.Geocoder', 'AMap.MarkerClusterer', 'AMap.AutoComplete'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
16
+ AMapUI: {
17
+ version: '1.1', // AMapUI 缺省 1.1
18
+ plugins: ['misc/PositionPicker'] // 需要加载的 AMapUI ui插件
19
+ }
20
+ })
21
+ }
22
+ return Amap
23
+ }
24
+
25
+ async function getGDMap (address) {
26
+ new (await GetGDMap()).Geocoder({
27
+ radius: 500 // 范围,默认:500
28
+ }).getLocation(address, function (status, result) {
29
+ if (status === 'complete' && result.geocodes.length) {
30
+ return ({ lng: result.geocodes[0].location.lng, lat: result.geocodes[0].location.lat })
31
+ } else {
32
+ // eslint-disable-next-line prefer-promise-reject-errors
33
+ throw new Error('根据经纬度查询地址失败')
34
+ }
35
+ })
36
+ }
37
+
38
+ async function GetLocation (address) {
39
+ return new Promise((resolve, reject) => {
40
+ try {
41
+ resolve(getGDMap(address))
42
+ } catch (e) {
43
+ reject(e)
44
+ }
45
+ })
46
+ }
47
+ export { GetGDMap, GetLocation }