@smart100/spu-web-plugin 1.0.9 → 1.0.10
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.
- package/dist/index.d.ts +21 -0
- package/dist/spu-web-plugin.mjs +48 -37
- package/package.json +1 -1
- package/src/map/MapService.ts +41 -22
- package/src/tenantSetting.ts +5 -7
- package/src/types/index.d.ts +21 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
// import type { App } from 'vue'
|
|
2
2
|
// import type { AxiosInstance } from 'axios'
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
// 高德地图
|
|
6
|
+
AMapLoader: any
|
|
7
|
+
_AMapSecurityConfig: {
|
|
8
|
+
securityJsCode: string
|
|
9
|
+
}
|
|
10
|
+
AMap: any
|
|
11
|
+
AMapUI: any
|
|
12
|
+
// 百度地图
|
|
13
|
+
BMap: any
|
|
14
|
+
BMAP_ANCHOR_TOP_LEFT: any
|
|
15
|
+
BMAP_ANCHOR_TOP_RIGHT: any
|
|
16
|
+
BMAP_ANCHOR_BOTTOM_LEFT: any
|
|
17
|
+
BMAP_ANCHOR_BOTTOM_RIGHT: any
|
|
18
|
+
BMAP_INITIAL_CALLBACK: any
|
|
19
|
+
// 腾讯地图
|
|
20
|
+
TMap: any
|
|
21
|
+
}
|
|
22
|
+
}
|
|
3
23
|
|
|
4
24
|
interface IAMapLoader {
|
|
5
25
|
load: (options?: {
|
|
@@ -16,6 +36,7 @@ interface IMapService {
|
|
|
16
36
|
AMap: any
|
|
17
37
|
BMap: any
|
|
18
38
|
TMap: any
|
|
39
|
+
MapCore: any
|
|
19
40
|
}
|
|
20
41
|
|
|
21
42
|
type StorageType = 'storage' | 'storage-1d' | 'storage-3m' | 'storage-1y'
|
package/dist/spu-web-plugin.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version = "1.0.
|
|
1
|
+
var version = "1.0.10";
|
|
2
2
|
|
|
3
3
|
/** Detect free variable `global` from Node.js. */
|
|
4
4
|
var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
|
|
@@ -16163,11 +16163,11 @@ var TenantSetting = /*#__PURE__*/function () {
|
|
|
16163
16163
|
// }
|
|
16164
16164
|
// }
|
|
16165
16165
|
// }
|
|
16166
|
-
//
|
|
16167
|
-
//
|
|
16168
|
-
//
|
|
16169
|
-
//
|
|
16170
|
-
//
|
|
16166
|
+
// tenantsetting.lbssetting.setting.type = 'amap'
|
|
16167
|
+
// tenantsetting.lbssetting.setting.key.web = '1993ac213d2f4675ac1bffb1b03ef1f0'
|
|
16168
|
+
// tenantsetting.lbssetting.setting.secretkey.web = '816fe46b7b7bce145940b93c1e4818fa'
|
|
16169
|
+
// tenantsetting.lbssetting.setting.type = 'tencent'
|
|
16170
|
+
// tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT'
|
|
16171
16171
|
// tenantsetting.lbssetting.setting.type = 'baidu'
|
|
16172
16172
|
// tenantsetting.lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
|
|
16173
16173
|
if (key) {
|
|
@@ -17071,6 +17071,10 @@ var MapService = /*#__PURE__*/function () {
|
|
|
17071
17071
|
function MapService() {
|
|
17072
17072
|
_classCallCheck$1(this, MapService);
|
|
17073
17073
|
_defineProperty$1(this, "isInit", false);
|
|
17074
|
+
_defineProperty$1(this, "AMap", null);
|
|
17075
|
+
_defineProperty$1(this, "TMap", null);
|
|
17076
|
+
_defineProperty$1(this, "BMap", null);
|
|
17077
|
+
_defineProperty$1(this, "MapCore", null);
|
|
17074
17078
|
}
|
|
17075
17079
|
_createClass$1(MapService, [{
|
|
17076
17080
|
key: "isLbssettingEnable",
|
|
@@ -17114,33 +17118,33 @@ var MapService = /*#__PURE__*/function () {
|
|
|
17114
17118
|
return 'amap';
|
|
17115
17119
|
}
|
|
17116
17120
|
}
|
|
17117
|
-
}, {
|
|
17118
|
-
key: "AMap",
|
|
17119
|
-
get: function get() {
|
|
17120
|
-
if (!this.isInit || this.type !== 'amap') {
|
|
17121
|
-
return null;
|
|
17122
|
-
}
|
|
17123
|
-
return window.AMap;
|
|
17124
|
-
}
|
|
17125
|
-
}, {
|
|
17126
|
-
key: "TMap",
|
|
17127
|
-
get: function get() {
|
|
17128
|
-
if (!this.isInit || this.type !== 'tencent') {
|
|
17129
|
-
return null;
|
|
17130
|
-
}
|
|
17131
|
-
return window.TMap;
|
|
17132
|
-
}
|
|
17133
|
-
}, {
|
|
17134
|
-
key: "BMap",
|
|
17135
|
-
get: function get() {
|
|
17136
|
-
if (!this.isInit || this.type !== 'baidu') {
|
|
17137
|
-
return null;
|
|
17138
|
-
}
|
|
17139
|
-
return window.BMap;
|
|
17140
|
-
}
|
|
17141
17121
|
}, {
|
|
17142
17122
|
key: "init",
|
|
17143
|
-
value:
|
|
17123
|
+
value: // get AMap() {
|
|
17124
|
+
// if (!this.isInit || this.type !== 'amap') {
|
|
17125
|
+
// return null
|
|
17126
|
+
// }
|
|
17127
|
+
// return window.AMap
|
|
17128
|
+
// }
|
|
17129
|
+
// get TMap() {
|
|
17130
|
+
// if (!this.isInit || this.type !== 'tencent') {
|
|
17131
|
+
// return null
|
|
17132
|
+
// }
|
|
17133
|
+
// return window.TMap
|
|
17134
|
+
// }
|
|
17135
|
+
// get BMap() {
|
|
17136
|
+
// if (!this.isInit || this.type !== 'baidu') {
|
|
17137
|
+
// return null
|
|
17138
|
+
// }
|
|
17139
|
+
// return window.BMap
|
|
17140
|
+
// }
|
|
17141
|
+
// get MapCore() {
|
|
17142
|
+
// if (!this.isInit) {
|
|
17143
|
+
// return null
|
|
17144
|
+
// }
|
|
17145
|
+
// return window.BMap
|
|
17146
|
+
// }
|
|
17147
|
+
function () {
|
|
17144
17148
|
var _init = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
17145
17149
|
var type;
|
|
17146
17150
|
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
@@ -17207,9 +17211,11 @@ var MapService = /*#__PURE__*/function () {
|
|
|
17207
17211
|
// `https://map.qq.com/api/gljs?v=1.exp&key=${this.key}`,
|
|
17208
17212
|
'TMap');
|
|
17209
17213
|
case 2:
|
|
17210
|
-
|
|
17214
|
+
this.TMap = window.TMap;
|
|
17215
|
+
this.MapCore = window.TMap;
|
|
17216
|
+
_context2.next = 6;
|
|
17211
17217
|
return delay(300);
|
|
17212
|
-
case
|
|
17218
|
+
case 6:
|
|
17213
17219
|
case "end":
|
|
17214
17220
|
return _context2.stop();
|
|
17215
17221
|
}
|
|
@@ -17247,12 +17253,14 @@ var MapService = /*#__PURE__*/function () {
|
|
|
17247
17253
|
case 3:
|
|
17248
17254
|
AMap = _context3.sent;
|
|
17249
17255
|
window.AMap = AMap;
|
|
17256
|
+
this.AMap = AMap;
|
|
17257
|
+
this.MapCore = window.AMap;
|
|
17250
17258
|
// console.log(window)
|
|
17251
17259
|
// console.log(window.AMap)
|
|
17252
17260
|
// console.log(window.AMapUI)
|
|
17253
17261
|
// console.log(window.AMapLoader)
|
|
17254
17262
|
// console.log(window.AMap === aaaa)
|
|
17255
|
-
case
|
|
17263
|
+
case 7:
|
|
17256
17264
|
case "end":
|
|
17257
17265
|
return _context3.stop();
|
|
17258
17266
|
}
|
|
@@ -17272,7 +17280,10 @@ var MapService = /*#__PURE__*/function () {
|
|
|
17272
17280
|
while (1) switch (_context4.prev = _context4.next) {
|
|
17273
17281
|
case 0:
|
|
17274
17282
|
return _context4.abrupt("return", new Promise(function (resolve, reject) {
|
|
17275
|
-
window.
|
|
17283
|
+
window.BMAP_INITIAL_CALLBACK = function () {
|
|
17284
|
+
_this.BMap = window.BMap;
|
|
17285
|
+
_this.MapCore = window.BMap;
|
|
17286
|
+
// debugger
|
|
17276
17287
|
// 启用google标准坐标体系
|
|
17277
17288
|
// coordsType 指定输入输出的坐标类型,BMAP_COORD_GCJ02为gcj02坐标,BMAP_COORD_BD09为bd0ll坐标,默认为BMAP_COORD_BD09。
|
|
17278
17289
|
window.BMap.coordType = 'BMAP_COORD_GCJ02';
|
|
@@ -17280,8 +17291,8 @@ var MapService = /*#__PURE__*/function () {
|
|
|
17280
17291
|
};
|
|
17281
17292
|
var script = document.createElement('script');
|
|
17282
17293
|
// 使用最新 3.0 api https://lbsyun.baidu.com/index.php?title=jspopular3.0
|
|
17283
|
-
script.src = "https://api.map.baidu.com/api?v=3.0&ak=".concat(_this.key, "&callback=
|
|
17284
|
-
// script.src = `https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=${this.key}&callback=
|
|
17294
|
+
script.src = "https://api.map.baidu.com/api?v=3.0&ak=".concat(_this.key, "&callback=BMAP_INITIAL_CALLBACK");
|
|
17295
|
+
// script.src = `https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=${this.key}&callback=BMAP_INITIAL_CALLBACK`
|
|
17285
17296
|
script.onerror = function (err) {
|
|
17286
17297
|
reject(err);
|
|
17287
17298
|
};
|
package/package.json
CHANGED
package/src/map/MapService.ts
CHANGED
|
@@ -19,7 +19,7 @@ interface ILbsSettingData {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
class MapService {
|
|
22
|
-
isInit = false
|
|
22
|
+
private isInit = false
|
|
23
23
|
|
|
24
24
|
get isLbssettingEnable() {
|
|
25
25
|
return tenantSetting.get('lbssetting')?.enable === '1'
|
|
@@ -53,26 +53,38 @@ class MapService {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return window.AMap
|
|
61
|
-
}
|
|
56
|
+
AMap: any = null
|
|
57
|
+
TMap: any = null
|
|
58
|
+
BMap: any = null
|
|
59
|
+
MapCore: any = null
|
|
62
60
|
|
|
63
|
-
get
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
61
|
+
// get AMap() {
|
|
62
|
+
// if (!this.isInit || this.type !== 'amap') {
|
|
63
|
+
// return null
|
|
64
|
+
// }
|
|
65
|
+
// return window.AMap
|
|
66
|
+
// }
|
|
69
67
|
|
|
70
|
-
get
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
68
|
+
// get TMap() {
|
|
69
|
+
// if (!this.isInit || this.type !== 'tencent') {
|
|
70
|
+
// return null
|
|
71
|
+
// }
|
|
72
|
+
// return window.TMap
|
|
73
|
+
// }
|
|
74
|
+
|
|
75
|
+
// get BMap() {
|
|
76
|
+
// if (!this.isInit || this.type !== 'baidu') {
|
|
77
|
+
// return null
|
|
78
|
+
// }
|
|
79
|
+
// return window.BMap
|
|
80
|
+
// }
|
|
81
|
+
|
|
82
|
+
// get MapCore() {
|
|
83
|
+
// if (!this.isInit) {
|
|
84
|
+
// return null
|
|
85
|
+
// }
|
|
86
|
+
// return window.BMap
|
|
87
|
+
// }
|
|
76
88
|
|
|
77
89
|
async init() {
|
|
78
90
|
if (this.isInit) return
|
|
@@ -103,6 +115,8 @@ class MapService {
|
|
|
103
115
|
// `https://map.qq.com/api/gljs?v=1.exp&key=${this.key}`,
|
|
104
116
|
'TMap'
|
|
105
117
|
)
|
|
118
|
+
this.TMap = window.TMap
|
|
119
|
+
this.MapCore = window.TMap
|
|
106
120
|
await delay(300)
|
|
107
121
|
}
|
|
108
122
|
|
|
@@ -126,6 +140,8 @@ class MapService {
|
|
|
126
140
|
}
|
|
127
141
|
})
|
|
128
142
|
window.AMap = AMap
|
|
143
|
+
this.AMap = AMap
|
|
144
|
+
this.MapCore = window.AMap
|
|
129
145
|
// console.log(window)
|
|
130
146
|
// console.log(window.AMap)
|
|
131
147
|
// console.log(window.AMapUI)
|
|
@@ -144,7 +160,10 @@ class MapService {
|
|
|
144
160
|
// mp.centerAndZoom(new BMap.Point(121.491, 31.233), 11)
|
|
145
161
|
// }
|
|
146
162
|
return new Promise((resolve, reject) => {
|
|
147
|
-
window.
|
|
163
|
+
window.BMAP_INITIAL_CALLBACK = () => {
|
|
164
|
+
this.BMap = window.BMap
|
|
165
|
+
this.MapCore = window.BMap
|
|
166
|
+
// debugger
|
|
148
167
|
// 启用google标准坐标体系
|
|
149
168
|
// coordsType 指定输入输出的坐标类型,BMAP_COORD_GCJ02为gcj02坐标,BMAP_COORD_BD09为bd0ll坐标,默认为BMAP_COORD_BD09。
|
|
150
169
|
window.BMap.coordType = 'BMAP_COORD_GCJ02'
|
|
@@ -152,8 +171,8 @@ class MapService {
|
|
|
152
171
|
}
|
|
153
172
|
const script = document.createElement('script')
|
|
154
173
|
// 使用最新 3.0 api https://lbsyun.baidu.com/index.php?title=jspopular3.0
|
|
155
|
-
script.src = `https://api.map.baidu.com/api?v=3.0&ak=${this.key}&callback=
|
|
156
|
-
// script.src = `https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=${this.key}&callback=
|
|
174
|
+
script.src = `https://api.map.baidu.com/api?v=3.0&ak=${this.key}&callback=BMAP_INITIAL_CALLBACK`
|
|
175
|
+
// script.src = `https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=${this.key}&callback=BMAP_INITIAL_CALLBACK`
|
|
157
176
|
script.onerror = (err) => {
|
|
158
177
|
reject(err)
|
|
159
178
|
}
|
package/src/tenantSetting.ts
CHANGED
|
@@ -43,7 +43,6 @@ class TenantSetting {
|
|
|
43
43
|
if (tenantsettingStr) {
|
|
44
44
|
const tenantsetting = JSON.parse(tenantsettingStr)
|
|
45
45
|
|
|
46
|
-
|
|
47
46
|
// tenantsetting.lbssetting = {
|
|
48
47
|
// enable: '1',
|
|
49
48
|
// setting: {
|
|
@@ -62,17 +61,16 @@ class TenantSetting {
|
|
|
62
61
|
// }
|
|
63
62
|
// }
|
|
64
63
|
// }
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
64
|
+
// tenantsetting.lbssetting.setting.type = 'amap'
|
|
65
|
+
// tenantsetting.lbssetting.setting.key.web = '1993ac213d2f4675ac1bffb1b03ef1f0'
|
|
66
|
+
// tenantsetting.lbssetting.setting.secretkey.web = '816fe46b7b7bce145940b93c1e4818fa'
|
|
68
67
|
|
|
69
|
-
//
|
|
70
|
-
//
|
|
68
|
+
// tenantsetting.lbssetting.setting.type = 'tencent'
|
|
69
|
+
// tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT'
|
|
71
70
|
|
|
72
71
|
// tenantsetting.lbssetting.setting.type = 'baidu'
|
|
73
72
|
// tenantsetting.lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
|
|
74
73
|
|
|
75
|
-
|
|
76
74
|
if (key) {
|
|
77
75
|
return tenantsetting[key]
|
|
78
76
|
}
|
package/src/types/index.d.ts
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
// import type { App } from 'vue'
|
|
2
2
|
// import type { AxiosInstance } from 'axios'
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
// 高德地图
|
|
6
|
+
AMapLoader: any
|
|
7
|
+
_AMapSecurityConfig: {
|
|
8
|
+
securityJsCode: string
|
|
9
|
+
}
|
|
10
|
+
AMap: any
|
|
11
|
+
AMapUI: any
|
|
12
|
+
// 百度地图
|
|
13
|
+
BMap: any
|
|
14
|
+
BMAP_ANCHOR_TOP_LEFT: any
|
|
15
|
+
BMAP_ANCHOR_TOP_RIGHT: any
|
|
16
|
+
BMAP_ANCHOR_BOTTOM_LEFT: any
|
|
17
|
+
BMAP_ANCHOR_BOTTOM_RIGHT: any
|
|
18
|
+
BMAP_INITIAL_CALLBACK: any
|
|
19
|
+
// 腾讯地图
|
|
20
|
+
TMap: any
|
|
21
|
+
}
|
|
22
|
+
}
|
|
3
23
|
|
|
4
24
|
interface IAMapLoader {
|
|
5
25
|
load: (options?: {
|
|
@@ -16,6 +36,7 @@ interface IMapService {
|
|
|
16
36
|
AMap: any
|
|
17
37
|
BMap: any
|
|
18
38
|
TMap: any
|
|
39
|
+
MapCore: any
|
|
19
40
|
}
|
|
20
41
|
|
|
21
42
|
type StorageType = 'storage' | 'storage-1d' | 'storage-3m' | 'storage-1y'
|