@alipay/ams-checkout 0.0.1691743027-dev.9 → 0.0.1691995963-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +15 -1
- package/esm/config/index.js +62 -9
- package/esm/constant/index.d.ts +32 -54
- package/esm/constant/index.js +32 -54
- package/esm/core/component/index.d.ts +9 -23
- package/esm/core/component/index.js +98 -161
- 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 +23 -6
- package/esm/core/instance/index.js +75 -31
- package/esm/index.d.ts +10 -4
- package/esm/index.js +30 -8
- package/esm/plugin/component/cashierApp.d.ts +6 -5
- package/esm/plugin/component/cashierApp.js +64 -48
- package/esm/plugin/component/{component.inline.style.d.ts → component.style.d.ts} +1 -4
- package/esm/plugin/component/component.style.js +15 -0
- package/esm/plugin/component/index.d.ts +33 -30
- package/esm/plugin/component/index.js +349 -248
- package/esm/plugin/drop-in/index.d.ts +5 -3
- package/esm/plugin/drop-in/index.js +3 -3
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +7 -8
- 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 +37 -96
- package/esm/types/index.js +52 -92
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +4 -6
- package/esm/util/index.js +5 -22
- package/esm/util/mock.js +2 -1
- package/package.json +1 -1
- package/esm/config/request.d.ts +0 -21
- package/esm/config/request.js +0 -67
- package/esm/image/skeleton.svg +0 -18
- package/esm/plugin/component/component.inline.style.js +0 -38
- package/esm/plugin/component/component.popup.style.d.ts +0 -12
- package/esm/plugin/component/component.popup.style.js +0 -163
@@ -2,6 +2,8 @@ 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; }
|
5
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6
8
|
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); } }
|
7
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
@@ -15,44 +17,62 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
17
|
* 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
18
|
*/
|
17
19
|
/* eslint-disable no-console */
|
18
|
-
import { COMPONENTPLUGINID,
|
20
|
+
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
19
21
|
import { queryPaymentInfo } from "../../service";
|
20
|
-
import {
|
21
|
-
import { getType, isJsonString, isPC } from "../../util";
|
22
|
+
import { componentNameEnum, messageName, Target } from "../../types";
|
23
|
+
import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
|
22
24
|
import { isLocalMock } from "../../util/mock";
|
23
25
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
24
|
-
import {
|
25
|
-
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
26
|
+
import { componentAddCSS } from "./component.style";
|
26
27
|
var _window = window,
|
27
28
|
innerHeight = _window.innerHeight;
|
29
|
+
var amsSetSize = function amsSetSize(event, dom) {
|
30
|
+
try {
|
31
|
+
var _dom = dom || document.getElementById('ams-component-container');
|
32
|
+
_dom.style.fontSize = "".concat(getDesignFontSize(), "px");
|
33
|
+
innerHeight = window.innerHeight;
|
34
|
+
// eslint-disable-next-line no-empty
|
35
|
+
} catch (error) {}
|
36
|
+
};
|
37
|
+
var addEvent = function addEvent() {
|
38
|
+
window.removeEventListener('resize', amsSetSize);
|
39
|
+
window.removeEventListener('pageShow', amsSetSize);
|
40
|
+
window.removeEventListener('DOMContentLoaded', amsSetSize);
|
41
|
+
window.addEventListener('resize', amsSetSize);
|
42
|
+
window.addEventListener('pageShow', amsSetSize);
|
43
|
+
window.addEventListener('DOMContentLoaded', amsSetSize);
|
44
|
+
};
|
45
|
+
var mockupId = 'ams-component-mockup';
|
46
|
+
var loadingId = 'ams-component-loading';
|
47
|
+
var listenerPrefix = '_ams_sdk_component_listener';
|
28
48
|
var ComponentApp = /*#__PURE__*/function () {
|
29
49
|
function ComponentApp() {
|
30
50
|
_classCallCheck(this, ComponentApp);
|
31
51
|
_defineProperty(this, "app", void 0);
|
52
|
+
_defineProperty(this, "appDomain", void 0);
|
32
53
|
_defineProperty(this, "AMSSDK", void 0);
|
33
54
|
_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);
|
38
55
|
_defineProperty(this, "createIframeNode", void 0);
|
39
56
|
_defineProperty(this, "_selector", void 0);
|
40
57
|
_defineProperty(this, "_appVersion", void 0);
|
41
58
|
_defineProperty(this, "_isRetention", void 0);
|
42
59
|
_defineProperty(this, "_actionQueryPromise", null);
|
43
60
|
_defineProperty(this, "_renderParams", null);
|
44
|
-
_defineProperty(this, "
|
61
|
+
_defineProperty(this, "_componentName", '');
|
62
|
+
_defineProperty(this, "_performanceData", []);
|
63
|
+
_defineProperty(this, "_isInitComponent", void 0);
|
45
64
|
_defineProperty(this, "_clickEventName", void 0);
|
46
|
-
|
47
|
-
this._appVersion = '1.5.0';
|
65
|
+
this._appVersion = '1.3.1';
|
48
66
|
this._isInitComponent = false;
|
49
|
-
this._selector =
|
67
|
+
this._selector = '#ams-component-section';
|
50
68
|
this.createIframeNode = function () {
|
51
69
|
return Promise.resolve();
|
52
70
|
};
|
53
|
-
this.platform = isPC() ?
|
54
|
-
this._clickEventName = this.platform ===
|
71
|
+
this.platform = isPC() ? 'desktop' : 'mobile';
|
72
|
+
this._clickEventName = this.platform === 'mobile' ? 'touchend' : 'click';
|
55
73
|
this._isRetention = true;
|
74
|
+
addEvent();
|
75
|
+
this.createMountElement();
|
56
76
|
this._performanceData.push({
|
57
77
|
key: 'sdk_init',
|
58
78
|
value: Date.now()
|
@@ -65,7 +85,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
65
85
|
_createClass(ComponentApp, [{
|
66
86
|
key: "logoutPlugin",
|
67
87
|
value: function logoutPlugin() {
|
68
|
-
this.
|
88
|
+
this.closeCashier();
|
69
89
|
}
|
70
90
|
|
71
91
|
/**
|
@@ -83,8 +103,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
83
103
|
*/
|
84
104
|
}, {
|
85
105
|
key: "setRender",
|
86
|
-
value: function setRender(
|
87
|
-
this.createIframeNode =
|
106
|
+
value: function setRender(createIframeNode) {
|
107
|
+
this.createIframeNode = createIframeNode;
|
88
108
|
}
|
89
109
|
|
90
110
|
/**
|
@@ -92,142 +112,89 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
92
112
|
*/
|
93
113
|
}, {
|
94
114
|
key: "appendIframeNodes",
|
95
|
-
value: function appendIframeNodes(
|
96
|
-
var
|
97
|
-
|
98
|
-
|
99
|
-
return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
100
|
-
}
|
115
|
+
value: function appendIframeNodes(componentName, renderParams) {
|
116
|
+
var _renderParams$appeara,
|
117
|
+
_this = this;
|
118
|
+
if (this._isInitComponent) return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
101
119
|
this._isInitComponent = true;
|
102
120
|
this._renderParams = renderParams;
|
103
|
-
this.
|
104
|
-
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
105
|
-
this._renderDisplayType = renderParams.renderDisplayType;
|
106
|
-
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
121
|
+
this._componentName = componentName;
|
107
122
|
this._performanceData.push({
|
108
123
|
key: 'sdk_create_component',
|
109
124
|
value: Date.now()
|
110
125
|
});
|
111
|
-
this.
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
createBaseElement(this.platform, this.closeBtnFunc.bind(this));
|
120
|
-
createRetentionPopup(this.platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
|
121
|
-
createMockup();
|
122
|
-
this.renderPopupLoading(renderParams);
|
126
|
+
this.createRetentionPopup();
|
127
|
+
this.createMockup();
|
128
|
+
if ((renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading) !== false) {
|
129
|
+
var mockup = document.getElementById(mockupId);
|
130
|
+
if (mockup) {
|
131
|
+
mockup.style.display = 'block';
|
132
|
+
}
|
133
|
+
this.showLoading();
|
123
134
|
}
|
135
|
+
this.showCashier();
|
124
136
|
this.createApp(renderParams);
|
125
|
-
|
126
|
-
|
127
|
-
|
137
|
+
this.createActionQueryPromise();
|
138
|
+
return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
|
139
|
+
selector: this._selector
|
140
|
+
})), this._actionQueryPromise]).catch(function () {
|
128
141
|
_this._isInitComponent = false;
|
129
|
-
_this.cleanContainer();
|
130
|
-
return Promise.reject(error);
|
131
|
-
});
|
132
|
-
}
|
133
|
-
}, {
|
134
|
-
key: "renderInlineLoading",
|
135
|
-
value: function renderInlineLoading(renderParams, selector) {
|
136
|
-
var _renderParams$appeara;
|
137
|
-
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
|
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
|
-
if (!showLoading) return;
|
148
|
-
var mockup = document.getElementById(MOCKUP_ID);
|
149
|
-
if (mockup) mockup.style.display = 'block';
|
150
|
-
addPopupLoading();
|
151
|
-
}
|
152
|
-
}, {
|
153
|
-
key: "_createLoadAppPromise",
|
154
|
-
value: function _createLoadAppPromise() {
|
155
|
-
var _this2 = this;
|
156
|
-
return new Promise(function (resolve, reject) {
|
157
|
-
_this2._loadAppPromiseResolve = resolve;
|
158
|
-
setTimeout(function () {
|
159
|
-
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
160
|
-
}, LOADTIME_LIMIT);
|
161
|
-
}).catch(function (error) {
|
162
|
-
_this2.dispatchToSDK(EVENT.error.name, {
|
163
|
-
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
|
164
|
-
message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
|
165
|
-
});
|
166
|
-
return Promise.reject(error);
|
167
142
|
});
|
168
143
|
}
|
169
|
-
|
170
144
|
/**
|
171
145
|
* @description Interface request
|
172
146
|
*/
|
173
147
|
}, {
|
174
148
|
key: "createActionQueryPromise",
|
175
149
|
value: function createActionQueryPromise() {
|
176
|
-
var
|
150
|
+
var _this2 = this;
|
177
151
|
this._performanceData.push({
|
178
152
|
key: 'sdk_action_query_start',
|
179
153
|
value: Date.now()
|
180
154
|
});
|
181
155
|
this._actionQueryPromise = new Promise(function (resolve, reject) {
|
182
|
-
var
|
156
|
+
var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
|
183
157
|
var params = {
|
184
|
-
paymentSessionData:
|
185
|
-
paymentSessionConfig: (
|
158
|
+
paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
|
159
|
+
paymentSessionConfig: (_this2$_renderParams2 = _this2._renderParams) === null || _this2$_renderParams2 === void 0 ? void 0 : (_this2$_renderParams3 = _this2$_renderParams2.paymentSessionMetaData) === null || _this2$_renderParams3 === void 0 ? void 0 : _this2$_renderParams3.paymentSessionConfig
|
186
160
|
};
|
187
|
-
|
188
|
-
* @description card
|
189
|
-
*/
|
190
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
|
161
|
+
if (componentNameEnum.card === _this2._componentName) {
|
191
162
|
params.paymentMethodType = 'CARD';
|
192
163
|
}
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
|
197
|
-
var _this3$_renderParams4;
|
164
|
+
if (componentNameEnum.easyPay === _this2._componentName) {
|
165
|
+
var _this2$_renderParams4;
|
166
|
+
// if EASY_PAY 2.0 , no need to query payment request
|
198
167
|
var _ref = params.paymentSessionConfig || {},
|
199
168
|
_ref$productSceneVers = _ref.productSceneVersion,
|
200
169
|
productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
|
201
170
|
_ref$productScene = _ref.productScene,
|
202
171
|
productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
|
203
|
-
var _ref2 = ((
|
172
|
+
var _ref2 = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : _this2$_renderParams4.paymentSessionMetaData) || {},
|
204
173
|
_ref2$action = _ref2.action,
|
205
174
|
_ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
|
206
175
|
_ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
|
207
176
|
autoDebitWithToken = _ref2$action2$autoDeb === void 0 ? false : _ref2$action2$autoDeb;
|
208
|
-
if (productScene ===
|
209
|
-
//
|
177
|
+
if (productScene === 'EASY_PAY' && productSceneVersion === '2.0' && !autoDebitWithToken) {
|
178
|
+
// make queryResult no data we setAppStateData in antom-web-checkout app,
|
179
|
+
// eslint-disable-next-line no-promise-executor-return
|
210
180
|
return resolve({
|
211
|
-
message: 'sdk no need to make query request'
|
212
|
-
success: true
|
181
|
+
message: 'sdk no need to make query request'
|
213
182
|
});
|
214
183
|
}
|
215
184
|
}
|
216
185
|
/**
|
217
186
|
* @author tianqiang
|
218
|
-
* @description
|
187
|
+
* @description 代扣逻辑处理
|
219
188
|
*/
|
220
|
-
if (
|
221
|
-
var
|
222
|
-
var action = ((
|
223
|
-
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;
|
189
|
+
if (componentNameEnum.autoDebit === _this2._componentName) {
|
190
|
+
var _this2$_renderParams5, _this2$_renderParams6, _action$web, _action$wap;
|
191
|
+
var action = ((_this2$_renderParams5 = _this2._renderParams) === null || _this2$_renderParams5 === void 0 ? void 0 : (_this2$_renderParams6 = _this2$_renderParams5.paymentSessionMetaData) === null || _this2$_renderParams6 === void 0 ? void 0 : _this2$_renderParams6.action) || {};
|
192
|
+
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) || '';
|
224
193
|
if (signType === 'SMS') {
|
225
194
|
return resolve({
|
226
|
-
message: 'sdk no need to make query request'
|
227
|
-
success: true
|
195
|
+
message: 'sdk no need to make query request'
|
228
196
|
});
|
229
|
-
}
|
230
|
-
if (!signType || signType !== 'REDIRECT') {
|
197
|
+
} else if (!signType || signType !== 'REDIRECT') {
|
231
198
|
return resolve({
|
232
199
|
success: false
|
233
200
|
});
|
@@ -237,15 +204,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
237
204
|
// mock
|
238
205
|
if (isLocalMock()) {
|
239
206
|
return resolve({
|
240
|
-
message: 'sdk no need to make query request'
|
241
|
-
success: true
|
207
|
+
message: 'sdk no need to make query request'
|
242
208
|
});
|
243
209
|
}
|
244
210
|
queryPaymentInfo(params, {
|
245
|
-
env:
|
246
|
-
locale:
|
211
|
+
env: _this2.AMSSDK.options.env.environment,
|
212
|
+
locale: _this2.AMSSDK.options.locale
|
247
213
|
}).then(function (res) {
|
248
|
-
|
214
|
+
_this2._performanceData.push({
|
249
215
|
key: 'sdk_action_query_end',
|
250
216
|
value: Date.now()
|
251
217
|
});
|
@@ -253,46 +219,26 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
253
219
|
resolve(res);
|
254
220
|
} else {
|
255
221
|
resolve(res);
|
222
|
+
_this2.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR);
|
256
223
|
}
|
257
224
|
}).catch(function (err) {
|
258
|
-
_this3.dispatchToSDK(EVENT.error.name, {
|
259
|
-
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
|
260
|
-
});
|
261
225
|
reject(err);
|
226
|
+
_this2.closeCashier();
|
262
227
|
});
|
263
228
|
});
|
264
|
-
return this._actionQueryPromise;
|
265
229
|
}
|
266
230
|
}, {
|
267
|
-
key: "
|
268
|
-
value: function
|
231
|
+
key: "cleanApp",
|
232
|
+
value: function cleanApp() {
|
269
233
|
try {
|
270
|
-
|
271
|
-
|
234
|
+
this.app = null;
|
235
|
+
this._removeEventListener();
|
272
236
|
if (getType(this._selector) === 'string') {
|
273
|
-
var
|
274
|
-
if (
|
237
|
+
var dorpinDom = document.querySelector(this._selector);
|
238
|
+
if (dorpinDom) dorpinDom.innerHTML = '';
|
275
239
|
}
|
276
|
-
|
277
|
-
|
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();
|
293
|
-
} catch (error) {
|
294
|
-
console.error(error);
|
295
|
-
}
|
240
|
+
// eslint-disable-next-line no-empty
|
241
|
+
} catch (error) {}
|
296
242
|
}
|
297
243
|
|
298
244
|
/**
|
@@ -317,13 +263,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
317
263
|
this.appDomain = getAppDomain({
|
318
264
|
environment: environment,
|
319
265
|
appVersion: this._appVersion,
|
320
|
-
|
266
|
+
componentName: this._componentName,
|
321
267
|
productSceneVersion: productSceneVersion,
|
322
268
|
extendInfo: extendInfo
|
323
269
|
});
|
324
|
-
this.app = createIframe(this.AMSSDK.options.mode
|
270
|
+
this.app = createIframe(this.AMSSDK.options.mode);
|
325
271
|
this.app.src = getIframeUrl({
|
326
|
-
|
272
|
+
componentName: this._componentName,
|
273
|
+
appearance: (renderParams === null || renderParams === void 0 ? void 0 : renderParams.appearance) || {},
|
327
274
|
analytics: this.AMSSDK.options.analytics,
|
328
275
|
productSceneVersion: productSceneVersion,
|
329
276
|
environment: environment,
|
@@ -334,7 +281,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
334
281
|
});
|
335
282
|
|
336
283
|
// Subscribe to messages from iframe
|
337
|
-
this.
|
284
|
+
this._addEventListener();
|
338
285
|
} catch (error) {
|
339
286
|
this.dispatchToSDK(EVENT.error.name, Object.assign({}, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.FAILED_TO_CREATE_IFRAME, {
|
340
287
|
stack: error
|
@@ -353,8 +300,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
353
300
|
if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
|
354
301
|
return;
|
355
302
|
}
|
356
|
-
// TODO
|
357
|
-
// 如果带有callback标识,则从map结构中取出callbackfunc,执行,执行后在map结构中删除
|
358
303
|
this._handleAppMessage(data);
|
359
304
|
} else {
|
360
305
|
console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
|
@@ -364,7 +309,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
364
309
|
}, {
|
365
310
|
key: "resizeListener",
|
366
311
|
value: function resizeListener() {
|
367
|
-
var cashier = document.getElementById(
|
312
|
+
var cashier = document.getElementById('ams-component-container');
|
368
313
|
cashier.style.transition = 'none';
|
369
314
|
this.dispatchToApp({
|
370
315
|
context: {
|
@@ -381,19 +326,19 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
381
326
|
* @description Initialize subscription iframe message
|
382
327
|
*/
|
383
328
|
}, {
|
384
|
-
key: "
|
385
|
-
value: function
|
386
|
-
this.
|
387
|
-
window["".concat(
|
388
|
-
|
389
|
-
window.addEventListener('message', window["".concat(
|
390
|
-
window.addEventListener('resize', window["".concat(
|
329
|
+
key: "_addEventListener",
|
330
|
+
value: function _addEventListener() {
|
331
|
+
window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
|
332
|
+
window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
|
333
|
+
this._removeEventListener();
|
334
|
+
window.addEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
|
335
|
+
window.addEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
391
336
|
}
|
392
337
|
}, {
|
393
|
-
key: "
|
394
|
-
value: function
|
395
|
-
window.removeEventListener('message', window["".concat(
|
396
|
-
window.removeEventListener('resize', window["".concat(
|
338
|
+
key: "_removeEventListener",
|
339
|
+
value: function _removeEventListener() {
|
340
|
+
window.removeEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
|
341
|
+
window.removeEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
397
342
|
}
|
398
343
|
|
399
344
|
/**
|
@@ -402,10 +347,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
402
347
|
}, {
|
403
348
|
key: "_handleAppMessage",
|
404
349
|
value: function _handleAppMessage(data) {
|
405
|
-
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.
|
406
|
-
if (!eventKeyMap.includes(data.context.event)) {
|
407
|
-
return;
|
408
|
-
}
|
350
|
+
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.onClose.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];
|
409
351
|
if (data.context.event === EVENT.dismissLoading.name) {
|
410
352
|
var _data$context$data;
|
411
353
|
this.dispatchToSDK(EVENT.eventCallback.name, {
|
@@ -414,19 +356,21 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
414
356
|
});
|
415
357
|
return;
|
416
358
|
}
|
359
|
+
if (!eventKeyMap.includes(data.context.event)) {
|
360
|
+
return;
|
361
|
+
}
|
417
362
|
if (data.context.event === EVENT.launch.name) {
|
418
363
|
this._performanceData.push({
|
419
364
|
key: 'sdk_onLaunch',
|
420
365
|
value: Date.now()
|
421
366
|
});
|
422
|
-
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
423
367
|
this.sendRenderEvent();
|
424
368
|
return;
|
425
369
|
}
|
426
370
|
if (data.context.event === EVENT.sizeChanged.name) {
|
427
371
|
this.handleSizeChanged(data);
|
428
372
|
}
|
429
|
-
if (data.context.event === EVENT.
|
373
|
+
if (data.context.event === EVENT.onClose.name) {
|
430
374
|
return this.closeBtnFunc();
|
431
375
|
}
|
432
376
|
if (data.context.event === EVENT.redirect.name) {
|
@@ -461,29 +405,29 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
461
405
|
key: "handleSizeChanged",
|
462
406
|
value: function handleSizeChanged(data) {
|
463
407
|
var _data$context$data2;
|
464
|
-
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height)
|
465
|
-
|
466
|
-
|
467
|
-
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
468
|
-
var _document$getElementB2;
|
469
|
-
var mockup = document.getElementById(MOCKUP_ID);
|
408
|
+
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) > 1) {
|
409
|
+
var _document$getElementB;
|
410
|
+
var mockup = document.getElementById(mockupId);
|
470
411
|
if (mockup) {
|
471
|
-
mockup.style.background = '
|
412
|
+
mockup.style.background = '#000000';
|
413
|
+
mockup.style.opacity = '0.6';
|
472
414
|
mockup.style.display = 'block';
|
473
415
|
}
|
474
|
-
(_document$
|
416
|
+
(_document$getElementB = document.getElementById(loadingId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
|
417
|
+
var cashier = document.getElementById('ams-component-container');
|
418
|
+
cashier.style.height = "".concat(data.context.data.height, "px");
|
475
419
|
if (this.platform === 'desktop') {
|
476
|
-
cashier.classList.add(
|
420
|
+
cashier.classList.add('ams-component-container-desktop-animation');
|
477
421
|
if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
|
478
422
|
}
|
479
423
|
if (this.platform === 'mobile') {
|
480
|
-
cashier.classList.add(
|
481
|
-
var animationStyleId =
|
424
|
+
cashier.classList.add('ams-component-container-mobile-animation');
|
425
|
+
var animationStyleId = 'ams-component-container-mobile-animation-style';
|
482
426
|
var animationStyle = document.getElementById(animationStyleId);
|
483
427
|
if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
|
484
428
|
|
485
429
|
// 弹出和弹入动画
|
486
|
-
var runkeyframes = "@keyframes
|
430
|
+
var runkeyframes = " @keyframes ams-component-container-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ".concat(data.context.data.height, "px;\n }\n }\n @keyframes ams-component-container-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 }");
|
487
431
|
// 创建style标签
|
488
432
|
var style = document.createElement('style');
|
489
433
|
style.id = animationStyleId;
|
@@ -499,18 +443,17 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
499
443
|
cashier.style.transition = 'height 0.28s ease-in-out';
|
500
444
|
}, 500);
|
501
445
|
}
|
446
|
+
this.app.style.height = "".concat(data.context.data.height, "px");
|
447
|
+
this.app.style.width = '100%';
|
448
|
+
this.app.style.border = '0';
|
449
|
+
this.app.style.overflow = 'hidden';
|
502
450
|
}
|
503
|
-
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
504
|
-
var _document$getElementB3;
|
505
|
-
(_document$getElementB3 = document.getElementById(LOADING_ID)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
|
506
|
-
}
|
507
|
-
this.app.style.height = "".concat(data.context.data.height, "px");
|
508
|
-
this.app.style.opacity = '1';
|
509
451
|
}
|
510
452
|
}, {
|
511
453
|
key: "handleRedirect",
|
512
454
|
value: function handleRedirect(data) {
|
513
|
-
var
|
455
|
+
var _this3 = this;
|
456
|
+
this.closeCashier();
|
514
457
|
var _data = typeof data === 'string' ? {
|
515
458
|
normalUrl: data
|
516
459
|
} : {
|
@@ -520,38 +463,37 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
520
463
|
target: data === null || data === void 0 ? void 0 : data.target
|
521
464
|
};
|
522
465
|
var successCallback = function successCallback(type, url) {
|
523
|
-
|
524
|
-
code:
|
466
|
+
_this3.dispatchToSDK(EVENT.eventCallback.name, {
|
467
|
+
code: 'SDK_CALL_URL_SUCCESS',
|
525
468
|
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
526
469
|
});
|
527
470
|
};
|
528
471
|
var failCallback = function failCallback() {
|
529
|
-
|
530
|
-
code:
|
472
|
+
_this3.dispatchToSDK(EVENT.eventCallback.name, {
|
473
|
+
code: 'SDK_CALL_URL_ERROR',
|
531
474
|
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)
|
532
475
|
});
|
533
476
|
};
|
534
477
|
|
535
478
|
// 支持 target: _blank,新开tab页打开
|
536
|
-
if (_data.target ===
|
479
|
+
if (_data.target === Target.BLANK) {
|
537
480
|
if (!_data.normalUrl) return failCallback();
|
538
481
|
successCallback('normalUrl', _data.normalUrl);
|
539
482
|
window.open(_data.normalUrl);
|
540
483
|
return;
|
541
484
|
}
|
542
|
-
this.cleanContainer();
|
543
485
|
this.AMSSDK._redirect({
|
544
486
|
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
|
545
487
|
}).then(function () {
|
546
488
|
successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
547
489
|
}).catch(function () {
|
548
|
-
return
|
490
|
+
return _this3.AMSSDK._redirect({
|
549
491
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
550
492
|
});
|
551
493
|
}).then(function () {
|
552
494
|
successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
553
495
|
}).catch(function () {
|
554
|
-
return
|
496
|
+
return _this3.AMSSDK._redirect({
|
555
497
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
556
498
|
});
|
557
499
|
}).then(function () {
|
@@ -565,18 +507,59 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
565
507
|
value: function handleDeclareInfo(_ref3) {
|
566
508
|
var _ref3$closeDialogData = _ref3.closeDialogData,
|
567
509
|
closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
|
568
|
-
|
569
|
-
closeDialogData
|
570
|
-
|
510
|
+
try {
|
511
|
+
if (closeDialogData) {
|
512
|
+
var retentionTitle = document.getElementById('ams-component-retention-title');
|
513
|
+
if (retentionTitle) {
|
514
|
+
var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
|
515
|
+
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");
|
516
|
+
retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
|
517
|
+
retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
|
518
|
+
}
|
519
|
+
var retentionMessage = document.getElementById('ams-component-retention-sub-title');
|
520
|
+
if (retentionMessage) {
|
521
|
+
var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
|
522
|
+
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");
|
523
|
+
retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
|
524
|
+
retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
|
525
|
+
}
|
526
|
+
var remainBtn = document.getElementById('ams-component-retention-remain');
|
527
|
+
if (remainBtn) {
|
528
|
+
var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
|
529
|
+
remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
|
530
|
+
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");
|
531
|
+
remainBtn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO3 = closeDialogData.btnOK) === null || _closeDialogData$btnO3 === void 0 ? void 0 : _closeDialogData$btnO3.fontColor;
|
532
|
+
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");
|
533
|
+
if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO5 = closeDialogData.btnOK) === null || _closeDialogData$btnO5 === void 0 ? void 0 : _closeDialogData$btnO5.type) === 'stroke') {
|
534
|
+
var _closeDialogData$btnO6;
|
535
|
+
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);
|
536
|
+
} 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;
|
537
|
+
}
|
538
|
+
var leaveBrn = document.getElementById('ams-component-retention-leave');
|
539
|
+
if (leaveBrn) {
|
540
|
+
var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
|
541
|
+
leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
|
542
|
+
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");
|
543
|
+
leaveBrn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC3 = closeDialogData.btnCancel) === null || _closeDialogData$btnC3 === void 0 ? void 0 : _closeDialogData$btnC3.fontColor;
|
544
|
+
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");
|
545
|
+
if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC5 = closeDialogData.btnCancel) === null || _closeDialogData$btnC5 === void 0 ? void 0 : _closeDialogData$btnC5.type) === 'stroke') {
|
546
|
+
var _closeDialogData$btnC6;
|
547
|
+
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);
|
548
|
+
} 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;
|
549
|
+
}
|
550
|
+
}
|
551
|
+
} catch (error) {
|
552
|
+
console.error(error);
|
553
|
+
}
|
571
554
|
}
|
572
555
|
}, {
|
573
556
|
key: "handleCloseBtnShow",
|
574
557
|
value: function handleCloseBtnShow(showClose) {
|
575
|
-
var closeBlock = document.getElementById(
|
558
|
+
var closeBlock = document.getElementById('asm-component-section-close-block');
|
576
559
|
if (showClose) {
|
577
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove(
|
560
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove('asm-component-close-block-hidden');
|
578
561
|
} else if (showClose === false) {
|
579
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add(
|
562
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add('asm-component-close-block-hidden');
|
580
563
|
}
|
581
564
|
}
|
582
565
|
|
@@ -586,7 +569,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
586
569
|
}, {
|
587
570
|
key: "dispatchToSDK",
|
588
571
|
value: function dispatchToSDK(event, data) {
|
589
|
-
this.AMSSDK.
|
572
|
+
this.AMSSDK.eventCenter.emit(event, data);
|
590
573
|
}
|
591
574
|
|
592
575
|
/**
|
@@ -601,11 +584,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
601
584
|
appId: COMPONENTPLUGINID,
|
602
585
|
instanceId: this.AMSSDK._instanceId
|
603
586
|
});
|
604
|
-
// TODO 如果存在回调函数,则增加callBack标识,并存入map。map可以设置
|
605
587
|
if (this.app && this.app.contentWindow) {
|
606
|
-
|
588
|
+
this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
607
589
|
}
|
608
|
-
throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
|
609
590
|
}
|
610
591
|
|
611
592
|
/**
|
@@ -618,7 +599,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
618
599
|
for (var key in eventKeyMap) {
|
619
600
|
// eslint-disable-next-line no-prototype-builtins
|
620
601
|
if (eventKeyMap.hasOwnProperty(key)) {
|
621
|
-
this.AMSSDK.
|
602
|
+
this.AMSSDK.eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
|
622
603
|
}
|
623
604
|
}
|
624
605
|
}
|
@@ -630,7 +611,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
630
611
|
key: "sendRenderEvent",
|
631
612
|
value: function () {
|
632
613
|
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
633
|
-
var _this$_renderParams, _this$_renderParams2,
|
614
|
+
var _this$_renderParams, _this$_renderParams2, res;
|
634
615
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
635
616
|
while (1) switch (_context.prev = _context.next) {
|
636
617
|
case 0:
|
@@ -657,8 +638,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
657
638
|
sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
|
658
639
|
paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
|
659
640
|
heightOfVisible: Math.max(innerHeight, window.innerHeight),
|
660
|
-
renderDisplayType: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.renderDisplayType,
|
661
|
-
appearance: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.appearance,
|
662
641
|
envInfo: {
|
663
642
|
screenHeight: screen.height,
|
664
643
|
screenWidth: screen.width
|
@@ -691,39 +670,68 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
691
670
|
}
|
692
671
|
return sendRenderEvent;
|
693
672
|
}()
|
673
|
+
}, {
|
674
|
+
key: "showLoading",
|
675
|
+
value: function showLoading() {
|
676
|
+
var loading = document.createElement('div');
|
677
|
+
loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
|
678
|
+
loading.id = loadingId;
|
679
|
+
loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
|
680
|
+
loading.style.fontSize = "".concat(getDesignFontSize(), "px");
|
681
|
+
var body = document.getElementsByTagName('body')[0];
|
682
|
+
body === null || body === void 0 ? void 0 : body.appendChild(loading);
|
683
|
+
}
|
684
|
+
|
685
|
+
/**
|
686
|
+
* @description show cashier
|
687
|
+
*/
|
688
|
+
}, {
|
689
|
+
key: "showCashier",
|
690
|
+
value: function showCashier() {
|
691
|
+
var cashier = document.getElementById('ams-component-container');
|
692
|
+
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("ams-component-container-hidden-".concat(this.platform));
|
693
|
+
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("ams-component-container-".concat(this.platform));
|
694
|
+
}
|
695
|
+
|
694
696
|
/**
|
695
697
|
* @description close cashier
|
696
698
|
*/
|
697
699
|
}, {
|
698
|
-
key: "
|
699
|
-
value: function
|
700
|
-
var _document$
|
701
|
-
_this5 = this;
|
700
|
+
key: "closeCashier",
|
701
|
+
value: function closeCashier() {
|
702
|
+
var _document$getElementB2;
|
702
703
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
703
|
-
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
704
704
|
this._performanceData = [];
|
705
705
|
this._isInitComponent = false;
|
706
|
-
|
707
|
-
|
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
|
-
}
|
706
|
+
(_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
|
707
|
+
this.hideComponentAndCleanDom(immediately);
|
716
708
|
}
|
717
709
|
}, {
|
718
|
-
key: "
|
719
|
-
value: function
|
720
|
-
var
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
710
|
+
key: "hideComponentAndCleanDom",
|
711
|
+
value: function hideComponentAndCleanDom() {
|
712
|
+
var _this4 = this;
|
713
|
+
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
714
|
+
var container = document.getElementById('ams-component-container');
|
715
|
+
// size变化动画取消
|
716
|
+
container.style.transition = '';
|
717
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform));
|
718
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform, "-animation"));
|
719
|
+
container === null || container === void 0 ? void 0 : container.classList.add("ams-component-container-hidden-".concat(this.platform));
|
720
|
+
var removeMockupAndApp = function removeMockupAndApp() {
|
721
|
+
var _document$getElementB3;
|
722
|
+
var body = document.getElementsByTagName('body')[0];
|
723
|
+
body.style.overflow = 'auto';
|
724
|
+
var mockup = document.getElementById(mockupId);
|
725
|
+
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
726
|
+
if (container) container.style.height = '';
|
727
|
+
(_document$getElementB3 = document.getElementById('ams-component-container-mobile-animation-style')) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
|
728
|
+
_this4.removeRetentionPopup();
|
729
|
+
_this4.cleanApp();
|
730
|
+
};
|
731
|
+
if (immediately) removeMockupAndApp();else {
|
732
|
+
setTimeout(function () {
|
733
|
+
removeMockupAndApp();
|
734
|
+
}, 300);
|
727
735
|
}
|
728
736
|
}
|
729
737
|
}, {
|
@@ -731,37 +739,129 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
731
739
|
value: function closeBtnFunc() {
|
732
740
|
// element && element.removeEventListener()
|
733
741
|
if (this._isRetention) this.showRetentionPopup();else {
|
734
|
-
this.
|
735
|
-
this.dispatchToSDK(EVENT.
|
742
|
+
this.closeCashier();
|
743
|
+
this.dispatchToSDK(EVENT.onClose.name, {});
|
744
|
+
}
|
745
|
+
}
|
746
|
+
|
747
|
+
/**
|
748
|
+
* @description create mount node
|
749
|
+
*/
|
750
|
+
}, {
|
751
|
+
key: "createMountElement",
|
752
|
+
value: function createMountElement() {
|
753
|
+
componentAddCSS();
|
754
|
+
var amsComponentContainer = document.createElement('div');
|
755
|
+
amsComponentContainer.className = "ams-component-container-hidden-".concat(this.platform);
|
756
|
+
amsComponentContainer.id = 'ams-component-container';
|
757
|
+
amsSetSize(null, amsComponentContainer);
|
758
|
+
document.body.appendChild(amsComponentContainer);
|
759
|
+
var amsComponentSection = document.createElement('div');
|
760
|
+
amsComponentSection.className = "ams-component-section-".concat(this.platform);
|
761
|
+
amsComponentSection.id = this._selector.slice(1);
|
762
|
+
amsComponentContainer.appendChild(amsComponentSection);
|
763
|
+
this.createCloseBtn();
|
764
|
+
}
|
765
|
+
}, {
|
766
|
+
key: "createCloseBtn",
|
767
|
+
value: function createCloseBtn() {
|
768
|
+
var _this5 = this;
|
769
|
+
var container = document.getElementById('ams-component-container');
|
770
|
+
// close btn
|
771
|
+
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg\"/>");
|
772
|
+
var closeBlock = document.createElement('div');
|
773
|
+
closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
|
774
|
+
closeBlock.id = 'asm-component-section-close-block';
|
775
|
+
closeBlock.innerHTML = closeBtnHTML;
|
776
|
+
closeBlock.addEventListener(this._clickEventName, function () {
|
777
|
+
_this5.closeBtnFunc();
|
778
|
+
});
|
779
|
+
if (container) container.appendChild(closeBlock);
|
780
|
+
}
|
781
|
+
}, {
|
782
|
+
key: "createRetentionPopup",
|
783
|
+
value: function createRetentionPopup() {
|
784
|
+
// retention popup
|
785
|
+
var retentionPopup = document.createElement('div');
|
786
|
+
retentionPopup.id = 'ams-component-retention';
|
787
|
+
retentionPopup.classList.add("ams-component-retention-".concat(this.platform));
|
788
|
+
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>");
|
789
|
+
document.body.appendChild(retentionPopup);
|
790
|
+
var remainBtn = document.getElementById('ams-component-retention-remain');
|
791
|
+
if (remainBtn) {
|
792
|
+
remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
|
793
|
+
}
|
794
|
+
var leaveBtn = document.getElementById('ams-component-retention-leave');
|
795
|
+
if (leaveBtn) {
|
796
|
+
leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
|
736
797
|
}
|
737
798
|
}
|
738
799
|
}, {
|
739
800
|
key: "retentionPopupLeaveFunc",
|
740
801
|
value: function retentionPopupLeaveFunc() {
|
741
|
-
this.dispatchToSDK(EVENT.
|
742
|
-
this.
|
743
|
-
this.
|
802
|
+
this.dispatchToSDK(EVENT.onClose.name, {});
|
803
|
+
this.hideRetentionPopup();
|
804
|
+
this.closeCashier();
|
744
805
|
}
|
745
806
|
}, {
|
746
807
|
key: "removeRetentionPopup",
|
747
|
-
value: function removeRetentionPopup(
|
748
|
-
|
808
|
+
value: function removeRetentionPopup() {
|
809
|
+
var _document$getElementB4;
|
810
|
+
var remainBtn = document.getElementById('ams-component-retention-remain');
|
811
|
+
if (remainBtn) {
|
812
|
+
remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
|
813
|
+
}
|
814
|
+
var leaveBtn = document.getElementById('ams-component-retention-leave');
|
815
|
+
if (leaveBtn) {
|
816
|
+
leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
|
817
|
+
}
|
818
|
+
(_document$getElementB4 = document.getElementById('ams-component-retention')) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
749
819
|
}
|
750
820
|
}, {
|
751
821
|
key: "showRetentionPopup",
|
752
822
|
value: function showRetentionPopup() {
|
753
|
-
var retentionPopup = document.getElementById(
|
754
|
-
var container = document.getElementById(
|
823
|
+
var retentionPopup = document.getElementById('ams-component-retention');
|
824
|
+
var container = document.getElementById('ams-component-container');
|
755
825
|
if (retentionPopup) {
|
756
|
-
container === null || container === void 0 ? void 0 : container.classList.add(
|
757
|
-
retentionPopup.classList.remove(
|
758
|
-
retentionPopup.classList.add(
|
826
|
+
container === null || container === void 0 ? void 0 : container.classList.add('ams-component-container-opacity');
|
827
|
+
retentionPopup.classList.remove('ams-component-retention-hidden');
|
828
|
+
retentionPopup.classList.add('ams-component-retention-show');
|
759
829
|
}
|
760
830
|
}
|
761
831
|
}, {
|
762
|
-
key: "
|
763
|
-
value: function
|
764
|
-
|
832
|
+
key: "hideRetentionPopup",
|
833
|
+
value: function hideRetentionPopup() {
|
834
|
+
var retentionPopup = document.getElementById('ams-component-retention');
|
835
|
+
var container = document.getElementById('ams-component-container');
|
836
|
+
if (retentionPopup) {
|
837
|
+
retentionPopup.classList.remove('ams-component-retention-show');
|
838
|
+
retentionPopup.classList.add('ams-component-retention-hidden');
|
839
|
+
setTimeout(function () {
|
840
|
+
retentionPopup.classList.remove('ams-component-retention-hidden');
|
841
|
+
container === null || container === void 0 ? void 0 : container.classList.remove('ams-component-container-opacity');
|
842
|
+
}, 250);
|
843
|
+
}
|
844
|
+
}
|
845
|
+
/**
|
846
|
+
* @description create mockup
|
847
|
+
*/
|
848
|
+
}, {
|
849
|
+
key: "createMockup",
|
850
|
+
value: function createMockup() {
|
851
|
+
var body = document.getElementsByTagName('body')[0];
|
852
|
+
body.style.overflow = 'hidden';
|
853
|
+
var mockup = document.createElement('div');
|
854
|
+
mockup.style.width = '100vw';
|
855
|
+
mockup.style.height = '100vh';
|
856
|
+
mockup.style.position = 'fixed';
|
857
|
+
mockup.style.top = '0';
|
858
|
+
mockup.style.left = '0';
|
859
|
+
mockup.style.zIndex = '1000';
|
860
|
+
mockup.style.background = '#ffffff';
|
861
|
+
mockup.style.opacity = '0.5';
|
862
|
+
mockup.style.display = 'none';
|
863
|
+
mockup.id = mockupId;
|
864
|
+
body.appendChild(mockup);
|
765
865
|
}
|
766
866
|
}, {
|
767
867
|
key: "submitForm",
|
@@ -782,6 +882,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
782
882
|
form.setAttribute('action', attributes.action);
|
783
883
|
form.setAttribute('method', 'post');
|
784
884
|
body.appendChild(form);
|
885
|
+
this.closeCashier(true);
|
785
886
|
setTimeout(function () {
|
786
887
|
form.submit();
|
787
888
|
}, 0);
|