@smart100/spu-web-plugin 1.0.14 → 1.0.15

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.14";
1
+ var version = "1.0.15";
2
2
 
3
3
  /** Detect free variable `global` from Node.js. */
4
4
  var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
@@ -18064,61 +18064,58 @@ var getLocationPromise = /*#__PURE__*/function () {
18064
18064
  case 9:
18065
18065
  location = _context17.sent;
18066
18066
  case 10:
18067
- _context17.next = 12;
18068
- return mapService.init();
18069
- case 12:
18070
18067
  if (location) {
18071
- _context17.next = 37;
18068
+ _context17.next = 35;
18072
18069
  break;
18073
18070
  }
18074
18071
  if (!(mapService.type === 'amap')) {
18075
- _context17.next = 23;
18072
+ _context17.next = 21;
18076
18073
  break;
18077
18074
  }
18078
- _context17.next = 16;
18075
+ _context17.next = 14;
18079
18076
  return getLocationByAMap();
18080
- case 16:
18077
+ case 14:
18081
18078
  location = _context17.sent;
18082
18079
  if (!(!location && isuseiplocarion)) {
18083
- _context17.next = 21;
18080
+ _context17.next = 19;
18084
18081
  break;
18085
18082
  }
18086
- _context17.next = 20;
18083
+ _context17.next = 18;
18087
18084
  return getCityLocationByAMap();
18088
- case 20:
18085
+ case 18:
18089
18086
  location = _context17.sent;
18090
- case 21:
18091
- _context17.next = 37;
18087
+ case 19:
18088
+ _context17.next = 35;
18092
18089
  break;
18093
- case 23:
18090
+ case 21:
18094
18091
  if (!(mapService.type === 'tencent' && isuseiplocarion)) {
18095
- _context17.next = 29;
18092
+ _context17.next = 27;
18096
18093
  break;
18097
18094
  }
18098
- _context17.next = 26;
18095
+ _context17.next = 24;
18099
18096
  return getIPLocationByTMap();
18100
- case 26:
18097
+ case 24:
18101
18098
  location = _context17.sent;
18102
- _context17.next = 37;
18099
+ _context17.next = 35;
18103
18100
  break;
18104
- case 29:
18101
+ case 27:
18105
18102
  if (!(mapService.type === 'baidu')) {
18106
- _context17.next = 37;
18103
+ _context17.next = 35;
18107
18104
  break;
18108
18105
  }
18109
- _context17.next = 32;
18106
+ _context17.next = 30;
18110
18107
  return getLocationByBMap();
18111
- case 32:
18108
+ case 30:
18112
18109
  location = _context17.sent;
18113
18110
  if (!(!location && isuseiplocarion)) {
18114
- _context17.next = 37;
18111
+ _context17.next = 35;
18115
18112
  break;
18116
18113
  }
18117
- _context17.next = 36;
18114
+ _context17.next = 34;
18118
18115
  return getCityLocationByBMap();
18119
- case 36:
18116
+ case 34:
18120
18117
  location = _context17.sent;
18121
- case 37:
18118
+ case 35:
18122
18119
  // 开发模式下为了方便测试提供虚拟定位
18123
18120
  if (!location && urlquery.isvirtuallocation) {
18124
18121
  location = {
@@ -18140,23 +18137,23 @@ var getLocationPromise = /*#__PURE__*/function () {
18140
18137
  // }
18141
18138
  // }
18142
18139
  if (!(location && !location.address)) {
18143
- _context17.next = 45;
18140
+ _context17.next = 43;
18144
18141
  break;
18145
18142
  }
18146
- _context17.next = 41;
18143
+ _context17.next = 39;
18147
18144
  return getAddress(location);
18148
- case 41:
18145
+ case 39:
18149
18146
  _context17.t0 = _context17.sent;
18150
18147
  if (_context17.t0) {
18151
- _context17.next = 44;
18148
+ _context17.next = 42;
18152
18149
  break;
18153
18150
  }
18154
18151
  _context17.t0 = '经纬度获取成功,但地址获取失败。';
18155
- case 44:
18152
+ case 42:
18156
18153
  location.address = _context17.t0;
18157
- case 45:
18154
+ case 43:
18158
18155
  return _context17.abrupt("return", location);
18159
- case 46:
18156
+ case 44:
18160
18157
  case "end":
18161
18158
  return _context17.stop();
18162
18159
  }
@@ -18181,24 +18178,27 @@ function _getLocation() {
18181
18178
  while (1) switch (_context20.prev = _context20.next) {
18182
18179
  case 0:
18183
18180
  isuseiplocarion = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : false;
18181
+ _context20.next = 3;
18182
+ return mapService.init();
18183
+ case 3:
18184
18184
  if (!(datetime && Date.now() - datetime <= cachetime && lastLocation && !runing)) {
18185
- _context20.next = 3;
18185
+ _context20.next = 5;
18186
18186
  break;
18187
18187
  }
18188
18188
  return _context20.abrupt("return", cloneDeep$1(lastLocation));
18189
- case 3:
18189
+ case 5:
18190
18190
  if (!(runing && locationPromise)) {
18191
- _context20.next = 5;
18191
+ _context20.next = 7;
18192
18192
  break;
18193
18193
  }
18194
18194
  return _context20.abrupt("return", locationPromise);
18195
- case 5:
18195
+ case 7:
18196
18196
  // console.log('runing')
18197
18197
  runing = true;
18198
18198
  locationPromise = getLocationPromise(isuseiplocarion);
18199
- _context20.next = 9;
18199
+ _context20.next = 11;
18200
18200
  return locationPromise;
18201
- case 9:
18201
+ case 11:
18202
18202
  locationRes = _context20.sent;
18203
18203
  runing = false;
18204
18204
  if (locationRes) {
@@ -18206,7 +18206,7 @@ function _getLocation() {
18206
18206
  lastLocation = locationRes;
18207
18207
  }
18208
18208
  return _context20.abrupt("return", locationRes);
18209
- case 13:
18209
+ case 15:
18210
18210
  case "end":
18211
18211
  return _context20.stop();
18212
18212
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart100/spu-web-plugin",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "npm run build:types && rollup -c -w",
package/src/map/index.ts CHANGED
@@ -489,8 +489,6 @@ const getLocationPromise = async (isuseiplocarion = false): Promise<Location> =>
489
489
  }
490
490
  // location = null
491
491
 
492
- await mapService.init()
493
-
494
492
  if (!location) {
495
493
  if (mapService.type === 'amap') {
496
494
  location = await getLocationByAMap()
@@ -544,6 +542,7 @@ const getLocationPromise = async (isuseiplocarion = false): Promise<Location> =>
544
542
  // https://www.jianshu.com/p/559029832a67
545
543
  // 不能精确定位的情况下是否启用ip城市定位,ip定位用于不需要精确定位的场景
546
544
  async function getLocation(isuseiplocarion = false) {
545
+ await mapService.init()
547
546
  // debugger
548
547
  // 缓存30秒
549
548
  if (datetime && Date.now() - datetime <= cachetime && lastLocation && !runing) {