@smart100/spu-web-plugin 0.0.34 → 0.0.35
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.
- package/dist/index.d.ts +2 -2
- package/dist/spu-web-plugin.mjs +1287 -1177
- package/package.json +1 -1
- package/src/axios.ts +17 -2
- package/src/index.ts +8 -9
- package/src/login.ts +83 -22
- package/src/package/ali-oss/aliyun-oss-sdk.js +25121 -25121
- package/src/package/ali-oss/aliyun-oss-sdk.min.js +14 -14
- package/src/package/ali-oss/package.json +162 -162
- package/src/types/index.d.ts +2 -2
package/dist/spu-web-plugin.mjs
CHANGED
|
@@ -708,7 +708,7 @@ function _toPropertyKey$1(arg) {
|
|
|
708
708
|
return typeof key === "symbol" ? key : String(key);
|
|
709
709
|
}
|
|
710
710
|
|
|
711
|
-
var version = "0.0.
|
|
711
|
+
var version = "0.0.35";
|
|
712
712
|
|
|
713
713
|
/** Detect free variable `global` from Node.js. */
|
|
714
714
|
var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
|
|
@@ -12532,7 +12532,7 @@ var WxworksuiteTree = /*#__PURE__*/function (_LitElement) {
|
|
|
12532
12532
|
// 判断是否开启企微通信录支持,默认不开启
|
|
12533
12533
|
_this.iswwopendata = false;
|
|
12534
12534
|
// 控制通信录转移类型
|
|
12535
|
-
_this.wwopendatatype = ''; // userName | departmentName | expression
|
|
12535
|
+
_this.wwopendatatype = ''; // userName | departmentName | expression | ''
|
|
12536
12536
|
_this.valuekey = 'id'; // 默认id 也可定义别的属性值比如 codepath(被定义的属性值必须唯一)
|
|
12537
12537
|
_this.ismulselect = false;
|
|
12538
12538
|
_this.displaytype = 'mobile'; // web | mobile
|
|
@@ -13298,7 +13298,7 @@ var WxworksuiteOrganizationpickMobile = /*#__PURE__*/function (_LitElement) {
|
|
|
13298
13298
|
function WxworksuiteOrganizationpickMobile() {
|
|
13299
13299
|
var _this;
|
|
13300
13300
|
_classCallCheck(this, WxworksuiteOrganizationpickMobile);
|
|
13301
|
-
_this = _super.
|
|
13301
|
+
_this = _super.apply(this, arguments);
|
|
13302
13302
|
_this.displaytype = 'mobile';
|
|
13303
13303
|
_this.ismulselect = false;
|
|
13304
13304
|
_this.issearch = true;
|
|
@@ -13315,44 +13315,51 @@ var WxworksuiteOrganizationpickMobile = /*#__PURE__*/function (_LitElement) {
|
|
|
13315
13315
|
// disable 不能选非末级节点 只能选末级节点 暂不实现
|
|
13316
13316
|
_this.singleselectmode = 'normal';
|
|
13317
13317
|
_this._expandicon = 'organization';
|
|
13318
|
+
_this._isWxworkSuiteTenant = true;
|
|
13318
13319
|
_this._list = [];
|
|
13319
|
-
// axios.post('/api/teapi/dy-biz/100000000000000000/110000000000000000', {
|
|
13320
|
-
// pl_orgstruct: {
|
|
13321
|
-
// status: '1'
|
|
13322
|
-
// }
|
|
13323
|
-
// }).then((res: any) => {
|
|
13324
|
-
// // console.log(res)
|
|
13325
|
-
// const list = res?.data?.pl_orgstruct || []
|
|
13326
|
-
// list.forEach((item: any) => {
|
|
13327
|
-
// item.name = item.orgname
|
|
13328
|
-
// // item.name = '1'
|
|
13329
|
-
// item.id = item.orgstructid
|
|
13330
|
-
// item.pid = item.parentorgstructid
|
|
13331
|
-
// })
|
|
13332
|
-
// this._list = list
|
|
13333
|
-
// })
|
|
13334
|
-
normalAxios$1.post('/api/system/v1.0/org/page', {
|
|
13335
|
-
showchild: true,
|
|
13336
|
-
orgstructtypeid: 1,
|
|
13337
|
-
useRule: _this.userule,
|
|
13338
|
-
pageindex: 1,
|
|
13339
|
-
pagesize: 99999,
|
|
13340
|
-
getAllStatus: false // 是否获取全部数据(即包含禁用)
|
|
13341
|
-
}).then(function (res) {
|
|
13342
|
-
var _res$data;
|
|
13343
|
-
// console.log(res)
|
|
13344
|
-
var list = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
|
|
13345
|
-
list.forEach(function (item) {
|
|
13346
|
-
item.name = item.orgname;
|
|
13347
|
-
// item.name = '1'
|
|
13348
|
-
item.id = item.orgstructid;
|
|
13349
|
-
item.pid = item.parentorgstructid;
|
|
13350
|
-
});
|
|
13351
|
-
_this._list = list;
|
|
13352
|
-
});
|
|
13353
13320
|
return _this;
|
|
13354
13321
|
}
|
|
13355
13322
|
_createClass(WxworksuiteOrganizationpickMobile, [{
|
|
13323
|
+
key: "connectedCallback",
|
|
13324
|
+
value: function connectedCallback() {
|
|
13325
|
+
var _this2 = this;
|
|
13326
|
+
_get(_getPrototypeOf(WxworksuiteOrganizationpickMobile.prototype), "connectedCallback", this).call(this);
|
|
13327
|
+
// axios.post('/api/teapi/dy-biz/100000000000000000/110000000000000000', {
|
|
13328
|
+
// pl_orgstruct: {
|
|
13329
|
+
// status: '1'
|
|
13330
|
+
// }
|
|
13331
|
+
// }).then((res: any) => {
|
|
13332
|
+
// // console.log(res)
|
|
13333
|
+
// const list = res?.data?.pl_orgstruct || []
|
|
13334
|
+
// list.forEach((item: any) => {
|
|
13335
|
+
// item.name = item.orgname
|
|
13336
|
+
// // item.name = '1'
|
|
13337
|
+
// item.id = item.orgstructid
|
|
13338
|
+
// item.pid = item.parentorgstructid
|
|
13339
|
+
// })
|
|
13340
|
+
// this._list = list
|
|
13341
|
+
// })
|
|
13342
|
+
normalAxios$1.post('/api/system/v1.0/org/page', {
|
|
13343
|
+
showchild: true,
|
|
13344
|
+
orgstructtypeid: 1,
|
|
13345
|
+
useRule: this.userule,
|
|
13346
|
+
pageindex: 1,
|
|
13347
|
+
pagesize: 99999,
|
|
13348
|
+
getAllStatus: false // 是否获取全部数据(即包含禁用)
|
|
13349
|
+
}).then(function (res) {
|
|
13350
|
+
var _res$data;
|
|
13351
|
+
// console.log(res)
|
|
13352
|
+
var list = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
|
|
13353
|
+
list.forEach(function (item) {
|
|
13354
|
+
item.name = item.orgname;
|
|
13355
|
+
// item.name = '1'
|
|
13356
|
+
item.id = item.orgstructid;
|
|
13357
|
+
item.pid = item.parentorgstructid;
|
|
13358
|
+
});
|
|
13359
|
+
_this2._list = list;
|
|
13360
|
+
});
|
|
13361
|
+
}
|
|
13362
|
+
}, {
|
|
13356
13363
|
key: "treeRef",
|
|
13357
13364
|
get: function get() {
|
|
13358
13365
|
var _this$renderRoot$quer, _this$renderRoot;
|
|
@@ -13420,7 +13427,7 @@ var WxworksuiteOrganizationpickMobile = /*#__PURE__*/function (_LitElement) {
|
|
|
13420
13427
|
}, {
|
|
13421
13428
|
key: "render",
|
|
13422
13429
|
value: function render() {
|
|
13423
|
-
return x(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n <wxworksuite-tree\n wwopendatatype=\"
|
|
13430
|
+
return x(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n <wxworksuite-tree\n wwopendatatype=\"", "\"\n displaytype=\"", "\"\n expandicon=\"", "\"\n searchplaceholder=\"", "\"\n .issearch=\"", "\"\n .iswwopendata=\"", "\"\n .list=\"", "\"\n .ismulselect=\"", "\"\n singleselectmode=\"", "\"\n mulselectmode=\"", "\"\n @select=\"", "\"\n @check=\"", "\"\n ></wxworksuite-tree>\n "])), this._isWxworkSuiteTenant ? 'departmentName' : '', this.displaytype, this._expandicon, this.searchplaceholder, this.issearch, this._isWxworkSuiteTenant, this._list, this.ismulselect, this.singleselectmode, this.mulselectmode, this._handleSelect, this._handleCheck);
|
|
13424
13431
|
}
|
|
13425
13432
|
}], [{
|
|
13426
13433
|
key: "register",
|
|
@@ -13457,6 +13464,7 @@ __decorate([n$1({
|
|
|
13457
13464
|
type: String
|
|
13458
13465
|
})], WxworksuiteOrganizationpickMobile.prototype, "singleselectmode", void 0);
|
|
13459
13466
|
__decorate([r$1()], WxworksuiteOrganizationpickMobile.prototype, "_expandicon", void 0);
|
|
13467
|
+
__decorate([r$1()], WxworksuiteOrganizationpickMobile.prototype, "_isWxworkSuiteTenant", void 0);
|
|
13460
13468
|
__decorate([r$1()], WxworksuiteOrganizationpickMobile.prototype, "_list", void 0);
|
|
13461
13469
|
|
|
13462
13470
|
var _class$2;
|
|
@@ -13495,7 +13503,7 @@ var WxworksuiteMemberpickMobile = /*#__PURE__*/function (_LitElement) {
|
|
|
13495
13503
|
function WxworksuiteMemberpickMobile() {
|
|
13496
13504
|
var _this;
|
|
13497
13505
|
_classCallCheck(this, WxworksuiteMemberpickMobile);
|
|
13498
|
-
_this = _super.
|
|
13506
|
+
_this = _super.apply(this, arguments);
|
|
13499
13507
|
_this.displaytype = 'mobile';
|
|
13500
13508
|
_this.ismulselect = false;
|
|
13501
13509
|
_this.issearch = true;
|
|
@@ -13511,57 +13519,72 @@ var WxworksuiteMemberpickMobile = /*#__PURE__*/function (_LitElement) {
|
|
|
13511
13519
|
// normal 正常选中取值
|
|
13512
13520
|
// disable 不能选非末级节点 只能选末级节点 暂不实现
|
|
13513
13521
|
_this.singleselectmode = 'normal';
|
|
13522
|
+
_this._isWxworkSuiteTenant = true;
|
|
13514
13523
|
_this._list = [];
|
|
13515
|
-
// axios.post('/api/teapi/dy-biz/1032470355689738336/1273067686762516579', {
|
|
13516
|
-
// member: {
|
|
13517
|
-
// searchkey: '',
|
|
13518
|
-
// orglimit: '',
|
|
13519
|
-
// orgstructid: '',
|
|
13520
|
-
// email: '',
|
|
13521
|
-
// includechild: '1'
|
|
13522
|
-
// }
|
|
13523
|
-
// }).then((res: any) => {
|
|
13524
|
-
// // console.log(res)
|
|
13525
|
-
// const list = res?.data?.member || []
|
|
13526
|
-
// list.forEach((item: any, index: number) => {
|
|
13527
|
-
// item.name = `__$$wwopendata(${item.userinfoname}, userName)(${item.positionname})`
|
|
13528
|
-
// // item.name = `__$$wwopendata(${item.userinfoname}, userName)(${item.positionname})__$$wwopendata(哈哈+${index}, departmentName)`
|
|
13529
|
-
// item.id = item.memberid
|
|
13530
|
-
// item.pid = ''
|
|
13531
|
-
// item.iswwopendata = true
|
|
13532
|
-
// item.wwopendatatype = 'expression'
|
|
13533
|
-
// })
|
|
13534
|
-
// this._list = list
|
|
13535
|
-
// })
|
|
13536
|
-
normalAxios$1.post('/api/system/v1.0/member/getMemberList', {
|
|
13537
|
-
name: '',
|
|
13538
|
-
phoneNumber: '',
|
|
13539
|
-
saleAreaCodePath: '',
|
|
13540
|
-
positionName: '',
|
|
13541
|
-
pageindex: 1,
|
|
13542
|
-
pagesize: 99999,
|
|
13543
|
-
// useRule: false, // 使用数据权限
|
|
13544
|
-
// useRule: this.userule, // 使用数据权限
|
|
13545
|
-
appcode: 'sales',
|
|
13546
|
-
belongDistributorId: ''
|
|
13547
|
-
}).then(function (res) {
|
|
13548
|
-
var _res$data;
|
|
13549
|
-
// console.log(res)
|
|
13550
|
-
// debugger
|
|
13551
|
-
var list = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
|
|
13552
|
-
list.forEach(function (item, index) {
|
|
13553
|
-
item.name = "__$$wwopendata(".concat(item.userName, ", userName)(").concat(item.positionName, ")");
|
|
13554
|
-
// item.name = `__$$wwopendata(${item.userName}, userName)(${item.positionName})__$$wwopendata(哈哈+${index}, departmentName)`
|
|
13555
|
-
item.id = item.memberId;
|
|
13556
|
-
item.pid = '';
|
|
13557
|
-
item.iswwopendata = true;
|
|
13558
|
-
item.wwopendatatype = 'expression';
|
|
13559
|
-
});
|
|
13560
|
-
_this._list = list;
|
|
13561
|
-
});
|
|
13562
13524
|
return _this;
|
|
13563
13525
|
}
|
|
13564
13526
|
_createClass(WxworksuiteMemberpickMobile, [{
|
|
13527
|
+
key: "connectedCallback",
|
|
13528
|
+
value: function connectedCallback() {
|
|
13529
|
+
var _this2 = this;
|
|
13530
|
+
_get(_getPrototypeOf(WxworksuiteMemberpickMobile.prototype), "connectedCallback", this).call(this);
|
|
13531
|
+
// axios.post('/api/teapi/dy-biz/1032470355689738336/1273067686762516579', {
|
|
13532
|
+
// member: {
|
|
13533
|
+
// searchkey: '',
|
|
13534
|
+
// orglimit: '',
|
|
13535
|
+
// orgstructid: '',
|
|
13536
|
+
// email: '',
|
|
13537
|
+
// includechild: '1'
|
|
13538
|
+
// }
|
|
13539
|
+
// }).then((res: any) => {
|
|
13540
|
+
// // console.log(res)
|
|
13541
|
+
// const list = res?.data?.member || []
|
|
13542
|
+
// list.forEach((item: any, index: number) => {
|
|
13543
|
+
// item.name = `__$$wwopendata(${item.userinfoname}, userName)(${item.positionname})`
|
|
13544
|
+
// // item.name = `__$$wwopendata(${item.userinfoname}, userName)(${item.positionname})__$$wwopendata(哈哈+${index}, departmentName)`
|
|
13545
|
+
// item.id = item.memberid
|
|
13546
|
+
// item.pid = ''
|
|
13547
|
+
// item.iswwopendata = true
|
|
13548
|
+
// item.wwopendatatype = 'expression'
|
|
13549
|
+
// })
|
|
13550
|
+
// this._list = list
|
|
13551
|
+
// })
|
|
13552
|
+
// console.log('issearch', this.issearch)
|
|
13553
|
+
// console.log('userule', this.userule)
|
|
13554
|
+
// debugger
|
|
13555
|
+
this._isWxworkSuiteTenant = isWxworkSuiteTenant();
|
|
13556
|
+
// debugger
|
|
13557
|
+
normalAxios$1.post('/api/system/v1.0/member/getMemberList', {
|
|
13558
|
+
name: '',
|
|
13559
|
+
phoneNumber: '',
|
|
13560
|
+
saleAreaCodePath: '',
|
|
13561
|
+
positionName: '',
|
|
13562
|
+
pageindex: 1,
|
|
13563
|
+
pagesize: 99999,
|
|
13564
|
+
notUseRule: !this.userule,
|
|
13565
|
+
appcode: 'sales',
|
|
13566
|
+
belongDistributorId: ''
|
|
13567
|
+
}).then(function (res) {
|
|
13568
|
+
var _res$data;
|
|
13569
|
+
// console.log(res)
|
|
13570
|
+
// debugger
|
|
13571
|
+
var list = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
|
|
13572
|
+
list.forEach(function (item, index) {
|
|
13573
|
+
item.id = item.memberId;
|
|
13574
|
+
item.pid = '';
|
|
13575
|
+
if (_this2._isWxworkSuiteTenant) {
|
|
13576
|
+
item.name = "__$$wwopendata(".concat(item.userName, ", userName)(").concat(item.positionName, ")");
|
|
13577
|
+
// item.name = `__$$wwopendata(${item.userName}, userName)(${item.positionName})__$$wwopendata(哈哈+${index}, departmentName)`
|
|
13578
|
+
item.iswwopendata = true;
|
|
13579
|
+
item.wwopendatatype = 'expression';
|
|
13580
|
+
} else {
|
|
13581
|
+
item.name = "".concat(item.userName, "(").concat(item.positionName, ")");
|
|
13582
|
+
}
|
|
13583
|
+
});
|
|
13584
|
+
_this2._list = list;
|
|
13585
|
+
});
|
|
13586
|
+
}
|
|
13587
|
+
}, {
|
|
13565
13588
|
key: "treeRef",
|
|
13566
13589
|
get: function get() {
|
|
13567
13590
|
var _this$renderRoot$quer, _this$renderRoot;
|
|
@@ -13629,7 +13652,7 @@ var WxworksuiteMemberpickMobile = /*#__PURE__*/function (_LitElement) {
|
|
|
13629
13652
|
}, {
|
|
13630
13653
|
key: "render",
|
|
13631
13654
|
value: function render() {
|
|
13632
|
-
return x(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n <wxworksuite-tree\n wwopendatatype=\"
|
|
13655
|
+
return x(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n <wxworksuite-tree\n wwopendatatype=\"", "\"\n displaytype=\"", "\"\n expandicon=\"normal\"\n searchplaceholder=\"", "\"\n .issearch=\"", "\"\n .iswwopendata=\"", "\"\n .list=\"", "\"\n .ismulselect=\"", "\"\n singleselectmode=\"", "\"\n mulselectmode=\"", "\"\n @select=\"", "\"\n @check=\"", "\"\n ></wxworksuite-tree>\n "])), this._isWxworkSuiteTenant ? 'expression' : '', this.displaytype, this.searchplaceholder, this.issearch, this._isWxworkSuiteTenant, this._list, this.ismulselect, this.singleselectmode, this.mulselectmode, this._handleSelect, this._handleCheck);
|
|
13633
13656
|
}
|
|
13634
13657
|
}], [{
|
|
13635
13658
|
key: "register",
|
|
@@ -13665,6 +13688,7 @@ __decorate([n$1({
|
|
|
13665
13688
|
__decorate([n$1({
|
|
13666
13689
|
type: String
|
|
13667
13690
|
})], WxworksuiteMemberpickMobile.prototype, "singleselectmode", void 0);
|
|
13691
|
+
__decorate([r$1()], WxworksuiteMemberpickMobile.prototype, "_isWxworkSuiteTenant", void 0);
|
|
13668
13692
|
__decorate([r$1()], WxworksuiteMemberpickMobile.prototype, "_list", void 0);
|
|
13669
13693
|
|
|
13670
13694
|
var _class;
|
|
@@ -17637,474 +17661,1200 @@ var Loadding = /*#__PURE__*/function () {
|
|
|
17637
17661
|
}();
|
|
17638
17662
|
var loadding = new Loadding();
|
|
17639
17663
|
|
|
17640
|
-
var
|
|
17641
|
-
var hostname = url.split('://')[1].split(':')[0].split('/')[0];
|
|
17642
|
-
var arr = hostname.split('.');
|
|
17643
|
-
if (arr.length !== 4) return false;
|
|
17644
|
-
var flag = true;
|
|
17645
|
-
for (var i = 0, len = arr.length; i < len; i++) {
|
|
17646
|
-
if (!Number.isInteger(Number(arr[i]))) {
|
|
17647
|
-
flag = false;
|
|
17648
|
-
break;
|
|
17649
|
-
}
|
|
17650
|
-
}
|
|
17651
|
-
return flag;
|
|
17652
|
-
};
|
|
17664
|
+
function e(e){this.message=e;}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,a=0,i=0,c="";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw "Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t})))}(t)}catch(e){return r(t)}}function n(e){this.message=e;}function o(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";
|
|
17653
17665
|
|
|
17654
|
-
|
|
17655
|
-
|
|
17656
|
-
|
|
17657
|
-
|
|
17658
|
-
|
|
17659
|
-
var arr = res.split('//');
|
|
17660
|
-
arr[0] = location.protocol;
|
|
17661
|
-
res = arr.join('//');
|
|
17662
|
-
}
|
|
17663
|
-
}
|
|
17664
|
-
return res;
|
|
17665
|
-
};
|
|
17666
|
-
var Core = /*#__PURE__*/function () {
|
|
17667
|
-
function Core() {
|
|
17668
|
-
_classCallCheck$1(this, Core);
|
|
17669
|
-
_defineProperty$1(this, "loadStatus", 0);
|
|
17670
|
-
// 0未开始 1正在加载 2加载完成
|
|
17671
|
-
_defineProperty$1(this, "cache", {
|
|
17672
|
-
envName: '',
|
|
17673
|
-
envData: null,
|
|
17674
|
-
tenantCode: '',
|
|
17675
|
-
webDefineData: null
|
|
17676
|
-
});
|
|
17677
|
-
_defineProperty$1(this, "requestDataPromise", null);
|
|
17666
|
+
var CloudServ = /*#__PURE__*/function () {
|
|
17667
|
+
function CloudServ() {
|
|
17668
|
+
_classCallCheck$1(this, CloudServ);
|
|
17669
|
+
_defineProperty$1(this, "CLOUD_SERVE_KEY", 'cloudserv');
|
|
17670
|
+
_defineProperty$1(this, "cacheStorage", null);
|
|
17678
17671
|
}
|
|
17679
|
-
_createClass$1(
|
|
17680
|
-
key: "
|
|
17681
|
-
value: function
|
|
17682
|
-
|
|
17683
|
-
this.
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
|
|
17689
|
-
|
|
17672
|
+
_createClass$1(CloudServ, [{
|
|
17673
|
+
key: "get",
|
|
17674
|
+
value: function get() {
|
|
17675
|
+
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17676
|
+
if (this.cacheStorage) {
|
|
17677
|
+
return this.cacheStorage[key] || null;
|
|
17678
|
+
}
|
|
17679
|
+
var storageStr = lsProxy.getItem(this.CLOUD_SERVE_KEY);
|
|
17680
|
+
if (!storageStr) {
|
|
17681
|
+
return null;
|
|
17682
|
+
}
|
|
17683
|
+
var storage = JSON.parse(storageStr);
|
|
17684
|
+
this.cacheStorage = storage;
|
|
17685
|
+
return storage[key];
|
|
17690
17686
|
}
|
|
17691
|
-
|
|
17692
|
-
// 请求实时G3数据
|
|
17693
17687
|
}, {
|
|
17694
|
-
key: "
|
|
17695
|
-
value: function () {
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
while (1) switch (_context.prev = _context.next) {
|
|
17700
|
-
case 0:
|
|
17701
|
-
_context.next = 2;
|
|
17702
|
-
return Module.getEnvname();
|
|
17703
|
-
case 2:
|
|
17704
|
-
nowEnvname = _context.sent;
|
|
17705
|
-
nowTenantCode = getUser('tenantcode') || '';
|
|
17706
|
-
this.cache.envName = nowEnvname;
|
|
17707
|
-
this.cache.tenantCode = nowTenantCode;
|
|
17708
|
-
_context.next = 8;
|
|
17709
|
-
return this.requestEnvData(nowEnvname);
|
|
17710
|
-
case 8:
|
|
17711
|
-
this.cache.envData = _context.sent;
|
|
17712
|
-
_context.next = 11;
|
|
17713
|
-
return this.requestWebDefineData();
|
|
17714
|
-
case 11:
|
|
17715
|
-
this.cache.webDefineData = _context.sent;
|
|
17716
|
-
return _context.abrupt("return", this.cache);
|
|
17717
|
-
case 13:
|
|
17718
|
-
case "end":
|
|
17719
|
-
return _context.stop();
|
|
17720
|
-
}
|
|
17721
|
-
}, _callee, this);
|
|
17722
|
-
}));
|
|
17723
|
-
function requestData() {
|
|
17724
|
-
return _requestData.apply(this, arguments);
|
|
17688
|
+
key: "set",
|
|
17689
|
+
value: function set(storage) {
|
|
17690
|
+
if (_typeof(storage) === 'object') {
|
|
17691
|
+
this.cacheStorage = storage;
|
|
17692
|
+
storage = JSON.stringify(storage);
|
|
17725
17693
|
}
|
|
17726
|
-
|
|
17727
|
-
}
|
|
17694
|
+
lsProxy.setItem(this.CLOUD_SERVE_KEY, storage);
|
|
17695
|
+
}
|
|
17728
17696
|
}, {
|
|
17729
|
-
key: "
|
|
17697
|
+
key: "remove",
|
|
17698
|
+
value: function remove() {
|
|
17699
|
+
lsProxy.removeItem(this.CLOUD_SERVE_KEY);
|
|
17700
|
+
}
|
|
17701
|
+
}, {
|
|
17702
|
+
key: "getProvider",
|
|
17703
|
+
value: function getProvider() {
|
|
17704
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17705
|
+
var storage = this.get(sign);
|
|
17706
|
+
if (!storage) {
|
|
17707
|
+
return false;
|
|
17708
|
+
}
|
|
17709
|
+
return storage.cloudserv_storage_provider;
|
|
17710
|
+
}
|
|
17711
|
+
}, {
|
|
17712
|
+
key: "isAliyun",
|
|
17713
|
+
value: function isAliyun() {
|
|
17714
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17715
|
+
return this.getProvider(sign) === 'aliyun';
|
|
17716
|
+
}
|
|
17717
|
+
}, {
|
|
17718
|
+
key: "isAzure",
|
|
17719
|
+
value: function isAzure() {
|
|
17720
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17721
|
+
return this.getProvider(sign) === 'azure';
|
|
17722
|
+
}
|
|
17723
|
+
}, {
|
|
17724
|
+
key: "isAwss3",
|
|
17725
|
+
value: function isAwss3() {
|
|
17726
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17727
|
+
return this.getProvider(sign) === 'awss3';
|
|
17728
|
+
}
|
|
17729
|
+
}, {
|
|
17730
|
+
key: "isHuawei",
|
|
17731
|
+
value: function isHuawei() {
|
|
17732
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17733
|
+
return this.getProvider(sign) === 'huawei';
|
|
17734
|
+
}
|
|
17735
|
+
}]);
|
|
17736
|
+
return CloudServ;
|
|
17737
|
+
}();
|
|
17738
|
+
var CloudServ$1 = new CloudServ();
|
|
17739
|
+
|
|
17740
|
+
var Login = /*#__PURE__*/function () {
|
|
17741
|
+
function Login() {
|
|
17742
|
+
_classCallCheck$1(this, Login);
|
|
17743
|
+
_defineProperty$1(this, "cache", {});
|
|
17744
|
+
_defineProperty$1(this, "refreshtokenTimer", null);
|
|
17745
|
+
}
|
|
17746
|
+
_createClass$1(Login, [{
|
|
17747
|
+
key: "getData",
|
|
17748
|
+
value: function getData(key) {
|
|
17749
|
+
if (this.cache[key]) {
|
|
17750
|
+
return this.cache[key];
|
|
17751
|
+
} else {
|
|
17752
|
+
var data = lsProxy.getItem(key);
|
|
17753
|
+
this.cache[key] = data;
|
|
17754
|
+
return data;
|
|
17755
|
+
}
|
|
17756
|
+
}
|
|
17757
|
+
}, {
|
|
17758
|
+
key: "setData",
|
|
17759
|
+
value: function setData(key, value) {
|
|
17760
|
+
this.cache[key] = value;
|
|
17761
|
+
lsProxy.setItem(key, value);
|
|
17762
|
+
}
|
|
17763
|
+
}, {
|
|
17764
|
+
key: "removeData",
|
|
17765
|
+
value: function removeData(key) {
|
|
17766
|
+
delete this.cache[key];
|
|
17767
|
+
lsProxy.removeItem(key);
|
|
17768
|
+
}
|
|
17769
|
+
}, {
|
|
17770
|
+
key: "getEnvname",
|
|
17730
17771
|
value: function () {
|
|
17731
|
-
var
|
|
17732
|
-
var
|
|
17733
|
-
|
|
17772
|
+
var _getEnvname = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
17773
|
+
var _context, _window, _window2;
|
|
17774
|
+
var envname, context, contextEnvname, queryEnvname;
|
|
17775
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context2) {
|
|
17734
17776
|
while (1) switch (_context2.prev = _context2.next) {
|
|
17735
17777
|
case 0:
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17778
|
+
envname = ''; // web 查 context 的 envname
|
|
17779
|
+
context = lsProxy.getItem('context');
|
|
17780
|
+
context && (context = JSON.parse(context));
|
|
17781
|
+
contextEnvname = ((_context = context) === null || _context === void 0 ? void 0 : _context.envname) || ''; // 链接有些spu可能会传 envname
|
|
17782
|
+
queryEnvname = this.getQueryEnvname();
|
|
17783
|
+
if (!contextEnvname) {
|
|
17784
|
+
_context2.next = 9;
|
|
17740
17785
|
break;
|
|
17741
17786
|
}
|
|
17742
|
-
|
|
17743
|
-
_context2.
|
|
17744
|
-
_context2.next = 6;
|
|
17745
|
-
return normalAxios.get("".concat(hostsRoot, "/multiplatconfig/env/").concat(envName), {
|
|
17746
|
-
isShowLoading: false,
|
|
17747
|
-
isSendToken: false
|
|
17748
|
-
});
|
|
17749
|
-
case 6:
|
|
17750
|
-
response = _context2.sent;
|
|
17751
|
-
// console.log(response)
|
|
17752
|
-
// debugger
|
|
17753
|
-
result = get$1(response, 'data.0');
|
|
17754
|
-
|
|
17755
|
-
// 如果是非ip地址 则切换为与主页面一样的 location.protocol 前缀
|
|
17756
|
-
((_result = result) === null || _result === void 0 ? void 0 : _result.business) && (result.business = toggleHttpOrHttps(result.business));
|
|
17757
|
-
((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.smartcenter) && (result.smartcenter = toggleHttpOrHttps(result.smartcenter));
|
|
17758
|
-
_context2.next = 15;
|
|
17787
|
+
envname = contextEnvname;
|
|
17788
|
+
_context2.next = 17;
|
|
17759
17789
|
break;
|
|
17760
|
-
case
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
console.error(_context2.t0);
|
|
17764
|
-
case 15:
|
|
17765
|
-
return _context2.abrupt("return", result);
|
|
17766
|
-
case 16:
|
|
17767
|
-
case "end":
|
|
17768
|
-
return _context2.stop();
|
|
17769
|
-
}
|
|
17770
|
-
}, _callee2, null, [[3, 12]]);
|
|
17771
|
-
}));
|
|
17772
|
-
function requestEnvData(_x) {
|
|
17773
|
-
return _requestEnvData.apply(this, arguments);
|
|
17774
|
-
}
|
|
17775
|
-
return requestEnvData;
|
|
17776
|
-
}()
|
|
17777
|
-
}, {
|
|
17778
|
-
key: "requestWebDefineData",
|
|
17779
|
-
value: function () {
|
|
17780
|
-
var _requestWebDefineData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
|
|
17781
|
-
var _this$cache$envData, _this$cache;
|
|
17782
|
-
var envId, tenantCode, smartcenter, result, _res, res, list, usedList;
|
|
17783
|
-
return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
|
|
17784
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
17785
|
-
case 0:
|
|
17786
|
-
envId = (_this$cache$envData = this.cache.envData) === null || _this$cache$envData === void 0 ? void 0 : _this$cache$envData.envid;
|
|
17787
|
-
tenantCode = this.cache.tenantCode;
|
|
17788
|
-
smartcenter = (_this$cache = this.cache) === null || _this$cache === void 0 || (_this$cache = _this$cache.envData) === null || _this$cache === void 0 ? void 0 : _this$cache.smartcenter;
|
|
17789
|
-
result = null;
|
|
17790
|
-
if (!(envId && tenantCode && smartcenter)) {
|
|
17791
|
-
_context3.next = 16;
|
|
17790
|
+
case 9:
|
|
17791
|
+
if (!queryEnvname) {
|
|
17792
|
+
_context2.next = 13;
|
|
17792
17793
|
break;
|
|
17793
17794
|
}
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
return normalAxios.post("".concat(smartcenter, "/api/smartcenter/biz/getTenantWebAndApiDefined"), {
|
|
17797
|
-
envid: envId,
|
|
17798
|
-
tenantcode: tenantCode
|
|
17799
|
-
}, {
|
|
17800
|
-
isShowLoading: false
|
|
17801
|
-
});
|
|
17802
|
-
case 8:
|
|
17803
|
-
res = _context3.sent;
|
|
17804
|
-
_context3.next = 14;
|
|
17795
|
+
envname = queryEnvname;
|
|
17796
|
+
_context2.next = 17;
|
|
17805
17797
|
break;
|
|
17806
|
-
case
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
case 14:
|
|
17811
|
-
// console.log(res)
|
|
17812
|
-
// debugger
|
|
17813
|
-
list = ((_res = res) === null || _res === void 0 || (_res = _res.data) === null || _res === void 0 ? void 0 : _res.list) || [];
|
|
17814
|
-
if (list && list.length) {
|
|
17815
|
-
usedList = list.filter(function (item) {
|
|
17816
|
-
return item.status === 1;
|
|
17817
|
-
});
|
|
17818
|
-
usedList.forEach(function (item) {
|
|
17819
|
-
if (item.protocol) {
|
|
17820
|
-
try {
|
|
17821
|
-
item.protocol = JSON.parse(item.protocol);
|
|
17822
|
-
} catch (err) {
|
|
17823
|
-
console.error(err);
|
|
17824
|
-
}
|
|
17825
|
-
}
|
|
17826
|
-
if (item.apiprotocol) {
|
|
17827
|
-
try {
|
|
17828
|
-
item.apiprotocol = JSON.parse(item.apiprotocol);
|
|
17829
|
-
} catch (err) {
|
|
17830
|
-
console.error(err);
|
|
17831
|
-
}
|
|
17832
|
-
}
|
|
17833
|
-
});
|
|
17834
|
-
result = usedList;
|
|
17798
|
+
case 13:
|
|
17799
|
+
if (!((_window = window) !== null && _window !== void 0 && (_window = _window.aPaaS) !== null && _window !== void 0 && _window.getWebInitParams && (_window2 = window) !== null && _window2 !== void 0 && (_window2 = _window2.Native) !== null && _window2 !== void 0 && _window2.setNavigationBarReturnButton)) {
|
|
17800
|
+
_context2.next = 17;
|
|
17801
|
+
break;
|
|
17835
17802
|
}
|
|
17803
|
+
_context2.next = 16;
|
|
17804
|
+
return new Promise(function (resolve, reject) {
|
|
17805
|
+
window.aPaaS.getWebInitParams(function (params) {
|
|
17806
|
+
resolve((params === null || params === void 0 ? void 0 : params.envname) || '');
|
|
17807
|
+
});
|
|
17808
|
+
});
|
|
17836
17809
|
case 16:
|
|
17837
|
-
|
|
17810
|
+
envname = _context2.sent;
|
|
17838
17811
|
case 17:
|
|
17812
|
+
return _context2.abrupt("return", envname);
|
|
17813
|
+
case 18:
|
|
17839
17814
|
case "end":
|
|
17840
|
-
return
|
|
17815
|
+
return _context2.stop();
|
|
17841
17816
|
}
|
|
17842
|
-
},
|
|
17817
|
+
}, _callee, this);
|
|
17843
17818
|
}));
|
|
17844
|
-
function
|
|
17845
|
-
return
|
|
17819
|
+
function getEnvname() {
|
|
17820
|
+
return _getEnvname.apply(this, arguments);
|
|
17846
17821
|
}
|
|
17847
|
-
return
|
|
17822
|
+
return getEnvname;
|
|
17848
17823
|
}()
|
|
17849
17824
|
}, {
|
|
17850
|
-
key: "
|
|
17851
|
-
value: function () {
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17825
|
+
key: "setQueryEnvname",
|
|
17826
|
+
value: function setQueryEnvname(value) {
|
|
17827
|
+
this.setData('envname', value);
|
|
17828
|
+
}
|
|
17829
|
+
}, {
|
|
17830
|
+
key: "getQueryEnvname",
|
|
17831
|
+
value: function getQueryEnvname() {
|
|
17832
|
+
return this.getData('envname') || '';
|
|
17833
|
+
}
|
|
17834
|
+
}, {
|
|
17835
|
+
key: "removeQueryEnvname",
|
|
17836
|
+
value: function removeQueryEnvname() {
|
|
17837
|
+
this.removeData('envname');
|
|
17838
|
+
}
|
|
17839
|
+
}, {
|
|
17840
|
+
key: "getToken",
|
|
17841
|
+
value: function getToken() {
|
|
17842
|
+
return this.getData('token');
|
|
17843
|
+
// return lsProxy.getItem('token') as string
|
|
17844
|
+
}
|
|
17845
|
+
}, {
|
|
17846
|
+
key: "setToken",
|
|
17847
|
+
value: function setToken(value) {
|
|
17848
|
+
this.setData('token', value);
|
|
17849
|
+
}
|
|
17850
|
+
}, {
|
|
17851
|
+
key: "removeToken",
|
|
17852
|
+
value: function removeToken() {
|
|
17853
|
+
this.removeData('token');
|
|
17854
|
+
}
|
|
17855
|
+
}, {
|
|
17856
|
+
key: "getTokenExpires",
|
|
17857
|
+
value: function getTokenExpires() {
|
|
17858
|
+
return this.getData('tokenexpires');
|
|
17859
|
+
}
|
|
17860
|
+
}, {
|
|
17861
|
+
key: "setTokenExpires",
|
|
17862
|
+
value: function setTokenExpires(value) {
|
|
17863
|
+
this.setData('tokenexpires', value);
|
|
17864
|
+
}
|
|
17865
|
+
}, {
|
|
17866
|
+
key: "removeTokenExpires",
|
|
17867
|
+
value: function removeTokenExpires() {
|
|
17868
|
+
this.removeData('tokenexpires');
|
|
17869
|
+
}
|
|
17870
|
+
}, {
|
|
17871
|
+
key: "getRefreshToken",
|
|
17872
|
+
value: function getRefreshToken() {
|
|
17873
|
+
return this.getData('refreshtoken');
|
|
17874
|
+
// return lsProxy.getItem('refreshtoken') as string
|
|
17875
|
+
}
|
|
17876
|
+
}, {
|
|
17877
|
+
key: "setRefreshToken",
|
|
17878
|
+
value: function setRefreshToken(value) {
|
|
17879
|
+
this.setData('refreshtoken', value);
|
|
17880
|
+
}
|
|
17881
|
+
}, {
|
|
17882
|
+
key: "removeRefreshToken",
|
|
17883
|
+
value: function removeRefreshToken() {
|
|
17884
|
+
this.removeData('refreshtoken');
|
|
17885
|
+
}
|
|
17886
|
+
}, {
|
|
17887
|
+
key: "updateToken",
|
|
17888
|
+
value: function updateToken() {
|
|
17889
|
+
var _this = this;
|
|
17890
|
+
// 如果是产品运营中心 则不走刷新token流程
|
|
17891
|
+
if (this.checkLogin() && this.getRole() === 'center') {
|
|
17892
|
+
console.warn('当前登录为产品运营中心用户,不支持自动刷新token。');
|
|
17893
|
+
return false;
|
|
17894
|
+
}
|
|
17895
|
+
var token = this.getToken();
|
|
17896
|
+
var refreshtoken = this.getRefreshToken();
|
|
17897
|
+
var sendToken = this.checkLoginByToken(token) ? token : refreshtoken;
|
|
17898
|
+
return normalAxios.get('/api/auth/refreshtoken', {
|
|
17899
|
+
params: {
|
|
17900
|
+
refreshtoken: sendToken
|
|
17901
|
+
},
|
|
17902
|
+
isShowLoadding: false,
|
|
17903
|
+
isShowErrorMessage: false,
|
|
17904
|
+
isSendToken: false,
|
|
17905
|
+
headers: {
|
|
17906
|
+
token: sendToken
|
|
17907
|
+
}
|
|
17908
|
+
}).then(function (res) {
|
|
17909
|
+
// console.log(res)
|
|
17910
|
+
var data = res === null || res === void 0 ? void 0 : res.data;
|
|
17911
|
+
if (data) {
|
|
17912
|
+
_this.setToken(data.token);
|
|
17913
|
+
_this.setRefreshToken(data.refreshtoken);
|
|
17914
|
+
_this.setTokenExpires(data.tokenexpires);
|
|
17915
|
+
}
|
|
17916
|
+
});
|
|
17917
|
+
}
|
|
17918
|
+
}, {
|
|
17919
|
+
key: "startRefreshtoken",
|
|
17920
|
+
value: function startRefreshtoken() {
|
|
17921
|
+
var _this2 = this;
|
|
17922
|
+
// 如果是产品运营中心 则不走刷新token流程
|
|
17923
|
+
if (this.checkLogin() && this.getRole() === 'center') {
|
|
17924
|
+
console.warn('当前登录为产品运营中心用户,不支持自动刷新token。');
|
|
17925
|
+
return false;
|
|
17926
|
+
}
|
|
17927
|
+
this.stopRefreshtoken();
|
|
17928
|
+
// 如果有登录 但 refreshtoken 不是完整 token 则10秒后【需要等单点登录走完后才刷新不然会被覆盖】刷新一次取到完整 token
|
|
17929
|
+
// 如果有登录 且 refreshtoken 是完整 token 如果剩余时间大于10分钟 则每隔10分钟刷一次 否则过期前15秒更新 token
|
|
17930
|
+
// 如果没登录 每隔1分钟走token更新逻辑(如果刚开始没登录 后面才登录【不需要再在登陆后写刷新token逻辑】)
|
|
17931
|
+
var time = 0;
|
|
17932
|
+
if (this.checkLogin()) {
|
|
17933
|
+
var user = this.getUserByToken(this.getRefreshToken());
|
|
17934
|
+
if (user !== null && user !== void 0 && user.tokenId) {
|
|
17935
|
+
time = Number(this.getTokenExpires()) - Date.now() - 1000 * 15;
|
|
17936
|
+
// 如果剩余时间大于10分钟 则每隔10分钟刷一次
|
|
17937
|
+
if (time > 600000) {
|
|
17938
|
+
time = 600000;
|
|
17939
|
+
} else if (time < 0) {
|
|
17940
|
+
time = 0;
|
|
17941
|
+
}
|
|
17942
|
+
} else {
|
|
17943
|
+
time = 10000;
|
|
17944
|
+
}
|
|
17945
|
+
} else {
|
|
17946
|
+
time = 60000;
|
|
17947
|
+
}
|
|
17948
|
+
// time = 5000
|
|
17949
|
+
this.refreshtokenTimer = window.setTimeout( /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2() {
|
|
17950
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context3) {
|
|
17951
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
17856
17952
|
case 0:
|
|
17857
|
-
|
|
17858
|
-
|
|
17859
|
-
case 2:
|
|
17860
|
-
nowEnvname = _context4.sent;
|
|
17861
|
-
nowTenantCode = getUser('tenantcode') || ''; // console.log(tenantCode)
|
|
17862
|
-
if (!(this.cache.envName === nowEnvname && this.cache.tenantCode === nowTenantCode && this.loadStatus === 2)) {
|
|
17863
|
-
_context4.next = 6;
|
|
17864
|
-
break;
|
|
17865
|
-
}
|
|
17866
|
-
return _context4.abrupt("return", this.cache);
|
|
17867
|
-
case 6:
|
|
17868
|
-
if (!(this.loadStatus === 1 && this.requestDataPromise)) {
|
|
17869
|
-
_context4.next = 8;
|
|
17953
|
+
if (!_this2.checkLogin()) {
|
|
17954
|
+
_context3.next = 3;
|
|
17870
17955
|
break;
|
|
17871
17956
|
}
|
|
17872
|
-
|
|
17873
|
-
|
|
17874
|
-
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
return this.requestDataPromise;
|
|
17878
|
-
case 12:
|
|
17879
|
-
this.loadStatus = 2;
|
|
17880
|
-
return _context4.abrupt("return", this.cache);
|
|
17881
|
-
case 14:
|
|
17957
|
+
_context3.next = 3;
|
|
17958
|
+
return _this2.updateToken();
|
|
17959
|
+
case 3:
|
|
17960
|
+
_this2.startRefreshtoken();
|
|
17961
|
+
case 4:
|
|
17882
17962
|
case "end":
|
|
17883
|
-
return
|
|
17963
|
+
return _context3.stop();
|
|
17884
17964
|
}
|
|
17885
|
-
},
|
|
17886
|
-
}));
|
|
17887
|
-
|
|
17888
|
-
return _getData.apply(this, arguments);
|
|
17889
|
-
}
|
|
17890
|
-
return getData;
|
|
17891
|
-
}()
|
|
17965
|
+
}, _callee2);
|
|
17966
|
+
})), time);
|
|
17967
|
+
}
|
|
17892
17968
|
}, {
|
|
17893
|
-
key: "
|
|
17894
|
-
value: function () {
|
|
17895
|
-
|
|
17896
|
-
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
data = _context5.sent;
|
|
17908
|
-
if (!data.envName) {
|
|
17909
|
-
res.errorMsg = '找不到租户环境名称,请检查登录时是否有填写企业名称。';
|
|
17910
|
-
} else if (!data.envData) {
|
|
17911
|
-
res.errorMsg = '找不到租户环境信息。';
|
|
17912
|
-
} else {
|
|
17913
|
-
res.data = data.envData;
|
|
17914
|
-
}
|
|
17915
|
-
return _context5.abrupt("return", res);
|
|
17916
|
-
case 6:
|
|
17917
|
-
case "end":
|
|
17918
|
-
return _context5.stop();
|
|
17919
|
-
}
|
|
17920
|
-
}, _callee5, this);
|
|
17921
|
-
}));
|
|
17922
|
-
function getEnvData() {
|
|
17923
|
-
return _getEnvData.apply(this, arguments);
|
|
17969
|
+
key: "stopRefreshtoken",
|
|
17970
|
+
value: function stopRefreshtoken() {
|
|
17971
|
+
clearTimeout(this.refreshtokenTimer);
|
|
17972
|
+
this.refreshtokenTimer = null;
|
|
17973
|
+
}
|
|
17974
|
+
}, {
|
|
17975
|
+
key: "getUser",
|
|
17976
|
+
value: function getUser(key) {
|
|
17977
|
+
var user = this.getData('user');
|
|
17978
|
+
var userObj = user ? JSON.parse(user) : null;
|
|
17979
|
+
if (!key) {
|
|
17980
|
+
return userObj;
|
|
17981
|
+
} else {
|
|
17982
|
+
return userObj ? userObj[key] || '' : '';
|
|
17924
17983
|
}
|
|
17925
|
-
|
|
17926
|
-
}()
|
|
17984
|
+
}
|
|
17927
17985
|
}, {
|
|
17928
|
-
key: "
|
|
17929
|
-
value: function () {
|
|
17930
|
-
var
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17986
|
+
key: "setUser",
|
|
17987
|
+
value: function setUser(value) {
|
|
17988
|
+
var res;
|
|
17989
|
+
if (typeof value === 'string') {
|
|
17990
|
+
res = JSON.parse(value);
|
|
17991
|
+
} else {
|
|
17992
|
+
res = cloneDeep$1(value);
|
|
17993
|
+
}
|
|
17994
|
+
for (var x in res) {
|
|
17995
|
+
res[x.toLowerCase()] = res[x];
|
|
17996
|
+
}
|
|
17997
|
+
this.setData('user', JSON.stringify(res));
|
|
17998
|
+
}
|
|
17999
|
+
}, {
|
|
18000
|
+
key: "setUserByToken",
|
|
18001
|
+
value: function setUserByToken(token) {
|
|
18002
|
+
var user = this.getUserByToken(token);
|
|
18003
|
+
if (user) {
|
|
18004
|
+
this.setUser(user);
|
|
18005
|
+
} else {
|
|
18006
|
+
this.removeUser();
|
|
18007
|
+
}
|
|
18008
|
+
}
|
|
18009
|
+
}, {
|
|
18010
|
+
key: "getUserByToken",
|
|
18011
|
+
value: function getUserByToken(token) {
|
|
18012
|
+
var jwtInfo = this.jwtDecode(token);
|
|
18013
|
+
if (jwtInfo && jwtInfo.LoginUser) {
|
|
18014
|
+
return jwtInfo.LoginUser;
|
|
18015
|
+
} else {
|
|
18016
|
+
return null;
|
|
18017
|
+
}
|
|
18018
|
+
}
|
|
18019
|
+
}, {
|
|
18020
|
+
key: "removeUser",
|
|
18021
|
+
value: function removeUser() {
|
|
18022
|
+
this.removeData('user');
|
|
18023
|
+
}
|
|
18024
|
+
}, {
|
|
18025
|
+
key: "jwtDecode",
|
|
18026
|
+
value: function jwtDecode(token) {
|
|
18027
|
+
if (!token) {
|
|
18028
|
+
console.error('token为空 jwt解析token出错');
|
|
18029
|
+
return null;
|
|
18030
|
+
}
|
|
18031
|
+
try {
|
|
18032
|
+
return o(token);
|
|
18033
|
+
} catch (e) {
|
|
18034
|
+
console.error('jwt解析token出错', token, e);
|
|
18035
|
+
return null;
|
|
18036
|
+
}
|
|
18037
|
+
}
|
|
18038
|
+
// // 产品运营中心token
|
|
18039
|
+
// {
|
|
18040
|
+
// "LoginUser": {
|
|
18041
|
+
// "appId": "100",
|
|
18042
|
+
// "tenantCode": "1656652",
|
|
18043
|
+
// "productCode": "100000000000000000",
|
|
18044
|
+
// "productVersionCode": null,
|
|
18045
|
+
// "clientTypeCode": null,
|
|
18046
|
+
// "userCode": "6",
|
|
18047
|
+
// "accountCode": "6",
|
|
18048
|
+
// "username": "庄焕滨",
|
|
18049
|
+
// "tokenId": "bd69b4a4-5376-47cd-91c3-f1e1576440e5",
|
|
18050
|
+
// "appCodes": null,
|
|
18051
|
+
// "appCode": null,
|
|
18052
|
+
// "platRoleCodes": ["1637696814759153664"],
|
|
18053
|
+
// "metamodeltype": 2,
|
|
18054
|
+
// "orgCode": "1751852081616130048",
|
|
18055
|
+
// "centerRole": true
|
|
18056
|
+
// },
|
|
18057
|
+
// "TwoFactorAuthCode": "6f56da978dffe31a3b03a56c446f9467",
|
|
18058
|
+
// "exp": 1751694745
|
|
18059
|
+
// }
|
|
18060
|
+
// // 租户token
|
|
18061
|
+
// {
|
|
18062
|
+
// "exp": 1720161305,
|
|
18063
|
+
// "LoginUser": {
|
|
18064
|
+
// "accountInfoCode": "1803686723986010112",
|
|
18065
|
+
// "accountCode": "1803686724107644928",
|
|
18066
|
+
// "tenantCode": "3000911",
|
|
18067
|
+
// "productCode": "100000000000000000",
|
|
18068
|
+
// "productVersionCode": "30000000000000911",
|
|
18069
|
+
// "clientTypeCode": 1,
|
|
18070
|
+
// "tokenId": "8614059e-69a5-4e1e-a948-f2ef680d0dd5",
|
|
18071
|
+
// "orgCode": "1803686397149065216",
|
|
18072
|
+
// "userInfoId": "1806591894588108800",
|
|
18073
|
+
// "userInfoName": "woOUQJEAAAn4r5-7jffaxad6yotbEZ5A",
|
|
18074
|
+
// "positionCode": "1803686397304254473",
|
|
18075
|
+
// "positionName": "系统管理员-勿删",
|
|
18076
|
+
// "memberCode": "1806591894659411968",
|
|
18077
|
+
// "refPositionCode": "1300728614534385664",
|
|
18078
|
+
// "categoryCode": "",
|
|
18079
|
+
// "orgStructTypeId": "1",
|
|
18080
|
+
// "userName": null,
|
|
18081
|
+
// "userName1": "woOUQJEAAAn4r5-7jffaxad6yotbEZ5A",
|
|
18082
|
+
// "userName2": null,
|
|
18083
|
+
// "userName3": null,
|
|
18084
|
+
// "tenantName": "智慧100-企微版-V9.1.1开发租户",
|
|
18085
|
+
// "appCode": "sales",
|
|
18086
|
+
// "appCodes": [
|
|
18087
|
+
// "promotion",
|
|
18088
|
+
// "distribution",
|
|
18089
|
+
// "sales"
|
|
18090
|
+
// ],
|
|
18091
|
+
// "subPdCodes": [
|
|
18092
|
+
// "sfa",
|
|
18093
|
+
// "dms",
|
|
18094
|
+
// "pmm",
|
|
18095
|
+
// "tpm",
|
|
18096
|
+
// "ai"
|
|
18097
|
+
// ],
|
|
18098
|
+
// "codepath": "1.1803686395634921472.1803686397149065216.",
|
|
18099
|
+
// "isleaforg": "true",
|
|
18100
|
+
// "metamodeltype": 1,
|
|
18101
|
+
// "isSmsLogin": false
|
|
18102
|
+
// }
|
|
18103
|
+
// }
|
|
18104
|
+
// 查询token所属登录角色
|
|
18105
|
+
// tenant: 普通租户登录 默认
|
|
18106
|
+
// center: 产品运营中心登录 单点登录时只带 token 没带 refreshtoken 和 tokenexpires
|
|
18107
|
+
}, {
|
|
18108
|
+
key: "getRoleByToken",
|
|
18109
|
+
value: function getRoleByToken(token) {
|
|
18110
|
+
var loginRole = 'tenant'; // center | tenant
|
|
18111
|
+
if (token) {
|
|
18112
|
+
var _jwtInfo$LoginUser, _jwtInfo$LoginUser2;
|
|
18113
|
+
var jwtInfo = this.jwtDecode(token);
|
|
18114
|
+
if (jwtInfo !== null && jwtInfo !== void 0 && (_jwtInfo$LoginUser = jwtInfo.LoginUser) !== null && _jwtInfo$LoginUser !== void 0 && _jwtInfo$LoginUser.centerRole || (jwtInfo === null || jwtInfo === void 0 || (_jwtInfo$LoginUser2 = jwtInfo.LoginUser) === null || _jwtInfo$LoginUser2 === void 0 ? void 0 : _jwtInfo$LoginUser2.appId) === '100') {
|
|
18115
|
+
// 产品运营中心登录
|
|
18116
|
+
loginRole = 'center';
|
|
18117
|
+
}
|
|
18118
|
+
}
|
|
18119
|
+
return loginRole;
|
|
18120
|
+
}
|
|
18121
|
+
}, {
|
|
18122
|
+
key: "getRole",
|
|
18123
|
+
value: function getRole() {
|
|
18124
|
+
return this.getRoleByToken(this.getToken());
|
|
18125
|
+
}
|
|
18126
|
+
// 检测当前用户是否登录状态
|
|
18127
|
+
}, {
|
|
18128
|
+
key: "checkLogin",
|
|
18129
|
+
value: function checkLogin() {
|
|
18130
|
+
var haslogged = false;
|
|
18131
|
+
var token = this.getToken();
|
|
18132
|
+
if (token) {
|
|
18133
|
+
if (this.getRole() === 'center') {
|
|
18134
|
+
haslogged = this.checkLoginByToken(token);
|
|
18135
|
+
} else {
|
|
18136
|
+
var refreshtoken = this.getRefreshToken();
|
|
18137
|
+
var tokenexpires = this.getTokenExpires();
|
|
18138
|
+
var now = Date.now();
|
|
18139
|
+
if (token && refreshtoken && tokenexpires && Number(tokenexpires) > now) {
|
|
18140
|
+
haslogged = this.checkLoginByToken(token);
|
|
17947
18141
|
}
|
|
17948
|
-
}
|
|
17949
|
-
}));
|
|
17950
|
-
function getEnvBusiness() {
|
|
17951
|
-
return _getEnvBusiness.apply(this, arguments);
|
|
18142
|
+
}
|
|
17952
18143
|
}
|
|
17953
|
-
return
|
|
17954
|
-
}
|
|
18144
|
+
return haslogged;
|
|
18145
|
+
}
|
|
18146
|
+
// 检测token是否过期
|
|
17955
18147
|
}, {
|
|
17956
|
-
key: "
|
|
18148
|
+
key: "checkLoginByToken",
|
|
18149
|
+
value: function checkLoginByToken(token) {
|
|
18150
|
+
var haslogged = false;
|
|
18151
|
+
if (token) {
|
|
18152
|
+
var now = Date.now();
|
|
18153
|
+
var jwtInfo = this.jwtDecode(token);
|
|
18154
|
+
if (jwtInfo !== null && jwtInfo !== void 0 && jwtInfo.exp) {
|
|
18155
|
+
haslogged = Number(jwtInfo.exp + '000') > now;
|
|
18156
|
+
} else {
|
|
18157
|
+
haslogged = false;
|
|
18158
|
+
}
|
|
18159
|
+
}
|
|
18160
|
+
return haslogged;
|
|
18161
|
+
}
|
|
18162
|
+
// 接口请求回来的 userInfo 有 functioncodes 以便做权限校验
|
|
18163
|
+
// 有可能是中心角色请求失败 兼容不报错
|
|
18164
|
+
}, {
|
|
18165
|
+
key: "getAndSetUserInfo",
|
|
17957
18166
|
value: function () {
|
|
17958
|
-
var
|
|
17959
|
-
var
|
|
17960
|
-
return _regeneratorRuntime$1().wrap(function
|
|
17961
|
-
while (1) switch (
|
|
18167
|
+
var _getAndSetUserInfo = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
|
|
18168
|
+
var accountinfo;
|
|
18169
|
+
return _regeneratorRuntime$1().wrap(function _callee3$(_context4) {
|
|
18170
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
17962
18171
|
case 0:
|
|
17963
|
-
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
|
|
17968
|
-
|
|
17969
|
-
|
|
17970
|
-
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
res.errorMsg = '缺少 modulekey,请检查。';
|
|
17976
|
-
} else if (!data.envName) {
|
|
17977
|
-
res.errorMsg = '找不到租户环境名称,请检查登录时是否有填写企业名称。';
|
|
17978
|
-
} else if (!data.envData) {
|
|
17979
|
-
res.errorMsg = '找不到租户环境信息。';
|
|
17980
|
-
} else if (!data.webDefineData) {
|
|
17981
|
-
res.errorMsg = '该租户没有部署 G3。';
|
|
17982
|
-
} else if (!data.webDefineData.length) {
|
|
17983
|
-
res.errorMsg = '该租户没有授权场景模块/SPU模块。';
|
|
17984
|
-
} else {
|
|
17985
|
-
res.data = data.webDefineData.find(function (item) {
|
|
17986
|
-
return item.modulekey === modulekey;
|
|
17987
|
-
});
|
|
17988
|
-
if (!res.data) {
|
|
17989
|
-
res.errorMsg = "\u8BE5\u79DF\u6237\u6CA1\u6709\u6388\u6743 ".concat(modulekey, " \u6A21\u5757\u3002");
|
|
18172
|
+
_context4.prev = 0;
|
|
18173
|
+
_context4.next = 3;
|
|
18174
|
+
return normalAxios.post('/api/teapi/rolepermission/account/getaccountinfo', {
|
|
18175
|
+
positionid: this.getUser('positioncode') || '',
|
|
18176
|
+
deviceinfo: '',
|
|
18177
|
+
sysversion: '',
|
|
18178
|
+
clientversion: ''
|
|
18179
|
+
}).then(function (res) {
|
|
18180
|
+
if (res.code === 200 && res.data) {
|
|
18181
|
+
return res.data;
|
|
18182
|
+
} else {
|
|
18183
|
+
return null;
|
|
17990
18184
|
}
|
|
18185
|
+
});
|
|
18186
|
+
case 3:
|
|
18187
|
+
accountinfo = _context4.sent;
|
|
18188
|
+
if (accountinfo) {
|
|
18189
|
+
this.setUser(accountinfo);
|
|
17991
18190
|
}
|
|
17992
|
-
|
|
18191
|
+
_context4.next = 11;
|
|
18192
|
+
break;
|
|
17993
18193
|
case 7:
|
|
18194
|
+
_context4.prev = 7;
|
|
18195
|
+
_context4.t0 = _context4["catch"](0);
|
|
18196
|
+
console.error(_context4.t0);
|
|
18197
|
+
console.warn('获取用户信息失败,当前您登录的帐号可能为非标准租户帐号。');
|
|
18198
|
+
case 11:
|
|
17994
18199
|
case "end":
|
|
17995
|
-
return
|
|
18200
|
+
return _context4.stop();
|
|
17996
18201
|
}
|
|
17997
|
-
},
|
|
18202
|
+
}, _callee3, this, [[0, 7]]);
|
|
17998
18203
|
}));
|
|
17999
|
-
function
|
|
18000
|
-
return
|
|
18204
|
+
function getAndSetUserInfo() {
|
|
18205
|
+
return _getAndSetUserInfo.apply(this, arguments);
|
|
18001
18206
|
}
|
|
18002
|
-
return
|
|
18207
|
+
return getAndSetUserInfo;
|
|
18003
18208
|
}()
|
|
18004
18209
|
}, {
|
|
18005
|
-
key: "
|
|
18006
|
-
value: function () {
|
|
18007
|
-
|
|
18008
|
-
|
|
18009
|
-
return _regeneratorRuntime$1().wrap(function _callee8$(_context8) {
|
|
18010
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
18011
|
-
case 0:
|
|
18012
|
-
if (!modulekey) {
|
|
18013
|
-
modulekey = globalOptions.modulekey;
|
|
18014
|
-
}
|
|
18015
|
-
_context8.next = 3;
|
|
18016
|
-
return this.getModuleData(modulekey);
|
|
18017
|
-
case 3:
|
|
18018
|
-
moduleData = _context8.sent;
|
|
18019
|
-
if (moduleData !== null && moduleData !== void 0 && moduleData.data) {
|
|
18020
|
-
context = {
|
|
18021
|
-
envid: moduleData.envid || '',
|
|
18022
|
-
envname: this.cache.envName || '',
|
|
18023
|
-
tenantcode: moduleData.tenantcode || '',
|
|
18024
|
-
modulecode: moduleData.modulecode || '',
|
|
18025
|
-
modulekey: moduleData.modulekey || '',
|
|
18026
|
-
modulename: moduleData.modulename || '',
|
|
18027
|
-
moduleversion: moduleData.moduleversion || '',
|
|
18028
|
-
versioncode: moduleData.versioncode || '',
|
|
18029
|
-
versionnum: moduleData.moduleversion || ''
|
|
18030
|
-
};
|
|
18031
|
-
}
|
|
18032
|
-
return _context8.abrupt("return", context);
|
|
18033
|
-
case 6:
|
|
18034
|
-
case "end":
|
|
18035
|
-
return _context8.stop();
|
|
18036
|
-
}
|
|
18037
|
-
}, _callee8, this);
|
|
18038
|
-
}));
|
|
18039
|
-
function getContext(_x3) {
|
|
18040
|
-
return _getContext.apply(this, arguments);
|
|
18210
|
+
key: "formatTenant",
|
|
18211
|
+
value: function formatTenant(tenant) {
|
|
18212
|
+
if (!tenant) {
|
|
18213
|
+
return null;
|
|
18041
18214
|
}
|
|
18042
|
-
|
|
18043
|
-
|
|
18215
|
+
var cloundTagMap = ['storage', 'storage-1d', 'storage-1y', 'storage-3m'];
|
|
18216
|
+
var result = {};
|
|
18217
|
+
for (var _i = 0, _cloundTagMap = cloundTagMap; _i < _cloundTagMap.length; _i++) {
|
|
18218
|
+
var keyItem = _cloundTagMap[_i];
|
|
18219
|
+
var _cloudServ = tenant.cloudserv[keyItem];
|
|
18220
|
+
if (_cloudServ) {
|
|
18221
|
+
result[keyItem] = {
|
|
18222
|
+
cloudserv_storage_provider: _cloudServ.provider,
|
|
18223
|
+
cloudserv_storage_storagebucket: _cloudServ.storagebucket,
|
|
18224
|
+
cloudserv_storage_storageendpoint: _cloudServ.storageendpoint,
|
|
18225
|
+
cloudserv_storage_storageurl: _cloudServ.storageurl,
|
|
18226
|
+
cloudserv_storage_accesskeyid: _cloudServ.accesskeyid,
|
|
18227
|
+
cloudserv_storage_region: _cloudServ.region
|
|
18228
|
+
};
|
|
18229
|
+
}
|
|
18230
|
+
}
|
|
18231
|
+
if (Object.keys(result).length === 0) {
|
|
18232
|
+
return null;
|
|
18233
|
+
}
|
|
18234
|
+
return result;
|
|
18235
|
+
}
|
|
18044
18236
|
}, {
|
|
18045
|
-
key: "
|
|
18237
|
+
key: "getAndSetTenant",
|
|
18046
18238
|
value: function () {
|
|
18047
|
-
var
|
|
18048
|
-
var
|
|
18049
|
-
return _regeneratorRuntime$1().wrap(function
|
|
18050
|
-
while (1) switch (
|
|
18239
|
+
var _getAndSetTenant = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(tenantcode) {
|
|
18240
|
+
var tenantsRes, tenant, normalizedTenant;
|
|
18241
|
+
return _regeneratorRuntime$1().wrap(function _callee4$(_context5) {
|
|
18242
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
18051
18243
|
case 0:
|
|
18052
|
-
|
|
18053
|
-
|
|
18054
|
-
return
|
|
18244
|
+
_context5.prev = 0;
|
|
18245
|
+
_context5.next = 3;
|
|
18246
|
+
return normalAxios.get('/api/auth/tenantlist', {}).then(function (res) {
|
|
18247
|
+
var _res$data;
|
|
18248
|
+
return res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.tenants;
|
|
18249
|
+
});
|
|
18055
18250
|
case 3:
|
|
18056
|
-
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18251
|
+
tenantsRes = _context5.sent;
|
|
18252
|
+
tenant = null;
|
|
18253
|
+
if (tenantsRes !== null && tenantsRes !== void 0 && tenantsRes.length) {
|
|
18254
|
+
if (!tenantcode) {
|
|
18255
|
+
tenant = tenantsRes[0];
|
|
18256
|
+
} else {
|
|
18257
|
+
tenant = tenantsRes.find(function (item) {
|
|
18258
|
+
return item.code === tenantcode;
|
|
18259
|
+
}) || null;
|
|
18260
|
+
}
|
|
18060
18261
|
}
|
|
18061
|
-
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18262
|
+
if (!tenant) {
|
|
18263
|
+
lsProxy.removeItem('tenant');
|
|
18264
|
+
CloudServ$1.remove();
|
|
18265
|
+
} else {
|
|
18266
|
+
lsProxy.setItem('tenant', JSON.stringify(tenant));
|
|
18267
|
+
normalizedTenant = this.formatTenant(tenant);
|
|
18268
|
+
if (normalizedTenant) {
|
|
18269
|
+
CloudServ$1.set(normalizedTenant);
|
|
18270
|
+
}
|
|
18271
|
+
}
|
|
18272
|
+
_context5.next = 13;
|
|
18273
|
+
break;
|
|
18066
18274
|
case 9:
|
|
18067
|
-
|
|
18068
|
-
|
|
18275
|
+
_context5.prev = 9;
|
|
18276
|
+
_context5.t0 = _context5["catch"](0);
|
|
18277
|
+
console.error(_context5.t0);
|
|
18278
|
+
console.warn('获取租户信息失败,当前您登录的帐号可能为非标准租户帐号。');
|
|
18279
|
+
case 13:
|
|
18069
18280
|
case "end":
|
|
18070
|
-
return
|
|
18281
|
+
return _context5.stop();
|
|
18071
18282
|
}
|
|
18072
|
-
},
|
|
18283
|
+
}, _callee4, this, [[0, 9]]);
|
|
18073
18284
|
}));
|
|
18074
|
-
function
|
|
18075
|
-
return
|
|
18285
|
+
function getAndSetTenant(_x) {
|
|
18286
|
+
return _getAndSetTenant.apply(this, arguments);
|
|
18076
18287
|
}
|
|
18077
|
-
return
|
|
18078
|
-
}()
|
|
18288
|
+
return getAndSetTenant;
|
|
18289
|
+
}() // 单点登录
|
|
18079
18290
|
}, {
|
|
18080
|
-
key: "
|
|
18291
|
+
key: "singleLogin",
|
|
18081
18292
|
value: function () {
|
|
18082
|
-
var
|
|
18083
|
-
var
|
|
18084
|
-
return _regeneratorRuntime$1().wrap(function
|
|
18085
|
-
while (1) switch (
|
|
18293
|
+
var _singleLogin = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5(query) {
|
|
18294
|
+
var flag, token, refreshtoken, tokenexpires, envname, context, isneedlogin, loginRole, user;
|
|
18295
|
+
return _regeneratorRuntime$1().wrap(function _callee5$(_context6) {
|
|
18296
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
18086
18297
|
case 0:
|
|
18087
|
-
|
|
18088
|
-
|
|
18298
|
+
query = cloneDeep$1(query);
|
|
18299
|
+
flag = false; // 是否登录成功
|
|
18300
|
+
token = query.token;
|
|
18301
|
+
refreshtoken = query.refreshtoken;
|
|
18302
|
+
tokenexpires = query.tokenexpires;
|
|
18303
|
+
envname = query.envname;
|
|
18304
|
+
context = query.context;
|
|
18305
|
+
if (!this.checkLoginByToken(token)) {
|
|
18306
|
+
_context6.next = 26;
|
|
18307
|
+
break;
|
|
18089
18308
|
}
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
|
|
18095
|
-
|
|
18309
|
+
isneedlogin = true; // 是否需要走单点登录流程
|
|
18310
|
+
loginRole = this.getRoleByToken(token);
|
|
18311
|
+
if (loginRole === 'center') {
|
|
18312
|
+
// 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
|
|
18313
|
+
// 之所以不强制校验 refreshtoken tokenexpires 是因为安装卸载配置页面有可能放在产品运营中心 没有这两字段
|
|
18314
|
+
if (this.checkLogin() && token === this.getToken()) {
|
|
18315
|
+
isneedlogin = false;
|
|
18316
|
+
flag = true;
|
|
18317
|
+
}
|
|
18318
|
+
} else {
|
|
18319
|
+
// 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
|
|
18320
|
+
if (this.checkLogin() && token === this.getToken() && refreshtoken === this.getRefreshToken() && tokenexpires === this.getTokenExpires()) {
|
|
18321
|
+
isneedlogin = false;
|
|
18322
|
+
flag = true;
|
|
18323
|
+
}
|
|
18324
|
+
}
|
|
18325
|
+
if (!isneedlogin) {
|
|
18326
|
+
_context6.next = 24;
|
|
18327
|
+
break;
|
|
18328
|
+
}
|
|
18329
|
+
this.setToken(token);
|
|
18330
|
+
this.setUserByToken(token); // 解析token为用户信息存入
|
|
18331
|
+
refreshtoken ? this.setRefreshToken(refreshtoken) : this.removeRefreshToken();
|
|
18332
|
+
tokenexpires ? this.setTokenExpires(tokenexpires) : this.removeTokenExpires();
|
|
18333
|
+
envname ? this.setQueryEnvname(envname) : this.removeQueryEnvname();
|
|
18334
|
+
// context 上下文字段 产品运营中心安装 卸载 配置 和 产品配置中心业务配置 页面需要用到
|
|
18335
|
+
// web 端有传 app没传 需要做兼容
|
|
18336
|
+
context && lsProxy.setItem('context', decodeURIComponent(context));
|
|
18337
|
+
// 单点登录写入 token 之后 换取完整的 refreshtoken
|
|
18338
|
+
try {
|
|
18339
|
+
if (this.checkLogin()) {
|
|
18340
|
+
user = this.getUserByToken(this.getRefreshToken());
|
|
18341
|
+
if (!(user !== null && user !== void 0 && user.tokenId)) {
|
|
18342
|
+
this.updateToken();
|
|
18343
|
+
}
|
|
18344
|
+
}
|
|
18345
|
+
} catch (err) {
|
|
18346
|
+
console.error(err);
|
|
18347
|
+
}
|
|
18348
|
+
// 这里兼容报错
|
|
18349
|
+
_context6.next = 21;
|
|
18350
|
+
return this.getAndSetTenant();
|
|
18351
|
+
case 21:
|
|
18352
|
+
_context6.next = 23;
|
|
18353
|
+
return this.getAndSetUserInfo();
|
|
18354
|
+
case 23:
|
|
18355
|
+
flag = true;
|
|
18356
|
+
case 24:
|
|
18357
|
+
_context6.next = 28;
|
|
18358
|
+
break;
|
|
18359
|
+
case 26:
|
|
18360
|
+
flag = false;
|
|
18361
|
+
console.error('没传 token 或所传 token 已过期,无法单点登录。');
|
|
18362
|
+
case 28:
|
|
18363
|
+
// 单点登录后 无论是否成功 都需要删除 query 中相关参数
|
|
18364
|
+
token && delete query.token;
|
|
18365
|
+
refreshtoken && delete query.refreshtoken;
|
|
18366
|
+
tokenexpires && delete query.tokenexpires;
|
|
18367
|
+
envname && delete query.envname;
|
|
18368
|
+
context && delete query.context;
|
|
18369
|
+
// debugger
|
|
18370
|
+
return _context6.abrupt("return", {
|
|
18371
|
+
flag: flag,
|
|
18372
|
+
query: query
|
|
18373
|
+
});
|
|
18374
|
+
case 34:
|
|
18096
18375
|
case "end":
|
|
18097
|
-
return
|
|
18376
|
+
return _context6.stop();
|
|
18098
18377
|
}
|
|
18099
|
-
},
|
|
18378
|
+
}, _callee5, this);
|
|
18100
18379
|
}));
|
|
18101
|
-
function
|
|
18102
|
-
return
|
|
18380
|
+
function singleLogin(_x2) {
|
|
18381
|
+
return _singleLogin.apply(this, arguments);
|
|
18103
18382
|
}
|
|
18104
|
-
return
|
|
18383
|
+
return singleLogin;
|
|
18105
18384
|
}()
|
|
18106
18385
|
}]);
|
|
18107
|
-
return
|
|
18386
|
+
return Login;
|
|
18387
|
+
}();
|
|
18388
|
+
var login = new Login();
|
|
18389
|
+
|
|
18390
|
+
var urlIsIp = function urlIsIp(url) {
|
|
18391
|
+
var hostname = url.split('://')[1].split(':')[0].split('/')[0];
|
|
18392
|
+
var arr = hostname.split('.');
|
|
18393
|
+
if (arr.length !== 4) return false;
|
|
18394
|
+
var flag = true;
|
|
18395
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
18396
|
+
if (!Number.isInteger(Number(arr[i]))) {
|
|
18397
|
+
flag = false;
|
|
18398
|
+
break;
|
|
18399
|
+
}
|
|
18400
|
+
}
|
|
18401
|
+
return flag;
|
|
18402
|
+
};
|
|
18403
|
+
|
|
18404
|
+
// 如果是非ip地址 则切换为与主页面一样的 location.protocol 前缀
|
|
18405
|
+
var toggleHttpOrHttps = function toggleHttpOrHttps(url) {
|
|
18406
|
+
var res = url;
|
|
18407
|
+
if (!urlIsIp(res)) {
|
|
18408
|
+
if (!res.startsWith(location.protocol)) {
|
|
18409
|
+
var arr = res.split('//');
|
|
18410
|
+
arr[0] = location.protocol;
|
|
18411
|
+
res = arr.join('//');
|
|
18412
|
+
}
|
|
18413
|
+
}
|
|
18414
|
+
return res;
|
|
18415
|
+
};
|
|
18416
|
+
var Core = /*#__PURE__*/function () {
|
|
18417
|
+
function Core() {
|
|
18418
|
+
_classCallCheck$1(this, Core);
|
|
18419
|
+
_defineProperty$1(this, "loadStatus", 0);
|
|
18420
|
+
// 0未开始 1正在加载 2加载完成
|
|
18421
|
+
_defineProperty$1(this, "cache", {
|
|
18422
|
+
envName: '',
|
|
18423
|
+
envData: null,
|
|
18424
|
+
tenantCode: '',
|
|
18425
|
+
webDefineData: null
|
|
18426
|
+
});
|
|
18427
|
+
_defineProperty$1(this, "requestDataPromise", null);
|
|
18428
|
+
}
|
|
18429
|
+
_createClass$1(Core, [{
|
|
18430
|
+
key: "clearCache",
|
|
18431
|
+
value: function clearCache() {
|
|
18432
|
+
this.loadStatus = 0;
|
|
18433
|
+
this.cache = {
|
|
18434
|
+
envName: '',
|
|
18435
|
+
envData: null,
|
|
18436
|
+
tenantCode: '',
|
|
18437
|
+
webDefineData: null
|
|
18438
|
+
};
|
|
18439
|
+
this.requestDataPromise = null;
|
|
18440
|
+
}
|
|
18441
|
+
|
|
18442
|
+
// 请求实时G3数据
|
|
18443
|
+
}, {
|
|
18444
|
+
key: "requestData",
|
|
18445
|
+
value: function () {
|
|
18446
|
+
var _requestData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
18447
|
+
var nowEnvname, nowTenantCode;
|
|
18448
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
18449
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18450
|
+
case 0:
|
|
18451
|
+
_context.next = 2;
|
|
18452
|
+
return Module.getEnvname();
|
|
18453
|
+
case 2:
|
|
18454
|
+
nowEnvname = _context.sent;
|
|
18455
|
+
nowTenantCode = getUser('tenantcode') || '';
|
|
18456
|
+
this.cache.envName = nowEnvname;
|
|
18457
|
+
this.cache.tenantCode = nowTenantCode;
|
|
18458
|
+
_context.next = 8;
|
|
18459
|
+
return this.requestEnvData(nowEnvname);
|
|
18460
|
+
case 8:
|
|
18461
|
+
this.cache.envData = _context.sent;
|
|
18462
|
+
_context.next = 11;
|
|
18463
|
+
return this.requestWebDefineData();
|
|
18464
|
+
case 11:
|
|
18465
|
+
this.cache.webDefineData = _context.sent;
|
|
18466
|
+
return _context.abrupt("return", this.cache);
|
|
18467
|
+
case 13:
|
|
18468
|
+
case "end":
|
|
18469
|
+
return _context.stop();
|
|
18470
|
+
}
|
|
18471
|
+
}, _callee, this);
|
|
18472
|
+
}));
|
|
18473
|
+
function requestData() {
|
|
18474
|
+
return _requestData.apply(this, arguments);
|
|
18475
|
+
}
|
|
18476
|
+
return requestData;
|
|
18477
|
+
}()
|
|
18478
|
+
}, {
|
|
18479
|
+
key: "requestEnvData",
|
|
18480
|
+
value: function () {
|
|
18481
|
+
var _requestEnvData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(envName) {
|
|
18482
|
+
var result, hostsRoot, response, _result, _result2;
|
|
18483
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
|
|
18484
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
18485
|
+
case 0:
|
|
18486
|
+
// envName = '产品运营中心验证'
|
|
18487
|
+
result = null;
|
|
18488
|
+
if (!envName) {
|
|
18489
|
+
_context2.next = 15;
|
|
18490
|
+
break;
|
|
18491
|
+
}
|
|
18492
|
+
hostsRoot = document.location.protocol === 'https:' ? 'https://mconfig.xtion.net' : 'http://mconfig.xtion.net:8015';
|
|
18493
|
+
_context2.prev = 3;
|
|
18494
|
+
_context2.next = 6;
|
|
18495
|
+
return normalAxios.get("".concat(hostsRoot, "/multiplatconfig/env/").concat(envName), {
|
|
18496
|
+
isShowLoading: false,
|
|
18497
|
+
isSendToken: false
|
|
18498
|
+
});
|
|
18499
|
+
case 6:
|
|
18500
|
+
response = _context2.sent;
|
|
18501
|
+
// console.log(response)
|
|
18502
|
+
// debugger
|
|
18503
|
+
result = get$1(response, 'data.0');
|
|
18504
|
+
|
|
18505
|
+
// 如果是非ip地址 则切换为与主页面一样的 location.protocol 前缀
|
|
18506
|
+
((_result = result) === null || _result === void 0 ? void 0 : _result.business) && (result.business = toggleHttpOrHttps(result.business));
|
|
18507
|
+
((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.smartcenter) && (result.smartcenter = toggleHttpOrHttps(result.smartcenter));
|
|
18508
|
+
_context2.next = 15;
|
|
18509
|
+
break;
|
|
18510
|
+
case 12:
|
|
18511
|
+
_context2.prev = 12;
|
|
18512
|
+
_context2.t0 = _context2["catch"](3);
|
|
18513
|
+
console.error(_context2.t0);
|
|
18514
|
+
case 15:
|
|
18515
|
+
return _context2.abrupt("return", result);
|
|
18516
|
+
case 16:
|
|
18517
|
+
case "end":
|
|
18518
|
+
return _context2.stop();
|
|
18519
|
+
}
|
|
18520
|
+
}, _callee2, null, [[3, 12]]);
|
|
18521
|
+
}));
|
|
18522
|
+
function requestEnvData(_x) {
|
|
18523
|
+
return _requestEnvData.apply(this, arguments);
|
|
18524
|
+
}
|
|
18525
|
+
return requestEnvData;
|
|
18526
|
+
}()
|
|
18527
|
+
}, {
|
|
18528
|
+
key: "requestWebDefineData",
|
|
18529
|
+
value: function () {
|
|
18530
|
+
var _requestWebDefineData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
|
|
18531
|
+
var _this$cache$envData, _this$cache;
|
|
18532
|
+
var envId, tenantCode, smartcenter, result, _res, res, list, usedList;
|
|
18533
|
+
return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
|
|
18534
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
18535
|
+
case 0:
|
|
18536
|
+
envId = (_this$cache$envData = this.cache.envData) === null || _this$cache$envData === void 0 ? void 0 : _this$cache$envData.envid;
|
|
18537
|
+
tenantCode = this.cache.tenantCode;
|
|
18538
|
+
smartcenter = (_this$cache = this.cache) === null || _this$cache === void 0 || (_this$cache = _this$cache.envData) === null || _this$cache === void 0 ? void 0 : _this$cache.smartcenter;
|
|
18539
|
+
result = null;
|
|
18540
|
+
if (!(envId && tenantCode && smartcenter)) {
|
|
18541
|
+
_context3.next = 16;
|
|
18542
|
+
break;
|
|
18543
|
+
}
|
|
18544
|
+
_context3.prev = 5;
|
|
18545
|
+
_context3.next = 8;
|
|
18546
|
+
return normalAxios.post("".concat(smartcenter, "/api/smartcenter/biz/getTenantWebAndApiDefined"), {
|
|
18547
|
+
envid: envId,
|
|
18548
|
+
tenantcode: tenantCode
|
|
18549
|
+
}, {
|
|
18550
|
+
isShowLoading: false
|
|
18551
|
+
});
|
|
18552
|
+
case 8:
|
|
18553
|
+
res = _context3.sent;
|
|
18554
|
+
_context3.next = 14;
|
|
18555
|
+
break;
|
|
18556
|
+
case 11:
|
|
18557
|
+
_context3.prev = 11;
|
|
18558
|
+
_context3.t0 = _context3["catch"](5);
|
|
18559
|
+
console.error(_context3.t0);
|
|
18560
|
+
case 14:
|
|
18561
|
+
// console.log(res)
|
|
18562
|
+
// debugger
|
|
18563
|
+
list = ((_res = res) === null || _res === void 0 || (_res = _res.data) === null || _res === void 0 ? void 0 : _res.list) || [];
|
|
18564
|
+
if (list && list.length) {
|
|
18565
|
+
usedList = list.filter(function (item) {
|
|
18566
|
+
return item.status === 1;
|
|
18567
|
+
});
|
|
18568
|
+
usedList.forEach(function (item) {
|
|
18569
|
+
if (item.protocol) {
|
|
18570
|
+
try {
|
|
18571
|
+
item.protocol = JSON.parse(item.protocol);
|
|
18572
|
+
} catch (err) {
|
|
18573
|
+
console.error(err);
|
|
18574
|
+
}
|
|
18575
|
+
}
|
|
18576
|
+
if (item.apiprotocol) {
|
|
18577
|
+
try {
|
|
18578
|
+
item.apiprotocol = JSON.parse(item.apiprotocol);
|
|
18579
|
+
} catch (err) {
|
|
18580
|
+
console.error(err);
|
|
18581
|
+
}
|
|
18582
|
+
}
|
|
18583
|
+
});
|
|
18584
|
+
result = usedList;
|
|
18585
|
+
}
|
|
18586
|
+
case 16:
|
|
18587
|
+
return _context3.abrupt("return", result);
|
|
18588
|
+
case 17:
|
|
18589
|
+
case "end":
|
|
18590
|
+
return _context3.stop();
|
|
18591
|
+
}
|
|
18592
|
+
}, _callee3, this, [[5, 11]]);
|
|
18593
|
+
}));
|
|
18594
|
+
function requestWebDefineData() {
|
|
18595
|
+
return _requestWebDefineData.apply(this, arguments);
|
|
18596
|
+
}
|
|
18597
|
+
return requestWebDefineData;
|
|
18598
|
+
}()
|
|
18599
|
+
}, {
|
|
18600
|
+
key: "getData",
|
|
18601
|
+
value: function () {
|
|
18602
|
+
var _getData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4() {
|
|
18603
|
+
var nowEnvname, nowTenantCode;
|
|
18604
|
+
return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
|
|
18605
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
18606
|
+
case 0:
|
|
18607
|
+
_context4.next = 2;
|
|
18608
|
+
return Module.getEnvname();
|
|
18609
|
+
case 2:
|
|
18610
|
+
nowEnvname = _context4.sent;
|
|
18611
|
+
nowTenantCode = getUser('tenantcode') || ''; // console.log(tenantCode)
|
|
18612
|
+
if (!(this.cache.envName === nowEnvname && this.cache.tenantCode === nowTenantCode && this.loadStatus === 2)) {
|
|
18613
|
+
_context4.next = 6;
|
|
18614
|
+
break;
|
|
18615
|
+
}
|
|
18616
|
+
return _context4.abrupt("return", this.cache);
|
|
18617
|
+
case 6:
|
|
18618
|
+
if (!(this.loadStatus === 1 && this.requestDataPromise)) {
|
|
18619
|
+
_context4.next = 8;
|
|
18620
|
+
break;
|
|
18621
|
+
}
|
|
18622
|
+
return _context4.abrupt("return", this.requestDataPromise);
|
|
18623
|
+
case 8:
|
|
18624
|
+
this.loadStatus = 1;
|
|
18625
|
+
this.requestDataPromise = this.requestData();
|
|
18626
|
+
_context4.next = 12;
|
|
18627
|
+
return this.requestDataPromise;
|
|
18628
|
+
case 12:
|
|
18629
|
+
this.loadStatus = 2;
|
|
18630
|
+
return _context4.abrupt("return", this.cache);
|
|
18631
|
+
case 14:
|
|
18632
|
+
case "end":
|
|
18633
|
+
return _context4.stop();
|
|
18634
|
+
}
|
|
18635
|
+
}, _callee4, this);
|
|
18636
|
+
}));
|
|
18637
|
+
function getData() {
|
|
18638
|
+
return _getData.apply(this, arguments);
|
|
18639
|
+
}
|
|
18640
|
+
return getData;
|
|
18641
|
+
}()
|
|
18642
|
+
}, {
|
|
18643
|
+
key: "getEnvData",
|
|
18644
|
+
value: function () {
|
|
18645
|
+
var _getEnvData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5() {
|
|
18646
|
+
var res, data;
|
|
18647
|
+
return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
|
|
18648
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
18649
|
+
case 0:
|
|
18650
|
+
res = {
|
|
18651
|
+
errorMsg: '',
|
|
18652
|
+
data: null
|
|
18653
|
+
};
|
|
18654
|
+
_context5.next = 3;
|
|
18655
|
+
return this.getData();
|
|
18656
|
+
case 3:
|
|
18657
|
+
data = _context5.sent;
|
|
18658
|
+
if (!data.envName) {
|
|
18659
|
+
res.errorMsg = '找不到租户环境名称,请检查登录时是否有填写企业名称。';
|
|
18660
|
+
} else if (!data.envData) {
|
|
18661
|
+
res.errorMsg = '找不到租户环境信息。';
|
|
18662
|
+
} else {
|
|
18663
|
+
res.data = data.envData;
|
|
18664
|
+
}
|
|
18665
|
+
return _context5.abrupt("return", res);
|
|
18666
|
+
case 6:
|
|
18667
|
+
case "end":
|
|
18668
|
+
return _context5.stop();
|
|
18669
|
+
}
|
|
18670
|
+
}, _callee5, this);
|
|
18671
|
+
}));
|
|
18672
|
+
function getEnvData() {
|
|
18673
|
+
return _getEnvData.apply(this, arguments);
|
|
18674
|
+
}
|
|
18675
|
+
return getEnvData;
|
|
18676
|
+
}()
|
|
18677
|
+
}, {
|
|
18678
|
+
key: "getEnvBusiness",
|
|
18679
|
+
value: function () {
|
|
18680
|
+
var _getEnvBusiness = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee6() {
|
|
18681
|
+
var business, envData;
|
|
18682
|
+
return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
|
|
18683
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
18684
|
+
case 0:
|
|
18685
|
+
business = '';
|
|
18686
|
+
_context6.next = 3;
|
|
18687
|
+
return this.getEnvData();
|
|
18688
|
+
case 3:
|
|
18689
|
+
envData = _context6.sent;
|
|
18690
|
+
if (envData.data) {
|
|
18691
|
+
business = envData.data.business;
|
|
18692
|
+
}
|
|
18693
|
+
return _context6.abrupt("return", business);
|
|
18694
|
+
case 6:
|
|
18695
|
+
case "end":
|
|
18696
|
+
return _context6.stop();
|
|
18697
|
+
}
|
|
18698
|
+
}, _callee6, this);
|
|
18699
|
+
}));
|
|
18700
|
+
function getEnvBusiness() {
|
|
18701
|
+
return _getEnvBusiness.apply(this, arguments);
|
|
18702
|
+
}
|
|
18703
|
+
return getEnvBusiness;
|
|
18704
|
+
}()
|
|
18705
|
+
}, {
|
|
18706
|
+
key: "getModuleData",
|
|
18707
|
+
value: function () {
|
|
18708
|
+
var _getModuleData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee7(modulekey) {
|
|
18709
|
+
var res, data;
|
|
18710
|
+
return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
|
|
18711
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
18712
|
+
case 0:
|
|
18713
|
+
if (!modulekey) {
|
|
18714
|
+
modulekey = globalOptions.modulekey;
|
|
18715
|
+
}
|
|
18716
|
+
res = {
|
|
18717
|
+
errorMsg: '',
|
|
18718
|
+
data: null
|
|
18719
|
+
};
|
|
18720
|
+
_context7.next = 4;
|
|
18721
|
+
return this.getData();
|
|
18722
|
+
case 4:
|
|
18723
|
+
data = _context7.sent;
|
|
18724
|
+
if (!modulekey) {
|
|
18725
|
+
res.errorMsg = '缺少 modulekey,请检查。';
|
|
18726
|
+
} else if (!data.envName) {
|
|
18727
|
+
res.errorMsg = '找不到租户环境名称,请检查登录时是否有填写企业名称。';
|
|
18728
|
+
} else if (!data.envData) {
|
|
18729
|
+
res.errorMsg = '找不到租户环境信息。';
|
|
18730
|
+
} else if (!data.webDefineData) {
|
|
18731
|
+
res.errorMsg = '该租户没有部署 G3。';
|
|
18732
|
+
} else if (!data.webDefineData.length) {
|
|
18733
|
+
res.errorMsg = '该租户没有授权场景模块/SPU模块。';
|
|
18734
|
+
} else {
|
|
18735
|
+
res.data = data.webDefineData.find(function (item) {
|
|
18736
|
+
return item.modulekey === modulekey;
|
|
18737
|
+
});
|
|
18738
|
+
if (!res.data) {
|
|
18739
|
+
res.errorMsg = "\u8BE5\u79DF\u6237\u6CA1\u6709\u6388\u6743 ".concat(modulekey, " \u6A21\u5757\u3002");
|
|
18740
|
+
}
|
|
18741
|
+
}
|
|
18742
|
+
return _context7.abrupt("return", res);
|
|
18743
|
+
case 7:
|
|
18744
|
+
case "end":
|
|
18745
|
+
return _context7.stop();
|
|
18746
|
+
}
|
|
18747
|
+
}, _callee7, this);
|
|
18748
|
+
}));
|
|
18749
|
+
function getModuleData(_x2) {
|
|
18750
|
+
return _getModuleData.apply(this, arguments);
|
|
18751
|
+
}
|
|
18752
|
+
return getModuleData;
|
|
18753
|
+
}()
|
|
18754
|
+
}, {
|
|
18755
|
+
key: "getContext",
|
|
18756
|
+
value: function () {
|
|
18757
|
+
var _getContext = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee8(modulekey) {
|
|
18758
|
+
var context, moduleData;
|
|
18759
|
+
return _regeneratorRuntime$1().wrap(function _callee8$(_context8) {
|
|
18760
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
18761
|
+
case 0:
|
|
18762
|
+
if (!modulekey) {
|
|
18763
|
+
modulekey = globalOptions.modulekey;
|
|
18764
|
+
}
|
|
18765
|
+
_context8.next = 3;
|
|
18766
|
+
return this.getModuleData(modulekey);
|
|
18767
|
+
case 3:
|
|
18768
|
+
moduleData = _context8.sent;
|
|
18769
|
+
if (moduleData !== null && moduleData !== void 0 && moduleData.data) {
|
|
18770
|
+
context = {
|
|
18771
|
+
envid: moduleData.envid || '',
|
|
18772
|
+
envname: this.cache.envName || '',
|
|
18773
|
+
tenantcode: moduleData.tenantcode || '',
|
|
18774
|
+
modulecode: moduleData.modulecode || '',
|
|
18775
|
+
modulekey: moduleData.modulekey || '',
|
|
18776
|
+
modulename: moduleData.modulename || '',
|
|
18777
|
+
moduleversion: moduleData.moduleversion || '',
|
|
18778
|
+
versioncode: moduleData.versioncode || '',
|
|
18779
|
+
versionnum: moduleData.moduleversion || ''
|
|
18780
|
+
};
|
|
18781
|
+
}
|
|
18782
|
+
return _context8.abrupt("return", context);
|
|
18783
|
+
case 6:
|
|
18784
|
+
case "end":
|
|
18785
|
+
return _context8.stop();
|
|
18786
|
+
}
|
|
18787
|
+
}, _callee8, this);
|
|
18788
|
+
}));
|
|
18789
|
+
function getContext(_x3) {
|
|
18790
|
+
return _getContext.apply(this, arguments);
|
|
18791
|
+
}
|
|
18792
|
+
return getContext;
|
|
18793
|
+
}()
|
|
18794
|
+
}, {
|
|
18795
|
+
key: "getModuleBusiness",
|
|
18796
|
+
value: function () {
|
|
18797
|
+
var _getModuleBusiness = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee9(modulekey) {
|
|
18798
|
+
var business, moduleData, envBusiness;
|
|
18799
|
+
return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
|
|
18800
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
18801
|
+
case 0:
|
|
18802
|
+
business = '';
|
|
18803
|
+
_context9.next = 3;
|
|
18804
|
+
return this.getModuleData(modulekey);
|
|
18805
|
+
case 3:
|
|
18806
|
+
moduleData = _context9.sent;
|
|
18807
|
+
if (!moduleData.data) {
|
|
18808
|
+
_context9.next = 9;
|
|
18809
|
+
break;
|
|
18810
|
+
}
|
|
18811
|
+
_context9.next = 7;
|
|
18812
|
+
return this.getEnvBusiness();
|
|
18813
|
+
case 7:
|
|
18814
|
+
envBusiness = _context9.sent;
|
|
18815
|
+
business = "".concat(moduleData.data.address || envBusiness);
|
|
18816
|
+
case 9:
|
|
18817
|
+
return _context9.abrupt("return", business);
|
|
18818
|
+
case 10:
|
|
18819
|
+
case "end":
|
|
18820
|
+
return _context9.stop();
|
|
18821
|
+
}
|
|
18822
|
+
}, _callee9, this);
|
|
18823
|
+
}));
|
|
18824
|
+
function getModuleBusiness(_x4) {
|
|
18825
|
+
return _getModuleBusiness.apply(this, arguments);
|
|
18826
|
+
}
|
|
18827
|
+
return getModuleBusiness;
|
|
18828
|
+
}()
|
|
18829
|
+
}, {
|
|
18830
|
+
key: "checkModule",
|
|
18831
|
+
value: function () {
|
|
18832
|
+
var _checkModule = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee10(modulekey) {
|
|
18833
|
+
var moduleData;
|
|
18834
|
+
return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
|
|
18835
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
18836
|
+
case 0:
|
|
18837
|
+
if (!modulekey) {
|
|
18838
|
+
modulekey = globalOptions.modulekey;
|
|
18839
|
+
}
|
|
18840
|
+
_context10.next = 3;
|
|
18841
|
+
return this.getModuleData(modulekey);
|
|
18842
|
+
case 3:
|
|
18843
|
+
moduleData = _context10.sent;
|
|
18844
|
+
return _context10.abrupt("return", !!moduleData.data);
|
|
18845
|
+
case 5:
|
|
18846
|
+
case "end":
|
|
18847
|
+
return _context10.stop();
|
|
18848
|
+
}
|
|
18849
|
+
}, _callee10, this);
|
|
18850
|
+
}));
|
|
18851
|
+
function checkModule(_x5) {
|
|
18852
|
+
return _checkModule.apply(this, arguments);
|
|
18853
|
+
}
|
|
18854
|
+
return checkModule;
|
|
18855
|
+
}()
|
|
18856
|
+
}]);
|
|
18857
|
+
return Core;
|
|
18108
18858
|
}();
|
|
18109
18859
|
var core = new Core();
|
|
18110
18860
|
|
|
@@ -18129,22 +18879,46 @@ var createAxiosInstance = function createAxiosInstance() {
|
|
|
18129
18879
|
while (1) switch (_context.prev = _context.next) {
|
|
18130
18880
|
case 0:
|
|
18131
18881
|
// const isShowLoading = typeof config?.isShowLoading !== 'undefined' ? config.isShowLoading : true
|
|
18882
|
+
// console.error(444444)
|
|
18883
|
+
// console.log(config)
|
|
18132
18884
|
isShowLoading = get$1(config, 'isShowLoading', true);
|
|
18133
18885
|
isShowLoading && loadding.open();
|
|
18134
18886
|
isSendToken = get$1(config, 'isSendToken', true);
|
|
18135
|
-
if (isSendToken) {
|
|
18136
|
-
|
|
18137
|
-
|
|
18138
|
-
|
|
18139
|
-
|
|
18887
|
+
if (!isSendToken) {
|
|
18888
|
+
_context.next = 16;
|
|
18889
|
+
break;
|
|
18890
|
+
}
|
|
18891
|
+
if (!(config.url !== '/api/auth/refreshtoken')) {
|
|
18892
|
+
_context.next = 14;
|
|
18893
|
+
break;
|
|
18140
18894
|
}
|
|
18895
|
+
if (!(!login.checkLogin() && login.getRole() !== 'center')) {
|
|
18896
|
+
_context.next = 14;
|
|
18897
|
+
break;
|
|
18898
|
+
}
|
|
18899
|
+
_context.prev = 6;
|
|
18900
|
+
_context.next = 9;
|
|
18901
|
+
return login.updateToken();
|
|
18902
|
+
case 9:
|
|
18903
|
+
_context.next = 14;
|
|
18904
|
+
break;
|
|
18905
|
+
case 11:
|
|
18906
|
+
_context.prev = 11;
|
|
18907
|
+
_context.t0 = _context["catch"](6);
|
|
18908
|
+
console.error(_context.t0);
|
|
18909
|
+
case 14:
|
|
18910
|
+
token = login.getToken();
|
|
18911
|
+
if (config !== null && config !== void 0 && config.headers && token) {
|
|
18912
|
+
config.headers.token = token;
|
|
18913
|
+
}
|
|
18914
|
+
case 16:
|
|
18141
18915
|
if (!(type === 'spu' && config.modulekey)) {
|
|
18142
|
-
_context.next =
|
|
18916
|
+
_context.next = 21;
|
|
18143
18917
|
break;
|
|
18144
18918
|
}
|
|
18145
|
-
_context.next =
|
|
18919
|
+
_context.next = 19;
|
|
18146
18920
|
return core.getModuleData(config.modulekey);
|
|
18147
|
-
case
|
|
18921
|
+
case 19:
|
|
18148
18922
|
moduleData = _context.sent;
|
|
18149
18923
|
if (moduleData.data) {
|
|
18150
18924
|
config.baseURL = "/api/".concat(config.modulekey, "/").concat(moduleData.data.moduleversion);
|
|
@@ -18152,13 +18926,13 @@ var createAxiosInstance = function createAxiosInstance() {
|
|
|
18152
18926
|
console.error(moduleData.errorMsg);
|
|
18153
18927
|
config.baseURL = "/api/".concat(config.modulekey, "/v?.?");
|
|
18154
18928
|
}
|
|
18155
|
-
case
|
|
18929
|
+
case 21:
|
|
18156
18930
|
return _context.abrupt("return", config);
|
|
18157
|
-
case
|
|
18931
|
+
case 22:
|
|
18158
18932
|
case "end":
|
|
18159
18933
|
return _context.stop();
|
|
18160
18934
|
}
|
|
18161
|
-
}, _callee);
|
|
18935
|
+
}, _callee, null, [[6, 11]]);
|
|
18162
18936
|
}));
|
|
18163
18937
|
return function (_x) {
|
|
18164
18938
|
return _ref.apply(this, arguments);
|
|
@@ -51607,80 +52381,6 @@ var dayjs_min = {exports: {}};
|
|
|
51607
52381
|
var dayjs_minExports = dayjs_min.exports;
|
|
51608
52382
|
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
51609
52383
|
|
|
51610
|
-
var CloudServ = /*#__PURE__*/function () {
|
|
51611
|
-
function CloudServ() {
|
|
51612
|
-
_classCallCheck$1(this, CloudServ);
|
|
51613
|
-
_defineProperty$1(this, "CLOUD_SERVE_KEY", 'cloudserv');
|
|
51614
|
-
_defineProperty$1(this, "cacheStorage", null);
|
|
51615
|
-
}
|
|
51616
|
-
_createClass$1(CloudServ, [{
|
|
51617
|
-
key: "get",
|
|
51618
|
-
value: function get() {
|
|
51619
|
-
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51620
|
-
if (this.cacheStorage) {
|
|
51621
|
-
return this.cacheStorage[key] || null;
|
|
51622
|
-
}
|
|
51623
|
-
var storageStr = lsProxy.getItem(this.CLOUD_SERVE_KEY);
|
|
51624
|
-
if (!storageStr) {
|
|
51625
|
-
return null;
|
|
51626
|
-
}
|
|
51627
|
-
var storage = JSON.parse(storageStr);
|
|
51628
|
-
this.cacheStorage = storage;
|
|
51629
|
-
return storage[key];
|
|
51630
|
-
}
|
|
51631
|
-
}, {
|
|
51632
|
-
key: "set",
|
|
51633
|
-
value: function set(storage) {
|
|
51634
|
-
if (_typeof(storage) === 'object') {
|
|
51635
|
-
this.cacheStorage = storage;
|
|
51636
|
-
storage = JSON.stringify(storage);
|
|
51637
|
-
}
|
|
51638
|
-
lsProxy.setItem(this.CLOUD_SERVE_KEY, storage);
|
|
51639
|
-
}
|
|
51640
|
-
}, {
|
|
51641
|
-
key: "remove",
|
|
51642
|
-
value: function remove() {
|
|
51643
|
-
lsProxy.removeItem(this.CLOUD_SERVE_KEY);
|
|
51644
|
-
}
|
|
51645
|
-
}, {
|
|
51646
|
-
key: "getProvider",
|
|
51647
|
-
value: function getProvider() {
|
|
51648
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51649
|
-
var storage = this.get(sign);
|
|
51650
|
-
if (!storage) {
|
|
51651
|
-
return false;
|
|
51652
|
-
}
|
|
51653
|
-
return storage.cloudserv_storage_provider;
|
|
51654
|
-
}
|
|
51655
|
-
}, {
|
|
51656
|
-
key: "isAliyun",
|
|
51657
|
-
value: function isAliyun() {
|
|
51658
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51659
|
-
return this.getProvider(sign) === 'aliyun';
|
|
51660
|
-
}
|
|
51661
|
-
}, {
|
|
51662
|
-
key: "isAzure",
|
|
51663
|
-
value: function isAzure() {
|
|
51664
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51665
|
-
return this.getProvider(sign) === 'azure';
|
|
51666
|
-
}
|
|
51667
|
-
}, {
|
|
51668
|
-
key: "isAwss3",
|
|
51669
|
-
value: function isAwss3() {
|
|
51670
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51671
|
-
return this.getProvider(sign) === 'awss3';
|
|
51672
|
-
}
|
|
51673
|
-
}, {
|
|
51674
|
-
key: "isHuawei",
|
|
51675
|
-
value: function isHuawei() {
|
|
51676
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51677
|
-
return this.getProvider(sign) === 'huawei';
|
|
51678
|
-
}
|
|
51679
|
-
}]);
|
|
51680
|
-
return CloudServ;
|
|
51681
|
-
}();
|
|
51682
|
-
var cloudServ = new CloudServ();
|
|
51683
|
-
|
|
51684
52384
|
// 一个小时的超时能力 1000 * 60 * 60
|
|
51685
52385
|
var last = 0;
|
|
51686
52386
|
var servtoken = null;
|
|
@@ -51852,7 +52552,7 @@ var getUrl = /*#__PURE__*/function () {
|
|
|
51852
52552
|
while (1) switch (_context.prev = _context.next) {
|
|
51853
52553
|
case 0:
|
|
51854
52554
|
_ref$type = _ref.type, type = _ref$type === void 0 ? 'img' : _ref$type, _ref$source = _ref.source, source = _ref$source === void 0 ? '' : _ref$source, _ref$filename = _ref.filename, filename = _ref$filename === void 0 ? '' : _ref$filename, _ref$datetime = _ref.datetime, datetime = _ref$datetime === void 0 ? '' : _ref$datetime, _ref$storagetype = _ref.storagetype, storagetype = _ref$storagetype === void 0 ? 'storage' : _ref$storagetype, _ref$cope = _ref.cope, cope = _ref$cope === void 0 ? '' : _ref$cope;
|
|
51855
|
-
cloudServStorage =
|
|
52555
|
+
cloudServStorage = CloudServ$1.get(storagetype);
|
|
51856
52556
|
if (cloudServStorage) {
|
|
51857
52557
|
_context.next = 4;
|
|
51858
52558
|
break;
|
|
@@ -51869,8 +52569,8 @@ var getUrl = /*#__PURE__*/function () {
|
|
|
51869
52569
|
}
|
|
51870
52570
|
throw Error('无可用servToken');
|
|
51871
52571
|
case 9:
|
|
51872
|
-
isAliYun =
|
|
51873
|
-
isHuawei =
|
|
52572
|
+
isAliYun = CloudServ$1.isAliyun(storagetype);
|
|
52573
|
+
isHuawei = CloudServ$1.isHuawei(storagetype);
|
|
51874
52574
|
tenantCode = getUser('tenantcode');
|
|
51875
52575
|
if (!filename) {
|
|
51876
52576
|
filename = source;
|
|
@@ -52023,7 +52723,7 @@ var downloadFile = /*#__PURE__*/function () {
|
|
|
52023
52723
|
// console.log(e)
|
|
52024
52724
|
// throw Error(e)
|
|
52025
52725
|
// })
|
|
52026
|
-
isAliYun =
|
|
52726
|
+
isAliYun = CloudServ$1.isAliyun(storagetype); // const isHuawei = CloudServ.isHuawei(storagetype)
|
|
52027
52727
|
if (isAliYun) {
|
|
52028
52728
|
downloadFileByUrl(url, filename);
|
|
52029
52729
|
} else {
|
|
@@ -52503,7 +53203,7 @@ var upload = /*#__PURE__*/function () {
|
|
|
52503
53203
|
}
|
|
52504
53204
|
throw Error('请传入文件');
|
|
52505
53205
|
case 3:
|
|
52506
|
-
cloudServStorage =
|
|
53206
|
+
cloudServStorage = CloudServ$1.get(storagetype);
|
|
52507
53207
|
if (cloudServStorage) {
|
|
52508
53208
|
_context4.next = 6;
|
|
52509
53209
|
break;
|
|
@@ -52520,8 +53220,8 @@ var upload = /*#__PURE__*/function () {
|
|
|
52520
53220
|
}
|
|
52521
53221
|
throw Error('无可用servToken');
|
|
52522
53222
|
case 11:
|
|
52523
|
-
isAliYun =
|
|
52524
|
-
isHuawei =
|
|
53223
|
+
isAliYun = CloudServ$1.isAliyun(storagetype);
|
|
53224
|
+
isHuawei = CloudServ$1.isHuawei(storagetype);
|
|
52525
53225
|
tenantCode = getUser('tenantcode');
|
|
52526
53226
|
suffix = '.' + file.name.substring(file.name.lastIndexOf('.') + 1);
|
|
52527
53227
|
source = source ? source : v4() + suffix;
|
|
@@ -52740,598 +53440,6 @@ var isInApp = function isInApp() {
|
|
|
52740
53440
|
}
|
|
52741
53441
|
};
|
|
52742
53442
|
|
|
52743
|
-
function e(e){this.message=e;}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,a=0,i=0,c="";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw "Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t})))}(t)}catch(e){return r(t)}}function n(e){this.message=e;}function o(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";
|
|
52744
|
-
|
|
52745
|
-
var Login = /*#__PURE__*/function () {
|
|
52746
|
-
function Login() {
|
|
52747
|
-
_classCallCheck$1(this, Login);
|
|
52748
|
-
_defineProperty$1(this, "cache", {});
|
|
52749
|
-
_defineProperty$1(this, "refreshtokenTimer", null);
|
|
52750
|
-
}
|
|
52751
|
-
_createClass$1(Login, [{
|
|
52752
|
-
key: "getData",
|
|
52753
|
-
value: function getData(key) {
|
|
52754
|
-
if (this.cache[key]) {
|
|
52755
|
-
return this.cache[key];
|
|
52756
|
-
} else {
|
|
52757
|
-
var data = lsProxy.getItem(key);
|
|
52758
|
-
this.cache[key] = data;
|
|
52759
|
-
return data;
|
|
52760
|
-
}
|
|
52761
|
-
}
|
|
52762
|
-
}, {
|
|
52763
|
-
key: "setData",
|
|
52764
|
-
value: function setData(key, value) {
|
|
52765
|
-
this.cache[key] = value;
|
|
52766
|
-
lsProxy.setItem(key, value);
|
|
52767
|
-
}
|
|
52768
|
-
}, {
|
|
52769
|
-
key: "removeData",
|
|
52770
|
-
value: function removeData(key) {
|
|
52771
|
-
delete this.cache[key];
|
|
52772
|
-
lsProxy.removeItem(key);
|
|
52773
|
-
}
|
|
52774
|
-
}, {
|
|
52775
|
-
key: "getEnvname",
|
|
52776
|
-
value: function () {
|
|
52777
|
-
var _getEnvname = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
52778
|
-
var _context, _window, _window2;
|
|
52779
|
-
var envname, context, contextEnvname, queryEnvname;
|
|
52780
|
-
return _regeneratorRuntime$1().wrap(function _callee$(_context2) {
|
|
52781
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
52782
|
-
case 0:
|
|
52783
|
-
envname = ''; // web 查 context 的 envname
|
|
52784
|
-
context = lsProxy.getItem('context');
|
|
52785
|
-
context && (context = JSON.parse(context));
|
|
52786
|
-
contextEnvname = ((_context = context) === null || _context === void 0 ? void 0 : _context.envname) || ''; // 链接有些spu可能会传 envname
|
|
52787
|
-
queryEnvname = this.getQueryEnvname();
|
|
52788
|
-
if (!contextEnvname) {
|
|
52789
|
-
_context2.next = 9;
|
|
52790
|
-
break;
|
|
52791
|
-
}
|
|
52792
|
-
envname = contextEnvname;
|
|
52793
|
-
_context2.next = 17;
|
|
52794
|
-
break;
|
|
52795
|
-
case 9:
|
|
52796
|
-
if (!queryEnvname) {
|
|
52797
|
-
_context2.next = 13;
|
|
52798
|
-
break;
|
|
52799
|
-
}
|
|
52800
|
-
envname = queryEnvname;
|
|
52801
|
-
_context2.next = 17;
|
|
52802
|
-
break;
|
|
52803
|
-
case 13:
|
|
52804
|
-
if (!((_window = window) !== null && _window !== void 0 && (_window = _window.aPaaS) !== null && _window !== void 0 && _window.getWebInitParams && (_window2 = window) !== null && _window2 !== void 0 && (_window2 = _window2.Native) !== null && _window2 !== void 0 && _window2.setNavigationBarReturnButton)) {
|
|
52805
|
-
_context2.next = 17;
|
|
52806
|
-
break;
|
|
52807
|
-
}
|
|
52808
|
-
_context2.next = 16;
|
|
52809
|
-
return new Promise(function (resolve, reject) {
|
|
52810
|
-
window.aPaaS.getWebInitParams(function (params) {
|
|
52811
|
-
resolve((params === null || params === void 0 ? void 0 : params.envname) || '');
|
|
52812
|
-
});
|
|
52813
|
-
});
|
|
52814
|
-
case 16:
|
|
52815
|
-
envname = _context2.sent;
|
|
52816
|
-
case 17:
|
|
52817
|
-
return _context2.abrupt("return", envname);
|
|
52818
|
-
case 18:
|
|
52819
|
-
case "end":
|
|
52820
|
-
return _context2.stop();
|
|
52821
|
-
}
|
|
52822
|
-
}, _callee, this);
|
|
52823
|
-
}));
|
|
52824
|
-
function getEnvname() {
|
|
52825
|
-
return _getEnvname.apply(this, arguments);
|
|
52826
|
-
}
|
|
52827
|
-
return getEnvname;
|
|
52828
|
-
}()
|
|
52829
|
-
}, {
|
|
52830
|
-
key: "setQueryEnvname",
|
|
52831
|
-
value: function setQueryEnvname(value) {
|
|
52832
|
-
this.setData('envname', value);
|
|
52833
|
-
}
|
|
52834
|
-
}, {
|
|
52835
|
-
key: "getQueryEnvname",
|
|
52836
|
-
value: function getQueryEnvname() {
|
|
52837
|
-
return this.getData('envname') || '';
|
|
52838
|
-
}
|
|
52839
|
-
}, {
|
|
52840
|
-
key: "removeQueryEnvname",
|
|
52841
|
-
value: function removeQueryEnvname() {
|
|
52842
|
-
this.removeData('envname');
|
|
52843
|
-
}
|
|
52844
|
-
}, {
|
|
52845
|
-
key: "getToken",
|
|
52846
|
-
value: function getToken() {
|
|
52847
|
-
return this.getData('token');
|
|
52848
|
-
}
|
|
52849
|
-
}, {
|
|
52850
|
-
key: "setToken",
|
|
52851
|
-
value: function setToken(value) {
|
|
52852
|
-
this.setData('token', value);
|
|
52853
|
-
}
|
|
52854
|
-
}, {
|
|
52855
|
-
key: "removeToken",
|
|
52856
|
-
value: function removeToken() {
|
|
52857
|
-
this.removeData('token');
|
|
52858
|
-
}
|
|
52859
|
-
}, {
|
|
52860
|
-
key: "getTokenExpires",
|
|
52861
|
-
value: function getTokenExpires() {
|
|
52862
|
-
return this.getData('tokenexpires');
|
|
52863
|
-
}
|
|
52864
|
-
}, {
|
|
52865
|
-
key: "setTokenExpires",
|
|
52866
|
-
value: function setTokenExpires(value) {
|
|
52867
|
-
this.setData('tokenexpires', value);
|
|
52868
|
-
}
|
|
52869
|
-
}, {
|
|
52870
|
-
key: "removeTokenExpires",
|
|
52871
|
-
value: function removeTokenExpires() {
|
|
52872
|
-
this.removeData('tokenexpires');
|
|
52873
|
-
}
|
|
52874
|
-
}, {
|
|
52875
|
-
key: "getRefreshToken",
|
|
52876
|
-
value: function getRefreshToken() {
|
|
52877
|
-
return this.getData('refreshtoken');
|
|
52878
|
-
}
|
|
52879
|
-
}, {
|
|
52880
|
-
key: "setRefreshToken",
|
|
52881
|
-
value: function setRefreshToken(value) {
|
|
52882
|
-
this.setData('refreshtoken', value);
|
|
52883
|
-
}
|
|
52884
|
-
}, {
|
|
52885
|
-
key: "removeRefreshToken",
|
|
52886
|
-
value: function removeRefreshToken() {
|
|
52887
|
-
this.removeData('refreshtoken');
|
|
52888
|
-
}
|
|
52889
|
-
}, {
|
|
52890
|
-
key: "updateToken",
|
|
52891
|
-
value: function updateToken() {
|
|
52892
|
-
var _this = this;
|
|
52893
|
-
return normalAxios.get('/api/auth/refreshtoken', {
|
|
52894
|
-
params: {
|
|
52895
|
-
refreshtoken: this.getRefreshToken()
|
|
52896
|
-
},
|
|
52897
|
-
isShowLoadding: false,
|
|
52898
|
-
isShowErrorMessage: false
|
|
52899
|
-
}).then(function (res) {
|
|
52900
|
-
// console.log(res)
|
|
52901
|
-
var data = res === null || res === void 0 ? void 0 : res.data;
|
|
52902
|
-
if (data) {
|
|
52903
|
-
_this.setToken(data.token);
|
|
52904
|
-
_this.setRefreshToken(data.refreshtoken);
|
|
52905
|
-
_this.setTokenExpires(data.tokenexpires);
|
|
52906
|
-
}
|
|
52907
|
-
});
|
|
52908
|
-
}
|
|
52909
|
-
}, {
|
|
52910
|
-
key: "startRefreshtoken",
|
|
52911
|
-
value: function startRefreshtoken() {
|
|
52912
|
-
var _this2 = this;
|
|
52913
|
-
// 如果有登录 则过期前15秒更新token
|
|
52914
|
-
// 如果没登录 每隔1分钟走token更新逻辑(如果刚开始没登录 后面才登录【不需要再在登陆后写刷新token逻辑】)
|
|
52915
|
-
this.stopRefreshtoken();
|
|
52916
|
-
var time = this.checkLogin() ? Number(this.getTokenExpires()) - Date.now() - 1000 * 15 : 1000 * 60;
|
|
52917
|
-
// const time = 5000
|
|
52918
|
-
if (time > 0) {
|
|
52919
|
-
this.refreshtokenTimer = window.setTimeout( /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2() {
|
|
52920
|
-
return _regeneratorRuntime$1().wrap(function _callee2$(_context3) {
|
|
52921
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
52922
|
-
case 0:
|
|
52923
|
-
if (!_this2.checkLogin()) {
|
|
52924
|
-
_context3.next = 3;
|
|
52925
|
-
break;
|
|
52926
|
-
}
|
|
52927
|
-
_context3.next = 3;
|
|
52928
|
-
return _this2.updateToken();
|
|
52929
|
-
case 3:
|
|
52930
|
-
_this2.startRefreshtoken();
|
|
52931
|
-
case 4:
|
|
52932
|
-
case "end":
|
|
52933
|
-
return _context3.stop();
|
|
52934
|
-
}
|
|
52935
|
-
}, _callee2);
|
|
52936
|
-
})), time);
|
|
52937
|
-
}
|
|
52938
|
-
}
|
|
52939
|
-
}, {
|
|
52940
|
-
key: "stopRefreshtoken",
|
|
52941
|
-
value: function stopRefreshtoken() {
|
|
52942
|
-
clearTimeout(this.refreshtokenTimer);
|
|
52943
|
-
this.refreshtokenTimer = null;
|
|
52944
|
-
}
|
|
52945
|
-
}, {
|
|
52946
|
-
key: "getUser",
|
|
52947
|
-
value: function getUser(key) {
|
|
52948
|
-
var user = this.getData('user');
|
|
52949
|
-
var userObj = user ? JSON.parse(user) : null;
|
|
52950
|
-
if (!key) {
|
|
52951
|
-
return userObj;
|
|
52952
|
-
} else {
|
|
52953
|
-
return userObj ? userObj[key] || '' : '';
|
|
52954
|
-
}
|
|
52955
|
-
}
|
|
52956
|
-
}, {
|
|
52957
|
-
key: "setUser",
|
|
52958
|
-
value: function setUser(value) {
|
|
52959
|
-
var res;
|
|
52960
|
-
if (typeof value === 'string') {
|
|
52961
|
-
res = JSON.parse(value);
|
|
52962
|
-
} else {
|
|
52963
|
-
res = cloneDeep$1(value);
|
|
52964
|
-
}
|
|
52965
|
-
for (var x in res) {
|
|
52966
|
-
res[x.toLowerCase()] = res[x];
|
|
52967
|
-
}
|
|
52968
|
-
this.setData('user', JSON.stringify(res));
|
|
52969
|
-
}
|
|
52970
|
-
}, {
|
|
52971
|
-
key: "setUserByToken",
|
|
52972
|
-
value: function setUserByToken(token) {
|
|
52973
|
-
var jwtInfo = this.jwtDecode(token);
|
|
52974
|
-
if (jwtInfo && jwtInfo.LoginUser) {
|
|
52975
|
-
this.setUser(jwtInfo.LoginUser);
|
|
52976
|
-
} else {
|
|
52977
|
-
this.removeUser();
|
|
52978
|
-
}
|
|
52979
|
-
}
|
|
52980
|
-
}, {
|
|
52981
|
-
key: "removeUser",
|
|
52982
|
-
value: function removeUser() {
|
|
52983
|
-
this.removeData('user');
|
|
52984
|
-
}
|
|
52985
|
-
}, {
|
|
52986
|
-
key: "jwtDecode",
|
|
52987
|
-
value: function jwtDecode(token) {
|
|
52988
|
-
if (!token) {
|
|
52989
|
-
console.error('token为空 jwt解析token出错');
|
|
52990
|
-
return null;
|
|
52991
|
-
}
|
|
52992
|
-
try {
|
|
52993
|
-
return o(token);
|
|
52994
|
-
} catch (e) {
|
|
52995
|
-
console.error('jwt解析token出错', token, e);
|
|
52996
|
-
return null;
|
|
52997
|
-
}
|
|
52998
|
-
}
|
|
52999
|
-
// // 产品运营中心token
|
|
53000
|
-
// {
|
|
53001
|
-
// "LoginUser": {
|
|
53002
|
-
// "appId": "100",
|
|
53003
|
-
// "tenantCode": "1656652",
|
|
53004
|
-
// "productCode": "100000000000000000",
|
|
53005
|
-
// "productVersionCode": null,
|
|
53006
|
-
// "clientTypeCode": null,
|
|
53007
|
-
// "userCode": "6",
|
|
53008
|
-
// "accountCode": "6",
|
|
53009
|
-
// "username": "庄焕滨",
|
|
53010
|
-
// "tokenId": "bd69b4a4-5376-47cd-91c3-f1e1576440e5",
|
|
53011
|
-
// "appCodes": null,
|
|
53012
|
-
// "appCode": null,
|
|
53013
|
-
// "platRoleCodes": ["1637696814759153664"],
|
|
53014
|
-
// "metamodeltype": 2,
|
|
53015
|
-
// "orgCode": "1751852081616130048",
|
|
53016
|
-
// "centerRole": true
|
|
53017
|
-
// },
|
|
53018
|
-
// "TwoFactorAuthCode": "6f56da978dffe31a3b03a56c446f9467",
|
|
53019
|
-
// "exp": 1751694745
|
|
53020
|
-
// }
|
|
53021
|
-
// // 租户token
|
|
53022
|
-
// {
|
|
53023
|
-
// "exp": 1720161305,
|
|
53024
|
-
// "LoginUser": {
|
|
53025
|
-
// "accountInfoCode": "1803686723986010112",
|
|
53026
|
-
// "accountCode": "1803686724107644928",
|
|
53027
|
-
// "tenantCode": "3000911",
|
|
53028
|
-
// "productCode": "100000000000000000",
|
|
53029
|
-
// "productVersionCode": "30000000000000911",
|
|
53030
|
-
// "clientTypeCode": 1,
|
|
53031
|
-
// "tokenId": "8614059e-69a5-4e1e-a948-f2ef680d0dd5",
|
|
53032
|
-
// "orgCode": "1803686397149065216",
|
|
53033
|
-
// "userInfoId": "1806591894588108800",
|
|
53034
|
-
// "userInfoName": "woOUQJEAAAn4r5-7jffaxad6yotbEZ5A",
|
|
53035
|
-
// "positionCode": "1803686397304254473",
|
|
53036
|
-
// "positionName": "系统管理员-勿删",
|
|
53037
|
-
// "memberCode": "1806591894659411968",
|
|
53038
|
-
// "refPositionCode": "1300728614534385664",
|
|
53039
|
-
// "categoryCode": "",
|
|
53040
|
-
// "orgStructTypeId": "1",
|
|
53041
|
-
// "userName": null,
|
|
53042
|
-
// "userName1": "woOUQJEAAAn4r5-7jffaxad6yotbEZ5A",
|
|
53043
|
-
// "userName2": null,
|
|
53044
|
-
// "userName3": null,
|
|
53045
|
-
// "tenantName": "智慧100-企微版-V9.1.1开发租户",
|
|
53046
|
-
// "appCode": "sales",
|
|
53047
|
-
// "appCodes": [
|
|
53048
|
-
// "promotion",
|
|
53049
|
-
// "distribution",
|
|
53050
|
-
// "sales"
|
|
53051
|
-
// ],
|
|
53052
|
-
// "subPdCodes": [
|
|
53053
|
-
// "sfa",
|
|
53054
|
-
// "dms",
|
|
53055
|
-
// "pmm",
|
|
53056
|
-
// "tpm",
|
|
53057
|
-
// "ai"
|
|
53058
|
-
// ],
|
|
53059
|
-
// "codepath": "1.1803686395634921472.1803686397149065216.",
|
|
53060
|
-
// "isleaforg": "true",
|
|
53061
|
-
// "metamodeltype": 1,
|
|
53062
|
-
// "isSmsLogin": false
|
|
53063
|
-
// }
|
|
53064
|
-
// }
|
|
53065
|
-
// 查询token所属登录角色
|
|
53066
|
-
// tenant: 普通租户登录 默认
|
|
53067
|
-
// center: 产品运营中心登录 单点登录时只带 token 没带 refreshtoken 和 tokenexpires
|
|
53068
|
-
}, {
|
|
53069
|
-
key: "getLoginRole",
|
|
53070
|
-
value: function getLoginRole(token) {
|
|
53071
|
-
var loginRole = 'tenant'; // center | tenant
|
|
53072
|
-
if (token) {
|
|
53073
|
-
var _jwtInfo$LoginUser, _jwtInfo$LoginUser2;
|
|
53074
|
-
var jwtInfo = this.jwtDecode(token);
|
|
53075
|
-
if (jwtInfo !== null && jwtInfo !== void 0 && (_jwtInfo$LoginUser = jwtInfo.LoginUser) !== null && _jwtInfo$LoginUser !== void 0 && _jwtInfo$LoginUser.centerRole || (jwtInfo === null || jwtInfo === void 0 || (_jwtInfo$LoginUser2 = jwtInfo.LoginUser) === null || _jwtInfo$LoginUser2 === void 0 ? void 0 : _jwtInfo$LoginUser2.appId) === '100') {
|
|
53076
|
-
// 产品运营中心登录
|
|
53077
|
-
loginRole = 'center';
|
|
53078
|
-
}
|
|
53079
|
-
}
|
|
53080
|
-
return loginRole;
|
|
53081
|
-
}
|
|
53082
|
-
// 检测当前用户是否登录状态
|
|
53083
|
-
}, {
|
|
53084
|
-
key: "checkLogin",
|
|
53085
|
-
value: function checkLogin() {
|
|
53086
|
-
var haslogged = false;
|
|
53087
|
-
var token = this.getToken();
|
|
53088
|
-
if (token) {
|
|
53089
|
-
if (this.getLoginRole(token) === 'center') {
|
|
53090
|
-
haslogged = this.checkTokenLogin(token);
|
|
53091
|
-
} else {
|
|
53092
|
-
var refreshtoken = this.getRefreshToken();
|
|
53093
|
-
var tokenexpires = this.getTokenExpires();
|
|
53094
|
-
var now = Date.now();
|
|
53095
|
-
if (token && refreshtoken && tokenexpires && Number(tokenexpires) > now) {
|
|
53096
|
-
haslogged = this.checkTokenLogin(token);
|
|
53097
|
-
}
|
|
53098
|
-
}
|
|
53099
|
-
}
|
|
53100
|
-
return haslogged;
|
|
53101
|
-
}
|
|
53102
|
-
// 检测token是否过期
|
|
53103
|
-
}, {
|
|
53104
|
-
key: "checkTokenLogin",
|
|
53105
|
-
value: function checkTokenLogin(token) {
|
|
53106
|
-
var haslogged = false;
|
|
53107
|
-
if (token) {
|
|
53108
|
-
var now = Date.now();
|
|
53109
|
-
var jwtInfo = this.jwtDecode(token);
|
|
53110
|
-
if (jwtInfo !== null && jwtInfo !== void 0 && jwtInfo.exp) {
|
|
53111
|
-
haslogged = Number(jwtInfo.exp + '000') > now;
|
|
53112
|
-
} else {
|
|
53113
|
-
haslogged = false;
|
|
53114
|
-
}
|
|
53115
|
-
}
|
|
53116
|
-
return haslogged;
|
|
53117
|
-
}
|
|
53118
|
-
// 接口请求回来的 userInfo 有 functioncodes 以便做权限校验
|
|
53119
|
-
// 有可能是中心角色请求失败 兼容不报错
|
|
53120
|
-
}, {
|
|
53121
|
-
key: "getAndSetUserInfo",
|
|
53122
|
-
value: function () {
|
|
53123
|
-
var _getAndSetUserInfo = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
|
|
53124
|
-
var accountinfo;
|
|
53125
|
-
return _regeneratorRuntime$1().wrap(function _callee3$(_context4) {
|
|
53126
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
53127
|
-
case 0:
|
|
53128
|
-
_context4.prev = 0;
|
|
53129
|
-
_context4.next = 3;
|
|
53130
|
-
return normalAxios.post('/api/teapi/rolepermission/account/getaccountinfo', {
|
|
53131
|
-
positionid: this.getUser('positioncode') || '',
|
|
53132
|
-
deviceinfo: '',
|
|
53133
|
-
sysversion: '',
|
|
53134
|
-
clientversion: ''
|
|
53135
|
-
}).then(function (res) {
|
|
53136
|
-
if (res.code === 200 && res.data) {
|
|
53137
|
-
return res.data;
|
|
53138
|
-
} else {
|
|
53139
|
-
return null;
|
|
53140
|
-
}
|
|
53141
|
-
});
|
|
53142
|
-
case 3:
|
|
53143
|
-
accountinfo = _context4.sent;
|
|
53144
|
-
if (accountinfo) {
|
|
53145
|
-
this.setUser(accountinfo);
|
|
53146
|
-
}
|
|
53147
|
-
_context4.next = 11;
|
|
53148
|
-
break;
|
|
53149
|
-
case 7:
|
|
53150
|
-
_context4.prev = 7;
|
|
53151
|
-
_context4.t0 = _context4["catch"](0);
|
|
53152
|
-
console.error(_context4.t0);
|
|
53153
|
-
console.warn('获取用户信息失败,当前您登录的帐号可能为非标准租户帐号。');
|
|
53154
|
-
case 11:
|
|
53155
|
-
case "end":
|
|
53156
|
-
return _context4.stop();
|
|
53157
|
-
}
|
|
53158
|
-
}, _callee3, this, [[0, 7]]);
|
|
53159
|
-
}));
|
|
53160
|
-
function getAndSetUserInfo() {
|
|
53161
|
-
return _getAndSetUserInfo.apply(this, arguments);
|
|
53162
|
-
}
|
|
53163
|
-
return getAndSetUserInfo;
|
|
53164
|
-
}()
|
|
53165
|
-
}, {
|
|
53166
|
-
key: "formatTenant",
|
|
53167
|
-
value: function formatTenant(tenant) {
|
|
53168
|
-
if (!tenant) {
|
|
53169
|
-
return null;
|
|
53170
|
-
}
|
|
53171
|
-
var cloundTagMap = ['storage', 'storage-1d', 'storage-1y', 'storage-3m'];
|
|
53172
|
-
var result = {};
|
|
53173
|
-
for (var _i = 0, _cloundTagMap = cloundTagMap; _i < _cloundTagMap.length; _i++) {
|
|
53174
|
-
var keyItem = _cloundTagMap[_i];
|
|
53175
|
-
var _cloudServ = tenant.cloudserv[keyItem];
|
|
53176
|
-
if (_cloudServ) {
|
|
53177
|
-
result[keyItem] = {
|
|
53178
|
-
cloudserv_storage_provider: _cloudServ.provider,
|
|
53179
|
-
cloudserv_storage_storagebucket: _cloudServ.storagebucket,
|
|
53180
|
-
cloudserv_storage_storageendpoint: _cloudServ.storageendpoint,
|
|
53181
|
-
cloudserv_storage_storageurl: _cloudServ.storageurl,
|
|
53182
|
-
cloudserv_storage_accesskeyid: _cloudServ.accesskeyid,
|
|
53183
|
-
cloudserv_storage_region: _cloudServ.region
|
|
53184
|
-
};
|
|
53185
|
-
}
|
|
53186
|
-
}
|
|
53187
|
-
if (Object.keys(result).length === 0) {
|
|
53188
|
-
return null;
|
|
53189
|
-
}
|
|
53190
|
-
return result;
|
|
53191
|
-
}
|
|
53192
|
-
}, {
|
|
53193
|
-
key: "getAndSetTenant",
|
|
53194
|
-
value: function () {
|
|
53195
|
-
var _getAndSetTenant = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(tenantcode) {
|
|
53196
|
-
var tenantsRes, tenant, normalizedTenant;
|
|
53197
|
-
return _regeneratorRuntime$1().wrap(function _callee4$(_context5) {
|
|
53198
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
53199
|
-
case 0:
|
|
53200
|
-
_context5.prev = 0;
|
|
53201
|
-
_context5.next = 3;
|
|
53202
|
-
return normalAxios.get('/api/auth/tenantlist', {}).then(function (res) {
|
|
53203
|
-
var _res$data;
|
|
53204
|
-
return res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.tenants;
|
|
53205
|
-
});
|
|
53206
|
-
case 3:
|
|
53207
|
-
tenantsRes = _context5.sent;
|
|
53208
|
-
tenant = null;
|
|
53209
|
-
if (tenantsRes !== null && tenantsRes !== void 0 && tenantsRes.length) {
|
|
53210
|
-
if (!tenantcode) {
|
|
53211
|
-
tenant = tenantsRes[0];
|
|
53212
|
-
} else {
|
|
53213
|
-
tenant = tenantsRes.find(function (item) {
|
|
53214
|
-
return item.code === tenantcode;
|
|
53215
|
-
}) || null;
|
|
53216
|
-
}
|
|
53217
|
-
}
|
|
53218
|
-
if (!tenant) {
|
|
53219
|
-
lsProxy.removeItem('tenant');
|
|
53220
|
-
cloudServ.remove();
|
|
53221
|
-
} else {
|
|
53222
|
-
lsProxy.setItem('tenant', JSON.stringify(tenant));
|
|
53223
|
-
normalizedTenant = this.formatTenant(tenant);
|
|
53224
|
-
if (normalizedTenant) {
|
|
53225
|
-
cloudServ.set(normalizedTenant);
|
|
53226
|
-
}
|
|
53227
|
-
}
|
|
53228
|
-
_context5.next = 13;
|
|
53229
|
-
break;
|
|
53230
|
-
case 9:
|
|
53231
|
-
_context5.prev = 9;
|
|
53232
|
-
_context5.t0 = _context5["catch"](0);
|
|
53233
|
-
console.error(_context5.t0);
|
|
53234
|
-
console.warn('获取租户信息失败,当前您登录的帐号可能为非标准租户帐号。');
|
|
53235
|
-
case 13:
|
|
53236
|
-
case "end":
|
|
53237
|
-
return _context5.stop();
|
|
53238
|
-
}
|
|
53239
|
-
}, _callee4, this, [[0, 9]]);
|
|
53240
|
-
}));
|
|
53241
|
-
function getAndSetTenant(_x) {
|
|
53242
|
-
return _getAndSetTenant.apply(this, arguments);
|
|
53243
|
-
}
|
|
53244
|
-
return getAndSetTenant;
|
|
53245
|
-
}() // 单点登录
|
|
53246
|
-
}, {
|
|
53247
|
-
key: "singleLogin",
|
|
53248
|
-
value: function () {
|
|
53249
|
-
var _singleLogin = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5(query) {
|
|
53250
|
-
var flag, token, refreshtoken, tokenexpires, envname, context, isneedlogin, loginRole;
|
|
53251
|
-
return _regeneratorRuntime$1().wrap(function _callee5$(_context6) {
|
|
53252
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
53253
|
-
case 0:
|
|
53254
|
-
query = cloneDeep$1(query);
|
|
53255
|
-
flag = false; // 是否登录成功
|
|
53256
|
-
token = query.token;
|
|
53257
|
-
refreshtoken = query.refreshtoken;
|
|
53258
|
-
tokenexpires = query.tokenexpires;
|
|
53259
|
-
envname = query.envname;
|
|
53260
|
-
context = query.context;
|
|
53261
|
-
if (!this.checkTokenLogin(token)) {
|
|
53262
|
-
_context6.next = 25;
|
|
53263
|
-
break;
|
|
53264
|
-
}
|
|
53265
|
-
isneedlogin = true; // 是否需要走单点登录流程
|
|
53266
|
-
loginRole = this.getLoginRole(token);
|
|
53267
|
-
if (loginRole === 'center') {
|
|
53268
|
-
// 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
|
|
53269
|
-
// 之所以不强制校验 refreshtoken tokenexpires 是因为安装卸载配置页面有可能放在产品运营中心 没有这两字段
|
|
53270
|
-
if (this.checkLogin() && token === this.getToken()) {
|
|
53271
|
-
isneedlogin = false;
|
|
53272
|
-
flag = true;
|
|
53273
|
-
}
|
|
53274
|
-
} else {
|
|
53275
|
-
// 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
|
|
53276
|
-
if (this.checkLogin() && token === this.getToken() && refreshtoken === this.getRefreshToken() && tokenexpires === this.getTokenExpires()) {
|
|
53277
|
-
isneedlogin = false;
|
|
53278
|
-
flag = true;
|
|
53279
|
-
}
|
|
53280
|
-
}
|
|
53281
|
-
if (!isneedlogin) {
|
|
53282
|
-
_context6.next = 23;
|
|
53283
|
-
break;
|
|
53284
|
-
}
|
|
53285
|
-
this.setToken(token);
|
|
53286
|
-
this.setUserByToken(token); // 解析token为用户信息存入
|
|
53287
|
-
refreshtoken ? this.setRefreshToken(refreshtoken) : this.removeRefreshToken();
|
|
53288
|
-
tokenexpires ? this.setTokenExpires(tokenexpires) : this.removeTokenExpires();
|
|
53289
|
-
envname ? this.setQueryEnvname(envname) : this.removeQueryEnvname();
|
|
53290
|
-
// context 上下文字段 产品运营中心安装 卸载 配置 和 产品配置中心业务配置 页面需要用到
|
|
53291
|
-
// web 端有传 app没传 需要做兼容
|
|
53292
|
-
context && lsProxy.setItem('context', decodeURIComponent(context));
|
|
53293
|
-
// 这里兼容报错
|
|
53294
|
-
_context6.next = 20;
|
|
53295
|
-
return this.getAndSetTenant();
|
|
53296
|
-
case 20:
|
|
53297
|
-
_context6.next = 22;
|
|
53298
|
-
return this.getAndSetUserInfo();
|
|
53299
|
-
case 22:
|
|
53300
|
-
flag = true;
|
|
53301
|
-
case 23:
|
|
53302
|
-
_context6.next = 27;
|
|
53303
|
-
break;
|
|
53304
|
-
case 25:
|
|
53305
|
-
flag = false;
|
|
53306
|
-
console.error('没传 token 或所传 token 已过期,无法单点登录。');
|
|
53307
|
-
case 27:
|
|
53308
|
-
// 单点登录后 无论是否成功 都需要删除 query 中相关参数
|
|
53309
|
-
token && delete query.token;
|
|
53310
|
-
refreshtoken && delete query.refreshtoken;
|
|
53311
|
-
tokenexpires && delete query.tokenexpires;
|
|
53312
|
-
envname && delete query.envname;
|
|
53313
|
-
context && delete query.context;
|
|
53314
|
-
// debugger
|
|
53315
|
-
return _context6.abrupt("return", {
|
|
53316
|
-
flag: flag,
|
|
53317
|
-
query: query
|
|
53318
|
-
});
|
|
53319
|
-
case 33:
|
|
53320
|
-
case "end":
|
|
53321
|
-
return _context6.stop();
|
|
53322
|
-
}
|
|
53323
|
-
}, _callee5, this);
|
|
53324
|
-
}));
|
|
53325
|
-
function singleLogin(_x2) {
|
|
53326
|
-
return _singleLogin.apply(this, arguments);
|
|
53327
|
-
}
|
|
53328
|
-
return singleLogin;
|
|
53329
|
-
}()
|
|
53330
|
-
}]);
|
|
53331
|
-
return Login;
|
|
53332
|
-
}();
|
|
53333
|
-
var login = new Login();
|
|
53334
|
-
|
|
53335
53443
|
// import SpuLoadding from './loadding'
|
|
53336
53444
|
// import SpuExpandexp from './expandexp'
|
|
53337
53445
|
var index = {
|
|
@@ -60582,10 +60690,12 @@ function _initTest() {
|
|
|
60582
60690
|
// }
|
|
60583
60691
|
// // SPUWebPlugin.install = install
|
|
60584
60692
|
// // SPUWebPlugin.version = version
|
|
60693
|
+
// 基于部署路径查出 modulekey moduleversion
|
|
60694
|
+
var arr = location.pathname.split('/');
|
|
60585
60695
|
var globalOptions = {
|
|
60586
|
-
|
|
60587
|
-
|
|
60588
|
-
moduleversion: '
|
|
60696
|
+
modulename: '',
|
|
60697
|
+
modulekey: arr[1] || '',
|
|
60698
|
+
moduleversion: arr[2] || '',
|
|
60589
60699
|
storageproxyprefix: '',
|
|
60590
60700
|
router: null
|
|
60591
60701
|
};
|
|
@@ -60669,13 +60779,13 @@ var SPUWebPlugin = {
|
|
|
60669
60779
|
install: install,
|
|
60670
60780
|
version: version
|
|
60671
60781
|
};
|
|
60782
|
+
var updateToken = login.updateToken.bind(login);
|
|
60672
60783
|
var getToken = login.getToken.bind(login);
|
|
60673
60784
|
var getTokenExpires = login.getTokenExpires.bind(login);
|
|
60674
60785
|
var getRefreshToken = login.getRefreshToken.bind(login);
|
|
60675
60786
|
var getUser = login.getUser.bind(login);
|
|
60676
60787
|
var checkLogin = login.checkLogin.bind(login);
|
|
60677
60788
|
var singleLogin = login.singleLogin.bind(login);
|
|
60678
|
-
var startRefreshtoken = login.startRefreshtoken.bind(login);
|
|
60679
60789
|
var wxworkSuite = {
|
|
60680
60790
|
JSSDK: jssdk,
|
|
60681
60791
|
isWxworkSuiteTenant: isWxworkSuiteTenant,
|
|
@@ -60691,4 +60801,4 @@ var Module = {
|
|
|
60691
60801
|
getSpuContainerType: getSpuContainerType
|
|
60692
60802
|
};
|
|
60693
60803
|
|
|
60694
|
-
export { AMapLoader, Module, normalAxios as apaasAxios, normalAxios 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, lsProxy, setTitle, singleLogin, spuAxios, spuConfig, ssProxy,
|
|
60804
|
+
export { AMapLoader, Module, normalAxios as apaasAxios, normalAxios 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, lsProxy, setTitle, singleLogin, spuAxios, spuConfig, ssProxy, updateToken, uploadService, wxworkSuite };
|