@smart100/spu-web-plugin 1.0.12 → 1.0.14

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.
@@ -1,4 +1,4 @@
1
- var version = "1.0.12";
1
+ var version = "1.0.14";
2
2
 
3
3
  /** Detect free variable `global` from Node.js. */
4
4
  var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
@@ -16162,13 +16162,32 @@ var TenantSetting = /*#__PURE__*/function () {
16162
16162
  // }
16163
16163
  // }
16164
16164
  // }
16165
+ // 高德地图key配置错误
16166
+ // 1 如果是key格式不对 那么没返回promise 连window.AMap都拿不到 地图和都不能用
16167
+ // 1 如果是key对式对 但key不对 有返回 window.AMap 但api定位调用失败 地图可以渲染空白地图
16168
+ // // 高德地图公司key
16165
16169
  // tenantsetting.lbssetting.setting.type = 'amap'
16166
16170
  // tenantsetting.lbssetting.setting.key.web = '1993ac213d2f4675ac1bffb1b03ef1f0'
16167
16171
  // tenantsetting.lbssetting.setting.secretkey.web = '816fe46b7b7bce145940b93c1e4818fa'
16168
- // // tenantsetting.lbssetting.setting.type = 'tencent'
16169
- // // tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT'
16170
- // // tenantsetting.lbssetting.setting.type = 'baidu'
16171
- // // tenantsetting.lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
16172
+ // // 高德地图个人key
16173
+ // tenantsetting.lbssetting.setting.type = 'amap'
16174
+ // tenantsetting.lbssetting.setting.key.web = 'e4d25fe4661a34198c4e6f79abe9afac'
16175
+ // tenantsetting.lbssetting.setting.secretkey.web = 'a6b674affd9a3278c68602cf7ba02fcb'
16176
+ // tencent地图key配置错误
16177
+ // 1 如果是地图 会在地图上明确文字提示 鉴权失败,请传入正确的key
16178
+ // 2 如果是调用定位等api 会返回 catch 和详细的错误信息
16179
+ // getIPLocationByTMap fail: {"status":311,"message":"key格式错误","request_id":"ccedb04fd95e4f3f9cd45cfbad729d10","id":"cbm919vjdj0"}
16180
+ // getIPLocationByTMap fail: {"status":190,"message":"无效的key","request_id":"b6ca9d0749eb4c91a47db9412b1253ca","id":"cbm919wxo40"}
16181
+ // tenantsetting.lbssetting.setting.type = 'tencent'
16182
+ // tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT'
16183
+ // tenantsetting.lbssetting.setting.secretkey.web = 'zowvV5I2pSxqgGb2Sgr1x62HGXbqdxT0'
16184
+ // 百度地图key配置错误alert以下信息
16185
+ // 您提供的密钥不是有效的百度LBS开放平台密钥,或此密钥未对本应用的百度地图JavaScriptAPI授权。您可以访问如下网址了解如何获取有效的密钥:http://lbsyun.baidu.com/apiconsole/key#。
16186
+ // tenantsetting.lbssetting.setting.type = 'baidu'
16187
+ // tenantsetting.lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
16188
+ // tenantsetting.lbssetting.setting.type = 'tencent'
16189
+ // tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT是的是的'
16190
+ // tenantsetting.lbssetting.setting.secretkey.web = 'zowvV5I2pSxqgGb2Sgr1x62HGXbqdxT0对对对'
16172
16191
  // lsProxy.setItem('tenantsetting', JSON.stringify(tenantsetting))
16173
16192
  var tenantsettingStr = lsProxy.getItem('tenantsetting');
16174
16193
  if (tenantsettingStr) {
@@ -17183,40 +17202,63 @@ var MapService = /*#__PURE__*/function () {
17183
17202
  key: "_init",
17184
17203
  value: function () {
17185
17204
  var _init3 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2() {
17186
- var type;
17205
+ var type, key, secretkey;
17187
17206
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
17188
17207
  while (1) switch (_context2.prev = _context2.next) {
17189
17208
  case 0:
17190
17209
  type = this.type;
17210
+ key = this.key;
17211
+ secretkey = this.secretkey;
17191
17212
  if (!(type === 'tencent')) {
17192
- _context2.next = 6;
17213
+ _context2.next = 11;
17193
17214
  break;
17194
17215
  }
17195
- _context2.next = 4;
17216
+ if (!(!key || !secretkey)) {
17217
+ _context2.next = 7;
17218
+ break;
17219
+ }
17220
+ console.error('请填写腾讯地图 Web App Key 和 Web Secret Key');
17221
+ return _context2.abrupt("return");
17222
+ case 7:
17223
+ _context2.next = 9;
17196
17224
  return this.initTecent();
17197
- case 4:
17198
- _context2.next = 14;
17225
+ case 9:
17226
+ _context2.next = 25;
17199
17227
  break;
17200
- case 6:
17228
+ case 11:
17201
17229
  if (!(type === 'amap')) {
17202
- _context2.next = 11;
17230
+ _context2.next = 19;
17203
17231
  break;
17204
17232
  }
17205
- _context2.next = 9;
17233
+ if (!(!key || !secretkey)) {
17234
+ _context2.next = 15;
17235
+ break;
17236
+ }
17237
+ console.error('请填写高德地图 Web App Key 和 Web Secret Key');
17238
+ return _context2.abrupt("return");
17239
+ case 15:
17240
+ _context2.next = 17;
17206
17241
  return this.initAmap();
17207
- case 9:
17208
- _context2.next = 14;
17242
+ case 17:
17243
+ _context2.next = 25;
17209
17244
  break;
17210
- case 11:
17245
+ case 19:
17211
17246
  if (!(type === 'baidu')) {
17212
- _context2.next = 14;
17247
+ _context2.next = 25;
17213
17248
  break;
17214
17249
  }
17215
- _context2.next = 14;
17250
+ if (key) {
17251
+ _context2.next = 23;
17252
+ break;
17253
+ }
17254
+ console.error('请填写百度地图 Web App Key');
17255
+ return _context2.abrupt("return");
17256
+ case 23:
17257
+ _context2.next = 25;
17216
17258
  return this.initBaidu();
17217
- case 14:
17259
+ case 25:
17218
17260
  this.isInit = true;
17219
- case 15:
17261
+ case 26:
17220
17262
  case "end":
17221
17263
  return _context2.stop();
17222
17264
  }
@@ -17259,42 +17301,66 @@ var MapService = /*#__PURE__*/function () {
17259
17301
  }, {
17260
17302
  key: "initAmap",
17261
17303
  value: function () {
17262
- var _initAmap = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4() {
17263
- var plugin, AMap;
17264
- return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
17265
- while (1) switch (_context4.prev = _context4.next) {
17304
+ var _initAmap = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5() {
17305
+ var _this = this;
17306
+ return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
17307
+ while (1) switch (_context5.prev = _context5.next) {
17266
17308
  case 0:
17267
- if (this.secretkey) {
17268
- window._AMapSecurityConfig = {
17269
- securityJsCode: this.secretkey
17309
+ return _context5.abrupt("return", new Promise( /*#__PURE__*/function () {
17310
+ var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(resolve, reject) {
17311
+ var time, plugin, AMap;
17312
+ return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
17313
+ while (1) switch (_context4.prev = _context4.next) {
17314
+ case 0:
17315
+ // 高德地图api初始化失败 没有返回reject 因此用超时机制检测
17316
+ time = setTimeout(function () {
17317
+ console.error('initAmap fail: 请检查高德地图 Web App Key 和 Web Secret Key 是否正确配置');
17318
+ resolve(null);
17319
+ }, 3000);
17320
+ if (_this.secretkey) {
17321
+ window._AMapSecurityConfig = {
17322
+ securityJsCode: _this.secretkey
17323
+ };
17324
+ }
17325
+ plugin = ['AMap.Geolocation', 'AMap.Geocoder']; // debugger
17326
+ _context4.next = 5;
17327
+ return AMapLoader$1.load({
17328
+ key: _this.key,
17329
+ version: '2.0',
17330
+ plugins: plugin,
17331
+ AMapUI: {
17332
+ version: '1.1',
17333
+ plugins: []
17334
+ }
17335
+ });
17336
+ case 5:
17337
+ AMap = _context4.sent;
17338
+ // debugger
17339
+ clearTimeout(time);
17340
+ window.AMap = AMap;
17341
+ _this.AMap = window.AMap;
17342
+ _this.MapCore = window.AMap;
17343
+ // console.log(window)
17344
+ // console.log(window.AMap)
17345
+ // console.log(window.AMapUI)
17346
+ // console.log(window.AMapLoader)
17347
+ // console.log(window.AMap === aaaa)
17348
+ resolve(window.AMap);
17349
+ case 11:
17350
+ case "end":
17351
+ return _context4.stop();
17352
+ }
17353
+ }, _callee4);
17354
+ }));
17355
+ return function (_x, _x2) {
17356
+ return _ref.apply(this, arguments);
17270
17357
  };
17271
- }
17272
- plugin = ['AMap.Geolocation', 'AMap.Geocoder'];
17273
- _context4.next = 4;
17274
- return AMapLoader$1.load({
17275
- key: this.key,
17276
- version: '2.0',
17277
- plugins: plugin,
17278
- AMapUI: {
17279
- version: '1.1',
17280
- plugins: []
17281
- }
17282
- });
17283
- case 4:
17284
- AMap = _context4.sent;
17285
- window.AMap = AMap;
17286
- this.AMap = AMap;
17287
- this.MapCore = window.AMap;
17288
- // console.log(window)
17289
- // console.log(window.AMap)
17290
- // console.log(window.AMapUI)
17291
- // console.log(window.AMapLoader)
17292
- // console.log(window.AMap === aaaa)
17293
- case 8:
17358
+ }()));
17359
+ case 1:
17294
17360
  case "end":
17295
- return _context4.stop();
17361
+ return _context5.stop();
17296
17362
  }
17297
- }, _callee4, this);
17363
+ }, _callee5);
17298
17364
  }));
17299
17365
  function initAmap() {
17300
17366
  return _initAmap.apply(this, arguments);
@@ -17304,15 +17370,17 @@ var MapService = /*#__PURE__*/function () {
17304
17370
  }, {
17305
17371
  key: "initBaidu",
17306
17372
  value: function () {
17307
- var _initBaidu = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5() {
17308
- var _this = this;
17309
- return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
17310
- while (1) switch (_context5.prev = _context5.next) {
17373
+ var _initBaidu = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee6() {
17374
+ var _this2 = this;
17375
+ return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
17376
+ while (1) switch (_context6.prev = _context6.next) {
17311
17377
  case 0:
17312
- return _context5.abrupt("return", new Promise(function (resolve, reject) {
17313
- window.BMAP_INITIAL_CALLBACK = function () {
17314
- _this.BMap = window.BMap;
17315
- _this.MapCore = window.BMap;
17378
+ return _context6.abrupt("return", new Promise(function (resolve, reject) {
17379
+ window.BMAP_INITIAL_CALLBACK = function (e) {
17380
+ // console.log(e)
17381
+ // debugger
17382
+ _this2.BMap = window.BMap;
17383
+ _this2.MapCore = window.BMap;
17316
17384
  // debugger
17317
17385
  // 启用google标准坐标体系
17318
17386
  // coordsType 指定输入输出的坐标类型,BMAP_COORD_GCJ02为gcj02坐标,BMAP_COORD_BD09为bd0ll坐标,默认为BMAP_COORD_BD09。
@@ -17321,7 +17389,7 @@ var MapService = /*#__PURE__*/function () {
17321
17389
  };
17322
17390
  var script = document.createElement('script');
17323
17391
  // 使用最新 3.0 api https://lbsyun.baidu.com/index.php?title=jspopular3.0
17324
- script.src = "https://api.map.baidu.com/api?v=3.0&ak=".concat(_this.key, "&callback=BMAP_INITIAL_CALLBACK");
17392
+ script.src = "https://api.map.baidu.com/api?v=3.0&ak=".concat(_this2.key, "&callback=BMAP_INITIAL_CALLBACK");
17325
17393
  // script.src = `https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=${this.key}&callback=BMAP_INITIAL_CALLBACK`
17326
17394
  script.onerror = function (err) {
17327
17395
  reject(err);
@@ -17330,9 +17398,9 @@ var MapService = /*#__PURE__*/function () {
17330
17398
  }));
17331
17399
  case 1:
17332
17400
  case "end":
17333
- return _context5.stop();
17401
+ return _context6.stop();
17334
17402
  }
17335
- }, _callee5);
17403
+ }, _callee6);
17336
17404
  }));
17337
17405
  function initBaidu() {
17338
17406
  return _initBaidu.apply(this, arguments);
@@ -17436,9 +17504,9 @@ var getLocationByNative = /*#__PURE__*/function () {
17436
17504
  }
17437
17505
  }, 30000);
17438
17506
  window.Native.getLocation(function (res, error, status) {
17439
- // console.log('getLocation res', res)
17440
- // console.log('getLocation error', error)
17441
- // console.log('getLocation status', status)
17507
+ // console.log('window.Native.getLocation res', res)
17508
+ // console.log('window.Native.getLocation error', error)
17509
+ // console.log('window.Native.getLocation status', status)
17442
17510
  isload = true;
17443
17511
  if (res && res !== null && res !== void 0 && res.longitude && res !== null && res !== void 0 && res.latitude) {
17444
17512
  var result = {
@@ -17516,139 +17584,24 @@ var getLocationByNavigator = /*#__PURE__*/function () {
17516
17584
  return _ref2.apply(this, arguments);
17517
17585
  };
17518
17586
  }();
17519
- // ipaas ip 定位
17520
- var getIPLocationByIpaas = /*#__PURE__*/function () {
17521
- var _ref3 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3(ip) {
17522
- return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
17523
- while (1) switch (_context3.prev = _context3.next) {
17524
- case 0:
17525
- console.log('getIPLocationByIpaas start...');
17526
- return _context3.abrupt("return", new Promise(function (resolve, reject) {
17527
- var AMapKey = getAMapKey();
17528
- normalAxios$1.post('https://silkroad.wxchina.com/api/openapi/publishEvent?topic=xw-listener&subtopic=xw-listener&apicaseid=6684389338001815271', {
17529
- key: AMapKey.key,
17530
- ip: ip || ''
17531
- }).then(function (res) {
17532
- // console.log(res)
17533
- // debugger
17534
- // res.data.rectangle = '113.1017375,22.93212254;113.6770499,23.3809537'
17535
- if (res.data.rectangle) {
17536
- var rectangle = res.data.rectangle;
17537
- var rects = rectangle.split(';').map(function (rect) {
17538
- var _rect$split = rect.split(','),
17539
- _rect$split2 = _slicedToArray(_rect$split, 2),
17540
- longitude = _rect$split2[0],
17541
- latitude = _rect$split2[1];
17542
- return {
17543
- longitude: Number(longitude),
17544
- latitude: Number(latitude)
17545
- };
17546
- });
17547
- var result = {
17548
- longitude: ((rects[0].longitude + rects[1].longitude) / 2).toString(),
17549
- latitude: ((rects[0].latitude + rects[1].latitude) / 2).toString()
17550
- };
17551
- console.log("getIPLocationByIpaas success: ".concat(JSON.stringify(result)));
17552
- resolve(result);
17553
- } else {
17554
- console.error('getIPLocationByIpaas fail');
17555
- resolve(null);
17556
- }
17557
- })["catch"](function (err) {
17558
- console.error(err);
17559
- console.error('getIPLocationByIpaas fail');
17560
- resolve(null);
17561
- });
17562
- }));
17563
- case 2:
17564
- case "end":
17565
- return _context3.stop();
17566
- }
17567
- }, _callee3);
17568
- }));
17569
- return function getIPLocationByIpaas(_x) {
17570
- return _ref3.apply(this, arguments);
17571
- };
17572
- }();
17573
- // ipaas 逆地址解析
17574
- var getAddressByIpaas = /*#__PURE__*/function () {
17575
- var _ref4 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5(position) {
17576
- return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
17577
- while (1) switch (_context5.prev = _context5.next) {
17578
- case 0:
17579
- console.log('getAddressByIpaas start...');
17580
- // 如果不设置安全秘钥的话 js-api的逆地址查询不成功 返回 INVALID_USER_SCODE 改成用ipaas服务查询
17581
- return _context5.abrupt("return", new Promise( /*#__PURE__*/function () {
17582
- var _ref5 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(resolve, reject) {
17583
- var _result$data, AMapKey, result, address;
17584
- return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
17585
- while (1) switch (_context4.prev = _context4.next) {
17586
- case 0:
17587
- if (!position) {
17588
- _context4.next = 15;
17589
- break;
17590
- }
17591
- _context4.prev = 1;
17592
- AMapKey = getAMapKey();
17593
- _context4.next = 5;
17594
- return normalAxios$1.post('https://silkroad.wxchina.com/api/openapi/publishEvent?topic=xw-listener&subtopic=xw-listener&apicaseid=6684389338001809906', {
17595
- longitude: position.longitude,
17596
- latitude: position.latitude,
17597
- key: AMapKey.key
17598
- // extensions: 'all'
17599
- });
17600
- case 5:
17601
- result = _context4.sent;
17602
- // console.log(result)
17603
- address = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.formatted_address;
17604
- if (address) {
17605
- console.log("getAddressByIpaas success: ".concat(address));
17606
- resolve(address);
17607
- } else {
17608
- console.error('getAddressByIpaas fail');
17609
- resolve('');
17610
- }
17611
- _context4.next = 15;
17612
- break;
17613
- case 10:
17614
- _context4.prev = 10;
17615
- _context4.t0 = _context4["catch"](1);
17616
- console.error(_context4.t0);
17617
- console.error('getAddressByIpaas fail');
17618
- resolve('');
17619
- case 15:
17620
- case "end":
17621
- return _context4.stop();
17622
- }
17623
- }, _callee4, null, [[1, 10]]);
17624
- }));
17625
- return function (_x3, _x4) {
17626
- return _ref5.apply(this, arguments);
17627
- };
17628
- }()));
17629
- case 2:
17630
- case "end":
17631
- return _context5.stop();
17632
- }
17633
- }, _callee5);
17634
- }));
17635
- return function getAddressByIpaas(_x2) {
17636
- return _ref4.apply(this, arguments);
17637
- };
17638
- }();
17639
17587
  // 高德定位
17640
- var getLocationByAmap = /*#__PURE__*/function () {
17588
+ var getLocationByAMap = /*#__PURE__*/function () {
17641
17589
  var _ref6 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee6() {
17642
17590
  return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
17643
17591
  while (1) switch (_context6.prev = _context6.next) {
17644
17592
  case 0:
17645
- console.log('getLocationByAmap start...');
17593
+ console.log('getLocationByAMap start...');
17646
17594
  return _context6.abrupt("return", new Promise(function (resolve, reject) {
17647
- var geolocation = new window.AMap.Geolocation({
17595
+ var _window;
17596
+ if (!((_window = window) !== null && _window !== void 0 && _window.AMap)) {
17597
+ console.error('getLocationByAMap fail: AMap is undefinded');
17598
+ resolve(null);
17599
+ return;
17600
+ }
17601
+ new window.AMap.Geolocation({
17648
17602
  enableHighAccuracy: true,
17649
17603
  timeout: 15000
17650
- });
17651
- geolocation.getCurrentPosition(function (status, res) {
17604
+ }).getCurrentPosition(function (status, res) {
17652
17605
  // console.log(status, result)
17653
17606
  // debugger
17654
17607
  if (status === 'complete') {
@@ -17659,10 +17612,10 @@ var getLocationByAmap = /*#__PURE__*/function () {
17659
17612
  longitude: lng.toString(),
17660
17613
  latitude: lat.toString()
17661
17614
  };
17662
- console.log("getLocationByAmap success: ".concat(JSON.stringify(result)));
17615
+ console.log("getLocationByAMap success: ".concat(JSON.stringify(result)));
17663
17616
  resolve(result);
17664
17617
  } else {
17665
- console.error('getLocationByAmap fail');
17618
+ console.error('getLocationByAMap fail');
17666
17619
  resolve(null);
17667
17620
  }
17668
17621
  });
@@ -17673,23 +17626,28 @@ var getLocationByAmap = /*#__PURE__*/function () {
17673
17626
  }
17674
17627
  }, _callee6);
17675
17628
  }));
17676
- return function getLocationByAmap() {
17629
+ return function getLocationByAMap() {
17677
17630
  return _ref6.apply(this, arguments);
17678
17631
  };
17679
17632
  }();
17680
17633
  // 高德城市定位
17681
- var getCityLocationByAmap = /*#__PURE__*/function () {
17634
+ var getCityLocationByAMap = /*#__PURE__*/function () {
17682
17635
  var _ref7 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee7() {
17683
17636
  return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
17684
17637
  while (1) switch (_context7.prev = _context7.next) {
17685
17638
  case 0:
17686
- console.log('getCityLocationByAmap start...');
17639
+ console.log('getCityLocationByAMap start...');
17687
17640
  return _context7.abrupt("return", new Promise(function (resolve, reject) {
17688
- var geolocation = new window.AMap.Geolocation({
17641
+ var _window2;
17642
+ if (!((_window2 = window) !== null && _window2 !== void 0 && _window2.AMap)) {
17643
+ console.error('getCityLocationByAMap fail: AMap is undefinded');
17644
+ resolve(null);
17645
+ return;
17646
+ }
17647
+ new window.AMap.Geolocation({
17689
17648
  enableHighAccuracy: true,
17690
17649
  timeout: 15000
17691
- });
17692
- geolocation.getCityInfo(function (status, res) {
17650
+ }).getCityInfo(function (status, res) {
17693
17651
  // console.log(res)
17694
17652
  // debugger
17695
17653
  if (status === 'complete') {
@@ -17699,10 +17657,10 @@ var getCityLocationByAmap = /*#__PURE__*/function () {
17699
17657
  longitude: lng.toString(),
17700
17658
  latitude: lat.toString()
17701
17659
  };
17702
- console.log("getCityLocationByAmap success: ".concat(JSON.stringify(result)));
17660
+ console.log("getCityLocationByAMap success: ".concat(JSON.stringify(result)));
17703
17661
  resolve(result);
17704
17662
  } else {
17705
- console.error('getCityLocationByAmap fail');
17663
+ console.error('getCityLocationByAMap fail');
17706
17664
  resolve(null);
17707
17665
  }
17708
17666
  });
@@ -17713,18 +17671,24 @@ var getCityLocationByAmap = /*#__PURE__*/function () {
17713
17671
  }
17714
17672
  }, _callee7);
17715
17673
  }));
17716
- return function getCityLocationByAmap() {
17674
+ return function getCityLocationByAMap() {
17717
17675
  return _ref7.apply(this, arguments);
17718
17676
  };
17719
17677
  }();
17720
17678
  // 高德逆地址解析
17721
- var getAddressByAmap = /*#__PURE__*/function () {
17679
+ var getAddressByAMap = /*#__PURE__*/function () {
17722
17680
  var _ref8 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee8(position) {
17723
17681
  return _regeneratorRuntime$1().wrap(function _callee8$(_context8) {
17724
17682
  while (1) switch (_context8.prev = _context8.next) {
17725
17683
  case 0:
17726
- console.log('getAddressByAmap start...');
17684
+ console.log('getAddressByAMap start...');
17727
17685
  return _context8.abrupt("return", new Promise(function (resolve, reject) {
17686
+ var _window3;
17687
+ if (!((_window3 = window) !== null && _window3 !== void 0 && _window3.AMap)) {
17688
+ console.error('getAddressByAMap fail: AMap is undefinded');
17689
+ resolve('');
17690
+ return;
17691
+ }
17728
17692
  if (position) {
17729
17693
  new window.AMap.Geocoder({
17730
17694
  city: '',
@@ -17736,10 +17700,10 @@ var getAddressByAmap = /*#__PURE__*/function () {
17736
17700
  // debugger
17737
17701
  if (status === 'complete' && result.info === 'OK' && result !== null && result !== void 0 && (_result$regeocode = result.regeocode) !== null && _result$regeocode !== void 0 && _result$regeocode.formattedAddress) {
17738
17702
  var address = result.regeocode.formattedAddress || '';
17739
- console.log("getAddressByAmap success: ".concat(address));
17703
+ console.log("getAddressByAMap success: ".concat(address));
17740
17704
  resolve(address);
17741
17705
  } else {
17742
- console.error("getAddressByAmap fail: status = ".concat(status, ", result = ").concat(result));
17706
+ console.error("getAddressByAMap fail: status = ".concat(status, ", result = ").concat(result));
17743
17707
  resolve('');
17744
17708
  }
17745
17709
  });
@@ -17751,7 +17715,7 @@ var getAddressByAmap = /*#__PURE__*/function () {
17751
17715
  }
17752
17716
  }, _callee8);
17753
17717
  }));
17754
- return function getAddressByAmap(_x5) {
17718
+ return function getAddressByAMap(_x5) {
17755
17719
  return _ref8.apply(this, arguments);
17756
17720
  };
17757
17721
  }();
@@ -17763,11 +17727,18 @@ var getIPLocationByTMap = /*#__PURE__*/function () {
17763
17727
  case 0:
17764
17728
  console.log('getIPLocationByTMap start...');
17765
17729
  return _context9.abrupt("return", new Promise(function (resolve, reject) {
17766
- var ipLocation = new window.TMap.service.IPLocation();
17730
+ var _window4;
17731
+ if (!((_window4 = window) !== null && _window4 !== void 0 && _window4.TMap)) {
17732
+ console.error('getIPLocationByTMap fail: TMap is undefinded');
17733
+ resolve(null);
17734
+ return;
17735
+ }
17767
17736
  var params = ip ? {
17768
17737
  ip: ip
17769
17738
  } : {};
17770
- ipLocation.locate(params).then(function (res) {
17739
+ new window.TMap.service.IPLocation().locate(_objectSpread2$1(_objectSpread2$1({}, params), {}, {
17740
+ servicesk: mapService.secretkey
17741
+ })).then(function (res) {
17771
17742
  var result = {
17772
17743
  longitude: res.result.location.lng.toString(),
17773
17744
  latitude: res.result.location.lat.toString()
@@ -17798,14 +17769,18 @@ var getAddressByTMap = /*#__PURE__*/function () {
17798
17769
  case 0:
17799
17770
  console.log('getAddressByTMap start...');
17800
17771
  return _context10.abrupt("return", new Promise(function (resolve, reject) {
17772
+ var _window5;
17773
+ if (!((_window5 = window) !== null && _window5 !== void 0 && _window5.TMap)) {
17774
+ console.error('getAddressByTMap fail: TMap is undefinded');
17775
+ resolve('');
17776
+ return;
17777
+ }
17801
17778
  if (position) {
17802
- var location = new window.TMap.LatLng(position.latitude, position.longitude);
17803
- // console.log(position)
17804
- // console.log(location)
17805
17779
  // debugger
17806
17780
  new window.TMap.service.Geocoder().getAddress({
17807
- location: location,
17808
- getPoi: false
17781
+ location: new window.TMap.LatLng(position.latitude, position.longitude),
17782
+ getPoi: false,
17783
+ servicesk: mapService.secretkey
17809
17784
  }).then(function (res) {
17810
17785
  var _res$result, _res$result2;
17811
17786
  // console.log(res)
@@ -17838,6 +17813,12 @@ var getLocationByBMap = /*#__PURE__*/function () {
17838
17813
  case 0:
17839
17814
  console.log('getLocationByBMap start...');
17840
17815
  return _context12.abrupt("return", new Promise(function (resolve, reject) {
17816
+ var _window6;
17817
+ if (!((_window6 = window) !== null && _window6 !== void 0 && _window6.BMap)) {
17818
+ console.error('getLocationByBMap fail: BMap is undefinded');
17819
+ resolve(null);
17820
+ return;
17821
+ }
17841
17822
  new window.BMap.Geolocation().getCurrentPosition( /*#__PURE__*/function () {
17842
17823
  var _ref12 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee11(res) {
17843
17824
  var lng, lat, result;
@@ -17922,6 +17903,12 @@ var getCityLocationByBMap = /*#__PURE__*/function () {
17922
17903
  case 0:
17923
17904
  console.log('getCityLocationByBMap start...');
17924
17905
  return _context14.abrupt("return", new Promise(function (resolve, reject) {
17906
+ var _window7;
17907
+ if (!((_window7 = window) !== null && _window7 !== void 0 && _window7.BMap)) {
17908
+ console.error('getCityLocationByBMap fail: BMap is undefinded');
17909
+ resolve(null);
17910
+ return;
17911
+ }
17925
17912
  new window.BMap.LocalCity().get( /*#__PURE__*/function () {
17926
17913
  var _ref14 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee13(res) {
17927
17914
  var lng, lat, point, result;
@@ -17986,18 +17973,27 @@ var getAddressByBmap = /*#__PURE__*/function () {
17986
17973
  console.log('getAddressByBmap start...');
17987
17974
  return _context16.abrupt("return", new Promise( /*#__PURE__*/function () {
17988
17975
  var _ref16 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee15(resolve, reject) {
17976
+ var _window8;
17989
17977
  var point;
17990
17978
  return _regeneratorRuntime$1().wrap(function _callee15$(_context15) {
17991
17979
  while (1) switch (_context15.prev = _context15.next) {
17992
17980
  case 0:
17993
- if (position) {
17981
+ if ((_window8 = window) !== null && _window8 !== void 0 && _window8.BMap) {
17994
17982
  _context15.next = 4;
17995
17983
  break;
17996
17984
  }
17997
- console.error('getAddressByBmap fail');
17985
+ console.error('getAddressByBmap fail: BMap is undefinded');
17998
17986
  resolve('');
17999
17987
  return _context15.abrupt("return");
18000
17988
  case 4:
17989
+ if (position) {
17990
+ _context15.next = 8;
17991
+ break;
17992
+ }
17993
+ console.error('getAddressByBmap fail');
17994
+ resolve('');
17995
+ return _context15.abrupt("return");
17996
+ case 8:
18001
17997
  // // 把 GCJ02 转化为百度 BD09 地址
18002
17998
  // const points: any = await transformGCJ02ToBD09Points([{
18003
17999
  // lng: position.longitude,
@@ -18015,10 +18011,11 @@ var getAddressByBmap = /*#__PURE__*/function () {
18015
18011
  resolve(address);
18016
18012
  } else {
18017
18013
  console.error('getAddressByBmap fail');
18014
+ // console.error(result)
18018
18015
  resolve('');
18019
18016
  }
18020
18017
  });
18021
- case 6:
18018
+ case 10:
18022
18019
  case "end":
18023
18020
  return _context15.stop();
18024
18021
  }
@@ -18040,7 +18037,7 @@ var getAddressByBmap = /*#__PURE__*/function () {
18040
18037
  }();
18041
18038
  var getLocationPromise = /*#__PURE__*/function () {
18042
18039
  var _ref17 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee17() {
18043
- var _window;
18040
+ var _window9;
18044
18041
  var isuseiplocarion,
18045
18042
  location,
18046
18043
  _args17 = arguments;
@@ -18049,7 +18046,7 @@ var getLocationPromise = /*#__PURE__*/function () {
18049
18046
  case 0:
18050
18047
  isuseiplocarion = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : false;
18051
18048
  location = null; // 在 SPU 容器里使用 Native-API 的定位
18052
- if (!((_window = window) !== null && _window !== void 0 && (_window = _window.Native) !== null && _window !== void 0 && _window.getLocation)) {
18049
+ if (!((_window9 = window) !== null && _window9 !== void 0 && (_window9 = _window9.Native) !== null && _window9 !== void 0 && _window9.getLocation)) {
18053
18050
  _context17.next = 6;
18054
18051
  break;
18055
18052
  }
@@ -18067,67 +18064,61 @@ var getLocationPromise = /*#__PURE__*/function () {
18067
18064
  case 9:
18068
18065
  location = _context17.sent;
18069
18066
  case 10:
18067
+ _context17.next = 12;
18068
+ return mapService.init();
18069
+ case 12:
18070
18070
  if (location) {
18071
- _context17.next = 39;
18071
+ _context17.next = 37;
18072
18072
  break;
18073
18073
  }
18074
18074
  if (!(mapService.type === 'amap')) {
18075
- _context17.next = 25;
18076
- break;
18077
- }
18078
- _context17.next = 14;
18079
- return getLocationByAmap();
18080
- case 14:
18081
- location = _context17.sent;
18082
- if (!(!location && isuseiplocarion)) {
18083
- _context17.next = 19;
18075
+ _context17.next = 23;
18084
18076
  break;
18085
18077
  }
18086
- _context17.next = 18;
18087
- return getCityLocationByAmap();
18088
- case 18:
18078
+ _context17.next = 16;
18079
+ return getLocationByAMap();
18080
+ case 16:
18089
18081
  location = _context17.sent;
18090
- case 19:
18091
18082
  if (!(!location && isuseiplocarion)) {
18092
- _context17.next = 23;
18083
+ _context17.next = 21;
18093
18084
  break;
18094
18085
  }
18095
- _context17.next = 22;
18096
- return getIPLocationByIpaas();
18097
- case 22:
18086
+ _context17.next = 20;
18087
+ return getCityLocationByAMap();
18088
+ case 20:
18098
18089
  location = _context17.sent;
18099
- case 23:
18100
- _context17.next = 39;
18090
+ case 21:
18091
+ _context17.next = 37;
18101
18092
  break;
18102
- case 25:
18093
+ case 23:
18103
18094
  if (!(mapService.type === 'tencent' && isuseiplocarion)) {
18104
- _context17.next = 31;
18095
+ _context17.next = 29;
18105
18096
  break;
18106
18097
  }
18107
- _context17.next = 28;
18098
+ _context17.next = 26;
18108
18099
  return getIPLocationByTMap();
18109
- case 28:
18100
+ case 26:
18110
18101
  location = _context17.sent;
18111
- _context17.next = 39;
18102
+ _context17.next = 37;
18112
18103
  break;
18113
- case 31:
18104
+ case 29:
18114
18105
  if (!(mapService.type === 'baidu')) {
18115
- _context17.next = 39;
18106
+ _context17.next = 37;
18116
18107
  break;
18117
18108
  }
18118
- _context17.next = 34;
18109
+ _context17.next = 32;
18119
18110
  return getLocationByBMap();
18120
- case 34:
18111
+ case 32:
18121
18112
  location = _context17.sent;
18122
18113
  if (!(!location && isuseiplocarion)) {
18123
- _context17.next = 39;
18114
+ _context17.next = 37;
18124
18115
  break;
18125
18116
  }
18126
- _context17.next = 38;
18117
+ _context17.next = 36;
18127
18118
  return getCityLocationByBMap();
18128
- case 38:
18119
+ case 36:
18129
18120
  location = _context17.sent;
18130
- case 39:
18121
+ case 37:
18131
18122
  // 开发模式下为了方便测试提供虚拟定位
18132
18123
  if (!location && urlquery.isvirtuallocation) {
18133
18124
  location = {
@@ -18135,24 +18126,37 @@ var getLocationPromise = /*#__PURE__*/function () {
18135
18126
  latitude: '39.908671'
18136
18127
  };
18137
18128
  }
18129
+ // if (location) {
18130
+ // for (let i = 0, len = 5000; i < len; i++) {
18131
+ // // location.latitude = (Number(location.latitude) + 0.02).toString()
18132
+ // location.longitude = (Number(location.longitude) + 0.002).toString()
18133
+ // await getAddress(location)
18134
+ // .then((res: any) => {
18135
+ // console.log(res)
18136
+ // }).catch((err: any) => {
18137
+ // console.error(err)
18138
+ // })
18139
+ // await delay(300)
18140
+ // }
18141
+ // }
18138
18142
  if (!(location && !location.address)) {
18139
- _context17.next = 47;
18143
+ _context17.next = 45;
18140
18144
  break;
18141
18145
  }
18142
- _context17.next = 43;
18146
+ _context17.next = 41;
18143
18147
  return getAddress(location);
18144
- case 43:
18148
+ case 41:
18145
18149
  _context17.t0 = _context17.sent;
18146
18150
  if (_context17.t0) {
18147
- _context17.next = 46;
18151
+ _context17.next = 44;
18148
18152
  break;
18149
18153
  }
18150
18154
  _context17.t0 = '经纬度获取成功,但地址获取失败。';
18151
- case 46:
18155
+ case 44:
18152
18156
  location.address = _context17.t0;
18153
- case 47:
18157
+ case 45:
18154
18158
  return _context17.abrupt("return", location);
18155
- case 48:
18159
+ case 46:
18156
18160
  case "end":
18157
18161
  return _context17.stop();
18158
18162
  }
@@ -18177,27 +18181,24 @@ function _getLocation() {
18177
18181
  while (1) switch (_context20.prev = _context20.next) {
18178
18182
  case 0:
18179
18183
  isuseiplocarion = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : false;
18180
- _context20.next = 3;
18181
- return mapService.init();
18182
- case 3:
18183
18184
  if (!(datetime && Date.now() - datetime <= cachetime && lastLocation && !runing)) {
18184
- _context20.next = 5;
18185
+ _context20.next = 3;
18185
18186
  break;
18186
18187
  }
18187
18188
  return _context20.abrupt("return", cloneDeep$1(lastLocation));
18188
- case 5:
18189
+ case 3:
18189
18190
  if (!(runing && locationPromise)) {
18190
- _context20.next = 7;
18191
+ _context20.next = 5;
18191
18192
  break;
18192
18193
  }
18193
18194
  return _context20.abrupt("return", locationPromise);
18194
- case 7:
18195
+ case 5:
18195
18196
  // console.log('runing')
18196
18197
  runing = true;
18197
18198
  locationPromise = getLocationPromise(isuseiplocarion);
18198
- _context20.next = 11;
18199
+ _context20.next = 9;
18199
18200
  return locationPromise;
18200
- case 11:
18201
+ case 9:
18201
18202
  locationRes = _context20.sent;
18202
18203
  runing = false;
18203
18204
  if (locationRes) {
@@ -18205,7 +18206,7 @@ function _getLocation() {
18205
18206
  lastLocation = locationRes;
18206
18207
  }
18207
18208
  return _context20.abrupt("return", locationRes);
18208
- case 15:
18209
+ case 13:
18209
18210
  case "end":
18210
18211
  return _context20.stop();
18211
18212
  }
@@ -18224,51 +18225,42 @@ var getAddress = /*#__PURE__*/function () {
18224
18225
  case 2:
18225
18226
  address = '';
18226
18227
  if (address) {
18227
- _context18.next = 24;
18228
+ _context18.next = 20;
18228
18229
  break;
18229
18230
  }
18230
18231
  if (!(mapService.type === 'amap')) {
18231
- _context18.next = 14;
18232
+ _context18.next = 10;
18232
18233
  break;
18233
18234
  }
18234
18235
  _context18.next = 7;
18235
- return getAddressByAmap(position);
18236
+ return getAddressByAMap(position);
18236
18237
  case 7:
18237
18238
  address = _context18.sent;
18238
- if (address) {
18239
- _context18.next = 12;
18240
- break;
18241
- }
18242
- _context18.next = 11;
18243
- return getAddressByIpaas(position);
18244
- case 11:
18245
- address = _context18.sent;
18246
- case 12:
18247
- _context18.next = 24;
18239
+ _context18.next = 20;
18248
18240
  break;
18249
- case 14:
18241
+ case 10:
18250
18242
  if (!(mapService.type === 'tencent')) {
18251
- _context18.next = 20;
18243
+ _context18.next = 16;
18252
18244
  break;
18253
18245
  }
18254
- _context18.next = 17;
18246
+ _context18.next = 13;
18255
18247
  return getAddressByTMap(position);
18256
- case 17:
18248
+ case 13:
18257
18249
  address = _context18.sent;
18258
- _context18.next = 24;
18250
+ _context18.next = 20;
18259
18251
  break;
18260
- case 20:
18252
+ case 16:
18261
18253
  if (!(mapService.type === 'baidu')) {
18262
- _context18.next = 24;
18254
+ _context18.next = 20;
18263
18255
  break;
18264
18256
  }
18265
- _context18.next = 23;
18257
+ _context18.next = 19;
18266
18258
  return getAddressByBmap(position);
18267
- case 23:
18259
+ case 19:
18268
18260
  address = _context18.sent;
18269
- case 24:
18261
+ case 20:
18270
18262
  return _context18.abrupt("return", address);
18271
- case 25:
18263
+ case 21:
18272
18264
  case "end":
18273
18265
  return _context18.stop();
18274
18266
  }
@@ -70051,4 +70043,4 @@ var SPUWebPlugin = {
70051
70043
  version: version
70052
70044
  };
70053
70045
 
70054
- export { AMapLoader, Module, normalAxios$1 as apaasAxios, normalAxios$1 as axios, checkLogin, index as components, SPUWebPlugin as default, downloadService, expandexp, functionCheck, getDistance, getLocation, getRefreshToken, getToken, getTokenExpires, getUniqueid, getUser, v4 as getUuid, globalConfig, globalOptions, isInApp, isdebugger, isvirtuallocation, lsProxy, mapService, setTitle, singleLogin, spuAxios, spuConfig, ssProxy, updateToken, uploadService, wxworkSuite };
70046
+ export { AMapLoader, Module, normalAxios$1 as apaasAxios, normalAxios$1 as axios, checkLogin, index as components, SPUWebPlugin as default, downloadService, expandexp, functionCheck, getAddress, getDistance, getLocation, getRefreshToken, getToken, getTokenExpires, getUniqueid, getUser, v4 as getUuid, globalConfig, globalOptions, isInApp, isdebugger, isvirtuallocation, lsProxy, mapService, setTitle, singleLogin, spuAxios, spuConfig, ssProxy, updateToken, uploadService, wxworkSuite };