@alipay/ams-checkout 0.0.1691379784-dev.6 → 0.0.1691743027-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/constant/index.d.ts +40 -32
- package/esm/constant/index.js +40 -32
- package/esm/core/component/index.d.ts +22 -9
- package/esm/core/component/index.js +148 -43
- package/esm/core/drop-in/index.d.ts +1 -1
- 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 +15 -15
- package/esm/plugin/component/component.style.d.ts +4 -1
- package/esm/plugin/component/component.style.js +32 -4
- package/esm/plugin/component/index.d.ts +16 -9
- package/esm/plugin/component/index.js +213 -157
- package/esm/plugin/drop-in/index.js +1 -1
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +3 -3
- package/esm/request/utils.d.ts +3 -3
- package/esm/request/utils.js +4 -4
- package/esm/service/index.d.ts +2 -2
- package/esm/types/index.d.ts +61 -34
- package/esm/types/index.js +73 -47
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +6 -4
- package/esm/util/index.js +22 -5
- package/esm/util/mock.js +1 -2
- package/package.json +1 -1
@@ -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; }
|
@@ -19,32 +17,22 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
19
17
|
/* eslint-disable no-console */
|
20
18
|
import { closeImg, COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
21
19
|
import { queryPaymentInfo } from "../../service";
|
22
|
-
import { componentSignEnum, messageName, productSceneEnum,
|
23
|
-
import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
|
20
|
+
import { componentSignEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
|
21
|
+
import { addSetFontSizeEvent, amsSetSize, getDesignFontSize, getType, isJsonString, isPC } from "../../util";
|
24
22
|
import { isLocalMock } from "../../util/mock";
|
25
23
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
26
|
-
import { componentAddCSS } from "./component.style";
|
24
|
+
import { componentAddCSS, inlineComponentAddCss, showInlineLoading } from "./component.style";
|
27
25
|
var _window = window,
|
28
26
|
innerHeight = _window.innerHeight;
|
29
|
-
var
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
innerHeight = window.innerHeight;
|
34
|
-
// eslint-disable-next-line no-empty
|
35
|
-
} catch (error) {}
|
36
|
-
};
|
37
|
-
var addEvent = function addEvent() {
|
38
|
-
window.removeEventListener('resize', amsSetSize);
|
39
|
-
window.removeEventListener('pageShow', amsSetSize);
|
40
|
-
window.removeEventListener('DOMContentLoaded', amsSetSize);
|
41
|
-
window.addEventListener('resize', amsSetSize);
|
42
|
-
window.addEventListener('pageShow', amsSetSize);
|
43
|
-
window.addEventListener('DOMContentLoaded', amsSetSize);
|
44
|
-
};
|
27
|
+
var componentContainerId = 'ams-component-container';
|
28
|
+
var componentSectionId = 'ams-component-section';
|
29
|
+
var componentCloseBlockId = 'asm-component-close-block';
|
30
|
+
var componentRetentionId = 'ams-component-retention';
|
45
31
|
var mockupId = 'ams-component-mockup';
|
46
32
|
var loadingId = 'ams-component-loading';
|
47
33
|
var listenerPrefix = '_ams_sdk_component_listener';
|
34
|
+
var inlineBaseStyleId = 'ams-inline-component-style';
|
35
|
+
var loadTimeLimit = 15000;
|
48
36
|
var ComponentApp = /*#__PURE__*/function () {
|
49
37
|
function ComponentApp() {
|
50
38
|
_classCallCheck(this, ComponentApp);
|
@@ -57,22 +45,22 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
57
45
|
_defineProperty(this, "_appVersion", void 0);
|
58
46
|
_defineProperty(this, "_isRetention", void 0);
|
59
47
|
_defineProperty(this, "_actionQueryPromise", null);
|
48
|
+
_defineProperty(this, "_loadAppPromiseResolve", null);
|
60
49
|
_defineProperty(this, "_renderParams", null);
|
61
50
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
62
51
|
_defineProperty(this, "_performanceData", []);
|
63
52
|
_defineProperty(this, "_isInitComponent", void 0);
|
64
53
|
_defineProperty(this, "_clickEventName", void 0);
|
65
|
-
this
|
54
|
+
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
55
|
+
this._appVersion = '1.5.0';
|
66
56
|
this._isInitComponent = false;
|
67
|
-
this._selector =
|
57
|
+
this._selector = "#".concat(componentSectionId);
|
68
58
|
this.createIframeNode = function () {
|
69
59
|
return Promise.resolve();
|
70
60
|
};
|
71
|
-
this.platform = isPC() ?
|
72
|
-
this._clickEventName = this.platform ===
|
61
|
+
this.platform = isPC() ? platformEnum.desktop : platformEnum.mobile;
|
62
|
+
this._clickEventName = this.platform === platformEnum.mobile ? 'touchend' : 'click';
|
73
63
|
this._isRetention = true;
|
74
|
-
addEvent();
|
75
|
-
this.createMountElement();
|
76
64
|
this._performanceData.push({
|
77
65
|
key: 'sdk_init',
|
78
66
|
value: Date.now()
|
@@ -85,7 +73,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
85
73
|
_createClass(ComponentApp, [{
|
86
74
|
key: "logoutPlugin",
|
87
75
|
value: function logoutPlugin() {
|
88
|
-
this.
|
76
|
+
this.cleanContainer(true);
|
89
77
|
}
|
90
78
|
|
91
79
|
/**
|
@@ -103,8 +91,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
103
91
|
*/
|
104
92
|
}, {
|
105
93
|
key: "setRender",
|
106
|
-
value: function setRender(
|
107
|
-
this.createIframeNode =
|
94
|
+
value: function setRender(renderFunc) {
|
95
|
+
this.createIframeNode = renderFunc;
|
108
96
|
}
|
109
97
|
|
110
98
|
/**
|
@@ -113,68 +101,103 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
113
101
|
}, {
|
114
102
|
key: "appendIframeNodes",
|
115
103
|
value: function appendIframeNodes(componentSign, renderParams) {
|
116
|
-
var
|
117
|
-
|
118
|
-
|
104
|
+
var _this = this;
|
105
|
+
if (this._isInitComponent) {
|
106
|
+
this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
107
|
+
return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
108
|
+
}
|
119
109
|
this._isInitComponent = true;
|
120
110
|
this._renderParams = renderParams;
|
121
111
|
this._componentSign = componentSign;
|
112
|
+
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
113
|
+
this._renderDisplayType = renderParams.renderDisplayType;
|
114
|
+
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(componentContainerId) : this._selector;
|
122
115
|
this._performanceData.push({
|
123
116
|
key: 'sdk_create_component',
|
124
117
|
value: Date.now()
|
125
118
|
});
|
126
|
-
this.
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
this.
|
119
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
120
|
+
this.createInlineBaseElement(renderParams);
|
121
|
+
}
|
122
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
123
|
+
this.createBaseElement();
|
124
|
+
this.setContainerClass();
|
125
|
+
this.createRetentionPopup();
|
126
|
+
this.createMockup();
|
127
|
+
this.renderPopupLoading(renderParams);
|
134
128
|
}
|
135
|
-
this.showCashier();
|
136
129
|
this.createApp(renderParams);
|
137
|
-
this.createActionQueryPromise()
|
138
|
-
return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
|
139
|
-
selector: this._selector
|
140
|
-
})), this._actionQueryPromise]).catch(function () {
|
130
|
+
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this.createLoadAppPromise()]).catch(function (error) {
|
141
131
|
_this._isInitComponent = false;
|
132
|
+
_this.cleanContainer();
|
133
|
+
return Promise.reject(error);
|
142
134
|
});
|
143
135
|
}
|
136
|
+
}, {
|
137
|
+
key: "renderPopupLoading",
|
138
|
+
value: function renderPopupLoading(renderParams) {
|
139
|
+
var _renderParams$appeara;
|
140
|
+
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
|
141
|
+
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
142
|
+
if (!showLoading) return;
|
143
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
144
|
+
var mockup = document.getElementById(mockupId);
|
145
|
+
if (mockup) mockup.style.display = 'block';
|
146
|
+
return this.showPopupLoading();
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}, {
|
150
|
+
key: "createLoadAppPromise",
|
151
|
+
value: function createLoadAppPromise() {
|
152
|
+
var _this2 = this;
|
153
|
+
return new Promise(function (resolve, reject) {
|
154
|
+
_this2._loadAppPromiseResolve = resolve;
|
155
|
+
setTimeout(function () {
|
156
|
+
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
157
|
+
}, loadTimeLimit);
|
158
|
+
}).catch(function (error) {
|
159
|
+
_this2.dispatchToSDK(EVENT.error.name, {
|
160
|
+
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
|
161
|
+
message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
|
162
|
+
});
|
163
|
+
return Promise.reject(error);
|
164
|
+
});
|
165
|
+
}
|
166
|
+
|
144
167
|
/**
|
145
168
|
* @description Interface request
|
146
169
|
*/
|
147
170
|
}, {
|
148
171
|
key: "createActionQueryPromise",
|
149
172
|
value: function createActionQueryPromise() {
|
150
|
-
var
|
173
|
+
var _this3 = this;
|
151
174
|
this._performanceData.push({
|
152
175
|
key: 'sdk_action_query_start',
|
153
176
|
value: Date.now()
|
154
177
|
});
|
155
178
|
this._actionQueryPromise = new Promise(function (resolve, reject) {
|
156
|
-
var
|
179
|
+
var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
|
157
180
|
var params = {
|
158
|
-
paymentSessionData:
|
159
|
-
paymentSessionConfig: (
|
181
|
+
paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.paymentSessionData) || '',
|
182
|
+
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
|
160
183
|
};
|
161
184
|
/**
|
162
185
|
* @description card
|
163
186
|
*/
|
164
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD ===
|
187
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
|
165
188
|
params.paymentMethodType = 'CARD';
|
166
189
|
}
|
167
190
|
/**
|
168
191
|
* @description easyPay
|
169
192
|
*/
|
170
|
-
if (componentSignEnum.EASY_PAY_WALLET ===
|
171
|
-
var
|
193
|
+
if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
|
194
|
+
var _this3$_renderParams4;
|
172
195
|
var _ref = params.paymentSessionConfig || {},
|
173
196
|
_ref$productSceneVers = _ref.productSceneVersion,
|
174
197
|
productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
|
175
198
|
_ref$productScene = _ref.productScene,
|
176
199
|
productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
|
177
|
-
var _ref2 = ((
|
200
|
+
var _ref2 = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.paymentSessionMetaData) || {},
|
178
201
|
_ref2$action = _ref2.action,
|
179
202
|
_ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
|
180
203
|
_ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
|
@@ -191,9 +214,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
191
214
|
* @author tianqiang
|
192
215
|
* @description autoDebit
|
193
216
|
*/
|
194
|
-
if (componentSignEnum.AUTO_DEBIT_WALLET ===
|
195
|
-
var
|
196
|
-
var action = ((
|
217
|
+
if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
|
218
|
+
var _this3$_renderParams5, _this3$_renderParams6, _action$web, _action$wap;
|
219
|
+
var action = ((_this3$_renderParams5 = _this3._renderParams) === null || _this3$_renderParams5 === void 0 ? void 0 : (_this3$_renderParams6 = _this3$_renderParams5.paymentSessionMetaData) === null || _this3$_renderParams6 === void 0 ? void 0 : _this3$_renderParams6.action) || {};
|
197
220
|
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;
|
198
221
|
if (signType === 'SMS') {
|
199
222
|
return resolve({
|
@@ -216,10 +239,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
216
239
|
});
|
217
240
|
}
|
218
241
|
queryPaymentInfo(params, {
|
219
|
-
env:
|
220
|
-
locale:
|
242
|
+
env: _this3.AMSSDK.options.env.environment,
|
243
|
+
locale: _this3.AMSSDK.options.locale
|
221
244
|
}).then(function (res) {
|
222
|
-
|
245
|
+
_this3._performanceData.push({
|
223
246
|
key: 'sdk_action_query_end',
|
224
247
|
value: Date.now()
|
225
248
|
});
|
@@ -227,13 +250,15 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
227
250
|
resolve(res);
|
228
251
|
} else {
|
229
252
|
resolve(res);
|
230
|
-
_this2.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR);
|
231
253
|
}
|
232
254
|
}).catch(function (err) {
|
255
|
+
_this3.dispatchToSDK(EVENT.error.name, {
|
256
|
+
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
|
257
|
+
});
|
233
258
|
reject(err);
|
234
|
-
_this2.closeCashier();
|
235
259
|
});
|
236
260
|
});
|
261
|
+
return this._actionQueryPromise;
|
237
262
|
}
|
238
263
|
}, {
|
239
264
|
key: "cleanApp",
|
@@ -242,11 +267,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
242
267
|
this.app = null;
|
243
268
|
this._removeEventListener();
|
244
269
|
if (getType(this._selector) === 'string') {
|
245
|
-
var
|
246
|
-
if (
|
270
|
+
var selectorDom = document.querySelector(this._selector);
|
271
|
+
if (selectorDom) selectorDom.innerHTML = '';
|
247
272
|
}
|
248
273
|
// eslint-disable-next-line no-empty
|
249
|
-
} catch (error) {
|
274
|
+
} catch (error) {
|
275
|
+
console.error(error);
|
276
|
+
}
|
250
277
|
}
|
251
278
|
|
252
279
|
/**
|
@@ -275,7 +302,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
275
302
|
productSceneVersion: productSceneVersion,
|
276
303
|
extendInfo: extendInfo
|
277
304
|
});
|
278
|
-
this.app = createIframe(this.AMSSDK.options.mode);
|
305
|
+
this.app = createIframe(this.AMSSDK.options.mode, this.platform);
|
279
306
|
this.app.src = getIframeUrl({
|
280
307
|
componentSign: this._componentSign,
|
281
308
|
analytics: this.AMSSDK.options.analytics,
|
@@ -316,7 +343,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
316
343
|
}, {
|
317
344
|
key: "resizeListener",
|
318
345
|
value: function resizeListener() {
|
319
|
-
var cashier = document.getElementById(
|
346
|
+
var cashier = document.getElementById(componentContainerId);
|
320
347
|
cashier.style.transition = 'none';
|
321
348
|
this.dispatchToApp({
|
322
349
|
context: {
|
@@ -354,7 +381,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
354
381
|
}, {
|
355
382
|
key: "_handleAppMessage",
|
356
383
|
value: function _handleAppMessage(data) {
|
357
|
-
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.
|
384
|
+
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];
|
358
385
|
if (data.context.event === EVENT.dismissLoading.name) {
|
359
386
|
var _data$context$data;
|
360
387
|
this.dispatchToSDK(EVENT.eventCallback.name, {
|
@@ -371,13 +398,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
371
398
|
key: 'sdk_onLaunch',
|
372
399
|
value: Date.now()
|
373
400
|
});
|
401
|
+
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
374
402
|
this.sendRenderEvent();
|
375
403
|
return;
|
376
404
|
}
|
377
405
|
if (data.context.event === EVENT.sizeChanged.name) {
|
378
406
|
this.handleSizeChanged(data);
|
379
407
|
}
|
380
|
-
if (data.context.event === EVENT.
|
408
|
+
if (data.context.event === EVENT.close.name) {
|
381
409
|
return this.closeBtnFunc();
|
382
410
|
}
|
383
411
|
if (data.context.event === EVENT.redirect.name) {
|
@@ -412,7 +440,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
412
440
|
key: "handleSizeChanged",
|
413
441
|
value: function handleSizeChanged(data) {
|
414
442
|
var _data$context$data2;
|
415
|
-
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height)
|
443
|
+
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
|
444
|
+
var cashier = document.getElementById(componentContainerId);
|
445
|
+
cashier.style.height = "".concat(data.context.data.height, "px");
|
446
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
416
447
|
var _document$getElementB;
|
417
448
|
var mockup = document.getElementById(mockupId);
|
418
449
|
if (mockup) {
|
@@ -421,20 +452,18 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
421
452
|
mockup.style.display = 'block';
|
422
453
|
}
|
423
454
|
(_document$getElementB = document.getElementById(loadingId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
|
424
|
-
var cashier = document.getElementById('ams-component-container');
|
425
|
-
cashier.style.height = "".concat(data.context.data.height, "px");
|
426
455
|
if (this.platform === 'desktop') {
|
427
|
-
cashier.classList.add(
|
456
|
+
cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
|
428
457
|
if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
|
429
458
|
}
|
430
459
|
if (this.platform === 'mobile') {
|
431
|
-
cashier.classList.add(
|
432
|
-
var animationStyleId =
|
460
|
+
cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
|
461
|
+
var animationStyleId = "".concat(componentContainerId, "-").concat(this.platform, "-animation-style");
|
433
462
|
var animationStyle = document.getElementById(animationStyleId);
|
434
463
|
if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
|
435
464
|
|
436
465
|
// 弹出和弹入动画
|
437
|
-
var runkeyframes = "
|
466
|
+
var runkeyframes = "@keyframes ".concat(componentContainerId, "-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ").concat(data.context.data.height, "px;\n }\n }\n @keyframes ").concat(componentContainerId, "-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 }");
|
438
467
|
// 创建style标签
|
439
468
|
var style = document.createElement('style');
|
440
469
|
style.id = animationStyleId;
|
@@ -450,17 +479,20 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
450
479
|
cashier.style.transition = 'height 0.28s ease-in-out';
|
451
480
|
}, 500);
|
452
481
|
}
|
453
|
-
this.app.style.height = "".concat(data.context.data.height, "px");
|
454
|
-
this.app.style.width = '100%';
|
455
|
-
this.app.style.border = '0';
|
456
|
-
this.app.style.overflow = 'hidden';
|
457
482
|
}
|
483
|
+
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
484
|
+
var _document$getElementB2;
|
485
|
+
(_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
|
486
|
+
}
|
487
|
+
this.app.style.height = "".concat(data.context.data.height, "px");
|
488
|
+
this.app.style.width = '100%';
|
489
|
+
this.app.style.border = '0';
|
490
|
+
this.app.style.overflow = 'hidden';
|
458
491
|
}
|
459
492
|
}, {
|
460
493
|
key: "handleRedirect",
|
461
494
|
value: function handleRedirect(data) {
|
462
|
-
var
|
463
|
-
this.closeCashier();
|
495
|
+
var _this4 = this;
|
464
496
|
var _data = typeof data === 'string' ? {
|
465
497
|
normalUrl: data
|
466
498
|
} : {
|
@@ -470,37 +502,38 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
470
502
|
target: data === null || data === void 0 ? void 0 : data.target
|
471
503
|
};
|
472
504
|
var successCallback = function successCallback(type, url) {
|
473
|
-
|
505
|
+
_this4.dispatchToSDK(EVENT.eventCallback.name, {
|
474
506
|
code: 'SDK_CALL_URL_SUCCESS',
|
475
507
|
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
476
508
|
});
|
477
509
|
};
|
478
510
|
var failCallback = function failCallback() {
|
479
|
-
|
511
|
+
_this4.dispatchToSDK(EVENT.eventCallback.name, {
|
480
512
|
code: 'SDK_CALL_URL_ERROR',
|
481
513
|
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)
|
482
514
|
});
|
483
515
|
};
|
484
516
|
|
485
517
|
// 支持 target: _blank,新开tab页打开
|
486
|
-
if (_data.target ===
|
518
|
+
if (_data.target === targetEnum.BLANK) {
|
487
519
|
if (!_data.normalUrl) return failCallback();
|
488
520
|
successCallback('normalUrl', _data.normalUrl);
|
489
521
|
window.open(_data.normalUrl);
|
490
522
|
return;
|
491
523
|
}
|
524
|
+
this.cleanContainer();
|
492
525
|
this.AMSSDK._redirect({
|
493
526
|
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
|
494
527
|
}).then(function () {
|
495
528
|
successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
496
529
|
}).catch(function () {
|
497
|
-
return
|
530
|
+
return _this4.AMSSDK._redirect({
|
498
531
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
499
532
|
});
|
500
533
|
}).then(function () {
|
501
534
|
successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
502
535
|
}).catch(function () {
|
503
|
-
return
|
536
|
+
return _this4.AMSSDK._redirect({
|
504
537
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
505
538
|
});
|
506
539
|
}).then(function () {
|
@@ -516,21 +549,21 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
516
549
|
closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
|
517
550
|
try {
|
518
551
|
if (closeDialogData) {
|
519
|
-
var retentionTitle = document.getElementById(
|
552
|
+
var retentionTitle = document.getElementById("".concat(componentRetentionId, "-title"));
|
520
553
|
if (retentionTitle) {
|
521
554
|
var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
|
522
555
|
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");
|
523
556
|
retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
|
524
557
|
retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
|
525
558
|
}
|
526
|
-
var retentionMessage = document.getElementById(
|
559
|
+
var retentionMessage = document.getElementById("".concat(componentRetentionId, "-sub-title"));
|
527
560
|
if (retentionMessage) {
|
528
561
|
var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
|
529
562
|
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");
|
530
563
|
retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
|
531
564
|
retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
|
532
565
|
}
|
533
|
-
var remainBtn = document.getElementById(
|
566
|
+
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
|
534
567
|
if (remainBtn) {
|
535
568
|
var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
|
536
569
|
remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
|
@@ -542,7 +575,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
542
575
|
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);
|
543
576
|
} 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;
|
544
577
|
}
|
545
|
-
var leaveBrn = document.getElementById(
|
578
|
+
var leaveBrn = document.getElementById("".concat(componentRetentionId, "-leave"));
|
546
579
|
if (leaveBrn) {
|
547
580
|
var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
|
548
581
|
leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
|
@@ -562,11 +595,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
562
595
|
}, {
|
563
596
|
key: "handleCloseBtnShow",
|
564
597
|
value: function handleCloseBtnShow(showClose) {
|
565
|
-
var closeBlock = document.getElementById(
|
598
|
+
var closeBlock = document.getElementById(componentCloseBlockId);
|
566
599
|
if (showClose) {
|
567
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove(
|
600
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(componentCloseBlockId, "-hidden"));
|
568
601
|
} else if (showClose === false) {
|
569
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add(
|
602
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(componentCloseBlockId, "-hidden"));
|
570
603
|
}
|
571
604
|
}
|
572
605
|
|
@@ -576,7 +609,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
576
609
|
}, {
|
577
610
|
key: "dispatchToSDK",
|
578
611
|
value: function dispatchToSDK(event, data) {
|
579
|
-
this.AMSSDK.
|
612
|
+
this.AMSSDK._eventCenter.emit(event, data);
|
580
613
|
}
|
581
614
|
|
582
615
|
/**
|
@@ -592,8 +625,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
592
625
|
instanceId: this.AMSSDK._instanceId
|
593
626
|
});
|
594
627
|
if (this.app && this.app.contentWindow) {
|
595
|
-
this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
628
|
+
return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
596
629
|
}
|
630
|
+
throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
|
597
631
|
}
|
598
632
|
|
599
633
|
/**
|
@@ -606,7 +640,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
606
640
|
for (var key in eventKeyMap) {
|
607
641
|
// eslint-disable-next-line no-prototype-builtins
|
608
642
|
if (eventKeyMap.hasOwnProperty(key)) {
|
609
|
-
this.AMSSDK.
|
643
|
+
this.AMSSDK._eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
|
610
644
|
}
|
611
645
|
}
|
612
646
|
}
|
@@ -618,7 +652,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
618
652
|
key: "sendRenderEvent",
|
619
653
|
value: function () {
|
620
654
|
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
621
|
-
var _this$_renderParams, _this$_renderParams2, res;
|
655
|
+
var _this$_renderParams, _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, res;
|
622
656
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
623
657
|
while (1) switch (_context.prev = _context.next) {
|
624
658
|
case 0:
|
@@ -645,6 +679,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
645
679
|
sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
|
646
680
|
paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
|
647
681
|
heightOfVisible: Math.max(innerHeight, window.innerHeight),
|
682
|
+
renderDisplayType: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.renderDisplayType,
|
683
|
+
appearance: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.appearance,
|
648
684
|
envInfo: {
|
649
685
|
screenHeight: screen.height,
|
650
686
|
screenWidth: screen.width
|
@@ -678,8 +714,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
678
714
|
return sendRenderEvent;
|
679
715
|
}()
|
680
716
|
}, {
|
681
|
-
key: "
|
682
|
-
value: function
|
717
|
+
key: "showPopupLoading",
|
718
|
+
value: function showPopupLoading() {
|
683
719
|
var loading = document.createElement('div');
|
684
720
|
loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
|
685
721
|
loading.id = loadingId;
|
@@ -693,47 +729,50 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
693
729
|
* @description show cashier
|
694
730
|
*/
|
695
731
|
}, {
|
696
|
-
key: "
|
697
|
-
value: function
|
698
|
-
var cashier = document.getElementById(
|
699
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("
|
700
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("
|
732
|
+
key: "setContainerClass",
|
733
|
+
value: function setContainerClass() {
|
734
|
+
var cashier = document.getElementById(componentContainerId);
|
735
|
+
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("".concat(componentContainerId, "-hidden-").concat(this.platform));
|
736
|
+
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform));
|
701
737
|
}
|
702
738
|
|
703
739
|
/**
|
704
740
|
* @description close cashier
|
705
741
|
*/
|
706
742
|
}, {
|
707
|
-
key: "
|
708
|
-
value: function
|
709
|
-
var _document$
|
743
|
+
key: "cleanContainer",
|
744
|
+
value: function cleanContainer() {
|
745
|
+
var _document$getElementB3;
|
710
746
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
747
|
+
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
711
748
|
this._performanceData = [];
|
712
749
|
this._isInitComponent = false;
|
713
|
-
(_document$
|
750
|
+
(_document$getElementB3 = document.getElementById(loadingId)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
|
714
751
|
this.hideComponentAndCleanDom(immediately);
|
715
752
|
}
|
716
753
|
}, {
|
717
754
|
key: "hideComponentAndCleanDom",
|
718
755
|
value: function hideComponentAndCleanDom() {
|
719
|
-
var
|
756
|
+
var _this5 = this;
|
720
757
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
721
|
-
var container = document.getElementById(
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
758
|
+
var container = document.getElementById(componentContainerId);
|
759
|
+
if (container) {
|
760
|
+
// size变化动画取消
|
761
|
+
container.style.transition = '';
|
762
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-").concat(this.platform));
|
763
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
|
764
|
+
container === null || container === void 0 ? void 0 : container.classList.add("".concat(componentContainerId, "-hidden-").concat(this.platform));
|
765
|
+
}
|
727
766
|
var removeMockupAndApp = function removeMockupAndApp() {
|
728
|
-
var _document$
|
767
|
+
var _document$getElementB4;
|
729
768
|
var body = document.getElementsByTagName('body')[0];
|
730
769
|
body.style.overflow = 'auto';
|
731
770
|
var mockup = document.getElementById(mockupId);
|
732
771
|
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
733
772
|
if (container) container.style.height = '';
|
734
|
-
(_document$
|
735
|
-
|
736
|
-
|
773
|
+
(_document$getElementB4 = document.getElementById("".concat(componentContainerId, "-").concat(_this5.platform, "-animation-style"))) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
774
|
+
_this5.removeRetentionPopup();
|
775
|
+
_this5.cleanApp();
|
737
776
|
};
|
738
777
|
if (immediately) removeMockupAndApp();else {
|
739
778
|
setTimeout(function () {
|
@@ -746,8 +785,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
746
785
|
value: function closeBtnFunc() {
|
747
786
|
// element && element.removeEventListener()
|
748
787
|
if (this._isRetention) this.showRetentionPopup();else {
|
749
|
-
this.
|
750
|
-
this.dispatchToSDK(EVENT.
|
788
|
+
this.cleanContainer();
|
789
|
+
this.dispatchToSDK(EVENT.close.name, {});
|
751
790
|
}
|
752
791
|
}
|
753
792
|
|
@@ -755,33 +794,51 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
755
794
|
* @description create mount node
|
756
795
|
*/
|
757
796
|
}, {
|
758
|
-
key: "
|
759
|
-
value: function
|
797
|
+
key: "createBaseElement",
|
798
|
+
value: function createBaseElement() {
|
799
|
+
if (document.getElementById(componentContainerId)) return;
|
760
800
|
componentAddCSS();
|
801
|
+
addSetFontSizeEvent();
|
761
802
|
var amsComponentContainer = document.createElement('div');
|
762
|
-
amsComponentContainer.className = "
|
763
|
-
amsComponentContainer.id =
|
803
|
+
amsComponentContainer.className = "".concat(componentContainerId, "-hidden-").concat(this.platform);
|
804
|
+
amsComponentContainer.id = componentContainerId;
|
764
805
|
amsSetSize(null, amsComponentContainer);
|
765
806
|
document.body.appendChild(amsComponentContainer);
|
766
807
|
var amsComponentSection = document.createElement('div');
|
767
808
|
amsComponentSection.className = "ams-component-section-".concat(this.platform);
|
768
|
-
amsComponentSection.id =
|
809
|
+
amsComponentSection.id = componentSectionId;
|
769
810
|
amsComponentContainer.appendChild(amsComponentSection);
|
770
811
|
this.createCloseBtn();
|
771
812
|
}
|
813
|
+
}, {
|
814
|
+
key: "createInlineBaseElement",
|
815
|
+
value: function createInlineBaseElement(renderParams) {
|
816
|
+
var _renderParams$appeara2;
|
817
|
+
var inlineBaseStyle = document.getElementById(inlineBaseStyleId);
|
818
|
+
if (!inlineBaseStyle) inlineComponentAddCss();
|
819
|
+
if (document.getElementById(componentContainerId)) return;
|
820
|
+
var amsComponentContainer = document.createElement('div');
|
821
|
+
amsComponentContainer.className = "".concat(componentContainerId, "-inline");
|
822
|
+
amsComponentContainer.id = componentContainerId;
|
823
|
+
var selectorDom = document.querySelector(this._selector);
|
824
|
+
if (selectorDom) selectorDom.appendChild(amsComponentContainer);
|
825
|
+
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
|
826
|
+
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
827
|
+
if (showLoading) showInlineLoading(amsComponentContainer, this.platform);
|
828
|
+
}
|
772
829
|
}, {
|
773
830
|
key: "createCloseBtn",
|
774
831
|
value: function createCloseBtn() {
|
775
|
-
var
|
776
|
-
var container = document.getElementById(
|
832
|
+
var _this6 = this;
|
833
|
+
var container = document.getElementById(componentContainerId);
|
777
834
|
// close btn
|
778
|
-
var closeBtnHTML = "<img class='
|
835
|
+
var closeBtnHTML = "<img class='".concat(componentCloseBlockId, "-btn-").concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
|
779
836
|
var closeBlock = document.createElement('div');
|
780
|
-
closeBlock.classList.add("
|
781
|
-
closeBlock.id =
|
837
|
+
closeBlock.classList.add("".concat(componentCloseBlockId, "-").concat(this.platform), "".concat(componentCloseBlockId, "-hidden"));
|
838
|
+
closeBlock.id = componentCloseBlockId;
|
782
839
|
closeBlock.innerHTML = closeBtnHTML;
|
783
840
|
closeBlock.addEventListener(this._clickEventName, function () {
|
784
|
-
|
841
|
+
_this6.closeBtnFunc();
|
785
842
|
});
|
786
843
|
if (container) container.appendChild(closeBlock);
|
787
844
|
}
|
@@ -790,15 +847,15 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
790
847
|
value: function createRetentionPopup() {
|
791
848
|
// retention popup
|
792
849
|
var retentionPopup = document.createElement('div');
|
793
|
-
retentionPopup.id =
|
794
|
-
retentionPopup.classList.add("
|
795
|
-
retentionPopup.innerHTML = "\n <span id=\"
|
850
|
+
retentionPopup.id = componentRetentionId;
|
851
|
+
retentionPopup.classList.add("".concat(componentRetentionId, "-").concat(this.platform));
|
852
|
+
retentionPopup.innerHTML = "\n <span id=\"".concat(componentRetentionId, "-title\" class=\"").concat(componentRetentionId, "-title-").concat(this.platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"").concat(componentRetentionId, "-sub-title\"\n class=\"").concat(componentRetentionId, "-sub-title-").concat(this.platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"").concat(componentRetentionId, "-btn-block-").concat(this.platform, "\">\n <div id=\"").concat(componentRetentionId, "-remain\" class=\"").concat(componentRetentionId, "-remain-").concat(this.platform, "\">\n Continue Payment\n </div>\n <div id=\"").concat(componentRetentionId, "-leave\" class=\"").concat(componentRetentionId, "-leave-").concat(this.platform, "\">\n Leave\n </div>\n </div>");
|
796
853
|
document.body.appendChild(retentionPopup);
|
797
|
-
var remainBtn = document.getElementById(
|
854
|
+
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
|
798
855
|
if (remainBtn) {
|
799
856
|
remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
|
800
857
|
}
|
801
|
-
var leaveBtn = document.getElementById(
|
858
|
+
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
|
802
859
|
if (leaveBtn) {
|
803
860
|
leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
|
804
861
|
}
|
@@ -806,47 +863,47 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
806
863
|
}, {
|
807
864
|
key: "retentionPopupLeaveFunc",
|
808
865
|
value: function retentionPopupLeaveFunc() {
|
809
|
-
this.dispatchToSDK(EVENT.
|
866
|
+
this.dispatchToSDK(EVENT.close.name, {});
|
810
867
|
this.hideRetentionPopup();
|
811
|
-
this.
|
868
|
+
this.cleanContainer();
|
812
869
|
}
|
813
870
|
}, {
|
814
871
|
key: "removeRetentionPopup",
|
815
872
|
value: function removeRetentionPopup() {
|
816
|
-
var _document$
|
817
|
-
var remainBtn = document.getElementById(
|
873
|
+
var _document$getElementB5;
|
874
|
+
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
|
818
875
|
if (remainBtn) {
|
819
876
|
remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
|
820
877
|
}
|
821
|
-
var leaveBtn = document.getElementById(
|
878
|
+
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
|
822
879
|
if (leaveBtn) {
|
823
880
|
leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
|
824
881
|
}
|
825
|
-
(_document$
|
882
|
+
(_document$getElementB5 = document.getElementById(componentRetentionId)) === null || _document$getElementB5 === void 0 ? void 0 : _document$getElementB5.remove();
|
826
883
|
}
|
827
884
|
}, {
|
828
885
|
key: "showRetentionPopup",
|
829
886
|
value: function showRetentionPopup() {
|
830
|
-
var retentionPopup = document.getElementById(
|
831
|
-
var container = document.getElementById(
|
887
|
+
var retentionPopup = document.getElementById(componentRetentionId);
|
888
|
+
var container = document.getElementById(componentContainerId);
|
832
889
|
if (retentionPopup) {
|
833
|
-
container === null || container === void 0 ? void 0 : container.classList.add(
|
834
|
-
retentionPopup.classList.remove(
|
835
|
-
retentionPopup.classList.add(
|
890
|
+
container === null || container === void 0 ? void 0 : container.classList.add("".concat(componentContainerId, "-opacity"));
|
891
|
+
retentionPopup.classList.remove("".concat(componentRetentionId, "-hidden"));
|
892
|
+
retentionPopup.classList.add("".concat(componentRetentionId, "-show"));
|
836
893
|
}
|
837
894
|
}
|
838
895
|
}, {
|
839
896
|
key: "hideRetentionPopup",
|
840
897
|
value: function hideRetentionPopup() {
|
841
|
-
var retentionPopup = document.getElementById(
|
842
|
-
var container = document.getElementById(
|
898
|
+
var retentionPopup = document.getElementById(componentRetentionId);
|
899
|
+
var container = document.getElementById(componentContainerId);
|
843
900
|
if (retentionPopup) {
|
844
|
-
retentionPopup.classList.remove(
|
845
|
-
retentionPopup.classList.add(
|
901
|
+
retentionPopup.classList.remove("".concat(componentRetentionId, "-show"));
|
902
|
+
retentionPopup.classList.add("".concat(componentRetentionId, "-hidden"));
|
846
903
|
setTimeout(function () {
|
847
|
-
retentionPopup.classList.remove(
|
848
|
-
container === null || container === void 0 ? void 0 : container.classList.remove(
|
849
|
-
},
|
904
|
+
retentionPopup.classList.remove("".concat(componentRetentionId, "-hidden"));
|
905
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-opacity"));
|
906
|
+
}, 300);
|
850
907
|
}
|
851
908
|
}
|
852
909
|
/**
|
@@ -889,7 +946,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
889
946
|
form.setAttribute('action', attributes.action);
|
890
947
|
form.setAttribute('method', 'post');
|
891
948
|
body.appendChild(form);
|
892
|
-
this.closeCashier(true);
|
893
949
|
setTimeout(function () {
|
894
950
|
form.submit();
|
895
951
|
}, 0);
|