@alipay/ams-checkout 0.0.1744283958-dev.0 → 0.0.1744283958-dev.10
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/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +6 -0
- package/esm/constant/index.js +6 -0
- package/esm/core/component/element/elementContainerService/containerService.d.ts +3 -0
- package/esm/core/component/element/elementContainerService/containerService.js +17 -2
- package/esm/core/component/element/elementContainerService/index.d.ts +1 -0
- package/esm/core/component/element/elementContainerService/index.js +8 -0
- package/esm/core/component/element/elementController/index.d.ts +5 -0
- package/esm/core/component/element/elementController/index.js +188 -95
- package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +4 -1
- package/esm/core/component/element/elementProcessor/addressProcessor.js +28 -6
- package/esm/core/component/element/elementProcessor/authProcessor.d.ts +4 -1
- package/esm/core/component/element/elementProcessor/authProcessor.js +28 -566
- package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +2 -0
- package/esm/core/component/element/elementProcessor/baseElementProcessor.js +6 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +53 -18
- package/esm/core/component/element/mock.d.ts +8 -0
- package/esm/core/component/element/mock.js +927 -0
- package/esm/core/component/element/type.d.ts +13 -0
- package/esm/core/component/element/util.d.ts +2 -1
- package/esm/core/component/element/util.js +124 -0
- package/esm/foundation/core/index.js +2 -1
- package/esm/foundation/index.d.ts +7 -0
- package/esm/foundation/index.js +3 -0
- package/esm/foundation/service/container/index.js +9 -2
- package/package.json +1 -1
package/esm/config/index.d.ts
CHANGED
@@ -5,10 +5,10 @@ export declare const sdkVersion: string;
|
|
5
5
|
/**
|
6
6
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
7
7
|
*/
|
8
|
-
export declare const AMSCheckoutAppVersion = "1.
|
9
|
-
export declare const AMSAutoDebitAppVersion = "1.
|
10
|
-
export declare const AMSEasyPayAppVersion = "1.
|
11
|
-
export declare const AMSCashierPaymentAppVersion = "1.
|
12
|
-
export declare const AMSVaultingAppVersion = "1.
|
13
|
-
export declare const AMSPaymentElementAppVersion = "1.
|
14
|
-
export declare const ADDRESSElementAppVersion = "1.
|
8
|
+
export declare const AMSCheckoutAppVersion = "1.34.0";
|
9
|
+
export declare const AMSAutoDebitAppVersion = "1.34.0";
|
10
|
+
export declare const AMSEasyPayAppVersion = "1.34.0";
|
11
|
+
export declare const AMSCashierPaymentAppVersion = "1.34.0";
|
12
|
+
export declare const AMSVaultingAppVersion = "1.34.0";
|
13
|
+
export declare const AMSPaymentElementAppVersion = "1.34.0";
|
14
|
+
export declare const ADDRESSElementAppVersion = "1.34.0";
|
package/esm/config/index.js
CHANGED
@@ -35,10 +35,10 @@ export var sdkVersion = json.version;
|
|
35
35
|
/**
|
36
36
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
37
37
|
*/
|
38
|
-
export var AMSCheckoutAppVersion = '1.
|
39
|
-
export var AMSAutoDebitAppVersion = '1.
|
40
|
-
export var AMSEasyPayAppVersion = '1.
|
41
|
-
export var AMSCashierPaymentAppVersion = '1.
|
42
|
-
export var AMSVaultingAppVersion = '1.
|
43
|
-
export var AMSPaymentElementAppVersion = '1.
|
44
|
-
export var ADDRESSElementAppVersion = '1.
|
38
|
+
export var AMSCheckoutAppVersion = '1.34.0'; // 兜底版本号
|
39
|
+
export var AMSAutoDebitAppVersion = '1.34.0'; // 代扣
|
40
|
+
export var AMSEasyPayAppVersion = '1.34.0'; // easypay
|
41
|
+
export var AMSCashierPaymentAppVersion = '1.34.0'; // 收银台(卡、apm)
|
42
|
+
export var AMSVaultingAppVersion = '1.34.0'; // 绑卡
|
43
|
+
export var AMSPaymentElementAppVersion = '1.34.0'; // payment element
|
44
|
+
export var ADDRESSElementAppVersion = '1.34.0'; // address element
|
package/esm/constant/index.d.ts
CHANGED
@@ -213,6 +213,12 @@ export declare const EVENT: {
|
|
213
213
|
updated: {
|
214
214
|
name: string;
|
215
215
|
};
|
216
|
+
webAppReady: {
|
217
|
+
name: string;
|
218
|
+
};
|
219
|
+
showToast: {
|
220
|
+
name: string;
|
221
|
+
};
|
216
222
|
};
|
217
223
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
218
224
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
package/esm/constant/index.js
CHANGED
@@ -13,6 +13,7 @@ export declare class ContainerController {
|
|
13
13
|
private instanceId;
|
14
14
|
private containerService;
|
15
15
|
private eventService;
|
16
|
+
private containerElement;
|
16
17
|
private _globalData?;
|
17
18
|
constructor({ type, instanceId, selector, processor, options, }: {
|
18
19
|
type: string;
|
@@ -22,9 +23,11 @@ export declare class ContainerController {
|
|
22
23
|
options: any;
|
23
24
|
});
|
24
25
|
private addEventListener;
|
26
|
+
getContainerElement(): HTMLDivElement;
|
25
27
|
createWebLaunchPromise(): Promise<unknown>;
|
26
28
|
switchContainerStatus(status: IContainerStatus): void;
|
27
29
|
getContainerStatus(): IContainerStatus;
|
28
30
|
getEventService(): EventCenter;
|
31
|
+
destroy(): void;
|
29
32
|
getContainerService(): ContainerService;
|
30
33
|
}
|
@@ -29,6 +29,7 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
29
29
|
_defineProperty(this, "instanceId", void 0);
|
30
30
|
_defineProperty(this, "containerService", void 0);
|
31
31
|
_defineProperty(this, "eventService", void 0);
|
32
|
+
_defineProperty(this, "containerElement", void 0);
|
32
33
|
_defineProperty(this, "_globalData", void 0);
|
33
34
|
this._globalData = new Map();
|
34
35
|
this.switchContainerStatus(IContainerStatus.INITING);
|
@@ -39,12 +40,15 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
39
40
|
sdkVersion: '',
|
40
41
|
webAppVersion: ''
|
41
42
|
});
|
42
|
-
this.containerService.load({
|
43
|
+
this.containerElement = this.containerService.load({
|
43
44
|
type: DisplayTypeEnum.inline,
|
44
45
|
platform: PlatformEnum.desktop,
|
45
46
|
isRetention: false,
|
46
47
|
selector: selector,
|
47
|
-
appendAliasContainerId: true
|
48
|
+
appendAliasContainerId: true,
|
49
|
+
iframeStyle: {
|
50
|
+
display: 'block'
|
51
|
+
}
|
48
52
|
}, processor.generateIframeSrc({
|
49
53
|
link: options === null || options === void 0 || (_options$debugProps = options.debugProps) === null || _options$debugProps === void 0 ? void 0 : _options$debugProps.localLink,
|
50
54
|
instanceId: this.instanceId
|
@@ -72,6 +76,11 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
72
76
|
}
|
73
77
|
});
|
74
78
|
}
|
79
|
+
}, {
|
80
|
+
key: "getContainerElement",
|
81
|
+
value: function getContainerElement() {
|
82
|
+
return this.containerElement;
|
83
|
+
}
|
75
84
|
}, {
|
76
85
|
key: "createWebLaunchPromise",
|
77
86
|
value: function createWebLaunchPromise() {
|
@@ -97,6 +106,12 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
97
106
|
value: function getEventService() {
|
98
107
|
return this.eventService;
|
99
108
|
}
|
109
|
+
}, {
|
110
|
+
key: "destroy",
|
111
|
+
value: function destroy() {
|
112
|
+
this.eventService.destroy();
|
113
|
+
this.containerElement.remove();
|
114
|
+
}
|
100
115
|
}, {
|
101
116
|
key: "getContainerService",
|
102
117
|
value: function getContainerService() {
|
@@ -9,6 +9,7 @@ export declare class ElementContainerService {
|
|
9
9
|
addContainerService(name: ElementType, service: ContainerController): void;
|
10
10
|
getContainerService(name: ElementType): ContainerController | undefined;
|
11
11
|
getContainerServices(): Map<ElementType, ContainerController>;
|
12
|
+
destroy(): void;
|
12
13
|
mount({ type, selector, processor, options }: {
|
13
14
|
type: any;
|
14
15
|
selector: any;
|
@@ -30,6 +30,14 @@ export var ElementContainerService = /*#__PURE__*/function () {
|
|
30
30
|
value: function getContainerServices() {
|
31
31
|
return this.containerServices;
|
32
32
|
}
|
33
|
+
}, {
|
34
|
+
key: "destroy",
|
35
|
+
value: function destroy() {
|
36
|
+
this.containerServices.forEach(function (value) {
|
37
|
+
value.destroy();
|
38
|
+
});
|
39
|
+
this.containerServices = new Map();
|
40
|
+
}
|
33
41
|
}, {
|
34
42
|
key: "mount",
|
35
43
|
value: function mount(_ref2) {
|
@@ -5,7 +5,9 @@ declare class ElementController {
|
|
5
5
|
private serviceMap;
|
6
6
|
private loading;
|
7
7
|
private elementProcessors;
|
8
|
+
private initTimeout;
|
8
9
|
private elementContainerService;
|
10
|
+
private onStatusChangeCallback;
|
9
11
|
constructor(options: IElementOptions);
|
10
12
|
private initService;
|
11
13
|
private initElementProcessors;
|
@@ -16,7 +18,10 @@ declare class ElementController {
|
|
16
18
|
private changeLoading;
|
17
19
|
private addEventListener;
|
18
20
|
private sendRequestAndWaitWebLaunch;
|
21
|
+
private sendReady;
|
19
22
|
updatePayment(paymentSessionData: any): Promise<unknown>;
|
23
|
+
private destroyHandle;
|
20
24
|
destroy(): void;
|
25
|
+
private setControllerStatusOrView;
|
21
26
|
}
|
22
27
|
export default ElementController;
|
@@ -23,14 +23,17 @@ import { EVENT } from "../../../../constant";
|
|
23
23
|
import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
|
24
24
|
import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
|
25
25
|
import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
|
26
|
+
import { IElementStatus } from "../../../../foundation";
|
26
27
|
import { AntomSDKCore } from "../../../../foundation/core";
|
27
28
|
import { ElementProcessor } from "../../../../foundation/product-processor/element";
|
28
29
|
import { destroyModal } from "../../../../plugin/component/popupWindow.style";
|
29
30
|
import { ProductSceneEnum } from "../../../../types";
|
30
31
|
import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
|
31
32
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
32
|
-
import {
|
33
|
-
import {
|
33
|
+
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
34
|
+
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode } from "../type";
|
35
|
+
import { checkCanMount, checkCanUpdate, handleRedirect, showToast } from "../util";
|
36
|
+
var TIMEOUT_DURATION = 10000;
|
34
37
|
var ElementController = /*#__PURE__*/function () {
|
35
38
|
// 新增变量
|
36
39
|
|
@@ -41,13 +44,18 @@ var ElementController = /*#__PURE__*/function () {
|
|
41
44
|
_defineProperty(this, "serviceMap", void 0);
|
42
45
|
_defineProperty(this, "loading", void 0);
|
43
46
|
_defineProperty(this, "elementProcessors", void 0);
|
47
|
+
_defineProperty(this, "initTimeout", void 0);
|
44
48
|
_defineProperty(this, "elementContainerService", void 0);
|
45
|
-
|
49
|
+
// 新增变量
|
50
|
+
_defineProperty(this, "onStatusChangeCallback", void 0);
|
51
|
+
_defineProperty(this, "onValidateFunc", function (event, target, params) {
|
46
52
|
return new Promise(function (resolve) {
|
47
53
|
event.emitAndListen({
|
48
54
|
event: ElementPaymentEvent.VALIDATE,
|
49
55
|
data: {
|
50
|
-
params: _objectSpread({}, params)
|
56
|
+
params: _objectSpread({}, params),
|
57
|
+
target: target,
|
58
|
+
source: ElementPaymentMethod.CONTAINER_ELEMENT
|
51
59
|
}
|
52
60
|
}, function (result) {
|
53
61
|
resolve(result);
|
@@ -55,6 +63,8 @@ var ElementController = /*#__PURE__*/function () {
|
|
55
63
|
});
|
56
64
|
});
|
57
65
|
this.options = options;
|
66
|
+
var _options = options;
|
67
|
+
this.onStatusChangeCallback = _options === null || _options === void 0 ? void 0 : _options.onStatusChangeCallback;
|
58
68
|
this.elementContainer = new AntomSDKCore();
|
59
69
|
this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor());
|
60
70
|
this.elementContainer.init(this.options, ProductSceneEnum.ELEMENT_PAYMENT);
|
@@ -62,7 +72,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
62
72
|
this.elementContainerService = new ElementContainerService({
|
63
73
|
instanceId: this.elementContainer.getInstanceId()
|
64
74
|
});
|
65
|
-
this.
|
75
|
+
this.setControllerStatusOrView(IElementStatus.READY);
|
66
76
|
}
|
67
77
|
_createClass(ElementController, [{
|
68
78
|
key: "initService",
|
@@ -98,75 +108,97 @@ var ElementController = /*#__PURE__*/function () {
|
|
98
108
|
key: "mount",
|
99
109
|
value: function mount(renderOptions, sdkSelector, cashier) {
|
100
110
|
var _this = this;
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
111
|
+
return new Promise(function (resolve) {
|
112
|
+
var _checkCanMount = checkCanMount({
|
113
|
+
sdkSelector: sdkSelector,
|
114
|
+
status: _this.elementContainer.getStatus(),
|
115
|
+
containerService: _this.elementContainerService.getContainerService(renderOptions.type)
|
116
|
+
}),
|
117
|
+
success = _checkCanMount.success,
|
118
|
+
errorMsg = _checkCanMount.errorMsg;
|
119
|
+
if (!success) {
|
120
|
+
_this.onEventCallback({
|
121
|
+
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
122
|
+
message: errorMsg
|
123
|
+
});
|
124
|
+
resolve({
|
125
|
+
success: false
|
126
|
+
});
|
127
|
+
return;
|
128
|
+
}
|
129
|
+
clearTimeout(_this.initTimeout);
|
130
|
+
_this.initTimeout = null;
|
131
|
+
_this.initTimeout = setTimeout(function () {
|
132
|
+
clearTimeout(_this.initTimeout);
|
133
|
+
_this.initTimeout = null;
|
134
|
+
_this.changeLoading(false);
|
135
|
+
_this.setControllerStatusOrView(IElementStatus.READY);
|
136
|
+
_this.elementContainerService.getContainerServices().forEach(function (value) {
|
137
|
+
value.getContainerElement().remove();
|
138
|
+
});
|
139
|
+
_this.elementContainerService.destroy();
|
140
|
+
}, TIMEOUT_DURATION);
|
141
|
+
_this.changeLoading(true);
|
142
|
+
var startBizFlowData = {
|
143
|
+
paymentSession: _this.options.sessionData,
|
144
|
+
displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
|
145
|
+
appendAliasContainerId: true
|
146
|
+
})
|
147
|
+
};
|
148
|
+
if (cashier && renderOptions.sessionData) {
|
149
|
+
startBizFlowData.paymentSession = renderOptions.sessionData;
|
150
|
+
}
|
151
|
+
_this.setControllerStatusOrView(IElementStatus.IN_BIZ_FLOW);
|
152
|
+
_this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
|
153
|
+
_this.onEventCallback({
|
154
|
+
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
155
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
156
|
+
});
|
157
|
+
_this.changeLoading(false);
|
158
|
+
return;
|
112
159
|
});
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
appendAliasContainerId: true
|
120
|
-
})
|
121
|
-
};
|
122
|
-
if (cashier && renderOptions.sessionData) {
|
123
|
-
startBizFlowData.paymentSession = renderOptions.sessionData;
|
124
|
-
}
|
125
|
-
this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
|
126
|
-
_this.onEventCallback({
|
127
|
-
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
128
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
160
|
+
_this.initElementProcessors(renderOptions.type);
|
161
|
+
_this.elementContainerService.mount({
|
162
|
+
type: renderOptions.type,
|
163
|
+
selector: sdkSelector,
|
164
|
+
processor: _this.elementProcessors[renderOptions.type],
|
165
|
+
options: renderOptions
|
129
166
|
});
|
130
|
-
_this.
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
this.sendRequestAndWaitWebLaunch(renderOptions);
|
143
|
-
this.addEventListener();
|
144
|
-
this.serviceMap.EventCenter.addIFrame(this.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
|
145
|
-
return {
|
146
|
-
getValue: this.elementProcessors[renderOptions.type].getValue.bind(this.elementProcessors[renderOptions.type]),
|
147
|
-
on: function on(event, callback) {
|
148
|
-
_this.elementProcessors[renderOptions.type].registerEventListener(event, callback);
|
167
|
+
_this.elementProcessors[renderOptions.type].registerEventCenter(_this.elementContainerService.getEventService(renderOptions.type));
|
168
|
+
_this.elementProcessors[renderOptions.type].beforeMount();
|
169
|
+
_this.sendRequestAndWaitWebLaunch(renderOptions);
|
170
|
+
function readyCallback(payload) {
|
171
|
+
var _this2 = this;
|
172
|
+
var resultData = _objectSpread({
|
173
|
+
getValue: this === null || this === void 0 ? void 0 : this.elementProcessors[renderOptions.type].getValue.bind(this === null || this === void 0 ? void 0 : this.elementProcessors[renderOptions.type]),
|
174
|
+
on: function on(event, callback) {
|
175
|
+
_this2 === null || _this2 === void 0 || _this2.elementProcessors[renderOptions.type].registerEventListener(event, callback);
|
176
|
+
}
|
177
|
+
}, payload);
|
178
|
+
resolve(resultData);
|
149
179
|
}
|
150
|
-
|
180
|
+
_this.addEventListener(readyCallback);
|
181
|
+
_this.serviceMap.EventCenter.addIFrame(_this.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
|
182
|
+
});
|
151
183
|
}
|
152
184
|
}, {
|
153
185
|
key: "submitPayment",
|
154
186
|
value: function submitPayment() {
|
155
|
-
var
|
187
|
+
var _this3 = this;
|
156
188
|
this.changeLoading(true);
|
157
189
|
new Promise( /*#__PURE__*/function () {
|
158
190
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
|
159
|
-
var params,
|
191
|
+
var params, _this3$elementProcess, _result$data, _result$data2, result, _this3$elementProcess2, _result$data3, _result$data4, _result, _this3$elementProcess3;
|
160
192
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
161
193
|
while (1) switch (_context.prev = _context.next) {
|
162
194
|
case 0:
|
163
195
|
params = {};
|
164
|
-
if (!
|
196
|
+
if (!_this3.elementProcessors[ElementType.auth]) {
|
165
197
|
_context.next = 8;
|
166
198
|
break;
|
167
199
|
}
|
168
200
|
_context.next = 4;
|
169
|
-
return
|
201
|
+
return _this3.onValidateFunc((_this3$elementProcess = _this3.elementProcessors[ElementType.auth]) === null || _this3$elementProcess === void 0 ? void 0 : _this3$elementProcess.eventCenter, ElementPaymentMethod.AUTH_ELEMENT);
|
170
202
|
case 4:
|
171
203
|
result = _context.sent;
|
172
204
|
params.accountInfo = (_result$data = result.data) === null || _result$data === void 0 || (_result$data = _result$data.data) === null || _result$data === void 0 ? void 0 : _result$data.accountInfo;
|
@@ -176,12 +208,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
176
208
|
}
|
177
209
|
return _context.abrupt("return", resolve(undefined));
|
178
210
|
case 8:
|
179
|
-
if (!
|
211
|
+
if (!_this3.elementProcessors[ElementType.address]) {
|
180
212
|
_context.next = 15;
|
181
213
|
break;
|
182
214
|
}
|
183
215
|
_context.next = 11;
|
184
|
-
return
|
216
|
+
return _this3.onValidateFunc((_this3$elementProcess2 = _this3.elementProcessors[ElementType.address]) === null || _this3$elementProcess2 === void 0 ? void 0 : _this3$elementProcess2.eventCenter, ElementPaymentMethod.ADDRESS_ELEMENT);
|
185
217
|
case 11:
|
186
218
|
_result = _context.sent;
|
187
219
|
params.shipping = (_result$data3 = _result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
|
@@ -191,13 +223,13 @@ var ElementController = /*#__PURE__*/function () {
|
|
191
223
|
}
|
192
224
|
return _context.abrupt("return", resolve(undefined));
|
193
225
|
case 15:
|
194
|
-
if (!
|
226
|
+
if (!_this3.elementProcessors[ElementType.payment]) {
|
195
227
|
_context.next = 25;
|
196
228
|
break;
|
197
229
|
}
|
198
230
|
_context.prev = 16;
|
199
231
|
_context.next = 19;
|
200
|
-
return
|
232
|
+
return _this3.onValidateFunc((_this3$elementProcess3 = _this3.elementProcessors[ElementType.payment]) === null || _this3$elementProcess3 === void 0 ? void 0 : _this3$elementProcess3.eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
201
233
|
case 19:
|
202
234
|
return _context.abrupt("return", resolve(undefined));
|
203
235
|
case 22:
|
@@ -216,9 +248,9 @@ var ElementController = /*#__PURE__*/function () {
|
|
216
248
|
return _ref2.apply(this, arguments);
|
217
249
|
};
|
218
250
|
}()).then(function () {
|
219
|
-
|
251
|
+
_this3.changeLoading(false);
|
220
252
|
}, function () {
|
221
|
-
|
253
|
+
_this3.changeLoading(false);
|
222
254
|
});
|
223
255
|
}
|
224
256
|
}, {
|
@@ -242,95 +274,143 @@ var ElementController = /*#__PURE__*/function () {
|
|
242
274
|
}
|
243
275
|
}, {
|
244
276
|
key: "addEventListener",
|
245
|
-
value: function addEventListener() {
|
246
|
-
var
|
277
|
+
value: function addEventListener(renderCallback) {
|
278
|
+
var _this4 = this;
|
247
279
|
this.serviceMap.EventCenter.listen(ElementPaymentEvent.CALLBACK, function (data) {
|
248
|
-
if (
|
249
|
-
var
|
250
|
-
(
|
280
|
+
if (_this4.elementProcessors[data.source] && _this4.elementProcessors[data.source].eventListener[data.event]) {
|
281
|
+
var _this4$elementProcess, _this4$elementProcess2;
|
282
|
+
(_this4$elementProcess = (_this4$elementProcess2 = _this4.elementProcessors[data.source].eventListener)[data.event]) === null || _this4$elementProcess === void 0 || _this4$elementProcess.call(_this4$elementProcess2, data.data);
|
251
283
|
}
|
252
284
|
});
|
253
285
|
this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
|
254
|
-
|
255
|
-
|
286
|
+
clearTimeout(_this4.initTimeout);
|
287
|
+
_this4.initTimeout = null;
|
288
|
+
if (_this4.elementContainerService.getContainerService(data.source)) {
|
289
|
+
renderCallback({
|
290
|
+
success: true
|
291
|
+
});
|
292
|
+
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
293
|
+
}
|
294
|
+
_this4.changeLoading(false);
|
256
295
|
// 遍历containerService中的所有container查看是否所有状态都是IN_BIZ_FLOW
|
257
296
|
// const allContainersInBizFlow = Object.values(this.elementContainerService.getContainerServices()).every(
|
258
297
|
// (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
|
259
298
|
// );
|
260
299
|
// if (allContainersInBizFlow) {
|
261
|
-
// this.
|
300
|
+
// this.setControllerStatusOrView(IContainerStatus.IN_BIZ_FLOW);
|
262
301
|
// }
|
263
302
|
});
|
264
303
|
this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
|
265
304
|
handleRedirect(data);
|
266
305
|
});
|
306
|
+
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
307
|
+
_this4.setControllerStatusOrView(IElementStatus.READY);
|
308
|
+
_this4.destroyHandle();
|
309
|
+
});
|
310
|
+
this.serviceMap.EventCenter.listen(EVENT.webAppReady.name, function (data) {
|
311
|
+
clearTimeout(_this4.initTimeout);
|
312
|
+
if (_this4.elementContainerService.getContainerService(data.source)) {
|
313
|
+
renderCallback({
|
314
|
+
success: true
|
315
|
+
});
|
316
|
+
_this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
317
|
+
}
|
318
|
+
_this4.changeLoading(false);
|
319
|
+
});
|
320
|
+
this.serviceMap.EventCenter.listen(EVENT.showToast.name, function (data) {
|
321
|
+
showToast(data);
|
322
|
+
});
|
267
323
|
}
|
268
324
|
}, {
|
269
325
|
key: "sendRequestAndWaitWebLaunch",
|
270
326
|
value: function sendRequestAndWaitWebLaunch(renderOptions) {
|
271
|
-
var
|
327
|
+
var _this5 = this;
|
272
328
|
var type = renderOptions.type,
|
273
329
|
options = _objectWithoutProperties(renderOptions, _excluded);
|
274
330
|
var webLaunchPromise = this.elementContainerService.getContainerService(type).createWebLaunchPromise();
|
275
331
|
Promise.all([webLaunchPromise, this.elementProcessors[type].obtainData()]).then(function (_ref3) {
|
332
|
+
var _this5$elementContain;
|
276
333
|
var _ref4 = _slicedToArray(_ref3, 2),
|
277
334
|
_webLaunchRes = _ref4[0],
|
278
335
|
_obtainDataRes = _ref4[1];
|
279
|
-
|
280
|
-
|
281
|
-
|
336
|
+
(_this5$elementContain = _this5.elementContainerService.getContainerService(type)) === null || _this5$elementContain === void 0 || _this5$elementContain.switchContainerStatus(IContainerStatus.READY);
|
337
|
+
var allReady = true;
|
338
|
+
_this5.elementContainerService.getContainerServices().forEach(function (item) {
|
339
|
+
if (!allReady) return;
|
340
|
+
allReady = item.getContainerStatus() === IContainerStatus.READY;
|
341
|
+
});
|
342
|
+
if (allReady) {
|
343
|
+
_this5.elementContainerService.getContainerServices().forEach(function (value, key) {
|
344
|
+
_this5.sendReady(key, options);
|
345
|
+
});
|
346
|
+
}
|
282
347
|
});
|
283
348
|
}
|
349
|
+
}, {
|
350
|
+
key: "sendReady",
|
351
|
+
value: function sendReady(type, options) {
|
352
|
+
var _this$elementProcesso;
|
353
|
+
var paymentResult = (_this$elementProcesso = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso === void 0 ? void 0 : _this$elementProcesso.getObtainDataRes();
|
354
|
+
var paymentContext = this.elementContainer.getPaymentContext();
|
355
|
+
var params = _objectSpread(_objectSpread({}, options), {}, {
|
356
|
+
originActionQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originActionQueryResult,
|
357
|
+
originOneAccountQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originOneAccountQueryResult,
|
358
|
+
paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionId,
|
359
|
+
sessionResult: (paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj) || {}
|
360
|
+
});
|
361
|
+
this.elementProcessors[type].onReady(params);
|
362
|
+
}
|
284
363
|
}, {
|
285
364
|
key: "updatePayment",
|
286
365
|
value: function () {
|
287
366
|
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(paymentSessionData) {
|
288
|
-
var
|
367
|
+
var _this6 = this;
|
289
368
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
290
369
|
while (1) switch (_context3.prev = _context3.next) {
|
291
370
|
case 0:
|
292
371
|
return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
|
293
372
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
|
294
|
-
var prePaymentSessionData, data;
|
373
|
+
var prePaymentSessionData, data, LOCAL_MOCK;
|
295
374
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
296
375
|
while (1) switch (_context2.prev = _context2.next) {
|
297
376
|
case 0:
|
298
377
|
if (checkCanUpdate({
|
299
|
-
status:
|
300
|
-
paymentContainerService:
|
378
|
+
status: _this6.elementContainer.getStatus(),
|
379
|
+
paymentContainerService: _this6.elementContainerService.getContainerService(ElementType.payment),
|
301
380
|
newPaymentSessionData: paymentSessionData,
|
302
|
-
oldPaymentSessionData:
|
381
|
+
oldPaymentSessionData: _this6.options.sessionData
|
303
382
|
})) {
|
304
383
|
_context2.next = 2;
|
305
384
|
break;
|
306
385
|
}
|
307
386
|
return _context2.abrupt("return", resolve(false));
|
308
387
|
case 2:
|
309
|
-
prePaymentSessionData =
|
310
|
-
|
388
|
+
prePaymentSessionData = _this6.elementContainer.getPaymentContext().paymentSession;
|
389
|
+
_this6.elementContainer.updatePaymentSessionData(paymentSessionData);
|
311
390
|
// 1、数据获取
|
312
391
|
_context2.next = 6;
|
313
|
-
return
|
392
|
+
return _this6.elementProcessors[ElementType.payment].obtainData();
|
314
393
|
case 6:
|
315
394
|
data = _context2.sent;
|
316
|
-
// 2、发送update消息
|
317
|
-
Object.values(
|
395
|
+
LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
|
396
|
+
Object.values(_this6.elementProcessors).forEach(function (processor) {
|
318
397
|
processor.update({
|
319
398
|
data: {
|
320
|
-
|
399
|
+
originActionQueryResult: LOCAL_MOCK ? sdkActionUpdate : data.originActionQueryResult,
|
400
|
+
originOneAccountQueryResult: LOCAL_MOCK ? oneAccountUpdate : data.originOneAccountQueryResult
|
321
401
|
},
|
322
402
|
paymentSessionData: paymentSessionData
|
323
403
|
});
|
324
404
|
});
|
325
405
|
// 3、返回更新结果
|
326
|
-
|
406
|
+
_this6.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
|
327
407
|
// 若更新不成功,还原core.paymentContext信息
|
328
408
|
if (!data.success) {
|
329
|
-
|
409
|
+
_this6.elementContainer.updatePaymentSessionData(prePaymentSessionData);
|
330
410
|
}
|
331
411
|
return resolve(data.success || false);
|
332
412
|
});
|
333
|
-
case
|
413
|
+
case 10:
|
334
414
|
case "end":
|
335
415
|
return _context2.stop();
|
336
416
|
}
|
@@ -352,17 +432,30 @@ var ElementController = /*#__PURE__*/function () {
|
|
352
432
|
return updatePayment;
|
353
433
|
}()
|
354
434
|
}, {
|
355
|
-
key: "
|
356
|
-
value: function
|
357
|
-
this.
|
358
|
-
|
359
|
-
|
435
|
+
key: "destroyHandle",
|
436
|
+
value: function destroyHandle() {
|
437
|
+
this.elementContainer.destroy();
|
438
|
+
this.elementContainerService.destroy();
|
439
|
+
this.serviceMap.EventCenter.cleanIFrames();
|
360
440
|
// popup未注册会报错,但element不需要感知popup是否被注册
|
361
441
|
try {
|
362
442
|
destroyModal(); // 关闭popup弹窗
|
363
443
|
} catch (error) {}
|
364
|
-
|
365
|
-
|
444
|
+
}
|
445
|
+
}, {
|
446
|
+
key: "destroy",
|
447
|
+
value: function destroy() {
|
448
|
+
this.destroyHandle();
|
449
|
+
this.setControllerStatusOrView(IElementStatus.DESTROYED);
|
450
|
+
}
|
451
|
+
}, {
|
452
|
+
key: "setControllerStatusOrView",
|
453
|
+
value: function setControllerStatusOrView(status) {
|
454
|
+
var _this$onStatusChangeC;
|
455
|
+
var _status = this.elementContainer.getStatus();
|
456
|
+
if (status === _status) return;
|
457
|
+
(_this$onStatusChangeC = this.onStatusChangeCallback) === null || _this$onStatusChangeC === void 0 || _this$onStatusChangeC.call(this, "\u72B6\u6001\u7531 ".concat(_status, " \u53D8\u66F4\u4E3A ").concat(status));
|
458
|
+
this.elementContainer.setStatus(status);
|
366
459
|
}
|
367
460
|
}]);
|
368
461
|
return ElementController;
|