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