@smart100/spu-web-plugin 1.0.23 → 1.0.25-beta.1

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.23";
1
+ var version = "1.0.25-beta.1";
2
2
 
3
3
  /** Detect free variable `global` from Node.js. */
4
4
  var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
@@ -16589,12 +16589,16 @@ function startRefreshtoken() {
16589
16589
  console.warn('当前登录为产品运营中心用户,不支持自动刷新token。');
16590
16590
  return false;
16591
16591
  }
16592
+ if (!loginState.islogin) {
16593
+ console.warn('当前未登录/token过期,不支持自动刷新token。');
16594
+ return false;
16595
+ }
16592
16596
  // stopRefreshtoken()
16593
16597
  clearTimeout(refreshtokenTimer);
16594
16598
  refreshtokenTimer = null;
16595
- // 如果有登录 但 refreshtoken 不是完整 token 则10秒后【需要等单点登录走完后才刷新不然会被覆盖】刷新一次取到完整 token
16596
- // 如果有登录 且 refreshtoken 是完整 token 如果剩余时间大于10分钟 则每隔10分钟刷一次 否则过期前15秒更新 token
16597
- // 如果没登录 每隔10秒走token更新逻辑(如果刚开始没登录 后面才登录【不需要再在登陆后写刷新token逻辑】)
16599
+ // 如果有登录
16600
+ // 1、refreshtoken 不是完整 token 10秒后【需要等单点登录走完后才刷新不然会被覆盖】刷新一次取到完整 token
16601
+ // 2、refreshtoken 是完整 token 如果剩余时间大于10分钟 则每隔10分钟刷一次 否则过期前15秒更新 token
16598
16602
  var time = 0;
16599
16603
  if (loginState.islogin) {
16600
16604
  var user = getUserByToken(getRefreshToken());
@@ -16609,13 +16613,6 @@ function startRefreshtoken() {
16609
16613
  } else {
16610
16614
  time = 10000;
16611
16615
  }
16612
- } else {
16613
- if (loginState.type === 2) {
16614
- time = 0;
16615
- } else {
16616
- // console.error('未登录,10秒后尝试更新token')
16617
- time = 30000;
16618
- }
16619
16616
  }
16620
16617
  // time = 5000
16621
16618
  refreshtokenTimer = window.setTimeout( /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
@@ -16854,7 +16851,11 @@ function _singleLogin() {
16854
16851
  envname ? setQueryEnvname(envname) : removeQueryEnvname();
16855
16852
  // context 上下文字段 产品运营中心安装 卸载 配置 和 产品配置中心业务配置 页面需要用到
16856
16853
  // web 端有传 app没传 需要做兼容
16857
- context && lsProxy.setItem('context', decodeURIComponent(context));
16854
+ if (context) {
16855
+ lsProxy.setItem('context', decodeURIComponent(context));
16856
+ } else {
16857
+ lsProxy.removeItem('context');
16858
+ }
16858
16859
  };
16859
16860
  query = cloneDeep$1(query);
16860
16861
  if (!globalOptions.isfixapptokenexpired) {
@@ -16873,7 +16874,7 @@ function _singleLogin() {
16873
16874
  envname = query.envname;
16874
16875
  context = query.context;
16875
16876
  if (!checkLoginByToken(token)) {
16876
- _context8.next = 64;
16877
+ _context8.next = 65;
16877
16878
  break;
16878
16879
  }
16879
16880
  isneedlogin = true; // 是否需要走单点登录流程
@@ -16883,13 +16884,11 @@ function _singleLogin() {
16883
16884
  // 之所以不强制校验 refreshtoken tokenexpires 是因为安装卸载配置页面有可能放在产品运营中心 没有这两字段
16884
16885
  if (checkLogin() && token === getToken()) {
16885
16886
  isneedlogin = false;
16886
- flag = true;
16887
16887
  }
16888
16888
  } else {
16889
16889
  // 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
16890
16890
  if (checkLogin() && token === getToken() && refreshtoken === getRefreshToken() && tokenexpires === getTokenExpires()) {
16891
16891
  isneedlogin = false;
16892
- flag = true;
16893
16892
  }
16894
16893
  }
16895
16894
  // isneedlogin = true
@@ -16900,14 +16899,13 @@ function _singleLogin() {
16900
16899
  }
16901
16900
  setBaseInfo();
16902
16901
  // 单点登录写入 token 之后
16903
- // 1、如果 refreshtoken 不完整 则换取完整的 refreshtoken
16904
16902
  _context8.prev = 18;
16905
16903
  if (!checkLogin()) {
16906
16904
  _context8.next = 25;
16907
16905
  break;
16908
16906
  }
16909
16907
  refreshTokenUser = getUserByToken(getRefreshToken());
16910
- tokenUser = getUserByToken(getToken());
16908
+ tokenUser = getUserByToken(getToken()); // 如果 refreshtoken 不完整【由于web端登录时 如果有选择租户或选择职位的情况 得到的 refreshtoken 是不完整】 则通过完整的 token 换取完整的 refreshtoken 如果不换的话 通过刷新 token 接口得到的 token 也变成不完整的了
16911
16909
  if (!(!(refreshTokenUser !== null && refreshTokenUser !== void 0 && refreshTokenUser.tokenId) && tokenUser !== null && tokenUser !== void 0 && tokenUser.tokenId)) {
16912
16910
  _context8.next = 25;
16913
16911
  break;
@@ -16922,90 +16920,91 @@ function _singleLogin() {
16922
16920
  _context8.t0 = _context8["catch"](18);
16923
16921
  console.error(_context8.t0);
16924
16922
  case 30:
16925
- // 2、重新计算刷新 token 时间 因为刚开始进入就 startRefreshtoken 检测到没有 token 会过10秒才执行刷新 token 操作
16926
- startRefreshtoken();
16927
- // 获取环境信息和租户配置信息
16928
- _context8.next = 33;
16923
+ _context8.next = 32;
16929
16924
  return getEnvname();
16930
- case 33:
16925
+ case 32:
16931
16926
  nowEnvname = _context8.sent;
16932
16927
  if (!nowEnvname) {
16933
- _context8.next = 54;
16928
+ _context8.next = 53;
16934
16929
  break;
16935
16930
  }
16936
- _context8.next = 37;
16931
+ _context8.next = 36;
16937
16932
  return requestEnvdata(nowEnvname);
16938
- case 37:
16933
+ case 36:
16939
16934
  envData = _context8.sent;
16940
16935
  if (!envData) {
16941
- _context8.next = 50;
16936
+ _context8.next = 49;
16942
16937
  break;
16943
16938
  }
16944
16939
  saveEnvdata(envData);
16945
16940
  if (!envData.tenantcode) {
16946
- _context8.next = 46;
16941
+ _context8.next = 45;
16947
16942
  break;
16948
16943
  }
16949
16944
  setTecode(envData.tenantcode);
16950
16945
  // 租户配置
16951
- _context8.next = 44;
16946
+ _context8.next = 43;
16952
16947
  return tenantSetting.requestAndSetTenantSetting(envData.tenantcode);
16953
- case 44:
16954
- _context8.next = 48;
16948
+ case 43:
16949
+ _context8.next = 47;
16955
16950
  break;
16956
- case 46:
16951
+ case 45:
16957
16952
  tenantSetting.removeTenantSetting();
16958
16953
  removeTecode();
16959
- case 48:
16960
- _context8.next = 52;
16954
+ case 47:
16955
+ _context8.next = 51;
16961
16956
  break;
16962
- case 50:
16957
+ case 49:
16963
16958
  removeEnvdata();
16964
16959
  removeTecode();
16965
- case 52:
16966
- _context8.next = 56;
16960
+ case 51:
16961
+ _context8.next = 55;
16967
16962
  break;
16968
- case 54:
16963
+ case 53:
16969
16964
  removeEnvdata();
16970
16965
  removeTecode();
16971
- case 56:
16972
- _context8.next = 58;
16966
+ case 55:
16967
+ _context8.next = 57;
16973
16968
  return getAndSetTenant();
16974
- case 58:
16975
- _context8.next = 60;
16969
+ case 57:
16970
+ _context8.next = 59;
16976
16971
  return getAndSetUserInfo();
16977
- case 60:
16978
- // 单点登录后 获取 web 开发者模式 如果是则设置 isdebugger
16979
- urlquery.dealWebDebugger();
16972
+ case 59:
16980
16973
  flag = true;
16974
+ _context8.next = 63;
16975
+ break;
16981
16976
  case 62:
16982
- _context8.next = 67;
16977
+ flag = true;
16978
+ case 63:
16979
+ _context8.next = 68;
16983
16980
  break;
16984
- case 64:
16981
+ case 65:
16985
16982
  flag = false;
16986
16983
  setBaseInfo(); // 传递的token过期依然写入 如果不写入的话 有可能之前的token本来没过期 页面依然可用
16987
16984
  console.error('单点登录失败,请检查链接所传 token/refreshtoken/tokenexpires 是否非法或过期。');
16988
- case 67:
16985
+ case 68:
16989
16986
  if (!flag) {
16990
- _context8.next = 70;
16987
+ _context8.next = 77;
16991
16988
  break;
16992
16989
  }
16993
- _context8.next = 70;
16990
+ // 启动刷新token机制
16991
+ startRefreshtoken();
16992
+ // 获取spu 信息
16993
+ _context8.next = 72;
16994
16994
  return core$1.initGetData();
16995
- case 70:
16996
- if (flag) {
16997
- // 单点登录成功 需要删除 query 中相关参数
16998
- token && delete query.token;
16999
- refreshtoken && delete query.refreshtoken;
17000
- tokenexpires && delete query.tokenexpires;
17001
- envname && delete query.envname;
17002
- context && delete query.context;
17003
- }
16995
+ case 72:
16996
+ // 删除 query 中相关参数
16997
+ token && delete query.token;
16998
+ refreshtoken && delete query.refreshtoken;
16999
+ tokenexpires && delete query.tokenexpires;
17000
+ envname && delete query.envname;
17001
+ context && delete query.context;
17002
+ case 77:
17004
17003
  return _context8.abrupt("return", {
17005
17004
  flag: flag,
17006
17005
  query: query
17007
17006
  });
17008
- case 72:
17007
+ case 78:
17009
17008
  case "end":
17010
17009
  return _context8.stop();
17011
17010
  }
@@ -17014,7 +17013,13 @@ function _singleLogin() {
17014
17013
  return _singleLogin.apply(this, arguments);
17015
17014
  }
17016
17015
  function installAuth(options) {
17017
- startRefreshtoken();
17016
+ // 如果链接中没有带token 可能两种情况
17017
+ // 1、已经是单点登陆过了 只是用户刷新页面
17018
+ // 2、没登录过 用户直接访问链接
17019
+ // 以上情况需要判断用户登陆过 才启动刷新token机制
17020
+ if (location.href.indexOf('token=') === -1) {
17021
+ startRefreshtoken();
17022
+ }
17018
17023
  fixAppTokenExpired();
17019
17024
  if (options.router) {
17020
17025
  options.router.beforeEach( /*#__PURE__*/function () {
@@ -17237,21 +17242,14 @@ var Urlquery = /*#__PURE__*/function () {
17237
17242
  }
17238
17243
  return flag;
17239
17244
  }
17240
- // 单点登录后 获取 web 开发者模式 如果是则设置 isdebugger
17241
- }, {
17242
- key: "dealWebDebugger",
17243
- value: function dealWebDebugger() {
17244
- if (!this.isdebugger && !isMobile() && this.getWebDevmodel()) {
17245
- ssProxy.setItem('isdebugger', '1');
17246
- }
17247
- }
17248
17245
  }, {
17249
17246
  key: "init",
17250
17247
  value: function init() {
17251
17248
  if (this.isinit) return false;
17252
17249
  this.isinit = true;
17253
17250
  // 调试
17254
- if (location.href.indexOf('isdebugger=1') >= 0 || ssProxy.getItem('isdebugger') === '1') {
17251
+ // 如果开启了 web 开发者模式 也算
17252
+ if (location.href.indexOf('isdebugger=1') >= 0 || ssProxy.getItem('isdebugger') === '1' || !isMobile() && this.getWebDevmodel()) {
17255
17253
  ssProxy.setItem('isdebugger', '1');
17256
17254
  if (isMobile()) {
17257
17255
  new VConsole({
@@ -17742,6 +17740,22 @@ var BMapTransformBD09ToGCJ02Points = function BMapTransformBD09ToGCJ02Points(poi
17742
17740
  });
17743
17741
  });
17744
17742
  };
17743
+ var getPoiPhoneNumber = function getPoiPhoneNumber(tel) {
17744
+ if (Array.isArray(tel)) {
17745
+ tel = tel.filter(function (item) {
17746
+ return item;
17747
+ }).join(';');
17748
+ }
17749
+ // tel里面:020-84060333;13570071479 需要优先去除手机号,否则用电话
17750
+ if (tel) {
17751
+ var phoneReg = /1[3456789]\d{9}/;
17752
+ var phone = tel.match(phoneReg);
17753
+ if (phone) {
17754
+ return phone[0];
17755
+ }
17756
+ }
17757
+ return tel;
17758
+ };
17745
17759
 
17746
17760
  var cachetime = 30000; // 缓存时间30秒
17747
17761
  var datetime = null;
@@ -17772,7 +17786,22 @@ var getLocationByNative = /*#__PURE__*/function () {
17772
17786
  var result = {
17773
17787
  longitude: res.longitude.toString(),
17774
17788
  latitude: res.latitude.toString(),
17775
- address: res.address || ''
17789
+ address: res.address || '',
17790
+ poiname: res.poiname || '',
17791
+ regionid: res.regionid || '',
17792
+ country: res.country || '',
17793
+ province: res.province || '',
17794
+ city: res.city || '',
17795
+ district: res.district || '',
17796
+ street: res.street || '',
17797
+ number: res.number || '',
17798
+ detailaddr: res.detailaddr || '',
17799
+ poiid: res.poiid || '',
17800
+ poitypename: res.poitypename || '',
17801
+ poitypecode: res.poitypecode || '',
17802
+ phonenumber: res.phonenumber || '',
17803
+ signboard: res.signboard || '',
17804
+ maptype: res.maptype || ''
17776
17805
  };
17777
17806
  console.log("getLocationByNative success: ".concat(JSON.stringify(result)));
17778
17807
  resolve(result);
@@ -17870,10 +17899,53 @@ var getLocationByAMap = /*#__PURE__*/function () {
17870
17899
  lat = _res$position.lat;
17871
17900
  var result = {
17872
17901
  longitude: lng.toString(),
17873
- latitude: lat.toString()
17902
+ latitude: lat.toString(),
17903
+ address: '',
17904
+ poiname: '',
17905
+ regionid: '',
17906
+ country: '',
17907
+ province: '',
17908
+ city: '',
17909
+ district: '',
17910
+ street: '',
17911
+ number: '',
17912
+ detailaddr: '',
17913
+ poiid: '',
17914
+ poitypename: '',
17915
+ poitypecode: '',
17916
+ phonenumber: '',
17917
+ signboard: '',
17918
+ maptype: "amap"
17874
17919
  };
17875
- console.log("getLocationByAMap success: ".concat(JSON.stringify(result)));
17876
- resolve(result);
17920
+ // 通过经纬度获取详细地址信息
17921
+ getAddressDetailByAMap({
17922
+ longitude: lng.toString(),
17923
+ latitude: lat.toString()
17924
+ }).then(function (addrssDetail) {
17925
+ if (addrssDetail) {
17926
+ result.address = addrssDetail.addressDetail.address;
17927
+ result.poiname = addrssDetail.addressDetail.poiname;
17928
+ result.regionid = addrssDetail.addressDetail.regionid;
17929
+ result.country = addrssDetail.addressDetail.country;
17930
+ result.province = addrssDetail.addressDetail.province;
17931
+ result.city = addrssDetail.addressDetail.city;
17932
+ result.district = addrssDetail.addressDetail.district;
17933
+ result.street = addrssDetail.addressDetail.street;
17934
+ result.number = addrssDetail.addressDetail.number;
17935
+ result.detailaddr = addrssDetail.addressDetail.detailaddr;
17936
+ result.poiid = addrssDetail.addressDetail.poiid;
17937
+ result.poitypename = addrssDetail.addressDetail.poitypename;
17938
+ result.poitypecode = addrssDetail.addressDetail.poitypecode;
17939
+ result.phonenumber = addrssDetail.addressDetail.phonenumber;
17940
+ result.signboard = addrssDetail.addressDetail.signboard;
17941
+ }
17942
+ console.log("getLocationByAMap success: ".concat(JSON.stringify(result)));
17943
+ resolve(result);
17944
+ })["catch"](function (err) {
17945
+ console.error(err);
17946
+ console.error('getLocationByAMap fail');
17947
+ resolve(null);
17948
+ });
17877
17949
  } else {
17878
17950
  console.error('getLocationByAMap fail');
17879
17951
  resolve(null);
@@ -17915,10 +17987,54 @@ var getCityLocationByAMap = /*#__PURE__*/function () {
17915
17987
  var lat = res.position[1].toString();
17916
17988
  var result = {
17917
17989
  longitude: lng.toString(),
17918
- latitude: lat.toString()
17990
+ latitude: lat.toString(),
17991
+ address: '',
17992
+ poiname: '',
17993
+ regionid: '',
17994
+ country: '',
17995
+ province: '',
17996
+ city: '',
17997
+ district: '',
17998
+ street: '',
17999
+ number: '',
18000
+ detailaddr: '',
18001
+ poiid: '',
18002
+ poitypename: '',
18003
+ poitypecode: '',
18004
+ phonenumber: '',
18005
+ signboard: '',
18006
+ maptype: "amap"
17919
18007
  };
17920
18008
  console.log("getCityLocationByAMap success: ".concat(JSON.stringify(result)));
17921
- resolve(result);
18009
+ // 通过经纬度获取详细地址信息
18010
+ getAddressDetailByAMap({
18011
+ longitude: lng.toString(),
18012
+ latitude: lat.toString()
18013
+ }).then(function (addrssDetail) {
18014
+ if (addrssDetail) {
18015
+ result.address = addrssDetail.addressDetail.address;
18016
+ result.poiname = addrssDetail.addressDetail.poiname;
18017
+ result.regionid = addrssDetail.addressDetail.regionid;
18018
+ result.country = addrssDetail.addressDetail.country;
18019
+ result.province = addrssDetail.addressDetail.province;
18020
+ result.city = addrssDetail.addressDetail.city;
18021
+ result.district = addrssDetail.addressDetail.district;
18022
+ result.street = addrssDetail.addressDetail.street;
18023
+ result.number = addrssDetail.addressDetail.number;
18024
+ result.detailaddr = addrssDetail.addressDetail.detailaddr;
18025
+ result.poiid = addrssDetail.addressDetail.poiid;
18026
+ result.poitypename = addrssDetail.addressDetail.poitypename;
18027
+ result.poitypecode = addrssDetail.addressDetail.poitypecode;
18028
+ result.phonenumber = addrssDetail.addressDetail.phonenumber;
18029
+ result.signboard = addrssDetail.addressDetail.signboard;
18030
+ }
18031
+ console.log("getLocationByAMap success: ".concat(JSON.stringify(result)));
18032
+ resolve(result);
18033
+ })["catch"](function (err) {
18034
+ console.error(err);
18035
+ console.error('getLocationByAMap fail');
18036
+ resolve(null);
18037
+ });
17922
18038
  } else {
17923
18039
  console.error('getCityLocationByAMap fail');
17924
18040
  resolve(null);
@@ -17979,16 +18095,111 @@ var getAddressByAMap = /*#__PURE__*/function () {
17979
18095
  return _ref8.apply(this, arguments);
17980
18096
  };
17981
18097
  }();
17982
- // 腾讯ip定位:通过终端设备IP地址获取其当前所在地理位置,精确到市级,常用于显示当地城市天气预报、初始化用户城市等非精确定位场景。
17983
- var getIPLocationByTMap = /*#__PURE__*/function () {
17984
- var _ref9 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee9(ip) {
18098
+ // 高德逆地址解析详细数据
18099
+ var getAddressDetailByAMap = /*#__PURE__*/function () {
18100
+ var _ref9 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee9(position) {
17985
18101
  return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
17986
18102
  while (1) switch (_context9.prev = _context9.next) {
17987
18103
  case 0:
17988
- console.log('getIPLocationByTMap start...');
18104
+ console.log('getAddressDetailByAMap start...');
17989
18105
  return _context9.abrupt("return", new Promise(function (resolve, reject) {
17990
18106
  var _window4;
17991
- if (!((_window4 = window) !== null && _window4 !== void 0 && _window4.TMap)) {
18107
+ if (!((_window4 = window) !== null && _window4 !== void 0 && _window4.AMap)) {
18108
+ console.error('getAddressDetailByAMap fail: AMap is undefinded');
18109
+ resolve(null);
18110
+ return;
18111
+ }
18112
+ if (position) {
18113
+ new window.AMap.Geocoder({
18114
+ radius: 500,
18115
+ extensions: 'all'
18116
+ }).getAddress([position.longitude, position.latitude], function (status, result) {
18117
+ // console.log(status)
18118
+ // console.log(result)
18119
+ if (status === 'complete' && result.info === 'OK' && result !== null && result !== void 0 && result.regeocode) {
18120
+ console.log("getAddressByAMap success:", result.regeocode);
18121
+ var addressComponent = result.regeocode.addressComponent || {};
18122
+ // 确保 country 字段被正确获取
18123
+ // 直接从高德地图 API 返回的数据中获取 country 字段
18124
+ var country = addressComponent.country || '';
18125
+ var aois = result.regeocode.aois || [];
18126
+ var pois = result.regeocode.pois || [];
18127
+ if (Array.isArray(addressComponent.city)) {
18128
+ addressComponent.city = addressComponent.city.join(',');
18129
+ }
18130
+ var street = addressComponent.street || (addressComponent.streetNumber && isObject$4(addressComponent.streetNumber) ? addressComponent.streetNumber.street : '');
18131
+ var number = addressComponent.streetNumber && isObject$4(addressComponent.streetNumber) ? addressComponent.streetNumber.number : addressComponent.streetNumber || '';
18132
+ if (Array.isArray(street)) {
18133
+ street = street.join(',');
18134
+ }
18135
+ if (Array.isArray(number)) {
18136
+ number = number.join(',');
18137
+ }
18138
+ var poiname = aois && aois[0] && aois[0].name || '';
18139
+ var detailAddr = street + number + poiname || '';
18140
+ var address = (addressComponent.province || '') + (addressComponent.city || '') + (addressComponent.district || '') + (detailAddr || '');
18141
+ var tmpFullDistrinct = (addressComponent.province || '') + (addressComponent.city || '') + (addressComponent.district || '');
18142
+ if (!address.endsWith(poiname)) {
18143
+ address = address + poiname;
18144
+ }
18145
+ var selectedDetailAddr = detailAddr || '';
18146
+ // 去除前面的行政区域
18147
+ if (selectedDetailAddr.startsWith(tmpFullDistrinct)) {
18148
+ selectedDetailAddr = selectedDetailAddr.slice(tmpFullDistrinct.length);
18149
+ }
18150
+ var poiid = pois && pois[0] && pois[0].id;
18151
+ var poitypename = pois && pois[0] && pois[0].type;
18152
+ var addressDetail = {
18153
+ regeocode: result.regeocode,
18154
+ addressDetail: {
18155
+ longitude: position.longitude,
18156
+ latitude: position.latitude,
18157
+ address: address || '',
18158
+ poiname: poiname || '',
18159
+ regionid: addressComponent.adcode || '',
18160
+ country: country || '',
18161
+ province: addressComponent.province || '',
18162
+ city: addressComponent.city || '',
18163
+ district: addressComponent.district || addressComponent.township || '',
18164
+ street: street || '',
18165
+ number: number || '',
18166
+ detailaddr: selectedDetailAddr || '',
18167
+ poiid: poiid || '',
18168
+ poitypename: poitypename || '',
18169
+ poitypecode: '',
18170
+ phonenumber: getPoiPhoneNumber(pois && pois[0] && pois[0].tel),
18171
+ signboard: '',
18172
+ maptype: 'amap'
18173
+ }
18174
+ };
18175
+ resolve(addressDetail);
18176
+ } else {
18177
+ console.error("getAddressByAMap fail: status = ".concat(status, ", result = ").concat(result));
18178
+ resolve(null);
18179
+ }
18180
+ });
18181
+ }
18182
+ }));
18183
+ case 2:
18184
+ case "end":
18185
+ return _context9.stop();
18186
+ }
18187
+ }, _callee9);
18188
+ }));
18189
+ return function getAddressDetailByAMap(_x6) {
18190
+ return _ref9.apply(this, arguments);
18191
+ };
18192
+ }();
18193
+ // 腾讯ip定位:通过终端设备IP地址获取其当前所在地理位置,精确到市级,常用于显示当地城市天气预报、初始化用户城市等非精确定位场景。
18194
+ var getIPLocationByTMap = /*#__PURE__*/function () {
18195
+ var _ref10 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee10(ip) {
18196
+ return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
18197
+ while (1) switch (_context10.prev = _context10.next) {
18198
+ case 0:
18199
+ console.log('getIPLocationByTMap start...');
18200
+ return _context10.abrupt("return", new Promise(function (resolve, reject) {
18201
+ var _window5;
18202
+ if (!((_window5 = window) !== null && _window5 !== void 0 && _window5.TMap)) {
17992
18203
  console.error('getIPLocationByTMap fail: TMap is undefinded');
17993
18204
  resolve(null);
17994
18205
  return;
@@ -18013,24 +18224,24 @@ var getIPLocationByTMap = /*#__PURE__*/function () {
18013
18224
  }));
18014
18225
  case 2:
18015
18226
  case "end":
18016
- return _context9.stop();
18227
+ return _context10.stop();
18017
18228
  }
18018
- }, _callee9);
18229
+ }, _callee10);
18019
18230
  }));
18020
- return function getIPLocationByTMap(_x6) {
18021
- return _ref9.apply(this, arguments);
18231
+ return function getIPLocationByTMap(_x7) {
18232
+ return _ref10.apply(this, arguments);
18022
18233
  };
18023
18234
  }();
18024
18235
  // 腾讯逆地址解析
18025
18236
  var getAddressByTMap = /*#__PURE__*/function () {
18026
- var _ref10 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee10(position) {
18027
- return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
18028
- while (1) switch (_context10.prev = _context10.next) {
18237
+ var _ref11 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee11(position) {
18238
+ return _regeneratorRuntime$1().wrap(function _callee11$(_context11) {
18239
+ while (1) switch (_context11.prev = _context11.next) {
18029
18240
  case 0:
18030
18241
  console.log('getAddressByTMap start...');
18031
- return _context10.abrupt("return", new Promise(function (resolve, reject) {
18032
- var _window5;
18033
- if (!((_window5 = window) !== null && _window5 !== void 0 && _window5.TMap)) {
18242
+ return _context11.abrupt("return", new Promise(function (resolve, reject) {
18243
+ var _window6;
18244
+ if (!((_window6 = window) !== null && _window6 !== void 0 && _window6.TMap)) {
18034
18245
  console.error('getAddressByTMap fail: TMap is undefinded');
18035
18246
  resolve('');
18036
18247
  return;
@@ -18057,41 +18268,41 @@ var getAddressByTMap = /*#__PURE__*/function () {
18057
18268
  }));
18058
18269
  case 2:
18059
18270
  case "end":
18060
- return _context10.stop();
18271
+ return _context11.stop();
18061
18272
  }
18062
- }, _callee10);
18273
+ }, _callee11);
18063
18274
  }));
18064
- return function getAddressByTMap(_x7) {
18065
- return _ref10.apply(this, arguments);
18275
+ return function getAddressByTMap(_x8) {
18276
+ return _ref11.apply(this, arguments);
18066
18277
  };
18067
18278
  }();
18068
18279
  // 百度浏览器定位
18069
18280
  var getLocationByBMap = /*#__PURE__*/function () {
18070
- var _ref11 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee12() {
18071
- return _regeneratorRuntime$1().wrap(function _callee12$(_context12) {
18072
- while (1) switch (_context12.prev = _context12.next) {
18281
+ var _ref12 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee13() {
18282
+ return _regeneratorRuntime$1().wrap(function _callee13$(_context13) {
18283
+ while (1) switch (_context13.prev = _context13.next) {
18073
18284
  case 0:
18074
18285
  console.log('getLocationByBMap start...');
18075
- return _context12.abrupt("return", new Promise(function (resolve, reject) {
18076
- var _window6;
18077
- if (!((_window6 = window) !== null && _window6 !== void 0 && _window6.BMap)) {
18286
+ return _context13.abrupt("return", new Promise(function (resolve, reject) {
18287
+ var _window7;
18288
+ if (!((_window7 = window) !== null && _window7 !== void 0 && _window7.BMap)) {
18078
18289
  console.error('getLocationByBMap fail: BMap is undefinded');
18079
18290
  resolve(null);
18080
18291
  return;
18081
18292
  }
18082
18293
  new window.BMap.Geolocation().getCurrentPosition( /*#__PURE__*/function () {
18083
- var _ref12 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee11(res) {
18294
+ var _ref13 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee12(res) {
18084
18295
  var lng, lat, result;
18085
- return _regeneratorRuntime$1().wrap(function _callee11$(_context11) {
18086
- while (1) switch (_context11.prev = _context11.next) {
18296
+ return _regeneratorRuntime$1().wrap(function _callee12$(_context12) {
18297
+ while (1) switch (_context12.prev = _context12.next) {
18087
18298
  case 0:
18088
18299
  if (res) {
18089
- _context11.next = 4;
18300
+ _context12.next = 4;
18090
18301
  break;
18091
18302
  }
18092
18303
  console.error('getLocationByBMap fail');
18093
18304
  resolve(null);
18094
- return _context11.abrupt("return");
18305
+ return _context12.abrupt("return");
18095
18306
  case 4:
18096
18307
  // 初始化已经指定 window.BMap.coordType = 'BMAP_COORD_GCJ02' 定位返回的定位信息,外层[latitude,longitude]依然是BD09,然后point里面的是GCJ02
18097
18308
  // {
@@ -18134,12 +18345,12 @@ var getLocationByBMap = /*#__PURE__*/function () {
18134
18345
  resolve(result);
18135
18346
  case 9:
18136
18347
  case "end":
18137
- return _context11.stop();
18348
+ return _context12.stop();
18138
18349
  }
18139
- }, _callee11);
18350
+ }, _callee12);
18140
18351
  }));
18141
- return function (_x8) {
18142
- return _ref12.apply(this, arguments);
18352
+ return function (_x9) {
18353
+ return _ref13.apply(this, arguments);
18143
18354
  };
18144
18355
  }(), {
18145
18356
  enableHighAccuracy: true
@@ -18147,49 +18358,49 @@ var getLocationByBMap = /*#__PURE__*/function () {
18147
18358
  }));
18148
18359
  case 2:
18149
18360
  case "end":
18150
- return _context12.stop();
18361
+ return _context13.stop();
18151
18362
  }
18152
- }, _callee12);
18363
+ }, _callee13);
18153
18364
  }));
18154
18365
  return function getLocationByBMap() {
18155
- return _ref11.apply(this, arguments);
18366
+ return _ref12.apply(this, arguments);
18156
18367
  };
18157
18368
  }();
18158
18369
  // 百度城市定位
18159
18370
  var getCityLocationByBMap = /*#__PURE__*/function () {
18160
- var _ref13 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee14() {
18161
- return _regeneratorRuntime$1().wrap(function _callee14$(_context14) {
18162
- while (1) switch (_context14.prev = _context14.next) {
18371
+ var _ref14 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee15() {
18372
+ return _regeneratorRuntime$1().wrap(function _callee15$(_context15) {
18373
+ while (1) switch (_context15.prev = _context15.next) {
18163
18374
  case 0:
18164
18375
  console.log('getCityLocationByBMap start...');
18165
- return _context14.abrupt("return", new Promise(function (resolve, reject) {
18166
- var _window7;
18167
- if (!((_window7 = window) !== null && _window7 !== void 0 && _window7.BMap)) {
18376
+ return _context15.abrupt("return", new Promise(function (resolve, reject) {
18377
+ var _window8;
18378
+ if (!((_window8 = window) !== null && _window8 !== void 0 && _window8.BMap)) {
18168
18379
  console.error('getCityLocationByBMap fail: BMap is undefinded');
18169
18380
  resolve(null);
18170
18381
  return;
18171
18382
  }
18172
18383
  new window.BMap.LocalCity().get( /*#__PURE__*/function () {
18173
- var _ref14 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee13(res) {
18384
+ var _ref15 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee14(res) {
18174
18385
  var lng, lat, point, result;
18175
- return _regeneratorRuntime$1().wrap(function _callee13$(_context13) {
18176
- while (1) switch (_context13.prev = _context13.next) {
18386
+ return _regeneratorRuntime$1().wrap(function _callee14$(_context14) {
18387
+ while (1) switch (_context14.prev = _context14.next) {
18177
18388
  case 0:
18178
18389
  // console.log(res)
18179
18390
  // debugger
18180
18391
  lng = res.center.lng.toString();
18181
18392
  lat = res.center.lat.toString();
18182
18393
  if (!(lng && lat)) {
18183
- _context13.next = 11;
18394
+ _context14.next = 11;
18184
18395
  break;
18185
18396
  }
18186
- _context13.next = 5;
18397
+ _context14.next = 5;
18187
18398
  return BMapTransformBD09ToGCJ02Points([{
18188
18399
  lng: lng,
18189
18400
  lat: lat
18190
18401
  }]);
18191
18402
  case 5:
18192
- point = _context13.sent;
18403
+ point = _context14.sent;
18193
18404
  // console.log(point)
18194
18405
  // debugger
18195
18406
  result = {
@@ -18198,61 +18409,61 @@ var getCityLocationByBMap = /*#__PURE__*/function () {
18198
18409
  };
18199
18410
  console.log("getCityLocationByBMap success: ".concat(JSON.stringify(result)));
18200
18411
  resolve(result);
18201
- _context13.next = 13;
18412
+ _context14.next = 13;
18202
18413
  break;
18203
18414
  case 11:
18204
18415
  console.error('getCityLocationByBMap fail');
18205
18416
  resolve(null);
18206
18417
  case 13:
18207
18418
  case "end":
18208
- return _context13.stop();
18419
+ return _context14.stop();
18209
18420
  }
18210
- }, _callee13);
18421
+ }, _callee14);
18211
18422
  }));
18212
- return function (_x9) {
18213
- return _ref14.apply(this, arguments);
18423
+ return function (_x10) {
18424
+ return _ref15.apply(this, arguments);
18214
18425
  };
18215
18426
  }());
18216
18427
  }));
18217
18428
  case 2:
18218
18429
  case "end":
18219
- return _context14.stop();
18430
+ return _context15.stop();
18220
18431
  }
18221
- }, _callee14);
18432
+ }, _callee15);
18222
18433
  }));
18223
18434
  return function getCityLocationByBMap() {
18224
- return _ref13.apply(this, arguments);
18435
+ return _ref14.apply(this, arguments);
18225
18436
  };
18226
18437
  }();
18227
18438
  // 百度逆地址解析
18228
18439
  var getAddressByBmap = /*#__PURE__*/function () {
18229
- var _ref15 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee16(position) {
18230
- return _regeneratorRuntime$1().wrap(function _callee16$(_context16) {
18231
- while (1) switch (_context16.prev = _context16.next) {
18440
+ var _ref16 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee17(position) {
18441
+ return _regeneratorRuntime$1().wrap(function _callee17$(_context17) {
18442
+ while (1) switch (_context17.prev = _context17.next) {
18232
18443
  case 0:
18233
18444
  console.log('getAddressByBmap start...');
18234
- return _context16.abrupt("return", new Promise( /*#__PURE__*/function () {
18235
- var _ref16 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee15(resolve, reject) {
18236
- var _window8;
18445
+ return _context17.abrupt("return", new Promise( /*#__PURE__*/function () {
18446
+ var _ref17 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee16(resolve, reject) {
18447
+ var _window9;
18237
18448
  var point;
18238
- return _regeneratorRuntime$1().wrap(function _callee15$(_context15) {
18239
- while (1) switch (_context15.prev = _context15.next) {
18449
+ return _regeneratorRuntime$1().wrap(function _callee16$(_context16) {
18450
+ while (1) switch (_context16.prev = _context16.next) {
18240
18451
  case 0:
18241
- if ((_window8 = window) !== null && _window8 !== void 0 && _window8.BMap) {
18242
- _context15.next = 4;
18452
+ if ((_window9 = window) !== null && _window9 !== void 0 && _window9.BMap) {
18453
+ _context16.next = 4;
18243
18454
  break;
18244
18455
  }
18245
18456
  console.error('getAddressByBmap fail: BMap is undefinded');
18246
18457
  resolve('');
18247
- return _context15.abrupt("return");
18458
+ return _context16.abrupt("return");
18248
18459
  case 4:
18249
18460
  if (position) {
18250
- _context15.next = 8;
18461
+ _context16.next = 8;
18251
18462
  break;
18252
18463
  }
18253
18464
  console.error('getAddressByBmap fail');
18254
18465
  resolve('');
18255
- return _context15.abrupt("return");
18466
+ return _context16.abrupt("return");
18256
18467
  case 8:
18257
18468
  // // 把 GCJ02 转化为百度 BD09 地址
18258
18469
  // const points: any = await transformGCJ02ToBD09Points([{
@@ -18277,104 +18488,104 @@ var getAddressByBmap = /*#__PURE__*/function () {
18277
18488
  });
18278
18489
  case 10:
18279
18490
  case "end":
18280
- return _context15.stop();
18491
+ return _context16.stop();
18281
18492
  }
18282
- }, _callee15);
18493
+ }, _callee16);
18283
18494
  }));
18284
- return function (_x11, _x12) {
18285
- return _ref16.apply(this, arguments);
18495
+ return function (_x12, _x13) {
18496
+ return _ref17.apply(this, arguments);
18286
18497
  };
18287
18498
  }()));
18288
18499
  case 2:
18289
18500
  case "end":
18290
- return _context16.stop();
18501
+ return _context17.stop();
18291
18502
  }
18292
- }, _callee16);
18503
+ }, _callee17);
18293
18504
  }));
18294
- return function getAddressByBmap(_x10) {
18295
- return _ref15.apply(this, arguments);
18505
+ return function getAddressByBmap(_x11) {
18506
+ return _ref16.apply(this, arguments);
18296
18507
  };
18297
18508
  }();
18298
18509
  var getLocationPromise = /*#__PURE__*/function () {
18299
- var _ref17 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee17() {
18300
- var _window9;
18510
+ var _ref18 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee18() {
18511
+ var _window10;
18301
18512
  var isuseiplocation,
18302
18513
  location,
18303
- _args17 = arguments;
18304
- return _regeneratorRuntime$1().wrap(function _callee17$(_context17) {
18305
- while (1) switch (_context17.prev = _context17.next) {
18514
+ _args18 = arguments;
18515
+ return _regeneratorRuntime$1().wrap(function _callee18$(_context18) {
18516
+ while (1) switch (_context18.prev = _context18.next) {
18306
18517
  case 0:
18307
- isuseiplocation = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : false;
18518
+ isuseiplocation = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : false;
18308
18519
  location = null; // 在 SPU 容器里使用 Native-API 的定位
18309
- if (!((_window9 = window) !== null && _window9 !== void 0 && (_window9 = _window9.Native) !== null && _window9 !== void 0 && _window9.getLocation)) {
18310
- _context17.next = 6;
18520
+ if (!((_window10 = window) !== null && _window10 !== void 0 && (_window10 = _window10.Native) !== null && _window10 !== void 0 && _window10.getLocation)) {
18521
+ _context18.next = 6;
18311
18522
  break;
18312
18523
  }
18313
- _context17.next = 5;
18524
+ _context18.next = 5;
18314
18525
  return getLocationByNative();
18315
18526
  case 5:
18316
- location = _context17.sent;
18527
+ location = _context18.sent;
18317
18528
  case 6:
18318
18529
  if (location) {
18319
- _context17.next = 31;
18530
+ _context18.next = 31;
18320
18531
  break;
18321
18532
  }
18322
18533
  if (!(mapService.type === 'amap')) {
18323
- _context17.next = 17;
18534
+ _context18.next = 17;
18324
18535
  break;
18325
18536
  }
18326
- _context17.next = 10;
18537
+ _context18.next = 10;
18327
18538
  return getLocationByAMap();
18328
18539
  case 10:
18329
- location = _context17.sent;
18540
+ location = _context18.sent;
18330
18541
  if (!(!location && isuseiplocation)) {
18331
- _context17.next = 15;
18542
+ _context18.next = 15;
18332
18543
  break;
18333
18544
  }
18334
- _context17.next = 14;
18545
+ _context18.next = 14;
18335
18546
  return getCityLocationByAMap();
18336
18547
  case 14:
18337
- location = _context17.sent;
18548
+ location = _context18.sent;
18338
18549
  case 15:
18339
- _context17.next = 31;
18550
+ _context18.next = 31;
18340
18551
  break;
18341
18552
  case 17:
18342
18553
  if (!(mapService.type === 'tencent' && isuseiplocation)) {
18343
- _context17.next = 23;
18554
+ _context18.next = 23;
18344
18555
  break;
18345
18556
  }
18346
- _context17.next = 20;
18557
+ _context18.next = 20;
18347
18558
  return getIPLocationByTMap();
18348
18559
  case 20:
18349
- location = _context17.sent;
18350
- _context17.next = 31;
18560
+ location = _context18.sent;
18561
+ _context18.next = 31;
18351
18562
  break;
18352
18563
  case 23:
18353
18564
  if (!(mapService.type === 'baidu')) {
18354
- _context17.next = 31;
18565
+ _context18.next = 31;
18355
18566
  break;
18356
18567
  }
18357
- _context17.next = 26;
18568
+ _context18.next = 26;
18358
18569
  return getLocationByBMap();
18359
18570
  case 26:
18360
- location = _context17.sent;
18571
+ location = _context18.sent;
18361
18572
  if (!(!location && isuseiplocation)) {
18362
- _context17.next = 31;
18573
+ _context18.next = 31;
18363
18574
  break;
18364
18575
  }
18365
- _context17.next = 30;
18576
+ _context18.next = 30;
18366
18577
  return getCityLocationByBMap();
18367
18578
  case 30:
18368
- location = _context17.sent;
18579
+ location = _context18.sent;
18369
18580
  case 31:
18370
18581
  if (location) {
18371
- _context17.next = 35;
18582
+ _context18.next = 35;
18372
18583
  break;
18373
18584
  }
18374
- _context17.next = 34;
18585
+ _context18.next = 34;
18375
18586
  return getLocationByNavigator();
18376
18587
  case 34:
18377
- location = _context17.sent;
18588
+ location = _context18.sent;
18378
18589
  case 35:
18379
18590
  // location = null
18380
18591
  // 开发模式下为了方便测试提供虚拟定位
@@ -18398,30 +18609,30 @@ var getLocationPromise = /*#__PURE__*/function () {
18398
18609
  // }
18399
18610
  // }
18400
18611
  if (!(location && !location.address)) {
18401
- _context17.next = 43;
18612
+ _context18.next = 43;
18402
18613
  break;
18403
18614
  }
18404
- _context17.next = 39;
18615
+ _context18.next = 39;
18405
18616
  return getAddress(location);
18406
18617
  case 39:
18407
- _context17.t0 = _context17.sent;
18408
- if (_context17.t0) {
18409
- _context17.next = 42;
18618
+ _context18.t0 = _context18.sent;
18619
+ if (_context18.t0) {
18620
+ _context18.next = 42;
18410
18621
  break;
18411
18622
  }
18412
- _context17.t0 = '经纬度获取成功,但地址获取失败。';
18623
+ _context18.t0 = '经纬度获取成功,但地址获取失败。';
18413
18624
  case 42:
18414
- location.address = _context17.t0;
18625
+ location.address = _context18.t0;
18415
18626
  case 43:
18416
- return _context17.abrupt("return", location);
18627
+ return _context18.abrupt("return", location);
18417
18628
  case 44:
18418
18629
  case "end":
18419
- return _context17.stop();
18630
+ return _context18.stop();
18420
18631
  }
18421
- }, _callee17);
18632
+ }, _callee18);
18422
18633
  }));
18423
18634
  return function getLocationPromise() {
18424
- return _ref17.apply(this, arguments);
18635
+ return _ref18.apply(this, arguments);
18425
18636
  };
18426
18637
  }();
18427
18638
  // WGS84 GCJ-02 BD-09 坐标系
@@ -18431,104 +18642,104 @@ function getLocation() {
18431
18642
  return _getLocation.apply(this, arguments);
18432
18643
  } // 逆地址解析
18433
18644
  function _getLocation() {
18434
- _getLocation = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee20() {
18645
+ _getLocation = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee21() {
18435
18646
  var isuseiplocation,
18436
18647
  locationRes,
18437
- _args20 = arguments;
18438
- return _regeneratorRuntime$1().wrap(function _callee20$(_context20) {
18439
- while (1) switch (_context20.prev = _context20.next) {
18648
+ _args21 = arguments;
18649
+ return _regeneratorRuntime$1().wrap(function _callee21$(_context21) {
18650
+ while (1) switch (_context21.prev = _context21.next) {
18440
18651
  case 0:
18441
- isuseiplocation = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : false;
18442
- _context20.next = 3;
18652
+ isuseiplocation = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : false;
18653
+ _context21.next = 3;
18443
18654
  return mapService.init();
18444
18655
  case 3:
18445
18656
  if (!(datetime && Date.now() - datetime <= cachetime && lastLocation && !runing)) {
18446
- _context20.next = 5;
18657
+ _context21.next = 5;
18447
18658
  break;
18448
18659
  }
18449
- return _context20.abrupt("return", cloneDeep$1(lastLocation));
18660
+ return _context21.abrupt("return", cloneDeep$1(lastLocation));
18450
18661
  case 5:
18451
18662
  if (!(runing && locationPromise)) {
18452
- _context20.next = 7;
18663
+ _context21.next = 7;
18453
18664
  break;
18454
18665
  }
18455
- return _context20.abrupt("return", locationPromise);
18666
+ return _context21.abrupt("return", locationPromise);
18456
18667
  case 7:
18457
18668
  // console.log('runing')
18458
18669
  runing = true;
18459
18670
  locationPromise = getLocationPromise(isuseiplocation);
18460
- _context20.next = 11;
18671
+ _context21.next = 11;
18461
18672
  return locationPromise;
18462
18673
  case 11:
18463
- locationRes = _context20.sent;
18674
+ locationRes = _context21.sent;
18464
18675
  runing = false;
18465
18676
  if (locationRes) {
18466
18677
  datetime = Date.now();
18467
18678
  lastLocation = locationRes;
18468
18679
  }
18469
- return _context20.abrupt("return", locationRes);
18680
+ return _context21.abrupt("return", locationRes);
18470
18681
  case 15:
18471
18682
  case "end":
18472
- return _context20.stop();
18683
+ return _context21.stop();
18473
18684
  }
18474
- }, _callee20);
18685
+ }, _callee21);
18475
18686
  }));
18476
18687
  return _getLocation.apply(this, arguments);
18477
18688
  }
18478
18689
  var getAddress = /*#__PURE__*/function () {
18479
- var _ref18 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee18(position) {
18690
+ var _ref19 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee19(position) {
18480
18691
  var address;
18481
- return _regeneratorRuntime$1().wrap(function _callee18$(_context18) {
18482
- while (1) switch (_context18.prev = _context18.next) {
18692
+ return _regeneratorRuntime$1().wrap(function _callee19$(_context19) {
18693
+ while (1) switch (_context19.prev = _context19.next) {
18483
18694
  case 0:
18484
- _context18.next = 2;
18695
+ _context19.next = 2;
18485
18696
  return mapService.init();
18486
18697
  case 2:
18487
18698
  address = '';
18488
18699
  if (address) {
18489
- _context18.next = 20;
18700
+ _context19.next = 20;
18490
18701
  break;
18491
18702
  }
18492
18703
  if (!(mapService.type === 'amap')) {
18493
- _context18.next = 10;
18704
+ _context19.next = 10;
18494
18705
  break;
18495
18706
  }
18496
- _context18.next = 7;
18707
+ _context19.next = 7;
18497
18708
  return getAddressByAMap(position);
18498
18709
  case 7:
18499
- address = _context18.sent;
18500
- _context18.next = 20;
18710
+ address = _context19.sent;
18711
+ _context19.next = 20;
18501
18712
  break;
18502
18713
  case 10:
18503
18714
  if (!(mapService.type === 'tencent')) {
18504
- _context18.next = 16;
18715
+ _context19.next = 16;
18505
18716
  break;
18506
18717
  }
18507
- _context18.next = 13;
18718
+ _context19.next = 13;
18508
18719
  return getAddressByTMap(position);
18509
18720
  case 13:
18510
- address = _context18.sent;
18511
- _context18.next = 20;
18721
+ address = _context19.sent;
18722
+ _context19.next = 20;
18512
18723
  break;
18513
18724
  case 16:
18514
18725
  if (!(mapService.type === 'baidu')) {
18515
- _context18.next = 20;
18726
+ _context19.next = 20;
18516
18727
  break;
18517
18728
  }
18518
- _context18.next = 19;
18729
+ _context19.next = 19;
18519
18730
  return getAddressByBmap(position);
18520
18731
  case 19:
18521
- address = _context18.sent;
18732
+ address = _context19.sent;
18522
18733
  case 20:
18523
- return _context18.abrupt("return", address);
18734
+ return _context19.abrupt("return", address);
18524
18735
  case 21:
18525
18736
  case "end":
18526
- return _context18.stop();
18737
+ return _context19.stop();
18527
18738
  }
18528
- }, _callee18);
18739
+ }, _callee19);
18529
18740
  }));
18530
- return function getAddress(_x13) {
18531
- return _ref18.apply(this, arguments);
18741
+ return function getAddress(_x14) {
18742
+ return _ref19.apply(this, arguments);
18532
18743
  };
18533
18744
  }();
18534
18745
  // const getDistance = async (p1: [number, number], p2: [number, number]) => {
@@ -18537,10 +18748,10 @@ var getAddress = /*#__PURE__*/function () {
18537
18748
  // }
18538
18749
  // 两个经纬度距离计算
18539
18750
  var getDistance = /*#__PURE__*/function () {
18540
- var _ref19 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee19(latlng1, latlng2) {
18751
+ var _ref20 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee20(latlng1, latlng2) {
18541
18752
  var lng1, lat1, lng2, lat2, radLat1, radLat2, a, b, s;
18542
- return _regeneratorRuntime$1().wrap(function _callee19$(_context19) {
18543
- while (1) switch (_context19.prev = _context19.next) {
18753
+ return _regeneratorRuntime$1().wrap(function _callee20$(_context20) {
18754
+ while (1) switch (_context20.prev = _context20.next) {
18544
18755
  case 0:
18545
18756
  // console.log(latlng1)
18546
18757
  // console.log(latlng2)
@@ -18555,15 +18766,15 @@ var getDistance = /*#__PURE__*/function () {
18555
18766
  s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
18556
18767
  s = s * 6378.137; // EARTH_RADIUS
18557
18768
  s = Math.round(s * 10000) / 10000;
18558
- return _context19.abrupt("return", s * 1000);
18769
+ return _context20.abrupt("return", s * 1000);
18559
18770
  case 12:
18560
18771
  case "end":
18561
- return _context19.stop();
18772
+ return _context20.stop();
18562
18773
  }
18563
- }, _callee19);
18774
+ }, _callee20);
18564
18775
  }));
18565
- return function getDistance(_x14, _x15) {
18566
- return _ref19.apply(this, arguments);
18776
+ return function getDistance(_x15, _x16) {
18777
+ return _ref20.apply(this, arguments);
18567
18778
  };
18568
18779
  }();
18569
18780
 
@@ -70456,7 +70667,7 @@ var install = function install(app, options) {
70456
70667
  console.log("@smart100/spu-web-plugin@".concat(version, " globalOptions"));
70457
70668
  console.log(globalOptions);
70458
70669
  // setTimeout(() => {
70459
- // console.error('9999')
70670
+ // console.error('888')
70460
70671
  // }, 1000)
70461
70672
  // if (install.installed) return
70462
70673
  // install.installed = true