@smart100/spu-web-plugin 1.0.17 → 1.0.19

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.17";
1
+ var version = "1.0.19";
2
2
 
3
3
  /** Detect free variable `global` from Node.js. */
4
4
  var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
@@ -16143,53 +16143,6 @@ var TenantSetting = /*#__PURE__*/function () {
16143
16143
  }, {
16144
16144
  key: "get",
16145
16145
  value: function get(key) {
16146
- // const tenantsetting = {
16147
- // lbssetting: {
16148
- // enable: '1',
16149
- // setting: {
16150
- // type: '',
16151
- // key: {
16152
- // web: '',
16153
- // android: '',
16154
- // ios: '',
16155
- // harmony: ''
16156
- // },
16157
- // secretkey: {
16158
- // web: '',
16159
- // android: '',
16160
- // ios: '',
16161
- // harmony: ''
16162
- // }
16163
- // }
16164
- // }
16165
- // }
16166
- // 高德地图key配置错误
16167
- // 1 如果是key格式不对 那么没返回promise 连window.AMap都拿不到 地图和都不能用
16168
- // 1 如果是key对式对 但key不对 有返回 window.AMap 但api定位调用失败 地图可以渲染空白地图
16169
- // // 高德地图公司key
16170
- // tenantsetting.lbssetting.setting.type = 'amap'
16171
- // tenantsetting.lbssetting.setting.key.web = '1993ac213d2f4675ac1bffb1b03ef1f0'
16172
- // tenantsetting.lbssetting.setting.secretkey.web = '816fe46b7b7bce145940b93c1e4818fa'
16173
- // // 高德地图个人key
16174
- // tenantsetting.lbssetting.setting.type = 'amap'
16175
- // tenantsetting.lbssetting.setting.key.web = 'e4d25fe4661a34198c4e6f79abe9afac'
16176
- // tenantsetting.lbssetting.setting.secretkey.web = 'a6b674affd9a3278c68602cf7ba02fcb'
16177
- // tencent地图key配置错误
16178
- // 1 如果是地图 会在地图上明确文字提示 鉴权失败,请传入正确的key
16179
- // 2 如果是调用定位等api 会返回 catch 和详细的错误信息
16180
- // getIPLocationByTMap fail: {"status":311,"message":"key格式错误","request_id":"ccedb04fd95e4f3f9cd45cfbad729d10","id":"cbm919vjdj0"}
16181
- // getIPLocationByTMap fail: {"status":190,"message":"无效的key","request_id":"b6ca9d0749eb4c91a47db9412b1253ca","id":"cbm919wxo40"}
16182
- // tenantsetting.lbssetting.setting.type = 'tencent'
16183
- // tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT'
16184
- // tenantsetting.lbssetting.setting.secretkey.web = 'zowvV5I2pSxqgGb2Sgr1x62HGXbqdxT0'
16185
- // 百度地图key配置错误alert以下信息
16186
- // 您提供的密钥不是有效的百度LBS开放平台密钥,或此密钥未对本应用的百度地图JavaScriptAPI授权。您可以访问如下网址了解如何获取有效的密钥:http://lbsyun.baidu.com/apiconsole/key#。
16187
- // tenantsetting.lbssetting.setting.type = 'baidu'
16188
- // tenantsetting.lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
16189
- // tenantsetting.lbssetting.setting.type = 'tencent'
16190
- // tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT是的是的'
16191
- // tenantsetting.lbssetting.setting.secretkey.web = 'zowvV5I2pSxqgGb2Sgr1x62HGXbqdxT0对对对'
16192
- // lsProxy.setItem('tenantsetting', JSON.stringify(tenantsetting))
16193
16146
  var tenantsettingStr = lsProxy.getItem('tenantsetting');
16194
16147
  if (tenantsettingStr) {
16195
16148
  var tenantsetting = JSON.parse(tenantsettingStr);
@@ -16207,11 +16160,13 @@ var TenantSetting = /*#__PURE__*/function () {
16207
16160
  var tenantSetting = new TenantSetting();
16208
16161
 
16209
16162
  function getToken() {
16210
- return getData('token');
16211
- // return lsProxy.getItem('token') as string
16163
+ var token = getData('token');
16164
+ // const token = lsProxy.getItem('token') as string
16165
+ return token;
16212
16166
  }
16213
-
16214
16167
  function setToken(value) {
16168
+ // console.log('setToken', value)
16169
+ // debugger
16215
16170
  setData('token', value);
16216
16171
  }
16217
16172
  function getTokenExpires() {
@@ -16277,6 +16232,7 @@ function removeUser() {
16277
16232
  removeData('user');
16278
16233
  }
16279
16234
  function parseToken(token) {
16235
+ // debugger
16280
16236
  if (!token) {
16281
16237
  console.error('token为空 jwt解析token出错');
16282
16238
  return null;
@@ -16434,13 +16390,13 @@ function getAndSetUserInfo() {
16434
16390
  return _getAndSetUserInfo.apply(this, arguments);
16435
16391
  }
16436
16392
  function _getAndSetUserInfo() {
16437
- _getAndSetUserInfo = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
16393
+ _getAndSetUserInfo = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5() {
16438
16394
  var accountinfo;
16439
- return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
16440
- while (1) switch (_context3.prev = _context3.next) {
16395
+ return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
16396
+ while (1) switch (_context5.prev = _context5.next) {
16441
16397
  case 0:
16442
- _context3.prev = 0;
16443
- _context3.next = 3;
16398
+ _context5.prev = 0;
16399
+ _context5.next = 3;
16444
16400
  return normalAxios$1.post('/api/teapi/rolepermission/account/getaccountinfo', {
16445
16401
  positionid: getUser('positioncode') || '',
16446
16402
  deviceinfo: '',
@@ -16454,22 +16410,22 @@ function _getAndSetUserInfo() {
16454
16410
  }
16455
16411
  });
16456
16412
  case 3:
16457
- accountinfo = _context3.sent;
16413
+ accountinfo = _context5.sent;
16458
16414
  if (accountinfo) {
16459
16415
  setUser(accountinfo);
16460
16416
  }
16461
- _context3.next = 11;
16417
+ _context5.next = 11;
16462
16418
  break;
16463
16419
  case 7:
16464
- _context3.prev = 7;
16465
- _context3.t0 = _context3["catch"](0);
16466
- console.error(_context3.t0);
16420
+ _context5.prev = 7;
16421
+ _context5.t0 = _context5["catch"](0);
16422
+ console.error(_context5.t0);
16467
16423
  console.warn('获取用户信息失败,当前您登录的帐号可能为非标准租户帐号。');
16468
16424
  case 11:
16469
16425
  case "end":
16470
- return _context3.stop();
16426
+ return _context5.stop();
16471
16427
  }
16472
- }, _callee3, null, [[0, 7]]);
16428
+ }, _callee5, null, [[0, 7]]);
16473
16429
  }));
16474
16430
  return _getAndSetUserInfo.apply(this, arguments);
16475
16431
  }
@@ -16502,19 +16458,19 @@ function getAndSetTenant(_x) {
16502
16458
  return _getAndSetTenant.apply(this, arguments);
16503
16459
  }
16504
16460
  function _getAndSetTenant() {
16505
- _getAndSetTenant = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(tenantcode) {
16461
+ _getAndSetTenant = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee6(tenantcode) {
16506
16462
  var tenantsRes, tenant, normalizedTenant;
16507
- return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
16508
- while (1) switch (_context4.prev = _context4.next) {
16463
+ return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
16464
+ while (1) switch (_context6.prev = _context6.next) {
16509
16465
  case 0:
16510
- _context4.prev = 0;
16511
- _context4.next = 3;
16466
+ _context6.prev = 0;
16467
+ _context6.next = 3;
16512
16468
  return normalAxios$1.get('/api/auth/tenantlist', {}).then(function (res) {
16513
16469
  var _res$data;
16514
16470
  return res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.tenants;
16515
16471
  });
16516
16472
  case 3:
16517
- tenantsRes = _context4.sent;
16473
+ tenantsRes = _context6.sent;
16518
16474
  tenant = null;
16519
16475
  if (tenantsRes !== null && tenantsRes !== void 0 && tenantsRes.length) {
16520
16476
  if (!tenantcode) {
@@ -16535,18 +16491,18 @@ function _getAndSetTenant() {
16535
16491
  cloudServ.set(normalizedTenant);
16536
16492
  }
16537
16493
  }
16538
- _context4.next = 13;
16494
+ _context6.next = 13;
16539
16495
  break;
16540
16496
  case 9:
16541
- _context4.prev = 9;
16542
- _context4.t0 = _context4["catch"](0);
16543
- console.error(_context4.t0);
16497
+ _context6.prev = 9;
16498
+ _context6.t0 = _context6["catch"](0);
16499
+ console.error(_context6.t0);
16544
16500
  console.warn('获取租户信息失败,当前您登录的帐号可能为非标准租户帐号。');
16545
16501
  case 13:
16546
16502
  case "end":
16547
- return _context4.stop();
16503
+ return _context6.stop();
16548
16504
  }
16549
- }, _callee4, null, [[0, 9]]);
16505
+ }, _callee6, null, [[0, 9]]);
16550
16506
  }));
16551
16507
  return _getAndSetTenant.apply(this, arguments);
16552
16508
  }
@@ -16640,15 +16596,138 @@ function startRefreshtoken() {
16640
16596
  }, _callee);
16641
16597
  })), time);
16642
16598
  }
16599
+ // 获取 spu 容器 token
16600
+ var getSPUContainerToken = function getSPUContainerToken() {
16601
+ return new Promise(function (resolve, reject) {
16602
+ var _window$aPaaS;
16603
+ if ((_window$aPaaS = window.aPaaS) !== null && _window$aPaaS !== void 0 && _window$aPaaS.getToken) {
16604
+ window.aPaaS.getToken(function (res) {
16605
+ console.log('window.aPaaS.getToken success', res);
16606
+ var token = res === null || res === void 0 ? void 0 : res.token;
16607
+ var tokenexpires = res === null || res === void 0 ? void 0 : res.tokenExpires;
16608
+ var refreshtoken = res === null || res === void 0 ? void 0 : res.refreshToken;
16609
+ if (token && tokenexpires && refreshtoken) {
16610
+ resolve({
16611
+ token: token,
16612
+ tokenexpires: tokenexpires,
16613
+ refreshtoken: refreshtoken
16614
+ });
16615
+ } else {
16616
+ console.error('window.aPaaS.getToken fail');
16617
+ resolve(null);
16618
+ }
16619
+ });
16620
+ } else {
16621
+ console.warn('window.aPaaS.getToken fail: not in SPU container');
16622
+ resolve(null);
16623
+ }
16624
+ });
16625
+ };
16626
+ // 如果APP端在SPU页面切到后台 然后又切回前台 有可能发生
16627
+ // 1、切后台时间过长导致 token 过期
16628
+ // 2、切后台后打开太多别的应用 导致切回前台时内存不足 从而导致 SPU 的 webview reload
16629
+ // 如果 1 2 同时发生 那么当前SPU页面重走单点登录流程 而url上的token已经过期 会导致单点登录失败
16630
+ // 因此 在APP端 单点登录不使用url上的token 而是直接拿App端的 App端能保证拿到的token一直不过期
16631
+ var fixLoginQuery = /*#__PURE__*/function () {
16632
+ var _ref2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(query) {
16633
+ var _window$aPaaS2;
16634
+ var newQuery, type, tokenData;
16635
+ return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
16636
+ while (1) switch (_context2.prev = _context2.next) {
16637
+ case 0:
16638
+ newQuery = cloneDeep$1(query);
16639
+ _context2.next = 3;
16640
+ return Module.getSpuContainerType();
16641
+ case 3:
16642
+ type = _context2.sent;
16643
+ if (!(type === 'app' && (_window$aPaaS2 = window.aPaaS) !== null && _window$aPaaS2 !== void 0 && _window$aPaaS2.getToken)) {
16644
+ _context2.next = 12;
16645
+ break;
16646
+ }
16647
+ console.log('SPU is in App, singleLogin use App token.');
16648
+ _context2.next = 8;
16649
+ return getSPUContainerToken();
16650
+ case 8:
16651
+ tokenData = _context2.sent;
16652
+ if (tokenData) {
16653
+ newQuery.token = tokenData.token;
16654
+ newQuery.tokenexpires = tokenData.tokenexpires;
16655
+ newQuery.refreshtoken = tokenData.refreshtoken;
16656
+ }
16657
+ _context2.next = 13;
16658
+ break;
16659
+ case 12:
16660
+ console.log('SPU is not in App, singleLogin use query token.');
16661
+ case 13:
16662
+ return _context2.abrupt("return", newQuery);
16663
+ case 14:
16664
+ case "end":
16665
+ return _context2.stop();
16666
+ }
16667
+ }, _callee2);
16668
+ }));
16669
+ return function fixLoginQuery(_x2) {
16670
+ return _ref2.apply(this, arguments);
16671
+ };
16672
+ }();
16673
+ // 修复 App 切到后台时间过长导致 token 过期
16674
+ // 监听 App 切换到前台 判断token是否过期 如果过期就调用获取tokne方法更新token
16675
+ var fixAppTokenExpired = function fixAppTokenExpired() {
16676
+ var _window$Native;
16677
+ if (globalOptions.isfixapptokenexpired && (_window$Native = window.Native) !== null && _window$Native !== void 0 && _window$Native.onHostEnterForceground) {
16678
+ console.log('listen App enter forceground');
16679
+ window.Native.onHostEnterForceground( /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
16680
+ var loginState, tokenData;
16681
+ return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
16682
+ while (1) switch (_context3.prev = _context3.next) {
16683
+ case 0:
16684
+ console.log('App enter forceground');
16685
+ loginState = getLoginState();
16686
+ if (!(!loginState.islogin && loginState.type === 2 && loginState.role !== 'center')) {
16687
+ _context3.next = 20;
16688
+ break;
16689
+ }
16690
+ _context3.next = 5;
16691
+ return getSPUContainerToken();
16692
+ case 5:
16693
+ tokenData = _context3.sent;
16694
+ if (!tokenData) {
16695
+ _context3.next = 12;
16696
+ break;
16697
+ }
16698
+ setToken(tokenData.token);
16699
+ setRefreshToken(tokenData.refreshtoken);
16700
+ setTokenExpires(tokenData.tokenexpires);
16701
+ _context3.next = 20;
16702
+ break;
16703
+ case 12:
16704
+ _context3.prev = 12;
16705
+ _context3.next = 15;
16706
+ return updateToken();
16707
+ case 15:
16708
+ _context3.next = 20;
16709
+ break;
16710
+ case 17:
16711
+ _context3.prev = 17;
16712
+ _context3.t0 = _context3["catch"](12);
16713
+ console.error(_context3.t0);
16714
+ case 20:
16715
+ case "end":
16716
+ return _context3.stop();
16717
+ }
16718
+ }, _callee3, null, [[12, 17]]);
16719
+ })));
16720
+ }
16721
+ };
16643
16722
  // 单点登录
16644
- function singleLogin(_x2) {
16723
+ function singleLogin(_x3) {
16645
16724
  return _singleLogin.apply(this, arguments);
16646
16725
  }
16647
16726
  function _singleLogin() {
16648
- _singleLogin = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5(query) {
16727
+ _singleLogin = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee7(query) {
16649
16728
  var flag, token, refreshtoken, tokenexpires, envname, context, setBaseInfo, isneedlogin, loginRole, refreshTokenUser, tokenUser, nowEnvname, envData;
16650
- return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
16651
- while (1) switch (_context5.prev = _context5.next) {
16729
+ return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
16730
+ while (1) switch (_context7.prev = _context7.next) {
16652
16731
  case 0:
16653
16732
  setBaseInfo = function _setBaseInfo() {
16654
16733
  setToken(token);
@@ -16661,6 +16740,15 @@ function _singleLogin() {
16661
16740
  context && lsProxy.setItem('context', decodeURIComponent(context));
16662
16741
  };
16663
16742
  query = cloneDeep$1(query);
16743
+ if (!globalOptions.isfixapptokenexpired) {
16744
+ _context7.next = 6;
16745
+ break;
16746
+ }
16747
+ _context7.next = 5;
16748
+ return fixLoginQuery(query);
16749
+ case 5:
16750
+ query = _context7.sent;
16751
+ case 6:
16664
16752
  flag = false; // 是否登录成功
16665
16753
  token = query.token;
16666
16754
  refreshtoken = query.refreshtoken;
@@ -16668,7 +16756,7 @@ function _singleLogin() {
16668
16756
  envname = query.envname;
16669
16757
  context = query.context;
16670
16758
  if (!checkLoginByToken(token)) {
16671
- _context5.next = 60;
16759
+ _context7.next = 64;
16672
16760
  break;
16673
16761
  }
16674
16762
  isneedlogin = true; // 是否需要走单点登录流程
@@ -16690,104 +16778,104 @@ function _singleLogin() {
16690
16778
  // isneedlogin = true
16691
16779
  // debugger
16692
16780
  if (!isneedlogin) {
16693
- _context5.next = 58;
16781
+ _context7.next = 62;
16694
16782
  break;
16695
16783
  }
16696
16784
  setBaseInfo();
16697
16785
  // 单点登录写入 token 之后
16698
16786
  // 1、如果 refreshtoken 不完整 则换取完整的 refreshtoken
16699
- _context5.prev = 14;
16787
+ _context7.prev = 18;
16700
16788
  if (!checkLogin()) {
16701
- _context5.next = 21;
16789
+ _context7.next = 25;
16702
16790
  break;
16703
16791
  }
16704
16792
  refreshTokenUser = getUserByToken(getRefreshToken());
16705
16793
  tokenUser = getUserByToken(getToken());
16706
16794
  if (!(!(refreshTokenUser !== null && refreshTokenUser !== void 0 && refreshTokenUser.tokenId) && tokenUser !== null && tokenUser !== void 0 && tokenUser.tokenId)) {
16707
- _context5.next = 21;
16795
+ _context7.next = 25;
16708
16796
  break;
16709
16797
  }
16710
- _context5.next = 21;
16798
+ _context7.next = 25;
16711
16799
  return updateToken();
16712
- case 21:
16713
- _context5.next = 26;
16800
+ case 25:
16801
+ _context7.next = 30;
16714
16802
  break;
16715
- case 23:
16716
- _context5.prev = 23;
16717
- _context5.t0 = _context5["catch"](14);
16718
- console.error(_context5.t0);
16719
- case 26:
16803
+ case 27:
16804
+ _context7.prev = 27;
16805
+ _context7.t0 = _context7["catch"](18);
16806
+ console.error(_context7.t0);
16807
+ case 30:
16720
16808
  // 2、重新计算刷新 token 时间 因为刚开始进入就 startRefreshtoken 检测到没有 token 会过10秒才执行刷新 token 操作
16721
16809
  startRefreshtoken();
16722
16810
  // 获取环境信息和租户配置信息
16723
- _context5.next = 29;
16811
+ _context7.next = 33;
16724
16812
  return getEnvname();
16725
- case 29:
16726
- nowEnvname = _context5.sent;
16813
+ case 33:
16814
+ nowEnvname = _context7.sent;
16727
16815
  if (!nowEnvname) {
16728
- _context5.next = 50;
16816
+ _context7.next = 54;
16729
16817
  break;
16730
16818
  }
16731
- _context5.next = 33;
16819
+ _context7.next = 37;
16732
16820
  return requestEnvdata(nowEnvname);
16733
- case 33:
16734
- envData = _context5.sent;
16821
+ case 37:
16822
+ envData = _context7.sent;
16735
16823
  if (!envData) {
16736
- _context5.next = 46;
16824
+ _context7.next = 50;
16737
16825
  break;
16738
16826
  }
16739
16827
  saveEnvdata(envData);
16740
16828
  if (!envData.tenantcode) {
16741
- _context5.next = 42;
16829
+ _context7.next = 46;
16742
16830
  break;
16743
16831
  }
16744
16832
  setTecode(envData.tenantcode);
16745
16833
  // 租户配置
16746
- _context5.next = 40;
16834
+ _context7.next = 44;
16747
16835
  return tenantSetting.requestAndSetTenantSetting(envData.tenantcode);
16748
- case 40:
16749
- _context5.next = 44;
16750
- break;
16751
- case 42:
16752
- tenantSetting.removeTenantSetting();
16753
- removeTecode();
16754
16836
  case 44:
16755
- _context5.next = 48;
16837
+ _context7.next = 48;
16756
16838
  break;
16757
16839
  case 46:
16758
- removeEnvdata();
16840
+ tenantSetting.removeTenantSetting();
16759
16841
  removeTecode();
16760
16842
  case 48:
16761
- _context5.next = 52;
16843
+ _context7.next = 52;
16762
16844
  break;
16763
16845
  case 50:
16764
16846
  removeEnvdata();
16765
16847
  removeTecode();
16766
16848
  case 52:
16767
- _context5.next = 54;
16768
- return getAndSetTenant();
16849
+ _context7.next = 56;
16850
+ break;
16769
16851
  case 54:
16770
- _context5.next = 56;
16771
- return getAndSetUserInfo();
16852
+ removeEnvdata();
16853
+ removeTecode();
16772
16854
  case 56:
16855
+ _context7.next = 58;
16856
+ return getAndSetTenant();
16857
+ case 58:
16858
+ _context7.next = 60;
16859
+ return getAndSetUserInfo();
16860
+ case 60:
16773
16861
  // 单点登录后 获取 web 开发者模式 如果是则设置 isdebugger
16774
16862
  urlquery.dealWebDebugger();
16775
16863
  flag = true;
16776
- case 58:
16777
- _context5.next = 63;
16864
+ case 62:
16865
+ _context7.next = 67;
16778
16866
  break;
16779
- case 60:
16867
+ case 64:
16780
16868
  flag = false;
16781
16869
  setBaseInfo(); // 传递的token过期依然写入 如果不写入的话 有可能之前的token本来没过期 页面依然可用
16782
16870
  console.error('单点登录失败,请检查链接所传 token/refreshtoken/tokenexpires 是否非法或过期。');
16783
- case 63:
16871
+ case 67:
16784
16872
  if (!flag) {
16785
- _context5.next = 66;
16873
+ _context7.next = 70;
16786
16874
  break;
16787
16875
  }
16788
- _context5.next = 66;
16876
+ _context7.next = 70;
16789
16877
  return core$1.initGetData();
16790
- case 66:
16878
+ case 70:
16791
16879
  if (flag) {
16792
16880
  // 单点登录成功 需要删除 query 中相关参数
16793
16881
  token && delete query.token;
@@ -16796,36 +16884,38 @@ function _singleLogin() {
16796
16884
  envname && delete query.envname;
16797
16885
  context && delete query.context;
16798
16886
  }
16799
- return _context5.abrupt("return", {
16887
+ return _context7.abrupt("return", {
16800
16888
  flag: flag,
16801
16889
  query: query
16802
16890
  });
16803
- case 68:
16891
+ case 72:
16804
16892
  case "end":
16805
- return _context5.stop();
16893
+ return _context7.stop();
16806
16894
  }
16807
- }, _callee5, null, [[14, 23]]);
16895
+ }, _callee7, null, [[18, 27]]);
16808
16896
  }));
16809
16897
  return _singleLogin.apply(this, arguments);
16810
16898
  }
16811
16899
  function installAuth(options) {
16812
16900
  startRefreshtoken();
16901
+ fixAppTokenExpired();
16813
16902
  if (options.router) {
16814
16903
  options.router.beforeEach( /*#__PURE__*/function () {
16815
- var _ref2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(to, from, next) {
16904
+ var _ref4 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(to, from, next) {
16816
16905
  var singleLoginRes;
16817
- return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
16818
- while (1) switch (_context2.prev = _context2.next) {
16906
+ return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
16907
+ while (1) switch (_context4.prev = _context4.next) {
16819
16908
  case 0:
16820
16909
  if (!to.query.token) {
16821
- _context2.next = 8;
16910
+ _context4.next = 8;
16822
16911
  break;
16823
16912
  }
16824
- _context2.next = 3;
16913
+ _context4.next = 3;
16825
16914
  return singleLogin(to.query);
16826
16915
  case 3:
16827
- singleLoginRes = _context2.sent;
16916
+ singleLoginRes = _context4.sent;
16828
16917
  if (singleLoginRes.flag) {
16918
+ // next()
16829
16919
  next({
16830
16920
  path: to.path,
16831
16921
  params: to.params,
@@ -16835,22 +16925,22 @@ function installAuth(options) {
16835
16925
  next();
16836
16926
  }
16837
16927
  options.singleLoginCallback && options.singleLoginCallback(singleLoginRes);
16838
- _context2.next = 9;
16928
+ _context4.next = 9;
16839
16929
  break;
16840
16930
  case 8:
16841
16931
  next();
16842
16932
  case 9:
16843
16933
  case "end":
16844
- return _context2.stop();
16934
+ return _context4.stop();
16845
16935
  }
16846
- }, _callee2);
16936
+ }, _callee4);
16847
16937
  }));
16848
- return function (_x3, _x4, _x5) {
16849
- return _ref2.apply(this, arguments);
16938
+ return function (_x4, _x5, _x6) {
16939
+ return _ref4.apply(this, arguments);
16850
16940
  };
16851
16941
  }());
16852
16942
  } else {
16853
- console.warn('@smart100/spu-web-plugin 需要传入一个 vue-router 实例以便执行单点登录逻辑,如果您没传 vue-router 实例则需要自行在合适的位置执行单点登录代码。');
16943
+ console.warn('@smart100/spu-web-plugin 需要传入一个 vue-router 实例以便执行单点登录逻辑,如果您没传 vue-router 实例则需要自行在合适的位置执行单点登录代码,如果您已自行实现,请忽略该提示。');
16854
16944
  }
16855
16945
  if (checkLogin()) {
16856
16946
  core$1.initGetData();
@@ -16969,6 +17059,32 @@ var delay = function delay() {
16969
17059
  }, timeout);
16970
17060
  });
16971
17061
  };
17062
+ var getServerTime = function getServerTime() {
17063
+ return new Promise(function (resolve, reject) {
17064
+ var _window4;
17065
+ if ((_window4 = window) !== null && _window4 !== void 0 && (_window4 = _window4.Native) !== null && _window4 !== void 0 && _window4.getServerTime) {
17066
+ window.Native.getServerTime(function (res) {
17067
+ if (res) {
17068
+ resolve(res.toString());
17069
+ } else {
17070
+ resolve(Date.now().toString());
17071
+ }
17072
+ });
17073
+ } else {
17074
+ normalAxios$1.get('/api/teapi/offline/servertime', {}, {
17075
+ isShowLoading: false
17076
+ }).then(function (res) {
17077
+ if (res.data) {
17078
+ resolve(res.data.toString());
17079
+ } else {
17080
+ resolve(Date.now().toString());
17081
+ }
17082
+ })["catch"](function (err) {
17083
+ resolve(Date.now().toString());
17084
+ });
17085
+ }
17086
+ });
17087
+ };
16972
17088
 
16973
17089
  var Urlquery = /*#__PURE__*/function () {
16974
17090
  function Urlquery() {
@@ -17098,19 +17214,58 @@ var MapService = /*#__PURE__*/function () {
17098
17214
  _defineProperty$1(this, "AMap", null);
17099
17215
  _defineProperty$1(this, "TMap", null);
17100
17216
  _defineProperty$1(this, "BMap", null);
17101
- _defineProperty$1(this, "MapCore", null);
17102
17217
  }
17103
17218
  _createClass$1(MapService, [{
17219
+ key: "lbssetting",
17220
+ get: function get() {
17221
+ return tenantSetting.get('lbssetting');
17222
+ // const lbssetting: any = {
17223
+ // enable: '1',
17224
+ // setting: {
17225
+ // type: '',
17226
+ // key: {
17227
+ // web: '',
17228
+ // android: '',
17229
+ // ios: '',
17230
+ // harmony: ''
17231
+ // },
17232
+ // secretkey: {
17233
+ // web: '',
17234
+ // android: '',
17235
+ // ios: '',
17236
+ // harmony: ''
17237
+ // }
17238
+ // }
17239
+ // }
17240
+ // // // 高德地图公司key
17241
+ // // lbssetting.setting.type = 'amap'
17242
+ // // lbssetting.setting.key.web = '1993ac213d2f4675ac1bffb1b03ef1f0'
17243
+ // // lbssetting.setting.secretkey.web = '816fe46b7b7bce145940b93c1e4818fa'
17244
+ // // 高德地图个人key
17245
+ // lbssetting.setting.type = 'amap'
17246
+ // lbssetting.setting.key.web = 'e4d25fe4661a34198c4e6f79abe9afac'
17247
+ // lbssetting.setting.secretkey.web = 'a6b674affd9a3278c68602cf7ba02fcb'
17248
+ // // // 腾讯地图
17249
+ // // lbssetting.setting.type = 'tencent'
17250
+ // // lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT'
17251
+ // // lbssetting.setting.secretkey.web = 'zowvV5I2pSxqgGb2Sgr1x62HGXbqdxT0'
17252
+ // // // 百度地图
17253
+ // // lbssetting.setting.type = 'baidu'
17254
+ // // lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
17255
+ // // lbssetting.setting.secretkey.web = ''
17256
+ // return lbssetting
17257
+ }
17258
+ }, {
17104
17259
  key: "isLbssettingEnable",
17105
17260
  get: function get() {
17106
- var _tenantSetting$get;
17107
- return ((_tenantSetting$get = tenantSetting.get('lbssetting')) === null || _tenantSetting$get === void 0 ? void 0 : _tenantSetting$get.enable) === '1';
17261
+ var _this$lbssetting;
17262
+ return ((_this$lbssetting = this.lbssetting) === null || _this$lbssetting === void 0 ? void 0 : _this$lbssetting.enable) === '1';
17108
17263
  }
17109
17264
  }, {
17110
17265
  key: "setting",
17111
17266
  get: function get() {
17112
- var _tenantSetting$get2;
17113
- return (_tenantSetting$get2 = tenantSetting.get('lbssetting')) === null || _tenantSetting$get2 === void 0 ? void 0 : _tenantSetting$get2.setting;
17267
+ var _this$lbssetting2;
17268
+ return (_this$lbssetting2 = this.lbssetting) === null || _this$lbssetting2 === void 0 ? void 0 : _this$lbssetting2.setting;
17114
17269
  }
17115
17270
  }, {
17116
17271
  key: "key",
@@ -17144,31 +17299,7 @@ var MapService = /*#__PURE__*/function () {
17144
17299
  }
17145
17300
  }, {
17146
17301
  key: "init",
17147
- value: // get AMap() {
17148
- // if (!this.isInit || this.type !== 'amap') {
17149
- // return null
17150
- // }
17151
- // return window.AMap
17152
- // }
17153
- // get TMap() {
17154
- // if (!this.isInit || this.type !== 'tencent') {
17155
- // return null
17156
- // }
17157
- // return window.TMap
17158
- // }
17159
- // get BMap() {
17160
- // if (!this.isInit || this.type !== 'baidu') {
17161
- // return null
17162
- // }
17163
- // return window.BMap
17164
- // }
17165
- // get MapCore() {
17166
- // if (!this.isInit) {
17167
- // return null
17168
- // }
17169
- // return window.BMap
17170
- // }
17171
- function () {
17302
+ value: function () {
17172
17303
  var _init2 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
17173
17304
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
17174
17305
  while (1) switch (_context.prev = _context.next) {
@@ -17278,9 +17409,11 @@ var MapService = /*#__PURE__*/function () {
17278
17409
  return _init3.apply(this, arguments);
17279
17410
  }
17280
17411
  return _init;
17281
- }() // reset() {
17282
- // this.isInit = false
17283
- // }
17412
+ }() // 腾讯地图 key 配置错误
17413
+ // 1 如果是地图 会在地图上明确文字提示 鉴权失败,请传入正确的key
17414
+ // 2 如果是调用 api 会返回 catch 和详细的错误信息
17415
+ // getIPLocationByTMap fail: {"status":311,"message":"key格式错误","request_id":"ccedb04fd95e4f3f9cd45cfbad729d10","id":"cbm919vjdj0"}
17416
+ // getIPLocationByTMap fail: {"status":190,"message":"无效的key","request_id":"b6ca9d0749eb4c91a47db9412b1253ca","id":"cbm919wxo40"}
17284
17417
  }, {
17285
17418
  key: "initTecent",
17286
17419
  value: function () {
@@ -17294,10 +17427,9 @@ var MapService = /*#__PURE__*/function () {
17294
17427
  'TMap');
17295
17428
  case 2:
17296
17429
  this.TMap = window.TMap;
17297
- this.MapCore = window.TMap;
17298
- _context3.next = 6;
17430
+ _context3.next = 5;
17299
17431
  return delay(300);
17300
- case 6:
17432
+ case 5:
17301
17433
  case "end":
17302
17434
  return _context3.stop();
17303
17435
  }
@@ -17307,7 +17439,9 @@ var MapService = /*#__PURE__*/function () {
17307
17439
  return _initTecent.apply(this, arguments);
17308
17440
  }
17309
17441
  return initTecent;
17310
- }()
17442
+ }() // 高德地图 key 配置错误
17443
+ // 1 如果是 key 格式不对 那么没返回 promise 连 window.AMap 都拿不到 地图和都不能用
17444
+ // 1 如果是 key 格式对 但 key 不对 有返回 window.AMap 但 api 定位调用失败 地图可以渲染空白地图
17311
17445
  }, {
17312
17446
  key: "initAmap",
17313
17447
  value: function () {
@@ -17349,14 +17483,13 @@ var MapService = /*#__PURE__*/function () {
17349
17483
  clearTimeout(time);
17350
17484
  window.AMap = AMap;
17351
17485
  _this.AMap = window.AMap;
17352
- _this.MapCore = window.AMap;
17353
17486
  // console.log(window)
17354
17487
  // console.log(window.AMap)
17355
17488
  // console.log(window.AMapUI)
17356
17489
  // console.log(window.AMapLoader)
17357
17490
  // console.log(window.AMap === aaaa)
17358
17491
  resolve(window.AMap);
17359
- case 11:
17492
+ case 10:
17360
17493
  case "end":
17361
17494
  return _context4.stop();
17362
17495
  }
@@ -17376,7 +17509,8 @@ var MapService = /*#__PURE__*/function () {
17376
17509
  return _initAmap.apply(this, arguments);
17377
17510
  }
17378
17511
  return initAmap;
17379
- }()
17512
+ }() // 百度地图 key 配置错误
17513
+ // alert以下信息: 您提供的密钥不是有效的百度LBS开放平台密钥,或此密钥未对本应用的百度地图JavaScriptAPI授权。您可以访问如下网址了解如何获取有效的密钥:http://lbsyun.baidu.com/apiconsole/key#。
17380
17514
  }, {
17381
17515
  key: "initBaidu",
17382
17516
  value: function () {
@@ -17390,7 +17524,6 @@ var MapService = /*#__PURE__*/function () {
17390
17524
  // console.log(e)
17391
17525
  // debugger
17392
17526
  _this2.BMap = window.BMap;
17393
- _this2.MapCore = window.BMap;
17394
17527
  // debugger
17395
17528
  // 启用google标准坐标体系
17396
17529
  // coordsType 指定输入输出的坐标类型,BMAP_COORD_GCJ02为gcj02坐标,BMAP_COORD_BD09为bd0ll坐标,默认为BMAP_COORD_BD09。
@@ -18048,13 +18181,13 @@ var getAddressByBmap = /*#__PURE__*/function () {
18048
18181
  var getLocationPromise = /*#__PURE__*/function () {
18049
18182
  var _ref17 = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee17() {
18050
18183
  var _window9;
18051
- var isuseiplocarion,
18184
+ var isuseiplocation,
18052
18185
  location,
18053
18186
  _args17 = arguments;
18054
18187
  return _regeneratorRuntime$1().wrap(function _callee17$(_context17) {
18055
18188
  while (1) switch (_context17.prev = _context17.next) {
18056
18189
  case 0:
18057
- isuseiplocarion = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : false;
18190
+ isuseiplocation = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : false;
18058
18191
  location = null; // 在 SPU 容器里使用 Native-API 的定位
18059
18192
  if (!((_window9 = window) !== null && _window9 !== void 0 && (_window9 = _window9.Native) !== null && _window9 !== void 0 && _window9.getLocation)) {
18060
18193
  _context17.next = 6;
@@ -18077,7 +18210,7 @@ var getLocationPromise = /*#__PURE__*/function () {
18077
18210
  return getLocationByAMap();
18078
18211
  case 10:
18079
18212
  location = _context17.sent;
18080
- if (!(!location && isuseiplocarion)) {
18213
+ if (!(!location && isuseiplocation)) {
18081
18214
  _context17.next = 15;
18082
18215
  break;
18083
18216
  }
@@ -18089,7 +18222,7 @@ var getLocationPromise = /*#__PURE__*/function () {
18089
18222
  _context17.next = 31;
18090
18223
  break;
18091
18224
  case 17:
18092
- if (!(mapService.type === 'tencent' && isuseiplocarion)) {
18225
+ if (!(mapService.type === 'tencent' && isuseiplocation)) {
18093
18226
  _context17.next = 23;
18094
18227
  break;
18095
18228
  }
@@ -18108,7 +18241,7 @@ var getLocationPromise = /*#__PURE__*/function () {
18108
18241
  return getLocationByBMap();
18109
18242
  case 26:
18110
18243
  location = _context17.sent;
18111
- if (!(!location && isuseiplocarion)) {
18244
+ if (!(!location && isuseiplocation)) {
18112
18245
  _context17.next = 31;
18113
18246
  break;
18114
18247
  }
@@ -18182,13 +18315,13 @@ function getLocation() {
18182
18315
  } // 逆地址解析
18183
18316
  function _getLocation() {
18184
18317
  _getLocation = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee20() {
18185
- var isuseiplocarion,
18318
+ var isuseiplocation,
18186
18319
  locationRes,
18187
18320
  _args20 = arguments;
18188
18321
  return _regeneratorRuntime$1().wrap(function _callee20$(_context20) {
18189
18322
  while (1) switch (_context20.prev = _context20.next) {
18190
18323
  case 0:
18191
- isuseiplocarion = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : false;
18324
+ isuseiplocation = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : false;
18192
18325
  _context20.next = 3;
18193
18326
  return mapService.init();
18194
18327
  case 3:
@@ -18206,7 +18339,7 @@ function _getLocation() {
18206
18339
  case 7:
18207
18340
  // console.log('runing')
18208
18341
  runing = true;
18209
- locationPromise = getLocationPromise(isuseiplocarion);
18342
+ locationPromise = getLocationPromise(isuseiplocation);
18210
18343
  _context20.next = 11;
18211
18344
  return locationPromise;
18212
18345
  case 11:
@@ -70182,6 +70315,7 @@ var getDefaultGlobalOptions = function getDefaultGlobalOptions() {
70182
70315
  modulekey: arr[1] || '',
70183
70316
  moduleversion: arr[2] || '',
70184
70317
  storageproxyprefix: '',
70318
+ isfixapptokenexpired: false,
70185
70319
  singleLoginCallback: null,
70186
70320
  router: null
70187
70321
  };
@@ -70205,7 +70339,7 @@ var install = function install(app, options) {
70205
70339
  console.log("@smart100/spu-web-plugin@".concat(version, " globalOptions"));
70206
70340
  console.log(globalOptions);
70207
70341
  // setTimeout(() => {
70208
- // console.error('5416546544')
70342
+ // console.error('9999')
70209
70343
  // }, 1000)
70210
70344
  // if (install.installed) return
70211
70345
  // install.installed = true
@@ -70226,4 +70360,4 @@ var SPUWebPlugin = {
70226
70360
  version: version
70227
70361
  };
70228
70362
 
70229
- export { AMapLoader, Module, normalAxios$1 as apaasAxios, normalAxios$1 as axios, checkLogin, index as components, SPUWebPlugin as default, downloadService, expandexp, functionCheck, getAddress, getCloudServ, getDistance, getLocation, getRefreshToken, getServToken, getToken, getTokenExpires, getUniqueid, getUser, v4 as getUuid, globalConfig, globalOptions, isInApp, isdebugger, isvirtuallocation, lsProxy, mapService, setTitle, singleLogin, spuAxios, spuConfig, ssProxy, updateToken, uploadService, wxworkSuite };
70363
+ export { AMapLoader, Module, normalAxios$1 as apaasAxios, normalAxios$1 as axios, checkLogin, index as components, SPUWebPlugin as default, downloadService, expandexp, functionCheck, getAddress, getCloudServ, getDistance, getLocation, getRefreshToken, getServToken, getServerTime, getToken, getTokenExpires, getUniqueid, getUser, v4 as getUuid, globalConfig, globalOptions, isInApp, isdebugger, isvirtuallocation, lsProxy, mapService, setTitle, singleLogin, spuAxios, spuConfig, ssProxy, updateToken, uploadService, wxworkSuite };