@alipay/ams-checkout 0.0.1693912790-dev.3 → 0.0.1693912790-dev.4
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 +53 -32
- package/esm/constant/index.js +53 -32
- package/esm/core/component/index.d.ts +23 -9
- package/esm/core/component/index.js +145 -43
- package/esm/core/drop-in/index.d.ts +4 -4
- package/esm/core/drop-in/index.js +3 -3
- package/esm/core/instance/index.d.ts +6 -15
- package/esm/core/instance/index.js +31 -53
- package/esm/image/skeleton.svg +18 -0
- package/esm/index.d.ts +4 -10
- package/esm/index.js +8 -30
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/cashierApp.js +16 -15
- package/esm/plugin/component/{component.style.d.ts → component.inline.style.d.ts} +4 -1
- 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 +29 -32
- package/esm/plugin/component/index.js +231 -339
- package/esm/plugin/drop-in/index.d.ts +3 -5
- package/esm/plugin/drop-in/index.js +3 -3
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +3 -3
- package/esm/request/utils.d.ts +3 -3
- package/esm/request/utils.js +4 -4
- package/esm/service/index.d.ts +2 -2
- package/esm/types/index.d.ts +71 -34
- package/esm/types/index.js +84 -47
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +6 -4
- package/esm/util/index.js +22 -5
- package/esm/util/mock.js +1 -2
- package/package.json +1 -1
- package/esm/plugin/component/component.style.js +0 -15
@@ -2,8 +2,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
2
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
3
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
4
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
8
6
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
9
7
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
@@ -17,13 +15,14 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
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.
|
18
16
|
*/
|
19
17
|
/* eslint-disable no-console */
|
20
|
-
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";
|
21
19
|
import { queryPaymentInfo } from "../../service";
|
22
|
-
import { componentSignEnum, messageName, productSceneEnum,
|
23
|
-
import {
|
20
|
+
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
|
21
|
+
import { getType, isJsonString, isPC, queryParse } from "../../util";
|
24
22
|
import { isLocalMock } from "../../util/mock";
|
25
23
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
26
|
-
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";
|
27
26
|
import APDID from '@alipay/jshield-apdid';
|
28
27
|
import { getSecurityHost, getAppname } from "../../util/security";
|
29
28
|
var _ref = queryParse() || {},
|
@@ -33,32 +32,16 @@ var _ref = queryParse() || {},
|
|
33
32
|
region = _ref.region;
|
34
33
|
var _window = window,
|
35
34
|
innerHeight = _window.innerHeight;
|
36
|
-
var amsSetSize = function amsSetSize(event, dom) {
|
37
|
-
try {
|
38
|
-
var _dom = dom || document.getElementById('ams-component-container');
|
39
|
-
_dom.style.fontSize = "".concat(getDesignFontSize(), "px");
|
40
|
-
innerHeight = window.innerHeight;
|
41
|
-
// eslint-disable-next-line no-empty
|
42
|
-
} catch (error) {}
|
43
|
-
};
|
44
|
-
var addEvent = function addEvent() {
|
45
|
-
window.removeEventListener('resize', amsSetSize);
|
46
|
-
window.removeEventListener('pageShow', amsSetSize);
|
47
|
-
window.removeEventListener('DOMContentLoaded', amsSetSize);
|
48
|
-
window.addEventListener('resize', amsSetSize);
|
49
|
-
window.addEventListener('pageShow', amsSetSize);
|
50
|
-
window.addEventListener('DOMContentLoaded', amsSetSize);
|
51
|
-
};
|
52
|
-
var mockupId = 'ams-component-mockup';
|
53
|
-
var loadingId = 'ams-component-loading';
|
54
|
-
var listenerPrefix = '_ams_sdk_component_listener';
|
55
35
|
var ComponentApp = /*#__PURE__*/function () {
|
56
36
|
function ComponentApp() {
|
57
37
|
_classCallCheck(this, ComponentApp);
|
58
38
|
_defineProperty(this, "app", void 0);
|
59
|
-
_defineProperty(this, "appDomain", void 0);
|
60
39
|
_defineProperty(this, "AMSSDK", void 0);
|
61
40
|
_defineProperty(this, "platform", void 0);
|
41
|
+
_defineProperty(this, "_performanceData", []);
|
42
|
+
_defineProperty(this, "_loadAppPromiseResolve", null);
|
43
|
+
_defineProperty(this, "_isInitComponent", void 0);
|
44
|
+
_defineProperty(this, "appDomain", void 0);
|
62
45
|
_defineProperty(this, "createIframeNode", void 0);
|
63
46
|
_defineProperty(this, "_selector", void 0);
|
64
47
|
_defineProperty(this, "_appVersion", void 0);
|
@@ -66,20 +49,17 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
66
49
|
_defineProperty(this, "_actionQueryPromise", null);
|
67
50
|
_defineProperty(this, "_renderParams", null);
|
68
51
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
69
|
-
_defineProperty(this, "_performanceData", []);
|
70
|
-
_defineProperty(this, "_isInitComponent", void 0);
|
71
52
|
_defineProperty(this, "_clickEventName", void 0);
|
53
|
+
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
72
54
|
this._appVersion = '1.5.3';
|
73
55
|
this._isInitComponent = false;
|
74
|
-
this._selector =
|
56
|
+
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
75
57
|
this.createIframeNode = function () {
|
76
58
|
return Promise.resolve();
|
77
59
|
};
|
78
|
-
this.platform = isPC() ?
|
79
|
-
this._clickEventName = this.platform ===
|
60
|
+
this.platform = isPC() ? platformEnum.desktop : platformEnum.mobile;
|
61
|
+
this._clickEventName = this.platform === platformEnum.mobile ? 'touchend' : 'click';
|
80
62
|
this._isRetention = true;
|
81
|
-
addEvent();
|
82
|
-
this.createMountElement();
|
83
63
|
this._performanceData.push({
|
84
64
|
key: 'sdk_init',
|
85
65
|
value: Date.now()
|
@@ -92,7 +72,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
92
72
|
_createClass(ComponentApp, [{
|
93
73
|
key: "logoutPlugin",
|
94
74
|
value: function logoutPlugin() {
|
95
|
-
this.
|
75
|
+
this.cleanContainer(true);
|
96
76
|
}
|
97
77
|
|
98
78
|
/**
|
@@ -110,8 +90,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
110
90
|
*/
|
111
91
|
}, {
|
112
92
|
key: "setRender",
|
113
|
-
value: function setRender(
|
114
|
-
this.createIframeNode =
|
93
|
+
value: function setRender(renderFunc) {
|
94
|
+
this.createIframeNode = renderFunc;
|
115
95
|
}
|
116
96
|
}, {
|
117
97
|
key: "initAPSecurity",
|
@@ -143,83 +123,129 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
143
123
|
}, {
|
144
124
|
key: "appendIframeNodes",
|
145
125
|
value: function appendIframeNodes(componentSign, renderParams) {
|
146
|
-
var
|
147
|
-
|
148
|
-
|
126
|
+
var _this = this;
|
127
|
+
if (this._isInitComponent) {
|
128
|
+
this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
129
|
+
return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
130
|
+
}
|
149
131
|
this._isInitComponent = true;
|
150
132
|
this._renderParams = renderParams;
|
151
133
|
this._componentSign = componentSign;
|
134
|
+
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
135
|
+
this._renderDisplayType = renderParams.renderDisplayType;
|
136
|
+
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
137
|
+
this.initAPSecurity();
|
152
138
|
this._performanceData.push({
|
153
139
|
key: 'sdk_create_component',
|
154
140
|
value: Date.now()
|
155
141
|
});
|
156
|
-
this.
|
157
|
-
|
158
|
-
|
159
|
-
if (
|
160
|
-
var
|
161
|
-
if (
|
162
|
-
|
163
|
-
|
164
|
-
this.
|
142
|
+
this.dispatchToSDK(EVENT.eventCallback.name, {
|
143
|
+
code: eventCodeEnum.SDK_START_OF_LOADING
|
144
|
+
});
|
145
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
146
|
+
var container = createInlineBaseElement(this._selector);
|
147
|
+
if (container) this.renderInlineLoading(renderParams, container);
|
148
|
+
}
|
149
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
150
|
+
createBaseElement(this.platform, this.closeBtnFunc.bind(this));
|
151
|
+
createRetentionPopup(this.platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
|
152
|
+
createMockup();
|
153
|
+
this.renderPopupLoading(renderParams);
|
165
154
|
}
|
166
|
-
this.showCashier();
|
167
155
|
this.createApp(renderParams);
|
168
|
-
this.createActionQueryPromise()
|
169
|
-
|
170
|
-
|
171
|
-
})), this._actionQueryPromise]).catch(function () {
|
156
|
+
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
|
157
|
+
return Promise.resolve();
|
158
|
+
}).catch(function (error) {
|
172
159
|
_this._isInitComponent = false;
|
160
|
+
_this.cleanContainer();
|
161
|
+
return Promise.reject(error);
|
162
|
+
});
|
163
|
+
}
|
164
|
+
}, {
|
165
|
+
key: "renderInlineLoading",
|
166
|
+
value: function renderInlineLoading(renderParams, selector) {
|
167
|
+
var _renderParams$appeara;
|
168
|
+
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
|
169
|
+
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
170
|
+
if (showLoading) addInlineLoading(selector, this.platform);
|
171
|
+
}
|
172
|
+
}, {
|
173
|
+
key: "renderPopupLoading",
|
174
|
+
value: function renderPopupLoading(renderParams) {
|
175
|
+
var _renderParams$appeara2;
|
176
|
+
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
|
177
|
+
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
178
|
+
if (!showLoading) return;
|
179
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
180
|
+
if (mockup) mockup.style.display = 'block';
|
181
|
+
addPopupLoading();
|
182
|
+
}
|
183
|
+
}, {
|
184
|
+
key: "_createLoadAppPromise",
|
185
|
+
value: function _createLoadAppPromise() {
|
186
|
+
var _this2 = this;
|
187
|
+
return new Promise(function (resolve, reject) {
|
188
|
+
_this2._loadAppPromiseResolve = resolve;
|
189
|
+
setTimeout(function () {
|
190
|
+
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
191
|
+
}, LOADTIME_LIMIT);
|
192
|
+
}).catch(function (error) {
|
193
|
+
_this2.dispatchToSDK(EVENT.error.name, {
|
194
|
+
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
|
195
|
+
message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
|
196
|
+
});
|
197
|
+
return Promise.reject(error);
|
173
198
|
});
|
174
199
|
}
|
200
|
+
|
175
201
|
/**
|
176
202
|
* @description Interface request
|
177
203
|
*/
|
178
204
|
}, {
|
179
205
|
key: "createActionQueryPromise",
|
180
206
|
value: function createActionQueryPromise() {
|
181
|
-
var
|
207
|
+
var _this3 = this;
|
182
208
|
this._performanceData.push({
|
183
209
|
key: 'sdk_action_query_start',
|
184
210
|
value: Date.now()
|
185
211
|
});
|
186
212
|
this._actionQueryPromise = new Promise(function (resolve, reject) {
|
187
|
-
var
|
213
|
+
var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3, _this3$_renderParams4, _this3$_renderParams5;
|
188
214
|
var params = {
|
189
|
-
paymentSessionData:
|
190
|
-
paymentSessionConfig: (
|
215
|
+
paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.paymentSessionData) || '',
|
216
|
+
paymentSessionConfig: (_this3$_renderParams2 = _this3._renderParams) === null || _this3$_renderParams2 === void 0 ? void 0 : (_this3$_renderParams3 = _this3$_renderParams2.paymentSessionMetaData) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.paymentSessionConfig
|
191
217
|
};
|
192
218
|
/**
|
193
219
|
* @description card
|
194
220
|
*/
|
195
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD ===
|
221
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
|
196
222
|
params.paymentMethodType = 'CARD';
|
197
223
|
}
|
198
224
|
var needDeviceId = false;
|
199
225
|
var waitTime = '3000';
|
200
|
-
var securityConfig = (
|
201
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD ===
|
202
|
-
var
|
203
|
-
var extendInfo = ((
|
226
|
+
var securityConfig = (_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : (_this3$_renderParams5 = _this3$_renderParams4.paymentSessionMetaData) === null || _this3$_renderParams5 === void 0 ? void 0 : _this3$_renderParams5.securityConfig;
|
227
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign && securityConfig) {
|
228
|
+
var _this3$_renderParams6, _this3$_renderParams7;
|
229
|
+
var extendInfo = ((_this3$_renderParams6 = _this3._renderParams) === null || _this3$_renderParams6 === void 0 ? void 0 : (_this3$_renderParams7 = _this3$_renderParams6.paymentSessionMetaData) === null || _this3$_renderParams7 === void 0 ? void 0 : _this3$_renderParams7.extendInfo) || '';
|
204
230
|
var info = JSON.parse(extendInfo);
|
205
231
|
if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
|
206
|
-
var
|
232
|
+
var _this3$_renderParams8, _this3$_renderParams9, _this3$_renderParams10;
|
207
233
|
needDeviceId = true;
|
208
|
-
waitTime = (
|
234
|
+
waitTime = (_this3$_renderParams8 = _this3._renderParams) === null || _this3$_renderParams8 === void 0 ? void 0 : (_this3$_renderParams9 = _this3$_renderParams8.paymentSessionMetaData) === null || _this3$_renderParams9 === void 0 ? void 0 : (_this3$_renderParams10 = _this3$_renderParams9.securityConfig) === null || _this3$_renderParams10 === void 0 ? void 0 : _this3$_renderParams10.tokenCollectTime;
|
209
235
|
}
|
210
236
|
}
|
211
237
|
|
212
238
|
/**
|
213
239
|
* @description easyPay
|
214
240
|
*/
|
215
|
-
if (componentSignEnum.EASY_PAY_WALLET ===
|
216
|
-
var
|
241
|
+
if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
|
242
|
+
var _this3$_renderParams11;
|
217
243
|
var _ref2 = params.paymentSessionConfig || {},
|
218
244
|
_ref2$productSceneVer = _ref2.productSceneVersion,
|
219
245
|
productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
|
220
246
|
_ref2$productScene = _ref2.productScene,
|
221
247
|
productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
|
222
|
-
var _ref3 = ((
|
248
|
+
var _ref3 = ((_this3$_renderParams11 = _this3._renderParams) === null || _this3$_renderParams11 === void 0 ? void 0 : _this3$_renderParams11.paymentSessionMetaData) || {},
|
223
249
|
_ref3$action = _ref3.action,
|
224
250
|
_ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
|
225
251
|
_ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
|
@@ -236,9 +262,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
236
262
|
* @author tianqiang
|
237
263
|
* @description autoDebit
|
238
264
|
*/
|
239
|
-
if (componentSignEnum.AUTO_DEBIT_WALLET ===
|
240
|
-
var
|
241
|
-
var action = ((
|
265
|
+
if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
|
266
|
+
var _this3$_renderParams12, _this3$_renderParams13, _action$web, _action$wap;
|
267
|
+
var action = ((_this3$_renderParams12 = _this3._renderParams) === null || _this3$_renderParams12 === void 0 ? void 0 : (_this3$_renderParams13 = _this3$_renderParams12.paymentSessionMetaData) === null || _this3$_renderParams13 === void 0 ? void 0 : _this3$_renderParams13.action) || {};
|
242
268
|
var signType = isPC() ? action === null || action === void 0 ? void 0 : (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 ? void 0 : (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
243
269
|
if (signType === 'SMS') {
|
244
270
|
return resolve({
|
@@ -261,12 +287,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
261
287
|
});
|
262
288
|
}
|
263
289
|
queryPaymentInfo(params, {
|
264
|
-
env:
|
265
|
-
locale:
|
290
|
+
env: _this3.AMSSDK.options.env.environment,
|
291
|
+
locale: _this3.AMSSDK.options.locale,
|
266
292
|
needDeviceId: needDeviceId,
|
267
293
|
waitTime: waitTime
|
268
294
|
}).then(function (res) {
|
269
|
-
|
295
|
+
_this3._performanceData.push({
|
270
296
|
key: 'sdk_action_query_end',
|
271
297
|
value: Date.now()
|
272
298
|
});
|
@@ -274,26 +300,46 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
274
300
|
resolve(res);
|
275
301
|
} else {
|
276
302
|
resolve(res);
|
277
|
-
_this2.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR);
|
278
303
|
}
|
279
304
|
}).catch(function (err) {
|
305
|
+
_this3.dispatchToSDK(EVENT.error.name, {
|
306
|
+
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
|
307
|
+
});
|
280
308
|
reject(err);
|
281
|
-
_this2.closeCashier();
|
282
309
|
});
|
283
310
|
});
|
311
|
+
return this._actionQueryPromise;
|
284
312
|
}
|
285
313
|
}, {
|
286
|
-
key: "
|
287
|
-
value: function
|
314
|
+
key: "cleanElement",
|
315
|
+
value: function cleanElement() {
|
288
316
|
try {
|
289
|
-
|
290
|
-
|
317
|
+
var _document$getElementB;
|
318
|
+
// selector and container
|
291
319
|
if (getType(this._selector) === 'string') {
|
292
|
-
var
|
293
|
-
if (
|
320
|
+
var selectorDom = document.querySelector(this._selector);
|
321
|
+
if (selectorDom) selectorDom.innerHTML = '';
|
294
322
|
}
|
295
|
-
|
296
|
-
|
323
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
324
|
+
if (container) container === null || container === void 0 ? void 0 : container.remove();
|
325
|
+
|
326
|
+
// animation
|
327
|
+
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style"))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
|
328
|
+
|
329
|
+
// mockup
|
330
|
+
var body = document.getElementsByTagName('body')[0];
|
331
|
+
body.style.overflow = 'auto';
|
332
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
333
|
+
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
334
|
+
|
335
|
+
// retentionPopup
|
336
|
+
this.removeRetentionPopup(this.platform);
|
337
|
+
|
338
|
+
// listener
|
339
|
+
this.removeEventListener();
|
340
|
+
} catch (error) {
|
341
|
+
console.error(error);
|
342
|
+
}
|
297
343
|
}
|
298
344
|
|
299
345
|
/**
|
@@ -322,7 +368,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
322
368
|
productSceneVersion: productSceneVersion,
|
323
369
|
extendInfo: extendInfo
|
324
370
|
});
|
325
|
-
this.app = createIframe(this.AMSSDK.options.mode);
|
371
|
+
this.app = createIframe(this.AMSSDK.options.mode, this.platform);
|
326
372
|
this.app.src = getIframeUrl({
|
327
373
|
componentSign: this._componentSign,
|
328
374
|
analytics: this.AMSSDK.options.analytics,
|
@@ -335,7 +381,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
335
381
|
});
|
336
382
|
|
337
383
|
// Subscribe to messages from iframe
|
338
|
-
this.
|
384
|
+
this.addEventListener();
|
339
385
|
} catch (error) {
|
340
386
|
this.dispatchToSDK(EVENT.error.name, Object.assign({}, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.FAILED_TO_CREATE_IFRAME, {
|
341
387
|
stack: error
|
@@ -354,6 +400,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
354
400
|
if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
|
355
401
|
return;
|
356
402
|
}
|
403
|
+
// TODO
|
404
|
+
// 如果带有callback标识,则从map结构中取出callbackfunc,执行,执行后在map结构中删除
|
357
405
|
this._handleAppMessage(data);
|
358
406
|
} else {
|
359
407
|
console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
|
@@ -363,7 +411,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
363
411
|
}, {
|
364
412
|
key: "resizeListener",
|
365
413
|
value: function resizeListener() {
|
366
|
-
var cashier = document.getElementById(
|
414
|
+
var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
|
367
415
|
cashier.style.transition = 'none';
|
368
416
|
this.dispatchToApp({
|
369
417
|
context: {
|
@@ -380,19 +428,19 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
380
428
|
* @description Initialize subscription iframe message
|
381
429
|
*/
|
382
430
|
}, {
|
383
|
-
key: "
|
384
|
-
value: function
|
385
|
-
this.
|
386
|
-
window["".concat(
|
387
|
-
window["".concat(
|
388
|
-
window.addEventListener('message', window["".concat(
|
389
|
-
window.addEventListener('resize', window["".concat(
|
431
|
+
key: "addEventListener",
|
432
|
+
value: function addEventListener() {
|
433
|
+
this.removeEventListener();
|
434
|
+
window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
|
435
|
+
window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
|
436
|
+
window.addEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
|
437
|
+
window.addEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
390
438
|
}
|
391
439
|
}, {
|
392
|
-
key: "
|
393
|
-
value: function
|
394
|
-
window.removeEventListener('message', window["".concat(
|
395
|
-
window.removeEventListener('resize', window["".concat(
|
440
|
+
key: "removeEventListener",
|
441
|
+
value: function removeEventListener() {
|
442
|
+
window.removeEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
|
443
|
+
window.removeEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
396
444
|
}
|
397
445
|
|
398
446
|
/**
|
@@ -401,7 +449,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
401
449
|
}, {
|
402
450
|
key: "_handleAppMessage",
|
403
451
|
value: function _handleAppMessage(data) {
|
404
|
-
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.
|
452
|
+
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];
|
453
|
+
if (!eventKeyMap.includes(data.context.event)) {
|
454
|
+
return;
|
455
|
+
}
|
405
456
|
if (data.context.event === EVENT.dismissLoading.name) {
|
406
457
|
var _data$context$data;
|
407
458
|
this.dispatchToSDK(EVENT.eventCallback.name, {
|
@@ -410,21 +461,19 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
410
461
|
});
|
411
462
|
return;
|
412
463
|
}
|
413
|
-
if (!eventKeyMap.includes(data.context.event)) {
|
414
|
-
return;
|
415
|
-
}
|
416
464
|
if (data.context.event === EVENT.launch.name) {
|
417
465
|
this._performanceData.push({
|
418
466
|
key: 'sdk_onLaunch',
|
419
467
|
value: Date.now()
|
420
468
|
});
|
469
|
+
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
421
470
|
this.sendRenderEvent();
|
422
471
|
return;
|
423
472
|
}
|
424
473
|
if (data.context.event === EVENT.sizeChanged.name) {
|
425
474
|
this.handleSizeChanged(data);
|
426
475
|
}
|
427
|
-
if (data.context.event === EVENT.
|
476
|
+
if (data.context.event === EVENT.close.name) {
|
428
477
|
return this.closeBtnFunc();
|
429
478
|
}
|
430
479
|
if (data.context.event === EVENT.redirect.name) {
|
@@ -459,29 +508,29 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
459
508
|
key: "handleSizeChanged",
|
460
509
|
value: function handleSizeChanged(data) {
|
461
510
|
var _data$context$data2;
|
462
|
-
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height)
|
463
|
-
|
464
|
-
|
511
|
+
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
|
512
|
+
var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
|
513
|
+
cashier.style.height = "".concat(data.context.data.height, "px");
|
514
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
515
|
+
var _document$getElementB2;
|
516
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
465
517
|
if (mockup) {
|
466
|
-
mockup.style.background = '
|
467
|
-
mockup.style.opacity = '0.6';
|
518
|
+
mockup.style.background = 'rgb(0, 0, 0, 0.6)';
|
468
519
|
mockup.style.display = 'block';
|
469
520
|
}
|
470
|
-
(_document$
|
471
|
-
var cashier = document.getElementById('ams-component-container');
|
472
|
-
cashier.style.height = "".concat(data.context.data.height, "px");
|
521
|
+
(_document$getElementB2 = document.getElementById(LOADING_ID)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
|
473
522
|
if (this.platform === 'desktop') {
|
474
|
-
cashier.classList.add(
|
523
|
+
cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
475
524
|
if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
|
476
525
|
}
|
477
526
|
if (this.platform === 'mobile') {
|
478
|
-
cashier.classList.add(
|
479
|
-
var animationStyleId =
|
527
|
+
cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
528
|
+
var animationStyleId = "".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style");
|
480
529
|
var animationStyle = document.getElementById(animationStyleId);
|
481
530
|
if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
|
482
531
|
|
483
532
|
// 弹出和弹入动画
|
484
|
-
var runkeyframes = "
|
533
|
+
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 }");
|
485
534
|
// 创建style标签
|
486
535
|
var style = document.createElement('style');
|
487
536
|
style.id = animationStyleId;
|
@@ -497,17 +546,18 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
497
546
|
cashier.style.transition = 'height 0.28s ease-in-out';
|
498
547
|
}, 500);
|
499
548
|
}
|
500
|
-
this.app.style.height = "".concat(data.context.data.height, "px");
|
501
|
-
this.app.style.width = '100%';
|
502
|
-
this.app.style.border = '0';
|
503
|
-
this.app.style.overflow = 'hidden';
|
504
549
|
}
|
550
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
551
|
+
var _document$getElementB3;
|
552
|
+
(_document$getElementB3 = document.getElementById(LOADING_ID)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
|
553
|
+
}
|
554
|
+
this.app.style.height = "".concat(data.context.data.height, "px");
|
555
|
+
this.app.style.opacity = '1';
|
505
556
|
}
|
506
557
|
}, {
|
507
558
|
key: "handleRedirect",
|
508
559
|
value: function handleRedirect(data) {
|
509
|
-
var
|
510
|
-
this.closeCashier();
|
560
|
+
var _this4 = this;
|
511
561
|
var _data = typeof data === 'string' ? {
|
512
562
|
normalUrl: data
|
513
563
|
} : {
|
@@ -517,37 +567,38 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
517
567
|
target: data === null || data === void 0 ? void 0 : data.target
|
518
568
|
};
|
519
569
|
var successCallback = function successCallback(type, url) {
|
520
|
-
|
521
|
-
code:
|
570
|
+
_this4.dispatchToSDK(EVENT.eventCallback.name, {
|
571
|
+
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
522
572
|
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
523
573
|
});
|
524
574
|
};
|
525
575
|
var failCallback = function failCallback() {
|
526
|
-
|
527
|
-
code:
|
576
|
+
_this4.dispatchToSDK(EVENT.eventCallback.name, {
|
577
|
+
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
528
578
|
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
|
529
579
|
});
|
530
580
|
};
|
531
581
|
|
532
582
|
// 支持 target: _blank,新开tab页打开
|
533
|
-
if (_data.target ===
|
583
|
+
if (_data.target === targetEnum.BLANK) {
|
534
584
|
if (!_data.normalUrl) return failCallback();
|
535
585
|
successCallback('normalUrl', _data.normalUrl);
|
536
586
|
window.open(_data.normalUrl);
|
537
587
|
return;
|
538
588
|
}
|
589
|
+
this.cleanContainer();
|
539
590
|
this.AMSSDK._redirect({
|
540
591
|
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
|
541
592
|
}).then(function () {
|
542
593
|
successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
543
594
|
}).catch(function () {
|
544
|
-
return
|
595
|
+
return _this4.AMSSDK._redirect({
|
545
596
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
546
597
|
});
|
547
598
|
}).then(function () {
|
548
599
|
successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
549
600
|
}).catch(function () {
|
550
|
-
return
|
601
|
+
return _this4.AMSSDK._redirect({
|
551
602
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
552
603
|
});
|
553
604
|
}).then(function () {
|
@@ -561,59 +612,18 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
561
612
|
value: function handleDeclareInfo(_ref4) {
|
562
613
|
var _ref4$closeDialogData = _ref4.closeDialogData,
|
563
614
|
closeDialogData = _ref4$closeDialogData === void 0 ? {} : _ref4$closeDialogData;
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
if (retentionTitle) {
|
568
|
-
var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
|
569
|
-
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");
|
570
|
-
retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
|
571
|
-
retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
|
572
|
-
}
|
573
|
-
var retentionMessage = document.getElementById('ams-component-retention-sub-title');
|
574
|
-
if (retentionMessage) {
|
575
|
-
var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
|
576
|
-
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");
|
577
|
-
retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
|
578
|
-
retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
|
579
|
-
}
|
580
|
-
var remainBtn = document.getElementById('ams-component-retention-remain');
|
581
|
-
if (remainBtn) {
|
582
|
-
var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
|
583
|
-
remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
|
584
|
-
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");
|
585
|
-
remainBtn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO3 = closeDialogData.btnOK) === null || _closeDialogData$btnO3 === void 0 ? void 0 : _closeDialogData$btnO3.fontColor;
|
586
|
-
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");
|
587
|
-
if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO5 = closeDialogData.btnOK) === null || _closeDialogData$btnO5 === void 0 ? void 0 : _closeDialogData$btnO5.type) === 'stroke') {
|
588
|
-
var _closeDialogData$btnO6;
|
589
|
-
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);
|
590
|
-
} 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;
|
591
|
-
}
|
592
|
-
var leaveBrn = document.getElementById('ams-component-retention-leave');
|
593
|
-
if (leaveBrn) {
|
594
|
-
var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
|
595
|
-
leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
|
596
|
-
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");
|
597
|
-
leaveBrn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC3 = closeDialogData.btnCancel) === null || _closeDialogData$btnC3 === void 0 ? void 0 : _closeDialogData$btnC3.fontColor;
|
598
|
-
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");
|
599
|
-
if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC5 = closeDialogData.btnCancel) === null || _closeDialogData$btnC5 === void 0 ? void 0 : _closeDialogData$btnC5.type) === 'stroke') {
|
600
|
-
var _closeDialogData$btnC6;
|
601
|
-
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);
|
602
|
-
} 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;
|
603
|
-
}
|
604
|
-
}
|
605
|
-
} catch (error) {
|
606
|
-
console.error(error);
|
607
|
-
}
|
615
|
+
_handleDeclareInfo({
|
616
|
+
closeDialogData: closeDialogData
|
617
|
+
});
|
608
618
|
}
|
609
619
|
}, {
|
610
620
|
key: "handleCloseBtnShow",
|
611
621
|
value: function handleCloseBtnShow(showClose) {
|
612
|
-
var closeBlock = document.getElementById(
|
622
|
+
var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
|
613
623
|
if (showClose) {
|
614
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove(
|
624
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
|
615
625
|
} else if (showClose === false) {
|
616
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add(
|
626
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
|
617
627
|
}
|
618
628
|
}
|
619
629
|
|
@@ -623,7 +633,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
623
633
|
}, {
|
624
634
|
key: "dispatchToSDK",
|
625
635
|
value: function dispatchToSDK(event, data) {
|
626
|
-
this.AMSSDK.
|
636
|
+
this.AMSSDK._eventCenter.emit(event, data);
|
627
637
|
}
|
628
638
|
|
629
639
|
/**
|
@@ -638,9 +648,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
638
648
|
appId: COMPONENTPLUGINID,
|
639
649
|
instanceId: this.AMSSDK._instanceId
|
640
650
|
});
|
651
|
+
// TODO 如果存在回调函数,则增加callBack标识,并存入map。map可以设置
|
641
652
|
if (this.app && this.app.contentWindow) {
|
642
|
-
this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
653
|
+
return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
643
654
|
}
|
655
|
+
throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
|
644
656
|
}
|
645
657
|
|
646
658
|
/**
|
@@ -653,7 +665,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
653
665
|
for (var key in eventKeyMap) {
|
654
666
|
// eslint-disable-next-line no-prototype-builtins
|
655
667
|
if (eventKeyMap.hasOwnProperty(key)) {
|
656
|
-
this.AMSSDK.
|
668
|
+
this.AMSSDK._eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
|
657
669
|
}
|
658
670
|
}
|
659
671
|
}
|
@@ -665,7 +677,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
665
677
|
key: "sendRenderEvent",
|
666
678
|
value: function () {
|
667
679
|
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
668
|
-
var _this$_renderParams2, _this$_renderParams3, res;
|
680
|
+
var _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, _this$_renderParams5, res;
|
669
681
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
670
682
|
while (1) switch (_context.prev = _context.next) {
|
671
683
|
case 0:
|
@@ -692,6 +704,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
692
704
|
sessionResult: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionMetaData,
|
693
705
|
paymentSessionData: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.paymentSessionData,
|
694
706
|
heightOfVisible: Math.max(innerHeight, window.innerHeight),
|
707
|
+
renderDisplayType: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.renderDisplayType,
|
708
|
+
appearance: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.appearance,
|
695
709
|
envInfo: {
|
696
710
|
screenHeight: screen.height,
|
697
711
|
screenWidth: screen.width
|
@@ -724,198 +738,77 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
724
738
|
}
|
725
739
|
return sendRenderEvent;
|
726
740
|
}()
|
727
|
-
}, {
|
728
|
-
key: "showLoading",
|
729
|
-
value: function showLoading() {
|
730
|
-
var loading = document.createElement('div');
|
731
|
-
loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
|
732
|
-
loading.id = loadingId;
|
733
|
-
loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
|
734
|
-
loading.style.fontSize = "".concat(getDesignFontSize(), "px");
|
735
|
-
var body = document.getElementsByTagName('body')[0];
|
736
|
-
body === null || body === void 0 ? void 0 : body.appendChild(loading);
|
737
|
-
}
|
738
|
-
|
739
|
-
/**
|
740
|
-
* @description show cashier
|
741
|
-
*/
|
742
|
-
}, {
|
743
|
-
key: "showCashier",
|
744
|
-
value: function showCashier() {
|
745
|
-
var cashier = document.getElementById('ams-component-container');
|
746
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("ams-component-container-hidden-".concat(this.platform));
|
747
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("ams-component-container-".concat(this.platform));
|
748
|
-
}
|
749
|
-
|
750
741
|
/**
|
751
742
|
* @description close cashier
|
752
743
|
*/
|
753
744
|
}, {
|
754
|
-
key: "
|
755
|
-
value: function
|
756
|
-
var _document$
|
745
|
+
key: "cleanContainer",
|
746
|
+
value: function cleanContainer() {
|
747
|
+
var _document$getElementB4,
|
748
|
+
_this5 = this;
|
757
749
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
750
|
+
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
758
751
|
this._performanceData = [];
|
759
752
|
this._isInitComponent = false;
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
var _this4 = this;
|
767
|
-
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
768
|
-
var container = document.getElementById('ams-component-container');
|
769
|
-
// size变化动画取消
|
770
|
-
container.style.transition = '';
|
771
|
-
container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform));
|
772
|
-
container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform, "-animation"));
|
773
|
-
container === null || container === void 0 ? void 0 : container.classList.add("ams-component-container-hidden-".concat(this.platform));
|
774
|
-
var removeMockupAndApp = function removeMockupAndApp() {
|
775
|
-
var _document$getElementB3;
|
776
|
-
var body = document.getElementsByTagName('body')[0];
|
777
|
-
body.style.overflow = 'auto';
|
778
|
-
var mockup = document.getElementById(mockupId);
|
779
|
-
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
780
|
-
if (container) container.style.height = '';
|
781
|
-
(_document$getElementB3 = document.getElementById('ams-component-container-mobile-animation-style')) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
|
782
|
-
_this4.removeRetentionPopup();
|
783
|
-
_this4.cleanApp();
|
784
|
-
};
|
785
|
-
if (immediately) removeMockupAndApp();else {
|
753
|
+
this.app = null;
|
754
|
+
(_document$getElementB4 = document.getElementById(LOADING_ID)) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
755
|
+
this.hideComponentAnimation();
|
756
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
757
|
+
mockup === null || mockup === void 0 ? void 0 : mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
|
758
|
+
if (immediately) this.cleanElement();else {
|
786
759
|
setTimeout(function () {
|
787
|
-
|
760
|
+
_this5.cleanElement();
|
788
761
|
}, 300);
|
789
762
|
}
|
790
763
|
}
|
764
|
+
}, {
|
765
|
+
key: "hideComponentAnimation",
|
766
|
+
value: function hideComponentAnimation() {
|
767
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
768
|
+
if (container) {
|
769
|
+
// size变化动画取消
|
770
|
+
container.style.transition = '';
|
771
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform));
|
772
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
773
|
+
container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.platform));
|
774
|
+
}
|
775
|
+
}
|
791
776
|
}, {
|
792
777
|
key: "closeBtnFunc",
|
793
778
|
value: function closeBtnFunc() {
|
794
779
|
// element && element.removeEventListener()
|
795
780
|
if (this._isRetention) this.showRetentionPopup();else {
|
796
|
-
this.
|
797
|
-
this.dispatchToSDK(EVENT.
|
798
|
-
}
|
799
|
-
}
|
800
|
-
|
801
|
-
/**
|
802
|
-
* @description create mount node
|
803
|
-
*/
|
804
|
-
}, {
|
805
|
-
key: "createMountElement",
|
806
|
-
value: function createMountElement() {
|
807
|
-
componentAddCSS();
|
808
|
-
var amsComponentContainer = document.createElement('div');
|
809
|
-
amsComponentContainer.className = "ams-component-container-hidden-".concat(this.platform);
|
810
|
-
amsComponentContainer.id = 'ams-component-container';
|
811
|
-
amsSetSize(null, amsComponentContainer);
|
812
|
-
document.body.appendChild(amsComponentContainer);
|
813
|
-
var amsComponentSection = document.createElement('div');
|
814
|
-
amsComponentSection.className = "ams-component-section-".concat(this.platform);
|
815
|
-
amsComponentSection.id = this._selector.slice(1);
|
816
|
-
amsComponentContainer.appendChild(amsComponentSection);
|
817
|
-
this.createCloseBtn();
|
818
|
-
}
|
819
|
-
}, {
|
820
|
-
key: "createCloseBtn",
|
821
|
-
value: function createCloseBtn() {
|
822
|
-
var _this5 = this;
|
823
|
-
var container = document.getElementById('ams-component-container');
|
824
|
-
// close btn
|
825
|
-
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
|
826
|
-
var closeBlock = document.createElement('div');
|
827
|
-
closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
|
828
|
-
closeBlock.id = 'asm-component-section-close-block';
|
829
|
-
closeBlock.innerHTML = closeBtnHTML;
|
830
|
-
closeBlock.addEventListener(this._clickEventName, function () {
|
831
|
-
_this5.closeBtnFunc();
|
832
|
-
});
|
833
|
-
if (container) container.appendChild(closeBlock);
|
834
|
-
}
|
835
|
-
}, {
|
836
|
-
key: "createRetentionPopup",
|
837
|
-
value: function createRetentionPopup() {
|
838
|
-
// retention popup
|
839
|
-
var retentionPopup = document.createElement('div');
|
840
|
-
retentionPopup.id = 'ams-component-retention';
|
841
|
-
retentionPopup.classList.add("ams-component-retention-".concat(this.platform));
|
842
|
-
retentionPopup.innerHTML = "\n <span id=\"ams-component-retention-title\" class=\"ams-component-retention-title-".concat(this.platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"ams-component-retention-sub-title\"\n class=\"ams-component-retention-sub-title-").concat(this.platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"ams-component-retention-btn-block-").concat(this.platform, "\">\n <div id=\"ams-component-retention-remain\" class=\"ams-component-retention-remain-").concat(this.platform, "\">\n Continue Payment\n </div>\n <div id=\"ams-component-retention-leave\" class=\"ams-component-retention-leave-").concat(this.platform, "\">\n Leave\n </div>\n </div>");
|
843
|
-
document.body.appendChild(retentionPopup);
|
844
|
-
var remainBtn = document.getElementById('ams-component-retention-remain');
|
845
|
-
if (remainBtn) {
|
846
|
-
remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
|
847
|
-
}
|
848
|
-
var leaveBtn = document.getElementById('ams-component-retention-leave');
|
849
|
-
if (leaveBtn) {
|
850
|
-
leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
|
781
|
+
this.cleanContainer();
|
782
|
+
this.dispatchToSDK(EVENT.close.name, {});
|
851
783
|
}
|
852
784
|
}
|
853
785
|
}, {
|
854
786
|
key: "retentionPopupLeaveFunc",
|
855
787
|
value: function retentionPopupLeaveFunc() {
|
856
|
-
this.dispatchToSDK(EVENT.
|
857
|
-
this.
|
858
|
-
this.
|
788
|
+
this.dispatchToSDK(EVENT.close.name, {});
|
789
|
+
this.hideRetentionPopupFunc();
|
790
|
+
this.cleanContainer();
|
859
791
|
}
|
860
792
|
}, {
|
861
793
|
key: "removeRetentionPopup",
|
862
|
-
value: function removeRetentionPopup() {
|
863
|
-
|
864
|
-
var remainBtn = document.getElementById('ams-component-retention-remain');
|
865
|
-
if (remainBtn) {
|
866
|
-
remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
|
867
|
-
}
|
868
|
-
var leaveBtn = document.getElementById('ams-component-retention-leave');
|
869
|
-
if (leaveBtn) {
|
870
|
-
leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
|
871
|
-
}
|
872
|
-
(_document$getElementB4 = document.getElementById('ams-component-retention')) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
794
|
+
value: function removeRetentionPopup(platform) {
|
795
|
+
_removeRetentionPopup(platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
|
873
796
|
}
|
874
797
|
}, {
|
875
798
|
key: "showRetentionPopup",
|
876
799
|
value: function showRetentionPopup() {
|
877
|
-
var retentionPopup = document.getElementById(
|
878
|
-
var container = document.getElementById(
|
879
|
-
if (retentionPopup) {
|
880
|
-
container === null || container === void 0 ? void 0 : container.classList.add('ams-component-container-opacity');
|
881
|
-
retentionPopup.classList.remove('ams-component-retention-hidden');
|
882
|
-
retentionPopup.classList.add('ams-component-retention-show');
|
883
|
-
}
|
884
|
-
}
|
885
|
-
}, {
|
886
|
-
key: "hideRetentionPopup",
|
887
|
-
value: function hideRetentionPopup() {
|
888
|
-
var retentionPopup = document.getElementById('ams-component-retention');
|
889
|
-
var container = document.getElementById('ams-component-container');
|
800
|
+
var retentionPopup = document.getElementById(COMPONENT_RETENTION_ID);
|
801
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
890
802
|
if (retentionPopup) {
|
891
|
-
|
892
|
-
retentionPopup.classList.
|
893
|
-
|
894
|
-
retentionPopup.classList.remove('ams-component-retention-hidden');
|
895
|
-
container === null || container === void 0 ? void 0 : container.classList.remove('ams-component-container-opacity');
|
896
|
-
}, 250);
|
803
|
+
container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-opacity"));
|
804
|
+
retentionPopup.classList.remove("".concat(COMPONENT_RETENTION_ID, "-hidden"));
|
805
|
+
retentionPopup.classList.add("".concat(COMPONENT_RETENTION_ID, "-show"));
|
897
806
|
}
|
898
807
|
}
|
899
|
-
/**
|
900
|
-
* @description create mockup
|
901
|
-
*/
|
902
808
|
}, {
|
903
|
-
key: "
|
904
|
-
value: function
|
905
|
-
|
906
|
-
body.style.overflow = 'hidden';
|
907
|
-
var mockup = document.createElement('div');
|
908
|
-
mockup.style.width = '100vw';
|
909
|
-
mockup.style.height = '100vh';
|
910
|
-
mockup.style.position = 'fixed';
|
911
|
-
mockup.style.top = '0';
|
912
|
-
mockup.style.left = '0';
|
913
|
-
mockup.style.zIndex = '1000';
|
914
|
-
mockup.style.background = '#ffffff';
|
915
|
-
mockup.style.opacity = '0.5';
|
916
|
-
mockup.style.display = 'none';
|
917
|
-
mockup.id = mockupId;
|
918
|
-
body.appendChild(mockup);
|
809
|
+
key: "hideRetentionPopupFunc",
|
810
|
+
value: function hideRetentionPopupFunc() {
|
811
|
+
hideRetentionPopup();
|
919
812
|
}
|
920
813
|
}, {
|
921
814
|
key: "submitForm",
|
@@ -936,7 +829,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
936
829
|
form.setAttribute('action', attributes.action);
|
937
830
|
form.setAttribute('method', 'post');
|
938
831
|
body.appendChild(form);
|
939
|
-
this.closeCashier(true);
|
940
832
|
setTimeout(function () {
|
941
833
|
form.submit();
|
942
834
|
}, 0);
|