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