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