@alipay/ams-checkout 0.0.1692935171-dev.1 → 0.0.1692935171-dev.2
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/constant/index.d.ts +12 -0
- package/esm/constant/index.js +12 -0
- package/esm/core/component/index.d.ts +2 -1
- package/esm/core/component/index.js +4 -4
- package/esm/core/drop-in/index.d.ts +4 -4
- package/esm/core/drop-in/index.js +3 -3
- package/esm/plugin/component/{component.style.d.ts → component.inline.style.d.ts} +2 -2
- package/esm/plugin/component/component.inline.style.js +38 -0
- package/esm/plugin/component/component.popup.style.d.ts +12 -0
- package/esm/plugin/component/component.popup.style.js +163 -0
- package/esm/plugin/component/index.d.ts +14 -29
- package/esm/plugin/component/index.js +119 -286
- package/esm/plugin/drop-in/index.d.ts +3 -5
- package/esm/plugin/drop-in/index.js +2 -2
- package/package.json +1 -1
- package/esm/plugin/component/component.style.js +0 -43
@@ -15,46 +15,38 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
15
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
16
16
|
*/
|
17
17
|
/* eslint-disable no-console */
|
18
|
-
import {
|
18
|
+
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
19
19
|
import { queryPaymentInfo } from "../../service";
|
20
|
-
import { componentSignEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum
|
21
|
-
import {
|
20
|
+
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
|
21
|
+
import { getType, isJsonString, isPC } from "../../util";
|
22
22
|
import { isLocalMock } from "../../util/mock";
|
23
23
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
24
|
-
import {
|
24
|
+
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
25
|
+
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
25
26
|
var _window = window,
|
26
27
|
innerHeight = _window.innerHeight;
|
27
|
-
var componentContainerId = 'ams-component-container';
|
28
|
-
var componentSectionId = 'ams-component-section';
|
29
|
-
var componentCloseBlockId = 'asm-component-close-block';
|
30
|
-
var componentRetentionId = 'ams-component-retention';
|
31
|
-
var mockupId = 'ams-component-mockup';
|
32
|
-
var loadingId = 'ams-component-loading';
|
33
|
-
var listenerPrefix = '_ams_sdk_component_listener';
|
34
|
-
var inlineBaseStyleId = 'ams-inline-component-style';
|
35
|
-
var loadTimeLimit = 15000;
|
36
28
|
var ComponentApp = /*#__PURE__*/function () {
|
37
29
|
function ComponentApp() {
|
38
30
|
_classCallCheck(this, ComponentApp);
|
39
31
|
_defineProperty(this, "app", void 0);
|
40
|
-
_defineProperty(this, "appDomain", void 0);
|
41
32
|
_defineProperty(this, "AMSSDK", void 0);
|
42
33
|
_defineProperty(this, "platform", void 0);
|
34
|
+
_defineProperty(this, "_performanceData", []);
|
35
|
+
_defineProperty(this, "_loadAppPromiseResolve", null);
|
36
|
+
_defineProperty(this, "_isInitComponent", void 0);
|
37
|
+
_defineProperty(this, "appDomain", void 0);
|
43
38
|
_defineProperty(this, "createIframeNode", void 0);
|
44
39
|
_defineProperty(this, "_selector", void 0);
|
45
40
|
_defineProperty(this, "_appVersion", void 0);
|
46
41
|
_defineProperty(this, "_isRetention", void 0);
|
47
42
|
_defineProperty(this, "_actionQueryPromise", null);
|
48
|
-
_defineProperty(this, "_loadAppPromiseResolve", null);
|
49
43
|
_defineProperty(this, "_renderParams", null);
|
50
44
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
51
|
-
_defineProperty(this, "_performanceData", []);
|
52
|
-
_defineProperty(this, "_isInitComponent", void 0);
|
53
45
|
_defineProperty(this, "_clickEventName", void 0);
|
54
46
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
55
47
|
this._appVersion = '1.5.2';
|
56
48
|
this._isInitComponent = false;
|
57
|
-
this._selector = "#".concat(
|
49
|
+
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
58
50
|
this.createIframeNode = function () {
|
59
51
|
return Promise.resolve();
|
60
52
|
};
|
@@ -111,7 +103,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
111
103
|
this._componentSign = componentSign;
|
112
104
|
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
113
105
|
this._renderDisplayType = renderParams.renderDisplayType;
|
114
|
-
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(
|
106
|
+
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
115
107
|
this._performanceData.push({
|
116
108
|
key: 'sdk_create_component',
|
117
109
|
value: Date.now()
|
@@ -120,17 +112,17 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
120
112
|
code: eventCodeEnum.SDK_START_OF_LOADING
|
121
113
|
});
|
122
114
|
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
123
|
-
this.
|
115
|
+
var container = createInlineBaseElement(this._selector);
|
116
|
+
if (container) this.renderInlineLoading(renderParams, container);
|
124
117
|
}
|
125
118
|
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
126
|
-
this.
|
127
|
-
this.
|
128
|
-
|
129
|
-
this.createMockup();
|
119
|
+
createBaseElement(this.platform, this.closeBtnFunc.bind(this));
|
120
|
+
createRetentionPopup(this.platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
|
121
|
+
createMockup();
|
130
122
|
this.renderPopupLoading(renderParams);
|
131
123
|
}
|
132
124
|
this.createApp(renderParams);
|
133
|
-
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this.
|
125
|
+
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
|
134
126
|
return Promise.resolve();
|
135
127
|
}).catch(function (error) {
|
136
128
|
_this._isInitComponent = false;
|
@@ -139,27 +131,33 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
139
131
|
});
|
140
132
|
}
|
141
133
|
}, {
|
142
|
-
key: "
|
143
|
-
value: function
|
134
|
+
key: "renderInlineLoading",
|
135
|
+
value: function renderInlineLoading(renderParams, selector) {
|
144
136
|
var _renderParams$appeara;
|
145
137
|
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
|
146
138
|
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
139
|
+
if (showLoading) addInlineLoading(selector, this.platform);
|
140
|
+
}
|
141
|
+
}, {
|
142
|
+
key: "renderPopupLoading",
|
143
|
+
value: function renderPopupLoading(renderParams) {
|
144
|
+
var _renderParams$appeara2;
|
145
|
+
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
|
146
|
+
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
147
147
|
if (!showLoading) return;
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
return this.showPopupLoading();
|
152
|
-
}
|
148
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
149
|
+
if (mockup) mockup.style.display = 'block';
|
150
|
+
addPopupLoading();
|
153
151
|
}
|
154
152
|
}, {
|
155
|
-
key: "
|
156
|
-
value: function
|
153
|
+
key: "_createLoadAppPromise",
|
154
|
+
value: function _createLoadAppPromise() {
|
157
155
|
var _this2 = this;
|
158
156
|
return new Promise(function (resolve, reject) {
|
159
157
|
_this2._loadAppPromiseResolve = resolve;
|
160
158
|
setTimeout(function () {
|
161
159
|
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
162
|
-
},
|
160
|
+
}, LOADTIME_LIMIT);
|
163
161
|
}).catch(function (error) {
|
164
162
|
_this2.dispatchToSDK(EVENT.error.name, {
|
165
163
|
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
|
@@ -266,16 +264,32 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
266
264
|
return this._actionQueryPromise;
|
267
265
|
}
|
268
266
|
}, {
|
269
|
-
key: "
|
270
|
-
value: function
|
267
|
+
key: "cleanElement",
|
268
|
+
value: function cleanElement() {
|
271
269
|
try {
|
272
|
-
|
273
|
-
|
270
|
+
var _document$getElementB;
|
271
|
+
// selector and container
|
274
272
|
if (getType(this._selector) === 'string') {
|
275
273
|
var selectorDom = document.querySelector(this._selector);
|
276
274
|
if (selectorDom) selectorDom.innerHTML = '';
|
277
275
|
}
|
278
|
-
|
276
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
277
|
+
if (container) container === null || container === void 0 ? void 0 : container.remove();
|
278
|
+
|
279
|
+
// animation
|
280
|
+
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style"))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
|
281
|
+
|
282
|
+
// mockup
|
283
|
+
var body = document.getElementsByTagName('body')[0];
|
284
|
+
body.style.overflow = 'auto';
|
285
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
286
|
+
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
287
|
+
|
288
|
+
// retentionPopup
|
289
|
+
this.removeRetentionPopup(this.platform);
|
290
|
+
|
291
|
+
// listener
|
292
|
+
this.removeEventListener();
|
279
293
|
} catch (error) {
|
280
294
|
console.error(error);
|
281
295
|
}
|
@@ -320,7 +334,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
320
334
|
});
|
321
335
|
|
322
336
|
// Subscribe to messages from iframe
|
323
|
-
this.
|
337
|
+
this.addEventListener();
|
324
338
|
} catch (error) {
|
325
339
|
this.dispatchToSDK(EVENT.error.name, Object.assign({}, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.FAILED_TO_CREATE_IFRAME, {
|
326
340
|
stack: error
|
@@ -339,6 +353,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
339
353
|
if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
|
340
354
|
return;
|
341
355
|
}
|
356
|
+
// TODO
|
357
|
+
// 如果带有callback标识,则从map结构中取出callbackfunc,执行,执行后在map结构中删除
|
342
358
|
this._handleAppMessage(data);
|
343
359
|
} else {
|
344
360
|
console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
|
@@ -348,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
348
364
|
}, {
|
349
365
|
key: "resizeListener",
|
350
366
|
value: function resizeListener() {
|
351
|
-
var cashier = document.getElementById(
|
367
|
+
var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
|
352
368
|
cashier.style.transition = 'none';
|
353
369
|
this.dispatchToApp({
|
354
370
|
context: {
|
@@ -365,19 +381,19 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
365
381
|
* @description Initialize subscription iframe message
|
366
382
|
*/
|
367
383
|
}, {
|
368
|
-
key: "
|
369
|
-
value: function
|
370
|
-
this.
|
371
|
-
window["".concat(
|
372
|
-
window["".concat(
|
373
|
-
window.addEventListener('message', window["".concat(
|
374
|
-
window.addEventListener('resize', window["".concat(
|
384
|
+
key: "addEventListener",
|
385
|
+
value: function addEventListener() {
|
386
|
+
this.removeEventListener();
|
387
|
+
window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
|
388
|
+
window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
|
389
|
+
window.addEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
|
390
|
+
window.addEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
375
391
|
}
|
376
392
|
}, {
|
377
|
-
key: "
|
378
|
-
value: function
|
379
|
-
window.removeEventListener('message', window["".concat(
|
380
|
-
window.removeEventListener('resize', window["".concat(
|
393
|
+
key: "removeEventListener",
|
394
|
+
value: function removeEventListener() {
|
395
|
+
window.removeEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
|
396
|
+
window.removeEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
381
397
|
}
|
382
398
|
|
383
399
|
/**
|
@@ -387,6 +403,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
387
403
|
key: "_handleAppMessage",
|
388
404
|
value: function _handleAppMessage(data) {
|
389
405
|
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name];
|
406
|
+
if (!eventKeyMap.includes(data.context.event)) {
|
407
|
+
return;
|
408
|
+
}
|
390
409
|
if (data.context.event === EVENT.dismissLoading.name) {
|
391
410
|
var _data$context$data;
|
392
411
|
this.dispatchToSDK(EVENT.eventCallback.name, {
|
@@ -395,9 +414,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
395
414
|
});
|
396
415
|
return;
|
397
416
|
}
|
398
|
-
if (!eventKeyMap.includes(data.context.event)) {
|
399
|
-
return;
|
400
|
-
}
|
401
417
|
if (data.context.event === EVENT.launch.name) {
|
402
418
|
this._performanceData.push({
|
403
419
|
key: 'sdk_onLaunch',
|
@@ -446,29 +462,28 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
446
462
|
value: function handleSizeChanged(data) {
|
447
463
|
var _data$context$data2;
|
448
464
|
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
|
449
|
-
var cashier = document.getElementById(
|
465
|
+
var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
|
450
466
|
cashier.style.height = "".concat(data.context.data.height, "px");
|
451
467
|
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
452
|
-
var _document$
|
453
|
-
var mockup = document.getElementById(
|
468
|
+
var _document$getElementB2;
|
469
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
454
470
|
if (mockup) {
|
455
|
-
mockup.style.background = '
|
456
|
-
mockup.style.opacity = '0.6';
|
471
|
+
mockup.style.background = 'rgb(0, 0, 0, 0.6)';
|
457
472
|
mockup.style.display = 'block';
|
458
473
|
}
|
459
|
-
(_document$
|
474
|
+
(_document$getElementB2 = document.getElementById(LOADING_ID)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
|
460
475
|
if (this.platform === 'desktop') {
|
461
|
-
cashier.classList.add("".concat(
|
476
|
+
cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
462
477
|
if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
|
463
478
|
}
|
464
479
|
if (this.platform === 'mobile') {
|
465
|
-
cashier.classList.add("".concat(
|
466
|
-
var animationStyleId = "".concat(
|
480
|
+
cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
481
|
+
var animationStyleId = "".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style");
|
467
482
|
var animationStyle = document.getElementById(animationStyleId);
|
468
483
|
if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
|
469
484
|
|
470
485
|
// 弹出和弹入动画
|
471
|
-
var runkeyframes = "@keyframes ".concat(
|
486
|
+
var runkeyframes = "@keyframes ".concat(COMPONENT_CONTAINER_ID, "-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ").concat(data.context.data.height, "px;\n }\n }\n @keyframes ").concat(COMPONENT_CONTAINER_ID, "-slide-out {\n 0% {\n height: ").concat(data.context.data.height, "px;\n opacity: 1;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n height: 1px;\n opacity: 0;\n }\n }");
|
472
487
|
// 创建style标签
|
473
488
|
var style = document.createElement('style');
|
474
489
|
style.id = animationStyleId;
|
@@ -486,8 +501,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
486
501
|
}
|
487
502
|
}
|
488
503
|
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
489
|
-
var _document$
|
490
|
-
(_document$
|
504
|
+
var _document$getElementB3;
|
505
|
+
(_document$getElementB3 = document.getElementById(LOADING_ID)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
|
491
506
|
}
|
492
507
|
this.app.style.height = "".concat(data.context.data.height, "px");
|
493
508
|
this.app.style.opacity = '1';
|
@@ -550,59 +565,18 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
550
565
|
value: function handleDeclareInfo(_ref3) {
|
551
566
|
var _ref3$closeDialogData = _ref3.closeDialogData,
|
552
567
|
closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
if (retentionTitle) {
|
557
|
-
var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
|
558
|
-
retentionTitle.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl = closeDialogData.title) === null || _closeDialogData$titl === void 0 ? void 0 : _closeDialogData$titl.fontSize, "px");
|
559
|
-
retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
|
560
|
-
retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
|
561
|
-
}
|
562
|
-
var retentionMessage = document.getElementById("".concat(componentRetentionId, "-sub-title"));
|
563
|
-
if (retentionMessage) {
|
564
|
-
var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
|
565
|
-
retentionMessage.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess = closeDialogData.message) === null || _closeDialogData$mess === void 0 ? void 0 : _closeDialogData$mess.fontSize, "px");
|
566
|
-
retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
|
567
|
-
retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
|
568
|
-
}
|
569
|
-
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
|
570
|
-
if (remainBtn) {
|
571
|
-
var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
|
572
|
-
remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
|
573
|
-
remainBtn.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO2 = closeDialogData.btnOK) === null || _closeDialogData$btnO2 === void 0 ? void 0 : _closeDialogData$btnO2.fontSize, "px");
|
574
|
-
remainBtn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO3 = closeDialogData.btnOK) === null || _closeDialogData$btnO3 === void 0 ? void 0 : _closeDialogData$btnO3.fontColor;
|
575
|
-
remainBtn.style.borderRadius = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO4 = closeDialogData.btnOK) === null || _closeDialogData$btnO4 === void 0 ? void 0 : _closeDialogData$btnO4.corner, "px");
|
576
|
-
if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO5 = closeDialogData.btnOK) === null || _closeDialogData$btnO5 === void 0 ? void 0 : _closeDialogData$btnO5.type) === 'stroke') {
|
577
|
-
var _closeDialogData$btnO6;
|
578
|
-
remainBtn.style.border = "1px solid ".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO6 = closeDialogData.btnOK) === null || _closeDialogData$btnO6 === void 0 ? void 0 : _closeDialogData$btnO6.bg);
|
579
|
-
} else remainBtn.style.backgroundColor = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO7 = closeDialogData.btnOK) === null || _closeDialogData$btnO7 === void 0 ? void 0 : _closeDialogData$btnO7.bg;
|
580
|
-
}
|
581
|
-
var leaveBrn = document.getElementById("".concat(componentRetentionId, "-leave"));
|
582
|
-
if (leaveBrn) {
|
583
|
-
var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
|
584
|
-
leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
|
585
|
-
leaveBrn.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC2 = closeDialogData.btnCancel) === null || _closeDialogData$btnC2 === void 0 ? void 0 : _closeDialogData$btnC2.fontSize, "px");
|
586
|
-
leaveBrn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC3 = closeDialogData.btnCancel) === null || _closeDialogData$btnC3 === void 0 ? void 0 : _closeDialogData$btnC3.fontColor;
|
587
|
-
leaveBrn.style.borderRadius = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC4 = closeDialogData.btnCancel) === null || _closeDialogData$btnC4 === void 0 ? void 0 : _closeDialogData$btnC4.corner, "px");
|
588
|
-
if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC5 = closeDialogData.btnCancel) === null || _closeDialogData$btnC5 === void 0 ? void 0 : _closeDialogData$btnC5.type) === 'stroke') {
|
589
|
-
var _closeDialogData$btnC6;
|
590
|
-
leaveBrn.style.border = "1px solid ".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC6 = closeDialogData.btnCancel) === null || _closeDialogData$btnC6 === void 0 ? void 0 : _closeDialogData$btnC6.bg);
|
591
|
-
} else leaveBrn.style.backgroundColor = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC7 = closeDialogData.btnCancel) === null || _closeDialogData$btnC7 === void 0 ? void 0 : _closeDialogData$btnC7.bg;
|
592
|
-
}
|
593
|
-
}
|
594
|
-
} catch (error) {
|
595
|
-
console.error(error);
|
596
|
-
}
|
568
|
+
_handleDeclareInfo({
|
569
|
+
closeDialogData: closeDialogData
|
570
|
+
});
|
597
571
|
}
|
598
572
|
}, {
|
599
573
|
key: "handleCloseBtnShow",
|
600
574
|
value: function handleCloseBtnShow(showClose) {
|
601
|
-
var closeBlock = document.getElementById(
|
575
|
+
var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
|
602
576
|
if (showClose) {
|
603
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(
|
577
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
|
604
578
|
} else if (showClose === false) {
|
605
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(
|
579
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
|
606
580
|
}
|
607
581
|
}
|
608
582
|
|
@@ -627,6 +601,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
627
601
|
appId: COMPONENTPLUGINID,
|
628
602
|
instanceId: this.AMSSDK._instanceId
|
629
603
|
});
|
604
|
+
// TODO 如果存在回调函数,则增加callBack标识,并存入map。map可以设置
|
630
605
|
if (this.app && this.app.contentWindow) {
|
631
606
|
return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
632
607
|
}
|
@@ -716,71 +691,39 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
716
691
|
}
|
717
692
|
return sendRenderEvent;
|
718
693
|
}()
|
719
|
-
}, {
|
720
|
-
key: "showPopupLoading",
|
721
|
-
value: function showPopupLoading() {
|
722
|
-
var loading = document.createElement('div');
|
723
|
-
loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
|
724
|
-
loading.id = loadingId;
|
725
|
-
loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
|
726
|
-
loading.style.fontSize = "".concat(getDesignFontSize(), "px");
|
727
|
-
var body = document.getElementsByTagName('body')[0];
|
728
|
-
body === null || body === void 0 ? void 0 : body.appendChild(loading);
|
729
|
-
}
|
730
|
-
|
731
|
-
/**
|
732
|
-
* @description show cashier
|
733
|
-
*/
|
734
|
-
}, {
|
735
|
-
key: "setContainerClass",
|
736
|
-
value: function setContainerClass() {
|
737
|
-
var cashier = document.getElementById(componentContainerId);
|
738
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("".concat(componentContainerId, "-hidden-").concat(this.platform));
|
739
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform));
|
740
|
-
}
|
741
|
-
|
742
694
|
/**
|
743
695
|
* @description close cashier
|
744
696
|
*/
|
745
697
|
}, {
|
746
698
|
key: "cleanContainer",
|
747
699
|
value: function cleanContainer() {
|
748
|
-
var _document$
|
700
|
+
var _document$getElementB4,
|
701
|
+
_this5 = this;
|
749
702
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
750
703
|
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
751
704
|
this._performanceData = [];
|
752
705
|
this._isInitComponent = false;
|
753
|
-
|
754
|
-
|
706
|
+
this.app = null;
|
707
|
+
(_document$getElementB4 = document.getElementById(LOADING_ID)) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
708
|
+
this.hideComponentAnimation();
|
709
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
710
|
+
mockup === null || mockup === void 0 ? void 0 : mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
|
711
|
+
if (immediately) this.cleanElement();else {
|
712
|
+
setTimeout(function () {
|
713
|
+
_this5.cleanElement();
|
714
|
+
}, 300);
|
715
|
+
}
|
755
716
|
}
|
756
717
|
}, {
|
757
|
-
key: "
|
758
|
-
value: function
|
759
|
-
var
|
760
|
-
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
761
|
-
var container = document.getElementById(componentContainerId);
|
718
|
+
key: "hideComponentAnimation",
|
719
|
+
value: function hideComponentAnimation() {
|
720
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
762
721
|
if (container) {
|
763
722
|
// size变化动画取消
|
764
723
|
container.style.transition = '';
|
765
|
-
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(
|
766
|
-
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(
|
767
|
-
container === null || container === void 0 ? void 0 : container.classList.add("".concat(
|
768
|
-
}
|
769
|
-
var removeMockupAndApp = function removeMockupAndApp() {
|
770
|
-
var _document$getElementB4;
|
771
|
-
var body = document.getElementsByTagName('body')[0];
|
772
|
-
body.style.overflow = 'auto';
|
773
|
-
var mockup = document.getElementById(mockupId);
|
774
|
-
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
775
|
-
if (container) container.style.height = '';
|
776
|
-
(_document$getElementB4 = document.getElementById("".concat(componentContainerId, "-").concat(_this5.platform, "-animation-style"))) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
777
|
-
_this5.removeRetentionPopup();
|
778
|
-
_this5.cleanApp();
|
779
|
-
};
|
780
|
-
if (immediately) removeMockupAndApp();else {
|
781
|
-
setTimeout(function () {
|
782
|
-
removeMockupAndApp();
|
783
|
-
}, 300);
|
724
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform));
|
725
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
726
|
+
container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.platform));
|
784
727
|
}
|
785
728
|
}
|
786
729
|
}, {
|
@@ -792,143 +735,33 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
792
735
|
this.dispatchToSDK(EVENT.close.name, {});
|
793
736
|
}
|
794
737
|
}
|
795
|
-
|
796
|
-
/**
|
797
|
-
* @description create mount node
|
798
|
-
*/
|
799
|
-
}, {
|
800
|
-
key: "createBaseElement",
|
801
|
-
value: function createBaseElement() {
|
802
|
-
if (document.getElementById(componentContainerId)) return;
|
803
|
-
componentAddCSS();
|
804
|
-
addSetFontSizeEvent();
|
805
|
-
var amsComponentContainer = document.createElement('div');
|
806
|
-
amsComponentContainer.className = "".concat(componentContainerId, "-hidden-").concat(this.platform);
|
807
|
-
amsComponentContainer.id = componentContainerId;
|
808
|
-
amsSetSize(null, amsComponentContainer);
|
809
|
-
document.body.appendChild(amsComponentContainer);
|
810
|
-
var amsComponentSection = document.createElement('div');
|
811
|
-
amsComponentSection.className = "ams-component-section-".concat(this.platform);
|
812
|
-
amsComponentSection.id = componentSectionId;
|
813
|
-
amsComponentContainer.appendChild(amsComponentSection);
|
814
|
-
this.createCloseBtn();
|
815
|
-
}
|
816
|
-
}, {
|
817
|
-
key: "createInlineBaseElement",
|
818
|
-
value: function createInlineBaseElement(renderParams) {
|
819
|
-
var _renderParams$appeara2;
|
820
|
-
var inlineBaseStyle = document.getElementById(inlineBaseStyleId);
|
821
|
-
if (!inlineBaseStyle) inlineComponentAddCss();
|
822
|
-
if (document.getElementById(componentContainerId)) return;
|
823
|
-
var amsComponentContainer = document.createElement('div');
|
824
|
-
amsComponentContainer.className = "".concat(componentContainerId, "-inline");
|
825
|
-
amsComponentContainer.id = componentContainerId;
|
826
|
-
var selectorDom = document.querySelector(this._selector);
|
827
|
-
if (selectorDom) selectorDom.appendChild(amsComponentContainer);
|
828
|
-
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
|
829
|
-
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
830
|
-
if (showLoading) showInlineLoading(amsComponentContainer, this.platform);
|
831
|
-
}
|
832
|
-
}, {
|
833
|
-
key: "createCloseBtn",
|
834
|
-
value: function createCloseBtn() {
|
835
|
-
var _this6 = this;
|
836
|
-
var container = document.getElementById(componentContainerId);
|
837
|
-
// close btn
|
838
|
-
var closeBtnHTML = "<img class='".concat(componentCloseBlockId, "-btn-").concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
|
839
|
-
var closeBlock = document.createElement('div');
|
840
|
-
closeBlock.classList.add("".concat(componentCloseBlockId, "-").concat(this.platform), "".concat(componentCloseBlockId, "-hidden"));
|
841
|
-
closeBlock.id = componentCloseBlockId;
|
842
|
-
closeBlock.innerHTML = closeBtnHTML;
|
843
|
-
closeBlock.addEventListener(this._clickEventName, function () {
|
844
|
-
_this6.closeBtnFunc();
|
845
|
-
});
|
846
|
-
if (container) container.appendChild(closeBlock);
|
847
|
-
}
|
848
|
-
}, {
|
849
|
-
key: "createRetentionPopup",
|
850
|
-
value: function createRetentionPopup() {
|
851
|
-
// retention popup
|
852
|
-
var retentionPopup = document.createElement('div');
|
853
|
-
retentionPopup.id = componentRetentionId;
|
854
|
-
retentionPopup.classList.add("".concat(componentRetentionId, "-").concat(this.platform));
|
855
|
-
retentionPopup.innerHTML = "\n <span id=\"".concat(componentRetentionId, "-title\" class=\"").concat(componentRetentionId, "-title-").concat(this.platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"").concat(componentRetentionId, "-sub-title\"\n class=\"").concat(componentRetentionId, "-sub-title-").concat(this.platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"").concat(componentRetentionId, "-btn-block-").concat(this.platform, "\">\n <div id=\"").concat(componentRetentionId, "-remain\" class=\"").concat(componentRetentionId, "-remain-").concat(this.platform, "\">\n Continue Payment\n </div>\n <div id=\"").concat(componentRetentionId, "-leave\" class=\"").concat(componentRetentionId, "-leave-").concat(this.platform, "\">\n Leave\n </div>\n </div>");
|
856
|
-
document.body.appendChild(retentionPopup);
|
857
|
-
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
|
858
|
-
if (remainBtn) {
|
859
|
-
remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
|
860
|
-
}
|
861
|
-
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
|
862
|
-
if (leaveBtn) {
|
863
|
-
leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
|
864
|
-
}
|
865
|
-
}
|
866
738
|
}, {
|
867
739
|
key: "retentionPopupLeaveFunc",
|
868
740
|
value: function retentionPopupLeaveFunc() {
|
869
741
|
this.dispatchToSDK(EVENT.close.name, {});
|
870
|
-
this.
|
742
|
+
this.hideRetentionPopupFunc();
|
871
743
|
this.cleanContainer();
|
872
744
|
}
|
873
745
|
}, {
|
874
746
|
key: "removeRetentionPopup",
|
875
|
-
value: function removeRetentionPopup() {
|
876
|
-
|
877
|
-
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
|
878
|
-
if (remainBtn) {
|
879
|
-
remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
|
880
|
-
}
|
881
|
-
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
|
882
|
-
if (leaveBtn) {
|
883
|
-
leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
|
884
|
-
}
|
885
|
-
(_document$getElementB5 = document.getElementById(componentRetentionId)) === null || _document$getElementB5 === void 0 ? void 0 : _document$getElementB5.remove();
|
747
|
+
value: function removeRetentionPopup(platform) {
|
748
|
+
_removeRetentionPopup(platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
|
886
749
|
}
|
887
750
|
}, {
|
888
751
|
key: "showRetentionPopup",
|
889
752
|
value: function showRetentionPopup() {
|
890
|
-
var retentionPopup = document.getElementById(
|
891
|
-
var container = document.getElementById(
|
753
|
+
var retentionPopup = document.getElementById(COMPONENT_RETENTION_ID);
|
754
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
892
755
|
if (retentionPopup) {
|
893
|
-
container === null || container === void 0 ? void 0 : container.classList.add("".concat(
|
894
|
-
retentionPopup.classList.remove("".concat(
|
895
|
-
retentionPopup.classList.add("".concat(
|
756
|
+
container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-opacity"));
|
757
|
+
retentionPopup.classList.remove("".concat(COMPONENT_RETENTION_ID, "-hidden"));
|
758
|
+
retentionPopup.classList.add("".concat(COMPONENT_RETENTION_ID, "-show"));
|
896
759
|
}
|
897
760
|
}
|
898
761
|
}, {
|
899
|
-
key: "
|
900
|
-
value: function
|
901
|
-
|
902
|
-
var container = document.getElementById(componentContainerId);
|
903
|
-
if (retentionPopup) {
|
904
|
-
retentionPopup.classList.remove("".concat(componentRetentionId, "-show"));
|
905
|
-
retentionPopup.classList.add("".concat(componentRetentionId, "-hidden"));
|
906
|
-
setTimeout(function () {
|
907
|
-
retentionPopup.classList.remove("".concat(componentRetentionId, "-hidden"));
|
908
|
-
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-opacity"));
|
909
|
-
}, 300);
|
910
|
-
}
|
911
|
-
}
|
912
|
-
/**
|
913
|
-
* @description create mockup
|
914
|
-
*/
|
915
|
-
}, {
|
916
|
-
key: "createMockup",
|
917
|
-
value: function createMockup() {
|
918
|
-
var body = document.getElementsByTagName('body')[0];
|
919
|
-
body.style.overflow = 'hidden';
|
920
|
-
var mockup = document.createElement('div');
|
921
|
-
mockup.style.width = '100vw';
|
922
|
-
mockup.style.height = '100vh';
|
923
|
-
mockup.style.position = 'fixed';
|
924
|
-
mockup.style.top = '0';
|
925
|
-
mockup.style.left = '0';
|
926
|
-
mockup.style.zIndex = '1000';
|
927
|
-
mockup.style.background = '#ffffff';
|
928
|
-
mockup.style.opacity = '0.5';
|
929
|
-
mockup.style.display = 'none';
|
930
|
-
mockup.id = mockupId;
|
931
|
-
body.appendChild(mockup);
|
762
|
+
key: "hideRetentionPopupFunc",
|
763
|
+
value: function hideRetentionPopupFunc() {
|
764
|
+
hideRetentionPopup();
|
932
765
|
}
|
933
766
|
}, {
|
934
767
|
key: "submitForm",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type AMSCheckout from '../../core/instance';
|
2
|
-
import type {
|
2
|
+
import type { IcreatePaymentParams, eventPlayload } from '../../types';
|
3
3
|
export default class CheckoutApp {
|
4
4
|
app: any;
|
5
5
|
paymentMethodsResult: any;
|
@@ -16,13 +16,11 @@ export default class CheckoutApp {
|
|
16
16
|
/**
|
17
17
|
* @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
|
18
18
|
*/
|
19
|
-
setRender(createIframeNode:
|
20
|
-
selector: string | HTMLElement;
|
21
|
-
}) => Promise<void>): void;
|
19
|
+
setRender(createIframeNode: any): void;
|
22
20
|
/**
|
23
21
|
* @description High order function of rendering capability
|
24
22
|
*/
|
25
|
-
render(renderParams:
|
23
|
+
render(renderParams: IcreatePaymentParams): Promise<void>;
|
26
24
|
/**
|
27
25
|
* @description Cancel listening and destroy the dom
|
28
26
|
*/
|