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