@smart100/spu-web-plugin 1.0.11 → 1.0.13

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.11";
1
+ var version = "1.0.13";
2
2
 
3
3
  /** Detect free variable `global` from Node.js. */
4
4
  var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
@@ -16142,34 +16142,53 @@ var TenantSetting = /*#__PURE__*/function () {
16142
16142
  }, {
16143
16143
  key: "get",
16144
16144
  value: function get(key) {
16145
+ // const tenantsetting = {
16146
+ // lbssetting: {
16147
+ // enable: '1',
16148
+ // setting: {
16149
+ // type: '',
16150
+ // key: {
16151
+ // web: '',
16152
+ // android: '',
16153
+ // ios: '',
16154
+ // harmony: ''
16155
+ // },
16156
+ // secretkey: {
16157
+ // web: '',
16158
+ // android: '',
16159
+ // ios: '',
16160
+ // harmony: ''
16161
+ // }
16162
+ // }
16163
+ // }
16164
+ // }
16165
+ // // 高德地图key配置错误
16166
+ // // 1 如果是key格式不对 那么没返回promise 连window.AMap都拿不到 地图和都不能用
16167
+ // // 1 如果是key对式对 但key不对 有返回 window.AMap 但api定位调用失败 地图可以渲染空白地图
16168
+ // // // 高德地图公司key
16169
+ // // tenantsetting.lbssetting.setting.type = 'amap'
16170
+ // // tenantsetting.lbssetting.setting.key.web = '1993ac213d2f4675ac1bffb1b03ef1f0'
16171
+ // // tenantsetting.lbssetting.setting.secretkey.web = '816fe46b7b7bce145940b93c1e4818fa'
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
+ // lsProxy.setItem('tenantsetting', JSON.stringify(tenantsetting))
16145
16189
  var tenantsettingStr = lsProxy.getItem('tenantsetting');
16146
16190
  if (tenantsettingStr) {
16147
16191
  var tenantsetting = JSON.parse(tenantsettingStr);
16148
- // tenantsetting.lbssetting = {
16149
- // enable: '1',
16150
- // setting: {
16151
- // type: '',
16152
- // key: {
16153
- // web: '',
16154
- // android: '',
16155
- // ios: '',
16156
- // harmony: ''
16157
- // },
16158
- // secretkey: {
16159
- // web: '',
16160
- // android: '',
16161
- // ios: '',
16162
- // harmony: ''
16163
- // }
16164
- // }
16165
- // }
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
- // tenantsetting.lbssetting.setting.type = 'baidu'
16172
- // tenantsetting.lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
16173
16192
  if (key) {
16174
16193
  return tenantsetting[key];
16175
16194
  }
@@ -17256,42 +17275,66 @@ var MapService = /*#__PURE__*/function () {
17256
17275
  }, {
17257
17276
  key: "initAmap",
17258
17277
  value: function () {
17259
- var _initAmap = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4() {
17260
- var plugin, AMap;
17261
- return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
17262
- while (1) switch (_context4.prev = _context4.next) {
17278
+ var _initAmap = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5() {
17279
+ var _this = this;
17280
+ return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
17281
+ while (1) switch (_context5.prev = _context5.next) {
17263
17282
  case 0:
17264
- // if (this.secretkey) {
17265
- // window._AMapSecurityConfig = {
17266
- // securityJsCode: this.secretkey
17267
- // }
17268
- // }
17269
- plugin = ['AMap.Geolocation']; // plugin.push('AMap.Geocoder') // 不开放地址查询 改用ipaas
17270
- _context4.next = 3;
17271
- return AMapLoader$1.load({
17272
- key: this.key,
17273
- version: '2.0',
17274
- plugins: plugin,
17275
- AMapUI: {
17276
- version: '1.1',
17277
- plugins: []
17278
- }
17279
- });
17280
- case 3:
17281
- AMap = _context4.sent;
17282
- window.AMap = AMap;
17283
- this.AMap = AMap;
17284
- this.MapCore = window.AMap;
17285
- // console.log(window)
17286
- // console.log(window.AMap)
17287
- // console.log(window.AMapUI)
17288
- // console.log(window.AMapLoader)
17289
- // console.log(window.AMap === aaaa)
17290
- case 7:
17283
+ return _context5.abrupt("return", new Promise( /*#__PURE__*/function () {
17284
+ var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(resolve, reject) {
17285
+ var time, plugin, AMap;
17286
+ return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
17287
+ while (1) switch (_context4.prev = _context4.next) {
17288
+ case 0:
17289
+ // 高德地图api初始化失败 没有返回reject 因此用超时机制检测
17290
+ time = setTimeout(function () {
17291
+ console.error('initAmap fail: 请检查 AMap key 是否正确配置');
17292
+ resolve(null);
17293
+ }, 3000);
17294
+ if (_this.secretkey) {
17295
+ window._AMapSecurityConfig = {
17296
+ securityJsCode: _this.secretkey
17297
+ };
17298
+ }
17299
+ plugin = ['AMap.Geolocation', 'AMap.Geocoder']; // debugger
17300
+ _context4.next = 5;
17301
+ return AMapLoader$1.load({
17302
+ key: _this.key,
17303
+ version: '2.0',
17304
+ plugins: plugin,
17305
+ AMapUI: {
17306
+ version: '1.1',
17307
+ plugins: []
17308
+ }
17309
+ });
17310
+ case 5:
17311
+ AMap = _context4.sent;
17312
+ // debugger
17313
+ clearTimeout(time);
17314
+ window.AMap = AMap;
17315
+ _this.AMap = window.AMap;
17316
+ _this.MapCore = window.AMap;
17317
+ // console.log(window)
17318
+ // console.log(window.AMap)
17319
+ // console.log(window.AMapUI)
17320
+ // console.log(window.AMapLoader)
17321
+ // console.log(window.AMap === aaaa)
17322
+ resolve(window.AMap);
17323
+ case 11:
17324
+ case "end":
17325
+ return _context4.stop();
17326
+ }
17327
+ }, _callee4);
17328
+ }));
17329
+ return function (_x, _x2) {
17330
+ return _ref.apply(this, arguments);
17331
+ };
17332
+ }()));
17333
+ case 1:
17291
17334
  case "end":
17292
- return _context4.stop();
17335
+ return _context5.stop();
17293
17336
  }
17294
- }, _callee4, this);
17337
+ }, _callee5);
17295
17338
  }));
17296
17339
  function initAmap() {
17297
17340
  return _initAmap.apply(this, arguments);
@@ -17301,15 +17344,17 @@ var MapService = /*#__PURE__*/function () {
17301
17344
  }, {
17302
17345
  key: "initBaidu",
17303
17346
  value: function () {
17304
- var _initBaidu = _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) {
17347
+ var _initBaidu = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee6() {
17348
+ var _this2 = this;
17349
+ return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
17350
+ while (1) switch (_context6.prev = _context6.next) {
17308
17351
  case 0:
17309
- return _context5.abrupt("return", new Promise(function (resolve, reject) {
17310
- window.BMAP_INITIAL_CALLBACK = function () {
17311
- _this.BMap = window.BMap;
17312
- _this.MapCore = window.BMap;
17352
+ return _context6.abrupt("return", new Promise(function (resolve, reject) {
17353
+ window.BMAP_INITIAL_CALLBACK = function (e) {
17354
+ // console.log(e)
17355
+ // debugger
17356
+ _this2.BMap = window.BMap;
17357
+ _this2.MapCore = window.BMap;
17313
17358
  // debugger
17314
17359
  // 启用google标准坐标体系
17315
17360
  // coordsType 指定输入输出的坐标类型,BMAP_COORD_GCJ02为gcj02坐标,BMAP_COORD_BD09为bd0ll坐标,默认为BMAP_COORD_BD09。
@@ -17318,7 +17363,7 @@ var MapService = /*#__PURE__*/function () {
17318
17363
  };
17319
17364
  var script = document.createElement('script');
17320
17365
  // 使用最新 3.0 api https://lbsyun.baidu.com/index.php?title=jspopular3.0
17321
- script.src = "https://api.map.baidu.com/api?v=3.0&ak=".concat(_this.key, "&callback=BMAP_INITIAL_CALLBACK");
17366
+ script.src = "https://api.map.baidu.com/api?v=3.0&ak=".concat(_this2.key, "&callback=BMAP_INITIAL_CALLBACK");
17322
17367
  // script.src = `https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=${this.key}&callback=BMAP_INITIAL_CALLBACK`
17323
17368
  script.onerror = function (err) {
17324
17369
  reject(err);
@@ -17327,9 +17372,9 @@ var MapService = /*#__PURE__*/function () {
17327
17372
  }));
17328
17373
  case 1:
17329
17374
  case "end":
17330
- return _context5.stop();
17375
+ return _context6.stop();
17331
17376
  }
17332
- }, _callee5);
17377
+ }, _callee6);
17333
17378
  }));
17334
17379
  function initBaidu() {
17335
17380
  return _initBaidu.apply(this, arguments);
@@ -17433,9 +17478,9 @@ var getLocationByNative = /*#__PURE__*/function () {
17433
17478
  }
17434
17479
  }, 30000);
17435
17480
  window.Native.getLocation(function (res, error, status) {
17436
- // console.log('getLocation res', res)
17437
- // console.log('getLocation error', error)
17438
- // console.log('getLocation status', status)
17481
+ // console.log('window.Native.getLocation res', res)
17482
+ // console.log('window.Native.getLocation error', error)
17483
+ // console.log('window.Native.getLocation status', status)
17439
17484
  isload = true;
17440
17485
  if (res && res !== null && res !== void 0 && res.longitude && res !== null && res !== void 0 && res.latitude) {
17441
17486
  var result = {
@@ -17513,139 +17558,24 @@ var getLocationByNavigator = /*#__PURE__*/function () {
17513
17558
  return _ref2.apply(this, arguments);
17514
17559
  };
17515
17560
  }();
17516
- // ipaas ip 定位
17517
- var getIPLocationByIpaas = /*#__PURE__*/function () {
17518
- var _ref3 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3(ip) {
17519
- return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
17520
- while (1) switch (_context3.prev = _context3.next) {
17521
- case 0:
17522
- console.log('getIPLocationByIpaas start...');
17523
- return _context3.abrupt("return", new Promise(function (resolve, reject) {
17524
- var AMapKey = getAMapKey();
17525
- normalAxios$1.post('https://silkroad.wxchina.com/api/openapi/publishEvent?topic=xw-listener&subtopic=xw-listener&apicaseid=6684389338001815271', {
17526
- key: AMapKey.key,
17527
- ip: ip || ''
17528
- }).then(function (res) {
17529
- // console.log(res)
17530
- // debugger
17531
- // res.data.rectangle = '113.1017375,22.93212254;113.6770499,23.3809537'
17532
- if (res.data.rectangle) {
17533
- var rectangle = res.data.rectangle;
17534
- var rects = rectangle.split(';').map(function (rect) {
17535
- var _rect$split = rect.split(','),
17536
- _rect$split2 = _slicedToArray(_rect$split, 2),
17537
- longitude = _rect$split2[0],
17538
- latitude = _rect$split2[1];
17539
- return {
17540
- longitude: Number(longitude),
17541
- latitude: Number(latitude)
17542
- };
17543
- });
17544
- var result = {
17545
- longitude: ((rects[0].longitude + rects[1].longitude) / 2).toString(),
17546
- latitude: ((rects[0].latitude + rects[1].latitude) / 2).toString()
17547
- };
17548
- console.log("getIPLocationByIpaas success: ".concat(JSON.stringify(result)));
17549
- resolve(result);
17550
- } else {
17551
- console.error('getIPLocationByIpaas fail');
17552
- resolve(null);
17553
- }
17554
- })["catch"](function (err) {
17555
- console.error(err);
17556
- console.error('getIPLocationByIpaas fail');
17557
- resolve(null);
17558
- });
17559
- }));
17560
- case 2:
17561
- case "end":
17562
- return _context3.stop();
17563
- }
17564
- }, _callee3);
17565
- }));
17566
- return function getIPLocationByIpaas(_x) {
17567
- return _ref3.apply(this, arguments);
17568
- };
17569
- }();
17570
- // ipaas 逆地址解析
17571
- var getAddressByIpaas = /*#__PURE__*/function () {
17572
- var _ref4 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5(position) {
17573
- return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
17574
- while (1) switch (_context5.prev = _context5.next) {
17575
- case 0:
17576
- console.log('getAddressByIpaas start...');
17577
- // 如果不设置安全秘钥的话 js-api的逆地址查询不成功 返回 INVALID_USER_SCODE 改成用ipaas服务查询
17578
- return _context5.abrupt("return", new Promise( /*#__PURE__*/function () {
17579
- var _ref5 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(resolve, reject) {
17580
- var _result$data, AMapKey, result, address;
17581
- return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
17582
- while (1) switch (_context4.prev = _context4.next) {
17583
- case 0:
17584
- if (!position) {
17585
- _context4.next = 15;
17586
- break;
17587
- }
17588
- _context4.prev = 1;
17589
- AMapKey = getAMapKey();
17590
- _context4.next = 5;
17591
- return normalAxios$1.post('https://silkroad.wxchina.com/api/openapi/publishEvent?topic=xw-listener&subtopic=xw-listener&apicaseid=6684389338001809906', {
17592
- longitude: position.longitude,
17593
- latitude: position.latitude,
17594
- key: AMapKey.key
17595
- // extensions: 'all'
17596
- });
17597
- case 5:
17598
- result = _context4.sent;
17599
- // console.log(result)
17600
- address = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.formatted_address;
17601
- if (address) {
17602
- console.log("getAddressByIpaas success: ".concat(address));
17603
- resolve(address);
17604
- } else {
17605
- console.error('getAddressByIpaas fail');
17606
- resolve('');
17607
- }
17608
- _context4.next = 15;
17609
- break;
17610
- case 10:
17611
- _context4.prev = 10;
17612
- _context4.t0 = _context4["catch"](1);
17613
- console.error(_context4.t0);
17614
- console.error('getAddressByIpaas fail');
17615
- resolve('');
17616
- case 15:
17617
- case "end":
17618
- return _context4.stop();
17619
- }
17620
- }, _callee4, null, [[1, 10]]);
17621
- }));
17622
- return function (_x3, _x4) {
17623
- return _ref5.apply(this, arguments);
17624
- };
17625
- }()));
17626
- case 2:
17627
- case "end":
17628
- return _context5.stop();
17629
- }
17630
- }, _callee5);
17631
- }));
17632
- return function getAddressByIpaas(_x2) {
17633
- return _ref4.apply(this, arguments);
17634
- };
17635
- }();
17636
17561
  // 高德定位
17637
- var getLocationByAmap = /*#__PURE__*/function () {
17562
+ var getLocationByAMap = /*#__PURE__*/function () {
17638
17563
  var _ref6 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee6() {
17639
17564
  return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
17640
17565
  while (1) switch (_context6.prev = _context6.next) {
17641
17566
  case 0:
17642
- console.log('getLocationByAmap start...');
17567
+ console.log('getLocationByAMap start...');
17643
17568
  return _context6.abrupt("return", new Promise(function (resolve, reject) {
17644
- var geolocation = new window.AMap.Geolocation({
17569
+ var _window;
17570
+ if (!((_window = window) !== null && _window !== void 0 && _window.AMap)) {
17571
+ console.error('getLocationByAMap fail: AMap is undefinded');
17572
+ resolve(null);
17573
+ return;
17574
+ }
17575
+ new window.AMap.Geolocation({
17645
17576
  enableHighAccuracy: true,
17646
17577
  timeout: 15000
17647
- });
17648
- geolocation.getCurrentPosition(function (status, res) {
17578
+ }).getCurrentPosition(function (status, res) {
17649
17579
  // console.log(status, result)
17650
17580
  // debugger
17651
17581
  if (status === 'complete') {
@@ -17656,10 +17586,10 @@ var getLocationByAmap = /*#__PURE__*/function () {
17656
17586
  longitude: lng.toString(),
17657
17587
  latitude: lat.toString()
17658
17588
  };
17659
- console.log("getLocationByAmap success: ".concat(JSON.stringify(result)));
17589
+ console.log("getLocationByAMap success: ".concat(JSON.stringify(result)));
17660
17590
  resolve(result);
17661
17591
  } else {
17662
- console.error('getLocationByAmap fail');
17592
+ console.error('getLocationByAMap fail');
17663
17593
  resolve(null);
17664
17594
  }
17665
17595
  });
@@ -17670,23 +17600,28 @@ var getLocationByAmap = /*#__PURE__*/function () {
17670
17600
  }
17671
17601
  }, _callee6);
17672
17602
  }));
17673
- return function getLocationByAmap() {
17603
+ return function getLocationByAMap() {
17674
17604
  return _ref6.apply(this, arguments);
17675
17605
  };
17676
17606
  }();
17677
17607
  // 高德城市定位
17678
- var getCityLocationByAmap = /*#__PURE__*/function () {
17608
+ var getCityLocationByAMap = /*#__PURE__*/function () {
17679
17609
  var _ref7 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee7() {
17680
17610
  return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
17681
17611
  while (1) switch (_context7.prev = _context7.next) {
17682
17612
  case 0:
17683
- console.log('getCityLocationByAmap start...');
17613
+ console.log('getCityLocationByAMap start...');
17684
17614
  return _context7.abrupt("return", new Promise(function (resolve, reject) {
17685
- var geolocation = new window.AMap.Geolocation({
17615
+ var _window2;
17616
+ if (!((_window2 = window) !== null && _window2 !== void 0 && _window2.AMap)) {
17617
+ console.error('getCityLocationByAMap fail: AMap is undefinded');
17618
+ resolve(null);
17619
+ return;
17620
+ }
17621
+ new window.AMap.Geolocation({
17686
17622
  enableHighAccuracy: true,
17687
17623
  timeout: 15000
17688
- });
17689
- geolocation.getCityInfo(function (status, res) {
17624
+ }).getCityInfo(function (status, res) {
17690
17625
  // console.log(res)
17691
17626
  // debugger
17692
17627
  if (status === 'complete') {
@@ -17696,10 +17631,10 @@ var getCityLocationByAmap = /*#__PURE__*/function () {
17696
17631
  longitude: lng.toString(),
17697
17632
  latitude: lat.toString()
17698
17633
  };
17699
- console.log("getCityLocationByAmap success: ".concat(JSON.stringify(result)));
17634
+ console.log("getCityLocationByAMap success: ".concat(JSON.stringify(result)));
17700
17635
  resolve(result);
17701
17636
  } else {
17702
- console.error('getCityLocationByAmap fail');
17637
+ console.error('getCityLocationByAMap fail');
17703
17638
  resolve(null);
17704
17639
  }
17705
17640
  });
@@ -17710,47 +17645,51 @@ var getCityLocationByAmap = /*#__PURE__*/function () {
17710
17645
  }
17711
17646
  }, _callee7);
17712
17647
  }));
17713
- return function getCityLocationByAmap() {
17648
+ return function getCityLocationByAMap() {
17714
17649
  return _ref7.apply(this, arguments);
17715
17650
  };
17716
17651
  }();
17717
17652
  // 高德逆地址解析
17718
- var getAddressByAmap = /*#__PURE__*/function () {
17653
+ var getAddressByAMap = /*#__PURE__*/function () {
17719
17654
  var _ref8 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee8(position) {
17720
- var address;
17721
17655
  return _regeneratorRuntime$1().wrap(function _callee8$(_context8) {
17722
17656
  while (1) switch (_context8.prev = _context8.next) {
17723
17657
  case 0:
17724
- console.log('getAddressByAmap start...');
17725
- console.log('getAddressByAmap changeto getAddressByIpaas');
17726
- // return new Promise((resolve, reject) => {
17727
- // if (position) {
17728
- // new window.AMap.Geocoder({
17729
- // city: '',
17730
- // radius: 500
17731
- // }).getAddress([position.longitude, position.latitude], (status: string, result: any) => {
17732
- // if (status === 'complete' && result.info === 'OK' && result.regeocode) {
17733
- // resolve(result?.regeocode?.formattedAddress || '')
17734
- // } else {
17735
- // console.error('getAddressByAmap fail')
17736
- // resolve('')
17737
- // }
17738
- // })
17739
- // }
17740
- // })
17741
- // 如果不设置安全秘钥的话 js-api的逆地址查询不成功 返回 INVALID_USER_SCODE 改成用ipaas服务查询
17742
- _context8.next = 4;
17743
- return getAddressByIpaas(position);
17744
- case 4:
17745
- address = _context8.sent;
17746
- return _context8.abrupt("return", address);
17747
- case 6:
17658
+ console.log('getAddressByAMap start...');
17659
+ return _context8.abrupt("return", new Promise(function (resolve, reject) {
17660
+ if (position) {
17661
+ var _window3;
17662
+ if (!((_window3 = window) !== null && _window3 !== void 0 && _window3.AMap)) {
17663
+ console.error('getAddressByAMap fail: AMap is undefinded');
17664
+ resolve('');
17665
+ return;
17666
+ }
17667
+ new window.AMap.Geocoder({
17668
+ city: '',
17669
+ radius: 500
17670
+ }).getAddress([position.longitude, position.latitude], function (status, result) {
17671
+ var _result$regeocode;
17672
+ // console.log(status)
17673
+ // console.log(result)
17674
+ // debugger
17675
+ if (status === 'complete' && result.info === 'OK' && result !== null && result !== void 0 && (_result$regeocode = result.regeocode) !== null && _result$regeocode !== void 0 && _result$regeocode.formattedAddress) {
17676
+ var address = result.regeocode.formattedAddress || '';
17677
+ console.log("getAddressByAMap success: ".concat(address));
17678
+ resolve(address);
17679
+ } else {
17680
+ console.error("getAddressByAMap fail: status = ".concat(status, ", result = ").concat(result));
17681
+ resolve('');
17682
+ }
17683
+ });
17684
+ }
17685
+ }));
17686
+ case 2:
17748
17687
  case "end":
17749
17688
  return _context8.stop();
17750
17689
  }
17751
17690
  }, _callee8);
17752
17691
  }));
17753
- return function getAddressByAmap(_x5) {
17692
+ return function getAddressByAMap(_x5) {
17754
17693
  return _ref8.apply(this, arguments);
17755
17694
  };
17756
17695
  }();
@@ -17762,11 +17701,12 @@ var getIPLocationByTMap = /*#__PURE__*/function () {
17762
17701
  case 0:
17763
17702
  console.log('getIPLocationByTMap start...');
17764
17703
  return _context9.abrupt("return", new Promise(function (resolve, reject) {
17765
- var ipLocation = new window.TMap.service.IPLocation();
17766
17704
  var params = ip ? {
17767
17705
  ip: ip
17768
17706
  } : {};
17769
- ipLocation.locate(params).then(function (res) {
17707
+ new window.TMap.service.IPLocation().locate(_objectSpread2$1(_objectSpread2$1({}, params), {}, {
17708
+ servicesk: mapService.secretkey
17709
+ })).then(function (res) {
17770
17710
  var result = {
17771
17711
  longitude: res.result.location.lng.toString(),
17772
17712
  latitude: res.result.location.lat.toString()
@@ -17798,13 +17738,11 @@ var getAddressByTMap = /*#__PURE__*/function () {
17798
17738
  console.log('getAddressByTMap start...');
17799
17739
  return _context10.abrupt("return", new Promise(function (resolve, reject) {
17800
17740
  if (position) {
17801
- var location = new window.TMap.LatLng(position.latitude, position.longitude);
17802
- // console.log(position)
17803
- // console.log(location)
17804
17741
  // debugger
17805
17742
  new window.TMap.service.Geocoder().getAddress({
17806
- location: location,
17807
- getPoi: false
17743
+ location: new window.TMap.LatLng(position.latitude, position.longitude),
17744
+ getPoi: false,
17745
+ servicesk: mapService.secretkey
17808
17746
  }).then(function (res) {
17809
17747
  var _res$result, _res$result2;
17810
17748
  // console.log(res)
@@ -18014,6 +17952,7 @@ var getAddressByBmap = /*#__PURE__*/function () {
18014
17952
  resolve(address);
18015
17953
  } else {
18016
17954
  console.error('getAddressByBmap fail');
17955
+ // console.error(result)
18017
17956
  resolve('');
18018
17957
  }
18019
17958
  });
@@ -18037,94 +17976,87 @@ var getAddressByBmap = /*#__PURE__*/function () {
18037
17976
  return _ref15.apply(this, arguments);
18038
17977
  };
18039
17978
  }();
18040
- // 定位流程: 缓存 > 判断环境(APP,小程序,企微)基于环境获取定位 > 地图商高精度定位 > 地图商城市ip定位
18041
17979
  var getLocationPromise = /*#__PURE__*/function () {
18042
17980
  var _ref17 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee17() {
18043
- var _window;
18044
- var location;
17981
+ var _window4;
17982
+ var isuseiplocarion,
17983
+ location,
17984
+ _args17 = arguments;
18045
17985
  return _regeneratorRuntime$1().wrap(function _callee17$(_context17) {
18046
17986
  while (1) switch (_context17.prev = _context17.next) {
18047
17987
  case 0:
17988
+ isuseiplocarion = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : false;
18048
17989
  location = null; // 在 SPU 容器里使用 Native-API 的定位
18049
- if (!((_window = window) !== null && _window !== void 0 && (_window = _window.Native) !== null && _window !== void 0 && _window.getLocation)) {
18050
- _context17.next = 5;
17990
+ if (!((_window4 = window) !== null && _window4 !== void 0 && (_window4 = _window4.Native) !== null && _window4 !== void 0 && _window4.getLocation)) {
17991
+ _context17.next = 6;
18051
17992
  break;
18052
17993
  }
18053
- _context17.next = 4;
17994
+ _context17.next = 5;
18054
17995
  return getLocationByNative();
18055
- case 4:
18056
- location = _context17.sent;
18057
17996
  case 5:
17997
+ location = _context17.sent;
17998
+ case 6:
18058
17999
  if (location) {
18059
- _context17.next = 9;
18000
+ _context17.next = 10;
18060
18001
  break;
18061
18002
  }
18062
- _context17.next = 8;
18003
+ _context17.next = 9;
18063
18004
  return getLocationByNavigator();
18064
- case 8:
18065
- location = _context17.sent;
18066
18005
  case 9:
18006
+ location = _context17.sent;
18007
+ case 10:
18067
18008
  if (location) {
18068
- _context17.next = 34;
18009
+ _context17.next = 35;
18069
18010
  break;
18070
18011
  }
18071
18012
  if (!(mapService.type === 'amap')) {
18072
- _context17.next = 20;
18013
+ _context17.next = 21;
18073
18014
  break;
18074
18015
  }
18075
- _context17.next = 13;
18076
- return getLocationByAmap();
18077
- case 13:
18016
+ _context17.next = 14;
18017
+ return getLocationByAMap();
18018
+ case 14:
18078
18019
  location = _context17.sent;
18079
- if (location) {
18080
- _context17.next = 18;
18020
+ if (!(!location && isuseiplocarion)) {
18021
+ _context17.next = 19;
18081
18022
  break;
18082
18023
  }
18083
- _context17.next = 17;
18084
- return getCityLocationByAmap();
18085
- case 17:
18086
- location = _context17.sent;
18024
+ _context17.next = 18;
18025
+ return getCityLocationByAMap();
18087
18026
  case 18:
18088
- _context17.next = 34;
18027
+ location = _context17.sent;
18028
+ case 19:
18029
+ _context17.next = 35;
18089
18030
  break;
18090
- case 20:
18091
- if (!(mapService.type === 'tencent')) {
18092
- _context17.next = 26;
18031
+ case 21:
18032
+ if (!(mapService.type === 'tencent' && isuseiplocarion)) {
18033
+ _context17.next = 27;
18093
18034
  break;
18094
18035
  }
18095
- _context17.next = 23;
18036
+ _context17.next = 24;
18096
18037
  return getIPLocationByTMap();
18097
- case 23:
18038
+ case 24:
18098
18039
  location = _context17.sent;
18099
- _context17.next = 34;
18040
+ _context17.next = 35;
18100
18041
  break;
18101
- case 26:
18042
+ case 27:
18102
18043
  if (!(mapService.type === 'baidu')) {
18103
- _context17.next = 34;
18044
+ _context17.next = 35;
18104
18045
  break;
18105
18046
  }
18106
- _context17.next = 29;
18047
+ _context17.next = 30;
18107
18048
  return getLocationByBMap();
18108
- case 29:
18049
+ case 30:
18109
18050
  location = _context17.sent;
18110
- if (location) {
18111
- _context17.next = 34;
18051
+ if (!(!location && isuseiplocarion)) {
18052
+ _context17.next = 35;
18112
18053
  break;
18113
18054
  }
18114
- _context17.next = 33;
18055
+ _context17.next = 34;
18115
18056
  return getCityLocationByBMap();
18116
- case 33:
18117
- location = _context17.sent;
18118
18057
  case 34:
18119
- if (location) {
18120
- _context17.next = 38;
18121
- break;
18122
- }
18123
- _context17.next = 37;
18124
- return getIPLocationByIpaas();
18125
- case 37:
18126
18058
  location = _context17.sent;
18127
- case 38:
18059
+ case 35:
18128
18060
  // 开发模式下为了方便测试提供虚拟定位
18129
18061
  if (!location && urlquery.isvirtuallocation) {
18130
18062
  location = {
@@ -18132,24 +18064,37 @@ var getLocationPromise = /*#__PURE__*/function () {
18132
18064
  latitude: '39.908671'
18133
18065
  };
18134
18066
  }
18067
+ // if (location) {
18068
+ // for (let i = 0, len = 5000; i < len; i++) {
18069
+ // // location.latitude = (Number(location.latitude) + 0.02).toString()
18070
+ // location.longitude = (Number(location.longitude) + 0.002).toString()
18071
+ // await getAddress(location)
18072
+ // .then((res: any) => {
18073
+ // console.log(res)
18074
+ // }).catch((err: any) => {
18075
+ // console.error(err)
18076
+ // })
18077
+ // await delay(300)
18078
+ // }
18079
+ // }
18135
18080
  if (!(location && !location.address)) {
18136
- _context17.next = 46;
18081
+ _context17.next = 43;
18137
18082
  break;
18138
18083
  }
18139
- _context17.next = 42;
18084
+ _context17.next = 39;
18140
18085
  return getAddress(location);
18141
- case 42:
18086
+ case 39:
18142
18087
  _context17.t0 = _context17.sent;
18143
18088
  if (_context17.t0) {
18144
- _context17.next = 45;
18089
+ _context17.next = 42;
18145
18090
  break;
18146
18091
  }
18147
18092
  _context17.t0 = '经纬度获取成功,但地址获取失败。';
18148
- case 45:
18093
+ case 42:
18149
18094
  location.address = _context17.t0;
18150
- case 46:
18095
+ case 43:
18151
18096
  return _context17.abrupt("return", location);
18152
- case 47:
18097
+ case 44:
18153
18098
  case "end":
18154
18099
  return _context17.stop();
18155
18100
  }
@@ -18161,36 +18106,40 @@ var getLocationPromise = /*#__PURE__*/function () {
18161
18106
  }();
18162
18107
  // WGS84 GCJ-02 BD-09 坐标系
18163
18108
  // https://www.jianshu.com/p/559029832a67
18109
+ // 不能精确定位的情况下是否启用ip城市定位,ip定位用于不需要精确定位的场景
18164
18110
  function getLocation() {
18165
18111
  return _getLocation.apply(this, arguments);
18166
18112
  } // 逆地址解析
18167
18113
  function _getLocation() {
18168
18114
  _getLocation = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee20() {
18169
- var locationRes;
18115
+ var isuseiplocarion,
18116
+ locationRes,
18117
+ _args20 = arguments;
18170
18118
  return _regeneratorRuntime$1().wrap(function _callee20$(_context20) {
18171
18119
  while (1) switch (_context20.prev = _context20.next) {
18172
18120
  case 0:
18173
- _context20.next = 2;
18121
+ isuseiplocarion = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : false;
18122
+ _context20.next = 3;
18174
18123
  return mapService.init();
18175
- case 2:
18124
+ case 3:
18176
18125
  if (!(datetime && Date.now() - datetime <= cachetime && lastLocation && !runing)) {
18177
- _context20.next = 4;
18126
+ _context20.next = 5;
18178
18127
  break;
18179
18128
  }
18180
18129
  return _context20.abrupt("return", cloneDeep$1(lastLocation));
18181
- case 4:
18130
+ case 5:
18182
18131
  if (!(runing && locationPromise)) {
18183
- _context20.next = 6;
18132
+ _context20.next = 7;
18184
18133
  break;
18185
18134
  }
18186
18135
  return _context20.abrupt("return", locationPromise);
18187
- case 6:
18136
+ case 7:
18188
18137
  // console.log('runing')
18189
18138
  runing = true;
18190
- locationPromise = getLocationPromise();
18191
- _context20.next = 10;
18139
+ locationPromise = getLocationPromise(isuseiplocarion);
18140
+ _context20.next = 11;
18192
18141
  return locationPromise;
18193
- case 10:
18142
+ case 11:
18194
18143
  locationRes = _context20.sent;
18195
18144
  runing = false;
18196
18145
  if (locationRes) {
@@ -18198,7 +18147,7 @@ function _getLocation() {
18198
18147
  lastLocation = locationRes;
18199
18148
  }
18200
18149
  return _context20.abrupt("return", locationRes);
18201
- case 14:
18150
+ case 15:
18202
18151
  case "end":
18203
18152
  return _context20.stop();
18204
18153
  }
@@ -18215,49 +18164,44 @@ var getAddress = /*#__PURE__*/function () {
18215
18164
  _context18.next = 2;
18216
18165
  return mapService.init();
18217
18166
  case 2:
18218
- address = ''; // 先统一用ipaas解析 因为需要储存一致的地址格式(各地图商逆地址查询的地址格式不统一)
18219
- // 如果不行再按照各地图商解析
18220
- _context18.next = 5;
18221
- return getAddressByIpaas(position);
18222
- case 5:
18223
- address = _context18.sent;
18167
+ address = '';
18224
18168
  if (address) {
18225
- _context18.next = 23;
18169
+ _context18.next = 20;
18226
18170
  break;
18227
18171
  }
18228
18172
  if (!(mapService.type === 'amap')) {
18229
- _context18.next = 13;
18173
+ _context18.next = 10;
18230
18174
  break;
18231
18175
  }
18232
- _context18.next = 10;
18233
- return getAddressByAmap(position);
18234
- case 10:
18176
+ _context18.next = 7;
18177
+ return getAddressByAMap(position);
18178
+ case 7:
18235
18179
  address = _context18.sent;
18236
- _context18.next = 23;
18180
+ _context18.next = 20;
18237
18181
  break;
18238
- case 13:
18182
+ case 10:
18239
18183
  if (!(mapService.type === 'tencent')) {
18240
- _context18.next = 19;
18184
+ _context18.next = 16;
18241
18185
  break;
18242
18186
  }
18243
- _context18.next = 16;
18187
+ _context18.next = 13;
18244
18188
  return getAddressByTMap(position);
18245
- case 16:
18189
+ case 13:
18246
18190
  address = _context18.sent;
18247
- _context18.next = 23;
18191
+ _context18.next = 20;
18248
18192
  break;
18249
- case 19:
18193
+ case 16:
18250
18194
  if (!(mapService.type === 'baidu')) {
18251
- _context18.next = 23;
18195
+ _context18.next = 20;
18252
18196
  break;
18253
18197
  }
18254
- _context18.next = 22;
18198
+ _context18.next = 19;
18255
18199
  return getAddressByBmap(position);
18256
- case 22:
18200
+ case 19:
18257
18201
  address = _context18.sent;
18258
- case 23:
18202
+ case 20:
18259
18203
  return _context18.abrupt("return", address);
18260
- case 24:
18204
+ case 21:
18261
18205
  case "end":
18262
18206
  return _context18.stop();
18263
18207
  }
@@ -52888,9 +52832,7 @@ var load = function load(options) {
52888
52832
  };
52889
52833
  }
52890
52834
  }
52891
- // 不开放地址查询 改用ipaas
52892
- var plugin = ['AMap.Geolocation'];
52893
- // plugin.push('AMap.Geocoder') // 不开放地址查询 改用ipaas
52835
+ var plugin = ['AMap.Geolocation', 'AMap.Geocoder'];
52894
52836
  return AMapLoader$1.load({
52895
52837
  key: AMapKey.key,
52896
52838
  version: '2.0',
@@ -70042,4 +69984,4 @@ var SPUWebPlugin = {
70042
69984
  version: version
70043
69985
  };
70044
69986
 
70045
- 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 };
69987
+ 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 };