@alipay/ams-checkout 0.0.1692935171-dev.1 → 0.0.1693912790-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 +32 -41
- package/esm/constant/index.js +32 -41
- package/esm/core/component/index.d.ts +9 -22
- package/esm/core/component/index.js +43 -145
- package/esm/core/drop-in/index.d.ts +1 -1
- package/esm/core/instance/index.d.ts +15 -6
- package/esm/core/instance/index.js +53 -31
- package/esm/index.d.ts +10 -4
- package/esm/index.js +30 -8
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/cashierApp.js +15 -16
- package/esm/plugin/component/component.style.d.ts +1 -4
- package/esm/plugin/component/component.style.js +4 -32
- package/esm/plugin/component/index.d.ts +10 -22
- package/esm/plugin/component/index.js +159 -218
- 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 +34 -71
- package/esm/types/index.js +47 -84
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +4 -6
- package/esm/util/index.js +5 -22
- package/esm/util/mock.js +2 -1
- package/package.json +1 -1
- package/esm/image/skeleton.svg +0 -18
@@ -2,6 +2,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
2
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
3
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
4
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
5
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
6
8
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
7
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
@@ -17,22 +19,32 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
19
|
/* eslint-disable no-console */
|
18
20
|
import { closeImg, COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
19
21
|
import { queryPaymentInfo } from "../../service";
|
20
|
-
import { componentSignEnum, messageName,
|
21
|
-
import {
|
22
|
+
import { componentSignEnum, messageName, productSceneEnum, Target } from "../../types";
|
23
|
+
import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
|
22
24
|
import { isLocalMock } from "../../util/mock";
|
23
25
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
24
|
-
import { componentAddCSS
|
26
|
+
import { componentAddCSS } from "./component.style";
|
25
27
|
var _window = window,
|
26
28
|
innerHeight = _window.innerHeight;
|
27
|
-
var
|
28
|
-
|
29
|
-
var
|
30
|
-
|
29
|
+
var amsSetSize = function amsSetSize(event, dom) {
|
30
|
+
try {
|
31
|
+
var _dom = dom || document.getElementById('ams-component-container');
|
32
|
+
_dom.style.fontSize = "".concat(getDesignFontSize(), "px");
|
33
|
+
innerHeight = window.innerHeight;
|
34
|
+
// eslint-disable-next-line no-empty
|
35
|
+
} catch (error) {}
|
36
|
+
};
|
37
|
+
var addEvent = function addEvent() {
|
38
|
+
window.removeEventListener('resize', amsSetSize);
|
39
|
+
window.removeEventListener('pageShow', amsSetSize);
|
40
|
+
window.removeEventListener('DOMContentLoaded', amsSetSize);
|
41
|
+
window.addEventListener('resize', amsSetSize);
|
42
|
+
window.addEventListener('pageShow', amsSetSize);
|
43
|
+
window.addEventListener('DOMContentLoaded', amsSetSize);
|
44
|
+
};
|
31
45
|
var mockupId = 'ams-component-mockup';
|
32
46
|
var loadingId = 'ams-component-loading';
|
33
47
|
var listenerPrefix = '_ams_sdk_component_listener';
|
34
|
-
var inlineBaseStyleId = 'ams-inline-component-style';
|
35
|
-
var loadTimeLimit = 15000;
|
36
48
|
var ComponentApp = /*#__PURE__*/function () {
|
37
49
|
function ComponentApp() {
|
38
50
|
_classCallCheck(this, ComponentApp);
|
@@ -45,22 +57,22 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
45
57
|
_defineProperty(this, "_appVersion", void 0);
|
46
58
|
_defineProperty(this, "_isRetention", void 0);
|
47
59
|
_defineProperty(this, "_actionQueryPromise", null);
|
48
|
-
_defineProperty(this, "_loadAppPromiseResolve", null);
|
49
60
|
_defineProperty(this, "_renderParams", null);
|
50
61
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
51
62
|
_defineProperty(this, "_performanceData", []);
|
52
63
|
_defineProperty(this, "_isInitComponent", void 0);
|
53
64
|
_defineProperty(this, "_clickEventName", void 0);
|
54
|
-
|
55
|
-
this._appVersion = '1.5.2';
|
65
|
+
this._appVersion = '1.5.3';
|
56
66
|
this._isInitComponent = false;
|
57
|
-
this._selector =
|
67
|
+
this._selector = '#ams-component-section';
|
58
68
|
this.createIframeNode = function () {
|
59
69
|
return Promise.resolve();
|
60
70
|
};
|
61
|
-
this.platform = isPC() ?
|
62
|
-
this._clickEventName = this.platform ===
|
71
|
+
this.platform = isPC() ? 'desktop' : 'mobile';
|
72
|
+
this._clickEventName = this.platform === 'mobile' ? 'touchend' : 'click';
|
63
73
|
this._isRetention = true;
|
74
|
+
addEvent();
|
75
|
+
this.createMountElement();
|
64
76
|
this._performanceData.push({
|
65
77
|
key: 'sdk_init',
|
66
78
|
value: Date.now()
|
@@ -73,7 +85,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
73
85
|
_createClass(ComponentApp, [{
|
74
86
|
key: "logoutPlugin",
|
75
87
|
value: function logoutPlugin() {
|
76
|
-
this.
|
88
|
+
this.closeCashier();
|
77
89
|
}
|
78
90
|
|
79
91
|
/**
|
@@ -91,8 +103,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
91
103
|
*/
|
92
104
|
}, {
|
93
105
|
key: "setRender",
|
94
|
-
value: function setRender(
|
95
|
-
this.createIframeNode =
|
106
|
+
value: function setRender(createIframeNode) {
|
107
|
+
this.createIframeNode = createIframeNode;
|
96
108
|
}
|
97
109
|
|
98
110
|
/**
|
@@ -101,108 +113,68 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
101
113
|
}, {
|
102
114
|
key: "appendIframeNodes",
|
103
115
|
value: function appendIframeNodes(componentSign, renderParams) {
|
104
|
-
var
|
105
|
-
|
106
|
-
|
107
|
-
return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
108
|
-
}
|
116
|
+
var _renderParams$appeara,
|
117
|
+
_this = this;
|
118
|
+
if (this._isInitComponent) return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
109
119
|
this._isInitComponent = true;
|
110
120
|
this._renderParams = renderParams;
|
111
121
|
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;
|
115
122
|
this._performanceData.push({
|
116
123
|
key: 'sdk_create_component',
|
117
124
|
value: Date.now()
|
118
125
|
});
|
119
|
-
this.
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
this.
|
127
|
-
this.setContainerClass();
|
128
|
-
this.createRetentionPopup();
|
129
|
-
this.createMockup();
|
130
|
-
this.renderPopupLoading(renderParams);
|
126
|
+
this.createRetentionPopup();
|
127
|
+
this.createMockup();
|
128
|
+
if ((renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading) !== false) {
|
129
|
+
var mockup = document.getElementById(mockupId);
|
130
|
+
if (mockup) {
|
131
|
+
mockup.style.display = 'block';
|
132
|
+
}
|
133
|
+
this.showLoading();
|
131
134
|
}
|
135
|
+
this.showCashier();
|
132
136
|
this.createApp(renderParams);
|
133
|
-
|
134
|
-
|
135
|
-
|
137
|
+
this.createActionQueryPromise();
|
138
|
+
return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
|
139
|
+
selector: this._selector
|
140
|
+
})), this._actionQueryPromise]).catch(function () {
|
136
141
|
_this._isInitComponent = false;
|
137
|
-
_this.cleanContainer();
|
138
|
-
return Promise.reject(error);
|
139
|
-
});
|
140
|
-
}
|
141
|
-
}, {
|
142
|
-
key: "renderPopupLoading",
|
143
|
-
value: function renderPopupLoading(renderParams) {
|
144
|
-
var _renderParams$appeara;
|
145
|
-
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
|
146
|
-
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
147
|
-
if (!showLoading) return;
|
148
|
-
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
149
|
-
var mockup = document.getElementById(mockupId);
|
150
|
-
if (mockup) mockup.style.display = 'block';
|
151
|
-
return this.showPopupLoading();
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}, {
|
155
|
-
key: "createLoadAppPromise",
|
156
|
-
value: function createLoadAppPromise() {
|
157
|
-
var _this2 = this;
|
158
|
-
return new Promise(function (resolve, reject) {
|
159
|
-
_this2._loadAppPromiseResolve = resolve;
|
160
|
-
setTimeout(function () {
|
161
|
-
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
162
|
-
}, loadTimeLimit);
|
163
|
-
}).catch(function (error) {
|
164
|
-
_this2.dispatchToSDK(EVENT.error.name, {
|
165
|
-
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
|
166
|
-
message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
|
167
|
-
});
|
168
|
-
return Promise.reject(error);
|
169
142
|
});
|
170
143
|
}
|
171
|
-
|
172
144
|
/**
|
173
145
|
* @description Interface request
|
174
146
|
*/
|
175
147
|
}, {
|
176
148
|
key: "createActionQueryPromise",
|
177
149
|
value: function createActionQueryPromise() {
|
178
|
-
var
|
150
|
+
var _this2 = this;
|
179
151
|
this._performanceData.push({
|
180
152
|
key: 'sdk_action_query_start',
|
181
153
|
value: Date.now()
|
182
154
|
});
|
183
155
|
this._actionQueryPromise = new Promise(function (resolve, reject) {
|
184
|
-
var
|
156
|
+
var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
|
185
157
|
var params = {
|
186
|
-
paymentSessionData:
|
187
|
-
paymentSessionConfig: (
|
158
|
+
paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
|
159
|
+
paymentSessionConfig: (_this2$_renderParams2 = _this2._renderParams) === null || _this2$_renderParams2 === void 0 ? void 0 : (_this2$_renderParams3 = _this2$_renderParams2.paymentSessionMetaData) === null || _this2$_renderParams3 === void 0 ? void 0 : _this2$_renderParams3.paymentSessionConfig
|
188
160
|
};
|
189
161
|
/**
|
190
162
|
* @description card
|
191
163
|
*/
|
192
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD ===
|
164
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign) {
|
193
165
|
params.paymentMethodType = 'CARD';
|
194
166
|
}
|
195
167
|
/**
|
196
168
|
* @description easyPay
|
197
169
|
*/
|
198
|
-
if (componentSignEnum.EASY_PAY_WALLET ===
|
199
|
-
var
|
170
|
+
if (componentSignEnum.EASY_PAY_WALLET === _this2._componentSign) {
|
171
|
+
var _this2$_renderParams4;
|
200
172
|
var _ref = params.paymentSessionConfig || {},
|
201
173
|
_ref$productSceneVers = _ref.productSceneVersion,
|
202
174
|
productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
|
203
175
|
_ref$productScene = _ref.productScene,
|
204
176
|
productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
|
205
|
-
var _ref2 = ((
|
177
|
+
var _ref2 = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : _this2$_renderParams4.paymentSessionMetaData) || {},
|
206
178
|
_ref2$action = _ref2.action,
|
207
179
|
_ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
|
208
180
|
_ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
|
@@ -219,9 +191,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
219
191
|
* @author tianqiang
|
220
192
|
* @description autoDebit
|
221
193
|
*/
|
222
|
-
if (componentSignEnum.AUTO_DEBIT_WALLET ===
|
223
|
-
var
|
224
|
-
var action = ((
|
194
|
+
if (componentSignEnum.AUTO_DEBIT_WALLET === _this2._componentSign) {
|
195
|
+
var _this2$_renderParams5, _this2$_renderParams6, _action$web, _action$wap;
|
196
|
+
var action = ((_this2$_renderParams5 = _this2._renderParams) === null || _this2$_renderParams5 === void 0 ? void 0 : (_this2$_renderParams6 = _this2$_renderParams5.paymentSessionMetaData) === null || _this2$_renderParams6 === void 0 ? void 0 : _this2$_renderParams6.action) || {};
|
225
197
|
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;
|
226
198
|
if (signType === 'SMS') {
|
227
199
|
return resolve({
|
@@ -244,10 +216,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
244
216
|
});
|
245
217
|
}
|
246
218
|
queryPaymentInfo(params, {
|
247
|
-
env:
|
248
|
-
locale:
|
219
|
+
env: _this2.AMSSDK.options.env.environment,
|
220
|
+
locale: _this2.AMSSDK.options.locale
|
249
221
|
}).then(function (res) {
|
250
|
-
|
222
|
+
_this2._performanceData.push({
|
251
223
|
key: 'sdk_action_query_end',
|
252
224
|
value: Date.now()
|
253
225
|
});
|
@@ -255,15 +227,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
255
227
|
resolve(res);
|
256
228
|
} else {
|
257
229
|
resolve(res);
|
230
|
+
_this2.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR);
|
258
231
|
}
|
259
232
|
}).catch(function (err) {
|
260
|
-
_this3.dispatchToSDK(EVENT.error.name, {
|
261
|
-
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
|
262
|
-
});
|
263
233
|
reject(err);
|
234
|
+
_this2.closeCashier();
|
264
235
|
});
|
265
236
|
});
|
266
|
-
return this._actionQueryPromise;
|
267
237
|
}
|
268
238
|
}, {
|
269
239
|
key: "cleanApp",
|
@@ -272,13 +242,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
272
242
|
this.app = null;
|
273
243
|
this._removeEventListener();
|
274
244
|
if (getType(this._selector) === 'string') {
|
275
|
-
var
|
276
|
-
if (
|
245
|
+
var dorpinDom = document.querySelector(this._selector);
|
246
|
+
if (dorpinDom) dorpinDom.innerHTML = '';
|
277
247
|
}
|
278
248
|
// eslint-disable-next-line no-empty
|
279
|
-
} catch (error) {
|
280
|
-
console.error(error);
|
281
|
-
}
|
249
|
+
} catch (error) {}
|
282
250
|
}
|
283
251
|
|
284
252
|
/**
|
@@ -307,7 +275,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
307
275
|
productSceneVersion: productSceneVersion,
|
308
276
|
extendInfo: extendInfo
|
309
277
|
});
|
310
|
-
this.app = createIframe(this.AMSSDK.options.mode
|
278
|
+
this.app = createIframe(this.AMSSDK.options.mode);
|
311
279
|
this.app.src = getIframeUrl({
|
312
280
|
componentSign: this._componentSign,
|
313
281
|
analytics: this.AMSSDK.options.analytics,
|
@@ -348,7 +316,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
348
316
|
}, {
|
349
317
|
key: "resizeListener",
|
350
318
|
value: function resizeListener() {
|
351
|
-
var cashier = document.getElementById(
|
319
|
+
var cashier = document.getElementById('ams-component-container');
|
352
320
|
cashier.style.transition = 'none';
|
353
321
|
this.dispatchToApp({
|
354
322
|
context: {
|
@@ -386,7 +354,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
386
354
|
}, {
|
387
355
|
key: "_handleAppMessage",
|
388
356
|
value: function _handleAppMessage(data) {
|
389
|
-
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.
|
357
|
+
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.onClose.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name];
|
390
358
|
if (data.context.event === EVENT.dismissLoading.name) {
|
391
359
|
var _data$context$data;
|
392
360
|
this.dispatchToSDK(EVENT.eventCallback.name, {
|
@@ -403,14 +371,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
403
371
|
key: 'sdk_onLaunch',
|
404
372
|
value: Date.now()
|
405
373
|
});
|
406
|
-
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
407
374
|
this.sendRenderEvent();
|
408
375
|
return;
|
409
376
|
}
|
410
377
|
if (data.context.event === EVENT.sizeChanged.name) {
|
411
378
|
this.handleSizeChanged(data);
|
412
379
|
}
|
413
|
-
if (data.context.event === EVENT.
|
380
|
+
if (data.context.event === EVENT.onClose.name) {
|
414
381
|
return this.closeBtnFunc();
|
415
382
|
}
|
416
383
|
if (data.context.event === EVENT.redirect.name) {
|
@@ -445,10 +412,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
445
412
|
key: "handleSizeChanged",
|
446
413
|
value: function handleSizeChanged(data) {
|
447
414
|
var _data$context$data2;
|
448
|
-
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height)
|
449
|
-
var cashier = document.getElementById(componentContainerId);
|
450
|
-
cashier.style.height = "".concat(data.context.data.height, "px");
|
451
|
-
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
415
|
+
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) > 1) {
|
452
416
|
var _document$getElementB;
|
453
417
|
var mockup = document.getElementById(mockupId);
|
454
418
|
if (mockup) {
|
@@ -457,18 +421,20 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
457
421
|
mockup.style.display = 'block';
|
458
422
|
}
|
459
423
|
(_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");
|
460
426
|
if (this.platform === 'desktop') {
|
461
|
-
cashier.classList.add(
|
427
|
+
cashier.classList.add('ams-component-container-desktop-animation');
|
462
428
|
if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
|
463
429
|
}
|
464
430
|
if (this.platform === 'mobile') {
|
465
|
-
cashier.classList.add(
|
466
|
-
var animationStyleId =
|
431
|
+
cashier.classList.add('ams-component-container-mobile-animation');
|
432
|
+
var animationStyleId = 'ams-component-container-mobile-animation-style';
|
467
433
|
var animationStyle = document.getElementById(animationStyleId);
|
468
434
|
if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
|
469
435
|
|
470
436
|
// 弹出和弹入动画
|
471
|
-
var runkeyframes = "@keyframes
|
437
|
+
var runkeyframes = " @keyframes ams-component-container-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ".concat(data.context.data.height, "px;\n }\n }\n @keyframes ams-component-container-slide-out {\n 0% {\n height: ").concat(data.context.data.height, "px;\n opacity: 1;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n height: 1px;\n opacity: 0;\n }\n }");
|
472
438
|
// 创建style标签
|
473
439
|
var style = document.createElement('style');
|
474
440
|
style.id = animationStyleId;
|
@@ -484,18 +450,17 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
484
450
|
cashier.style.transition = 'height 0.28s ease-in-out';
|
485
451
|
}, 500);
|
486
452
|
}
|
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';
|
487
457
|
}
|
488
|
-
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
489
|
-
var _document$getElementB2;
|
490
|
-
(_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
|
491
|
-
}
|
492
|
-
this.app.style.height = "".concat(data.context.data.height, "px");
|
493
|
-
this.app.style.opacity = '1';
|
494
458
|
}
|
495
459
|
}, {
|
496
460
|
key: "handleRedirect",
|
497
461
|
value: function handleRedirect(data) {
|
498
|
-
var
|
462
|
+
var _this3 = this;
|
463
|
+
this.closeCashier();
|
499
464
|
var _data = typeof data === 'string' ? {
|
500
465
|
normalUrl: data
|
501
466
|
} : {
|
@@ -505,38 +470,37 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
505
470
|
target: data === null || data === void 0 ? void 0 : data.target
|
506
471
|
};
|
507
472
|
var successCallback = function successCallback(type, url) {
|
508
|
-
|
509
|
-
code:
|
473
|
+
_this3.dispatchToSDK(EVENT.eventCallback.name, {
|
474
|
+
code: 'SDK_CALL_URL_SUCCESS',
|
510
475
|
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
511
476
|
});
|
512
477
|
};
|
513
478
|
var failCallback = function failCallback() {
|
514
|
-
|
515
|
-
code:
|
479
|
+
_this3.dispatchToSDK(EVENT.eventCallback.name, {
|
480
|
+
code: 'SDK_CALL_URL_ERROR',
|
516
481
|
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)
|
517
482
|
});
|
518
483
|
};
|
519
484
|
|
520
485
|
// 支持 target: _blank,新开tab页打开
|
521
|
-
if (_data.target ===
|
486
|
+
if (_data.target === Target.BLANK) {
|
522
487
|
if (!_data.normalUrl) return failCallback();
|
523
488
|
successCallback('normalUrl', _data.normalUrl);
|
524
489
|
window.open(_data.normalUrl);
|
525
490
|
return;
|
526
491
|
}
|
527
|
-
this.cleanContainer();
|
528
492
|
this.AMSSDK._redirect({
|
529
493
|
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
|
530
494
|
}).then(function () {
|
531
495
|
successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
532
496
|
}).catch(function () {
|
533
|
-
return
|
497
|
+
return _this3.AMSSDK._redirect({
|
534
498
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
535
499
|
});
|
536
500
|
}).then(function () {
|
537
501
|
successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
538
502
|
}).catch(function () {
|
539
|
-
return
|
503
|
+
return _this3.AMSSDK._redirect({
|
540
504
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
541
505
|
});
|
542
506
|
}).then(function () {
|
@@ -552,21 +516,21 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
552
516
|
closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
|
553
517
|
try {
|
554
518
|
if (closeDialogData) {
|
555
|
-
var retentionTitle = document.getElementById(
|
519
|
+
var retentionTitle = document.getElementById('ams-component-retention-title');
|
556
520
|
if (retentionTitle) {
|
557
521
|
var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
|
558
522
|
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");
|
559
523
|
retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
|
560
524
|
retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
|
561
525
|
}
|
562
|
-
var retentionMessage = document.getElementById(
|
526
|
+
var retentionMessage = document.getElementById('ams-component-retention-sub-title');
|
563
527
|
if (retentionMessage) {
|
564
528
|
var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
|
565
529
|
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");
|
566
530
|
retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
|
567
531
|
retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
|
568
532
|
}
|
569
|
-
var remainBtn = document.getElementById(
|
533
|
+
var remainBtn = document.getElementById('ams-component-retention-remain');
|
570
534
|
if (remainBtn) {
|
571
535
|
var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
|
572
536
|
remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
|
@@ -578,7 +542,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
578
542
|
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);
|
579
543
|
} 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;
|
580
544
|
}
|
581
|
-
var leaveBrn = document.getElementById(
|
545
|
+
var leaveBrn = document.getElementById('ams-component-retention-leave');
|
582
546
|
if (leaveBrn) {
|
583
547
|
var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
|
584
548
|
leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
|
@@ -598,11 +562,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
598
562
|
}, {
|
599
563
|
key: "handleCloseBtnShow",
|
600
564
|
value: function handleCloseBtnShow(showClose) {
|
601
|
-
var closeBlock = document.getElementById(
|
565
|
+
var closeBlock = document.getElementById('asm-component-section-close-block');
|
602
566
|
if (showClose) {
|
603
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove(
|
567
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove('asm-component-close-block-hidden');
|
604
568
|
} else if (showClose === false) {
|
605
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add(
|
569
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add('asm-component-close-block-hidden');
|
606
570
|
}
|
607
571
|
}
|
608
572
|
|
@@ -612,7 +576,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
612
576
|
}, {
|
613
577
|
key: "dispatchToSDK",
|
614
578
|
value: function dispatchToSDK(event, data) {
|
615
|
-
this.AMSSDK.
|
579
|
+
this.AMSSDK.eventCenter.emit(event, data);
|
616
580
|
}
|
617
581
|
|
618
582
|
/**
|
@@ -628,9 +592,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
628
592
|
instanceId: this.AMSSDK._instanceId
|
629
593
|
});
|
630
594
|
if (this.app && this.app.contentWindow) {
|
631
|
-
|
595
|
+
this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
632
596
|
}
|
633
|
-
throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
|
634
597
|
}
|
635
598
|
|
636
599
|
/**
|
@@ -643,7 +606,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
643
606
|
for (var key in eventKeyMap) {
|
644
607
|
// eslint-disable-next-line no-prototype-builtins
|
645
608
|
if (eventKeyMap.hasOwnProperty(key)) {
|
646
|
-
this.AMSSDK.
|
609
|
+
this.AMSSDK.eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
|
647
610
|
}
|
648
611
|
}
|
649
612
|
}
|
@@ -655,7 +618,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
655
618
|
key: "sendRenderEvent",
|
656
619
|
value: function () {
|
657
620
|
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
658
|
-
var _this$_renderParams, _this$_renderParams2,
|
621
|
+
var _this$_renderParams, _this$_renderParams2, res;
|
659
622
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
660
623
|
while (1) switch (_context.prev = _context.next) {
|
661
624
|
case 0:
|
@@ -682,8 +645,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
682
645
|
sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
|
683
646
|
paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
|
684
647
|
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,
|
687
648
|
envInfo: {
|
688
649
|
screenHeight: screen.height,
|
689
650
|
screenWidth: screen.width
|
@@ -717,8 +678,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
717
678
|
return sendRenderEvent;
|
718
679
|
}()
|
719
680
|
}, {
|
720
|
-
key: "
|
721
|
-
value: function
|
681
|
+
key: "showLoading",
|
682
|
+
value: function showLoading() {
|
722
683
|
var loading = document.createElement('div');
|
723
684
|
loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
|
724
685
|
loading.id = loadingId;
|
@@ -732,50 +693,47 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
732
693
|
* @description show cashier
|
733
694
|
*/
|
734
695
|
}, {
|
735
|
-
key: "
|
736
|
-
value: function
|
737
|
-
var cashier = document.getElementById(
|
738
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("
|
739
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("
|
696
|
+
key: "showCashier",
|
697
|
+
value: function showCashier() {
|
698
|
+
var cashier = document.getElementById('ams-component-container');
|
699
|
+
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("ams-component-container-hidden-".concat(this.platform));
|
700
|
+
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("ams-component-container-".concat(this.platform));
|
740
701
|
}
|
741
702
|
|
742
703
|
/**
|
743
704
|
* @description close cashier
|
744
705
|
*/
|
745
706
|
}, {
|
746
|
-
key: "
|
747
|
-
value: function
|
748
|
-
var _document$
|
707
|
+
key: "closeCashier",
|
708
|
+
value: function closeCashier() {
|
709
|
+
var _document$getElementB2;
|
749
710
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
750
|
-
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
751
711
|
this._performanceData = [];
|
752
712
|
this._isInitComponent = false;
|
753
|
-
(_document$
|
713
|
+
(_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
|
754
714
|
this.hideComponentAndCleanDom(immediately);
|
755
715
|
}
|
756
716
|
}, {
|
757
717
|
key: "hideComponentAndCleanDom",
|
758
718
|
value: function hideComponentAndCleanDom() {
|
759
|
-
var
|
719
|
+
var _this4 = this;
|
760
720
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
761
|
-
var container = document.getElementById(
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
container === null || container === void 0 ? void 0 : container.classList.add("".concat(componentContainerId, "-hidden-").concat(this.platform));
|
768
|
-
}
|
721
|
+
var container = document.getElementById('ams-component-container');
|
722
|
+
// size变化动画取消
|
723
|
+
container.style.transition = '';
|
724
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform));
|
725
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform, "-animation"));
|
726
|
+
container === null || container === void 0 ? void 0 : container.classList.add("ams-component-container-hidden-".concat(this.platform));
|
769
727
|
var removeMockupAndApp = function removeMockupAndApp() {
|
770
|
-
var _document$
|
728
|
+
var _document$getElementB3;
|
771
729
|
var body = document.getElementsByTagName('body')[0];
|
772
730
|
body.style.overflow = 'auto';
|
773
731
|
var mockup = document.getElementById(mockupId);
|
774
732
|
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
775
733
|
if (container) container.style.height = '';
|
776
|
-
(_document$
|
777
|
-
|
778
|
-
|
734
|
+
(_document$getElementB3 = document.getElementById('ams-component-container-mobile-animation-style')) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
|
735
|
+
_this4.removeRetentionPopup();
|
736
|
+
_this4.cleanApp();
|
779
737
|
};
|
780
738
|
if (immediately) removeMockupAndApp();else {
|
781
739
|
setTimeout(function () {
|
@@ -788,8 +746,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
788
746
|
value: function closeBtnFunc() {
|
789
747
|
// element && element.removeEventListener()
|
790
748
|
if (this._isRetention) this.showRetentionPopup();else {
|
791
|
-
this.
|
792
|
-
this.dispatchToSDK(EVENT.
|
749
|
+
this.closeCashier();
|
750
|
+
this.dispatchToSDK(EVENT.onClose.name, {});
|
793
751
|
}
|
794
752
|
}
|
795
753
|
|
@@ -797,51 +755,33 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
797
755
|
* @description create mount node
|
798
756
|
*/
|
799
757
|
}, {
|
800
|
-
key: "
|
801
|
-
value: function
|
802
|
-
if (document.getElementById(componentContainerId)) return;
|
758
|
+
key: "createMountElement",
|
759
|
+
value: function createMountElement() {
|
803
760
|
componentAddCSS();
|
804
|
-
addSetFontSizeEvent();
|
805
761
|
var amsComponentContainer = document.createElement('div');
|
806
|
-
amsComponentContainer.className = "
|
807
|
-
amsComponentContainer.id =
|
762
|
+
amsComponentContainer.className = "ams-component-container-hidden-".concat(this.platform);
|
763
|
+
amsComponentContainer.id = 'ams-component-container';
|
808
764
|
amsSetSize(null, amsComponentContainer);
|
809
765
|
document.body.appendChild(amsComponentContainer);
|
810
766
|
var amsComponentSection = document.createElement('div');
|
811
767
|
amsComponentSection.className = "ams-component-section-".concat(this.platform);
|
812
|
-
amsComponentSection.id =
|
768
|
+
amsComponentSection.id = this._selector.slice(1);
|
813
769
|
amsComponentContainer.appendChild(amsComponentSection);
|
814
770
|
this.createCloseBtn();
|
815
771
|
}
|
816
|
-
}, {
|
817
|
-
key: "createInlineBaseElement",
|
818
|
-
value: function createInlineBaseElement(renderParams) {
|
819
|
-
var _renderParams$appeara2;
|
820
|
-
var inlineBaseStyle = document.getElementById(inlineBaseStyleId);
|
821
|
-
if (!inlineBaseStyle) inlineComponentAddCss();
|
822
|
-
if (document.getElementById(componentContainerId)) return;
|
823
|
-
var amsComponentContainer = document.createElement('div');
|
824
|
-
amsComponentContainer.className = "".concat(componentContainerId, "-inline");
|
825
|
-
amsComponentContainer.id = componentContainerId;
|
826
|
-
var selectorDom = document.querySelector(this._selector);
|
827
|
-
if (selectorDom) selectorDom.appendChild(amsComponentContainer);
|
828
|
-
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
|
829
|
-
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
830
|
-
if (showLoading) showInlineLoading(amsComponentContainer, this.platform);
|
831
|
-
}
|
832
772
|
}, {
|
833
773
|
key: "createCloseBtn",
|
834
774
|
value: function createCloseBtn() {
|
835
|
-
var
|
836
|
-
var container = document.getElementById(
|
775
|
+
var _this5 = this;
|
776
|
+
var container = document.getElementById('ams-component-container');
|
837
777
|
// close btn
|
838
|
-
var closeBtnHTML = "<img class='
|
778
|
+
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
|
839
779
|
var closeBlock = document.createElement('div');
|
840
|
-
closeBlock.classList.add("
|
841
|
-
closeBlock.id =
|
780
|
+
closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
|
781
|
+
closeBlock.id = 'asm-component-section-close-block';
|
842
782
|
closeBlock.innerHTML = closeBtnHTML;
|
843
783
|
closeBlock.addEventListener(this._clickEventName, function () {
|
844
|
-
|
784
|
+
_this5.closeBtnFunc();
|
845
785
|
});
|
846
786
|
if (container) container.appendChild(closeBlock);
|
847
787
|
}
|
@@ -850,15 +790,15 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
850
790
|
value: function createRetentionPopup() {
|
851
791
|
// retention popup
|
852
792
|
var retentionPopup = document.createElement('div');
|
853
|
-
retentionPopup.id =
|
854
|
-
retentionPopup.classList.add("
|
855
|
-
retentionPopup.innerHTML = "\n <span id=\"
|
793
|
+
retentionPopup.id = 'ams-component-retention';
|
794
|
+
retentionPopup.classList.add("ams-component-retention-".concat(this.platform));
|
795
|
+
retentionPopup.innerHTML = "\n <span id=\"ams-component-retention-title\" class=\"ams-component-retention-title-".concat(this.platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"ams-component-retention-sub-title\"\n class=\"ams-component-retention-sub-title-").concat(this.platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"ams-component-retention-btn-block-").concat(this.platform, "\">\n <div id=\"ams-component-retention-remain\" class=\"ams-component-retention-remain-").concat(this.platform, "\">\n Continue Payment\n </div>\n <div id=\"ams-component-retention-leave\" class=\"ams-component-retention-leave-").concat(this.platform, "\">\n Leave\n </div>\n </div>");
|
856
796
|
document.body.appendChild(retentionPopup);
|
857
|
-
var remainBtn = document.getElementById(
|
797
|
+
var remainBtn = document.getElementById('ams-component-retention-remain');
|
858
798
|
if (remainBtn) {
|
859
799
|
remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
|
860
800
|
}
|
861
|
-
var leaveBtn = document.getElementById(
|
801
|
+
var leaveBtn = document.getElementById('ams-component-retention-leave');
|
862
802
|
if (leaveBtn) {
|
863
803
|
leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
|
864
804
|
}
|
@@ -866,47 +806,47 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
866
806
|
}, {
|
867
807
|
key: "retentionPopupLeaveFunc",
|
868
808
|
value: function retentionPopupLeaveFunc() {
|
869
|
-
this.dispatchToSDK(EVENT.
|
809
|
+
this.dispatchToSDK(EVENT.onClose.name, {});
|
870
810
|
this.hideRetentionPopup();
|
871
|
-
this.
|
811
|
+
this.closeCashier();
|
872
812
|
}
|
873
813
|
}, {
|
874
814
|
key: "removeRetentionPopup",
|
875
815
|
value: function removeRetentionPopup() {
|
876
|
-
var _document$
|
877
|
-
var remainBtn = document.getElementById(
|
816
|
+
var _document$getElementB4;
|
817
|
+
var remainBtn = document.getElementById('ams-component-retention-remain');
|
878
818
|
if (remainBtn) {
|
879
819
|
remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
|
880
820
|
}
|
881
|
-
var leaveBtn = document.getElementById(
|
821
|
+
var leaveBtn = document.getElementById('ams-component-retention-leave');
|
882
822
|
if (leaveBtn) {
|
883
823
|
leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
|
884
824
|
}
|
885
|
-
(_document$
|
825
|
+
(_document$getElementB4 = document.getElementById('ams-component-retention')) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
886
826
|
}
|
887
827
|
}, {
|
888
828
|
key: "showRetentionPopup",
|
889
829
|
value: function showRetentionPopup() {
|
890
|
-
var retentionPopup = document.getElementById(
|
891
|
-
var container = document.getElementById(
|
830
|
+
var retentionPopup = document.getElementById('ams-component-retention');
|
831
|
+
var container = document.getElementById('ams-component-container');
|
892
832
|
if (retentionPopup) {
|
893
|
-
container === null || container === void 0 ? void 0 : container.classList.add(
|
894
|
-
retentionPopup.classList.remove(
|
895
|
-
retentionPopup.classList.add(
|
833
|
+
container === null || container === void 0 ? void 0 : container.classList.add('ams-component-container-opacity');
|
834
|
+
retentionPopup.classList.remove('ams-component-retention-hidden');
|
835
|
+
retentionPopup.classList.add('ams-component-retention-show');
|
896
836
|
}
|
897
837
|
}
|
898
838
|
}, {
|
899
839
|
key: "hideRetentionPopup",
|
900
840
|
value: function hideRetentionPopup() {
|
901
|
-
var retentionPopup = document.getElementById(
|
902
|
-
var container = document.getElementById(
|
841
|
+
var retentionPopup = document.getElementById('ams-component-retention');
|
842
|
+
var container = document.getElementById('ams-component-container');
|
903
843
|
if (retentionPopup) {
|
904
|
-
retentionPopup.classList.remove(
|
905
|
-
retentionPopup.classList.add(
|
844
|
+
retentionPopup.classList.remove('ams-component-retention-show');
|
845
|
+
retentionPopup.classList.add('ams-component-retention-hidden');
|
906
846
|
setTimeout(function () {
|
907
|
-
retentionPopup.classList.remove(
|
908
|
-
container === null || container === void 0 ? void 0 : container.classList.remove(
|
909
|
-
},
|
847
|
+
retentionPopup.classList.remove('ams-component-retention-hidden');
|
848
|
+
container === null || container === void 0 ? void 0 : container.classList.remove('ams-component-container-opacity');
|
849
|
+
}, 250);
|
910
850
|
}
|
911
851
|
}
|
912
852
|
/**
|
@@ -949,6 +889,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
949
889
|
form.setAttribute('action', attributes.action);
|
950
890
|
form.setAttribute('method', 'post');
|
951
891
|
body.appendChild(form);
|
892
|
+
this.closeCashier(true);
|
952
893
|
setTimeout(function () {
|
953
894
|
form.submit();
|
954
895
|
}, 0);
|