@alipay/ams-checkout 0.0.1744283958-dev.9 → 0.0.1745390310-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.
Files changed (64) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/component.inline.style.js +1 -1
  3. package/esm/component/popupWindow.style.js +1 -4
  4. package/esm/config/index.d.ts +7 -7
  5. package/esm/config/index.js +7 -7
  6. package/esm/constant/index.d.ts +0 -9
  7. package/esm/constant/index.js +0 -9
  8. package/esm/core/component/ckp/index.d.ts +26 -6
  9. package/esm/core/component/ckp/index.js +357 -25
  10. package/esm/core/component/ckp/interface.d.ts +540 -0
  11. package/esm/core/component/ckp/interface.js +233 -0
  12. package/esm/core/component/element/index.d.ts +46 -8
  13. package/esm/core/component/element/index.js +922 -28
  14. package/esm/core/component/element/mock.d.ts +0 -2
  15. package/esm/core/component/element/mock.js +0 -360
  16. package/esm/core/component/element/type.d.ts +1 -42
  17. package/esm/core/component/index.d.ts +1 -5
  18. package/esm/core/component/index.js +2 -1
  19. package/esm/foundation/core/index.d.ts +1 -6
  20. package/esm/foundation/core/index.js +35 -70
  21. package/esm/foundation/index.d.ts +0 -14
  22. package/esm/foundation/index.js +2 -13
  23. package/esm/foundation/service/container/index.d.ts +3 -6
  24. package/esm/foundation/service/container/index.js +16 -43
  25. package/esm/foundation/service/container/popup.d.ts +1 -1
  26. package/esm/foundation/service/event-center.js +0 -1
  27. package/esm/index.js +0 -1
  28. package/esm/plugin/component/cashierApp.d.ts +1 -1
  29. package/esm/plugin/component/index.js +1 -1
  30. package/esm/types/index.d.ts +1 -1
  31. package/esm/types/index.js +1 -1
  32. package/package.json +1 -1
  33. package/esm/core/component/element/elementContainerService/containerService.d.ts +0 -33
  34. package/esm/core/component/element/elementContainerService/containerService.js +0 -122
  35. package/esm/core/component/element/elementContainerService/index.d.ts +0 -20
  36. package/esm/core/component/element/elementContainerService/index.js +0 -63
  37. package/esm/core/component/element/elementController/index.d.ts +0 -25
  38. package/esm/core/component/element/elementController/index.js +0 -448
  39. package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +0 -20
  40. package/esm/core/component/element/elementProcessor/addressProcessor.js +0 -145
  41. package/esm/core/component/element/elementProcessor/authProcessor.d.ts +0 -20
  42. package/esm/core/component/element/elementProcessor/authProcessor.js +0 -125
  43. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +0 -38
  44. package/esm/core/component/element/elementProcessor/baseElementProcessor.js +0 -85
  45. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +0 -20
  46. package/esm/core/component/element/elementProcessor/paymentProcessor.js +0 -372
  47. package/esm/core/component/element/util.d.ts +0 -60
  48. package/esm/core/component/element/util.js +0 -451
  49. package/esm/core/component/oldElement/index.d.ts +0 -59
  50. package/esm/core/component/oldElement/index.js +0 -956
  51. package/esm/core/component/oldElement/mock.d.ts +0 -6
  52. package/esm/core/component/oldElement/mock.js +0 -567
  53. package/esm/core/component/oldElement/type.d.ts +0 -351
  54. package/esm/core/component/oldElement/type.js +0 -81
  55. package/esm/foundation/product-processor/element/index.d.ts +0 -7
  56. package/esm/foundation/product-processor/element/index.js +0 -24
  57. /package/esm/core/component/{oldElement → element}/components/address.d.ts +0 -0
  58. /package/esm/core/component/{oldElement → element}/components/address.js +0 -0
  59. /package/esm/core/component/{oldElement → element}/components/auth.d.ts +0 -0
  60. /package/esm/core/component/{oldElement → element}/components/auth.js +0 -0
  61. /package/esm/core/component/{oldElement → element}/components/payment.d.ts +0 -0
  62. /package/esm/core/component/{oldElement → element}/components/payment.js +0 -0
  63. /package/esm/core/component/{oldElement → element}/utils.d.ts +0 -0
  64. /package/esm/core/component/{oldElement → element}/utils.js +0 -0
@@ -1,448 +0,0 @@
1
- var _excluded = ["type"];
2
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
- 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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
12
- 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); } }
13
- 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); }); }; }
14
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
- 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); } }
18
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
21
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
22
- import { EVENT } from "../../../../constant";
23
- import AddressProcessor from "../../../../core/component/element/elementProcessor/addressProcessor";
24
- import AuthProcessor from "../../../../core/component/element/elementProcessor/authProcessor";
25
- import PaymentProcessor from "../../../../core/component/element/elementProcessor/paymentProcessor";
26
- import { AntomSDKCore } from "../../../../foundation/core";
27
- import { ElementProcessor } from "../../../../foundation/product-processor/element";
28
- import { destroyModal } from "../../../../plugin/component/popupWindow.style";
29
- import { ProductSceneEnum } from "../../../../types";
30
- import { ElementContainerService } from "../elementContainerService"; // 引入 ElementContainerService
31
- import { IContainerStatus } from "../elementContainerService/containerService";
32
- import { oneAccountUpdate, sdkActionUpdate } from "../mock";
33
- import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode } from "../type";
34
- import { checkCanMount, checkCanUpdate, handleRedirect, showToast } from "../util";
35
- var TIMEOUT_DURATION = 10000;
36
- var ElementController = /*#__PURE__*/function () {
37
- // 新增变量
38
-
39
- function ElementController(options) {
40
- _classCallCheck(this, ElementController);
41
- _defineProperty(this, "options", void 0);
42
- _defineProperty(this, "elementContainer", void 0);
43
- _defineProperty(this, "serviceMap", void 0);
44
- _defineProperty(this, "loading", void 0);
45
- _defineProperty(this, "elementProcessors", void 0);
46
- _defineProperty(this, "initTimeout", void 0);
47
- _defineProperty(this, "elementContainerService", void 0);
48
- _defineProperty(this, "onValidateFunc", function (event, target, params) {
49
- return new Promise(function (resolve) {
50
- event.emitAndListen({
51
- event: ElementPaymentEvent.VALIDATE,
52
- data: {
53
- params: _objectSpread({}, params),
54
- target: target,
55
- source: ElementPaymentMethod.CONTAINER_ELEMENT
56
- }
57
- }, function (result) {
58
- resolve(result);
59
- });
60
- });
61
- });
62
- this.options = options;
63
- this.elementContainer = new AntomSDKCore();
64
- this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor());
65
- this.elementContainer.init(this.options, ProductSceneEnum.ELEMENT_PAYMENT);
66
- this.initService();
67
- this.elementContainerService = new ElementContainerService({
68
- instanceId: this.elementContainer.getInstanceId()
69
- });
70
- this.elementContainer.setStatus(IContainerStatus.READY);
71
- }
72
- _createClass(ElementController, [{
73
- key: "initService",
74
- value: function initService() {
75
- this.serviceMap = {
76
- Log: this.elementContainer.getServiceProvider().getService('Log'),
77
- EventCenter: this.elementContainer.getServiceProvider().getService('EventCenter'),
78
- Requester: this.elementContainer.getServiceProvider().getService('Requester')
79
- };
80
- }
81
- }, {
82
- key: "initElementProcessors",
83
- value: function initElementProcessors(elementType) {
84
- var processorMap = {
85
- auth: new AuthProcessor(this.options),
86
- address: new AddressProcessor(this.options),
87
- payment: new PaymentProcessor(this.options)
88
- };
89
- this.elementProcessors = _objectSpread(_objectSpread({}, this.elementProcessors), {}, _defineProperty({}, elementType, processorMap[elementType]));
90
- this.elementProcessors[elementType].registerElementContainer(this.elementContainer);
91
- }
92
- }, {
93
- key: "onEventCallback",
94
- value: function onEventCallback(_ref) {
95
- var code = _ref.code,
96
- message = _ref.message;
97
- this.options.onEventCallback({
98
- code: code,
99
- message: message
100
- });
101
- }
102
- }, {
103
- key: "mount",
104
- value: function mount(renderOptions, sdkSelector, cashier) {
105
- var _this = this;
106
- return new Promise(function (resolve) {
107
- var _checkCanMount = checkCanMount({
108
- sdkSelector: sdkSelector,
109
- status: _this.elementContainer.getStatus(),
110
- containerService: _this.elementContainerService.getContainerService(renderOptions.type)
111
- }),
112
- success = _checkCanMount.success,
113
- errorMsg = _checkCanMount.errorMsg;
114
- if (!success) {
115
- _this.onEventCallback({
116
- code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
117
- message: errorMsg
118
- });
119
- resolve({
120
- success: false
121
- });
122
- return;
123
- }
124
- clearTimeout(_this.initTimeout);
125
- _this.initTimeout = null;
126
- _this.initTimeout = setTimeout(function () {
127
- clearTimeout(_this.initTimeout);
128
- _this.initTimeout = null;
129
- _this.changeLoading(false);
130
- _this.elementContainer.setStatus(IContainerStatus.READY);
131
- _this.elementContainerService.getContainerServices().forEach(function (value) {
132
- value.getContainerElement().remove();
133
- });
134
- _this.elementContainerService.destroy();
135
- }, TIMEOUT_DURATION);
136
- _this.changeLoading(true);
137
- var startBizFlowData = {
138
- paymentSession: _this.options.sessionData,
139
- displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
140
- appendAliasContainerId: true
141
- })
142
- };
143
- if (cashier && renderOptions.sessionData) {
144
- startBizFlowData.paymentSession = renderOptions.sessionData;
145
- }
146
- _this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
147
- _this.onEventCallback({
148
- code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
149
- message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
150
- });
151
- _this.changeLoading(false);
152
- return;
153
- });
154
- _this.initElementProcessors(renderOptions.type);
155
- _this.elementContainerService.mount({
156
- type: renderOptions.type,
157
- selector: sdkSelector,
158
- processor: _this.elementProcessors[renderOptions.type],
159
- options: renderOptions
160
- });
161
- _this.elementProcessors[renderOptions.type].registerEventCenter(_this.elementContainerService.getEventService(renderOptions.type));
162
- _this.elementProcessors[renderOptions.type].beforeMount();
163
- _this.sendRequestAndWaitWebLaunch(renderOptions);
164
- function readyCallback(payload) {
165
- var _this2 = this;
166
- var resultData = _objectSpread({
167
- getValue: this === null || this === void 0 ? void 0 : this.elementProcessors[renderOptions.type].getValue.bind(this === null || this === void 0 ? void 0 : this.elementProcessors[renderOptions.type]),
168
- on: function on(event, callback) {
169
- _this2 === null || _this2 === void 0 || _this2.elementProcessors[renderOptions.type].registerEventListener(event, callback);
170
- }
171
- }, payload);
172
- resolve(resultData);
173
- }
174
- _this.addEventListener(readyCallback);
175
- _this.serviceMap.EventCenter.addIFrame(_this.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
176
- });
177
- }
178
- }, {
179
- key: "submitPayment",
180
- value: function submitPayment() {
181
- var _this3 = this;
182
- this.changeLoading(true);
183
- new Promise( /*#__PURE__*/function () {
184
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
185
- var params, _this3$elementProcess, _result$data, _result$data2, result, _this3$elementProcess2, _result$data3, _result$data4, _result, _this3$elementProcess3;
186
- return _regeneratorRuntime().wrap(function _callee$(_context) {
187
- while (1) switch (_context.prev = _context.next) {
188
- case 0:
189
- params = {};
190
- if (!_this3.elementProcessors[ElementType.auth]) {
191
- _context.next = 8;
192
- break;
193
- }
194
- _context.next = 4;
195
- return _this3.onValidateFunc((_this3$elementProcess = _this3.elementProcessors[ElementType.auth]) === null || _this3$elementProcess === void 0 ? void 0 : _this3$elementProcess.eventCenter, ElementPaymentMethod.AUTH_ELEMENT);
196
- case 4:
197
- result = _context.sent;
198
- params.accountInfo = (_result$data = result.data) === null || _result$data === void 0 || (_result$data = _result$data.data) === null || _result$data === void 0 ? void 0 : _result$data.accountInfo;
199
- if (result !== null && result !== void 0 && (_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.success) {
200
- _context.next = 8;
201
- break;
202
- }
203
- return _context.abrupt("return", resolve(undefined));
204
- case 8:
205
- if (!_this3.elementProcessors[ElementType.address]) {
206
- _context.next = 15;
207
- break;
208
- }
209
- _context.next = 11;
210
- return _this3.onValidateFunc((_this3$elementProcess2 = _this3.elementProcessors[ElementType.address]) === null || _this3$elementProcess2 === void 0 ? void 0 : _this3$elementProcess2.eventCenter, ElementPaymentMethod.ADDRESS_ELEMENT);
211
- case 11:
212
- _result = _context.sent;
213
- params.shipping = (_result$data3 = _result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
214
- if (_result !== null && _result !== void 0 && (_result$data4 = _result.data) !== null && _result$data4 !== void 0 && _result$data4.success) {
215
- _context.next = 15;
216
- break;
217
- }
218
- return _context.abrupt("return", resolve(undefined));
219
- case 15:
220
- if (!_this3.elementProcessors[ElementType.payment]) {
221
- _context.next = 25;
222
- break;
223
- }
224
- _context.prev = 16;
225
- _context.next = 19;
226
- return _this3.onValidateFunc((_this3$elementProcess3 = _this3.elementProcessors[ElementType.payment]) === null || _this3$elementProcess3 === void 0 ? void 0 : _this3$elementProcess3.eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
227
- case 19:
228
- return _context.abrupt("return", resolve(undefined));
229
- case 22:
230
- _context.prev = 22;
231
- _context.t0 = _context["catch"](16);
232
- return _context.abrupt("return", resolve(undefined));
233
- case 25:
234
- resolve(params);
235
- case 26:
236
- case "end":
237
- return _context.stop();
238
- }
239
- }, _callee, null, [[16, 22]]);
240
- }));
241
- return function (_x) {
242
- return _ref2.apply(this, arguments);
243
- };
244
- }()).then(function () {
245
- _this3.changeLoading(false);
246
- }, function () {
247
- _this3.changeLoading(false);
248
- });
249
- }
250
- }, {
251
- key: "changeLoading",
252
- value: function changeLoading(loading) {
253
- if (loading) {
254
- var _this$options$loading;
255
- if ((_this$options$loading = this.options.loading) !== null && _this$options$loading !== void 0 && _this$options$loading.onStartLoading && !this.loading) {
256
- var _this$options$loading2, _this$options$loading3;
257
- this.loading = true;
258
- (_this$options$loading2 = this.options.loading) === null || _this$options$loading2 === void 0 || (_this$options$loading3 = _this$options$loading2.onStartLoading) === null || _this$options$loading3 === void 0 || _this$options$loading3.call(_this$options$loading2);
259
- }
260
- } else {
261
- var _this$options$loading4;
262
- if ((_this$options$loading4 = this.options.loading) !== null && _this$options$loading4 !== void 0 && _this$options$loading4.onEndLoading && this.loading) {
263
- var _this$options$loading5, _this$options$loading6;
264
- (_this$options$loading5 = this.options.loading) === null || _this$options$loading5 === void 0 || (_this$options$loading6 = _this$options$loading5.onEndLoading) === null || _this$options$loading6 === void 0 || _this$options$loading6.call(_this$options$loading5);
265
- }
266
- this.loading = false;
267
- }
268
- }
269
- }, {
270
- key: "addEventListener",
271
- value: function addEventListener(renderCallback) {
272
- var _this4 = this;
273
- this.serviceMap.EventCenter.listen(ElementPaymentEvent.CALLBACK, function (data) {
274
- if (_this4.elementProcessors[data.source] && _this4.elementProcessors[data.source].eventListener[data.event]) {
275
- var _this4$elementProcess, _this4$elementProcess2;
276
- (_this4$elementProcess = (_this4$elementProcess2 = _this4.elementProcessors[data.source].eventListener)[data.event]) === null || _this4$elementProcess === void 0 || _this4$elementProcess.call(_this4$elementProcess2, data.data);
277
- }
278
- });
279
- this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
280
- clearTimeout(_this4.initTimeout);
281
- _this4.initTimeout = null;
282
- if (_this4.elementContainerService.getContainerService(data.source)) {
283
- renderCallback({
284
- success: true
285
- });
286
- _this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
287
- }
288
- _this4.changeLoading(false);
289
- // 遍历containerService中的所有container查看是否所有状态都是IN_BIZ_FLOW
290
- // const allContainersInBizFlow = Object.values(this.elementContainerService.getContainerServices()).every(
291
- // (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
292
- // );
293
- // if (allContainersInBizFlow) {
294
- // this.elementContainer.setStatus(IContainerStatus.IN_BIZ_FLOW);
295
- // }
296
- });
297
- this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
298
- handleRedirect(data);
299
- });
300
- this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
301
- _this4.elementContainer.setStatus(IContainerStatus.READY);
302
- _this4.destroyHandle();
303
- });
304
- this.serviceMap.EventCenter.listen(EVENT.webAppReady.name, function (data) {
305
- clearTimeout(_this4.initTimeout);
306
- if (_this4.elementContainerService.getContainerService(data.source)) {
307
- renderCallback({
308
- success: true
309
- });
310
- _this4.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
311
- }
312
- _this4.changeLoading(false);
313
- });
314
- this.serviceMap.EventCenter.listen(EVENT.showToast.name, function (data) {
315
- showToast(data);
316
- });
317
- }
318
- }, {
319
- key: "sendRequestAndWaitWebLaunch",
320
- value: function sendRequestAndWaitWebLaunch(renderOptions) {
321
- var _this5 = this;
322
- var type = renderOptions.type,
323
- options = _objectWithoutProperties(renderOptions, _excluded);
324
- var webLaunchPromise = this.elementContainerService.getContainerService(type).createWebLaunchPromise();
325
- Promise.all([webLaunchPromise, this.elementProcessors[type].obtainData()]).then(function (_ref3) {
326
- var _this5$elementContain;
327
- var _ref4 = _slicedToArray(_ref3, 2),
328
- _webLaunchRes = _ref4[0],
329
- _obtainDataRes = _ref4[1];
330
- (_this5$elementContain = _this5.elementContainerService.getContainerService(type)) === null || _this5$elementContain === void 0 || _this5$elementContain.switchContainerStatus(IContainerStatus.READY);
331
- var allReady = true;
332
- _this5.elementContainerService.getContainerServices().forEach(function (item) {
333
- if (!allReady) return;
334
- allReady = item.getContainerStatus() === IContainerStatus.READY;
335
- });
336
- if (allReady) {
337
- _this5.elementContainerService.getContainerServices().forEach(function (value, key) {
338
- _this5.sendReady(key, options);
339
- });
340
- }
341
- });
342
- }
343
- }, {
344
- key: "sendReady",
345
- value: function sendReady(type, options) {
346
- var _this$elementProcesso;
347
- var paymentResult = (_this$elementProcesso = this.elementProcessors[ElementType.payment]) === null || _this$elementProcesso === void 0 ? void 0 : _this$elementProcesso.getObtainDataRes();
348
- var paymentContext = this.elementContainer.getPaymentContext();
349
- var params = _objectSpread(_objectSpread({}, options), {}, {
350
- originActionQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originActionQueryResult,
351
- originOneAccountQueryResult: paymentResult === null || paymentResult === void 0 ? void 0 : paymentResult.originOneAccountQueryResult,
352
- paymentSessionData: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionId,
353
- sessionResult: (paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj) || {}
354
- });
355
- this.elementProcessors[type].onReady(params);
356
- }
357
- }, {
358
- key: "updatePayment",
359
- value: function () {
360
- var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(paymentSessionData) {
361
- var _this6 = this;
362
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
363
- while (1) switch (_context3.prev = _context3.next) {
364
- case 0:
365
- return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
366
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
367
- var prePaymentSessionData, data, LOCAL_MOCK;
368
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
369
- while (1) switch (_context2.prev = _context2.next) {
370
- case 0:
371
- if (checkCanUpdate({
372
- status: _this6.elementContainer.getStatus(),
373
- paymentContainerService: _this6.elementContainerService.getContainerService(ElementType.payment),
374
- newPaymentSessionData: paymentSessionData,
375
- oldPaymentSessionData: _this6.options.sessionData
376
- })) {
377
- _context2.next = 2;
378
- break;
379
- }
380
- return _context2.abrupt("return", resolve(false));
381
- case 2:
382
- prePaymentSessionData = _this6.elementContainer.getPaymentContext().paymentSession;
383
- _this6.elementContainer.updatePaymentSessionData(paymentSessionData);
384
- // 1、数据获取
385
- _context2.next = 6;
386
- return _this6.elementProcessors[ElementType.payment].obtainData();
387
- case 6:
388
- data = _context2.sent;
389
- LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
390
- Object.values(_this6.elementProcessors).forEach(function (processor) {
391
- processor.update({
392
- data: {
393
- originActionQueryResult: LOCAL_MOCK ? sdkActionUpdate : data.originActionQueryResult,
394
- originOneAccountQueryResult: LOCAL_MOCK ? oneAccountUpdate : data.originOneAccountQueryResult
395
- },
396
- paymentSessionData: paymentSessionData
397
- });
398
- });
399
- // 3、返回更新结果
400
- _this6.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
401
- // 若更新不成功,还原core.paymentContext信息
402
- if (!data.success) {
403
- _this6.elementContainer.updatePaymentSessionData(prePaymentSessionData);
404
- }
405
- return resolve(data.success || false);
406
- });
407
- case 10:
408
- case "end":
409
- return _context2.stop();
410
- }
411
- }, _callee2);
412
- }));
413
- return function (_x3) {
414
- return _ref5.apply(this, arguments);
415
- };
416
- }()));
417
- case 1:
418
- case "end":
419
- return _context3.stop();
420
- }
421
- }, _callee3);
422
- }));
423
- function updatePayment(_x2) {
424
- return _updatePayment.apply(this, arguments);
425
- }
426
- return updatePayment;
427
- }()
428
- }, {
429
- key: "destroyHandle",
430
- value: function destroyHandle() {
431
- this.elementContainer.destroy();
432
- this.elementContainerService.destroy();
433
- this.serviceMap.EventCenter.cleanIFrames();
434
- // popup未注册会报错,但element不需要感知popup是否被注册
435
- try {
436
- destroyModal(); // 关闭popup弹窗
437
- } catch (error) {}
438
- }
439
- }, {
440
- key: "destroy",
441
- value: function destroy() {
442
- this.destroyHandle();
443
- this.elementContainer.setStatus(IContainerStatus.DESTROYED);
444
- }
445
- }]);
446
- return ElementController;
447
- }();
448
- export default ElementController;
@@ -1,20 +0,0 @@
1
- import BaseElementProcessor from './baseElementProcessor';
2
- declare class AddressProcessor extends BaseElementProcessor {
3
- onReady(extraParam: {
4
- [key: string]: any;
5
- }): void;
6
- parameterInitAndCheck(): void;
7
- beforeMount(): void;
8
- preload(): void;
9
- generateIframeSrc({ link, instanceId }: {
10
- link: any;
11
- instanceId: any;
12
- }): string;
13
- obtainData(): any;
14
- getValue(hasValidate?: boolean): any;
15
- update({ data, paymentSessionData }: {
16
- data: any;
17
- paymentSessionData: any;
18
- }): void;
19
- }
20
- export default AddressProcessor;
@@ -1,145 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
- 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); } }
10
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
14
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
17
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
19
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
- import { parseSessionData } from "../..";
21
- import PackageJson from "../../../../../package.json";
22
- import { generateIframeSrc as _generateIframeSrc } from "../util";
23
- import BaseElementProcessor from "./baseElementProcessor";
24
- var AddressProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
25
- _inherits(AddressProcessor, _BaseElementProcessor);
26
- var _super = _createSuper(AddressProcessor);
27
- function AddressProcessor() {
28
- _classCallCheck(this, AddressProcessor);
29
- return _super.apply(this, arguments);
30
- }
31
- _createClass(AddressProcessor, [{
32
- key: "onReady",
33
- value: function onReady(extraParam) {
34
- var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _extraParam$originOne;
35
- this.eventCenter.dispatchToApp({
36
- event: 'renderComponent',
37
- data: {
38
- params: {
39
- heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
40
- paymentSessionData: (_this$elementContaine = this.elementContainer.getPaymentContext()) === null || _this$elementContaine === void 0 ? void 0 : _this$elementContaine.paymentSessionId,
41
- queryResult: extraParam.queryResult,
42
- envInfo: {
43
- screenHeight: screen.height,
44
- screenWidth: screen.width
45
- },
46
- appearance: (_this$elementContaine2 = this.elementContainer.getPaymentContext()) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.displayInfo.appearance,
47
- sessionResult: (_this$elementContaine3 = this.elementContainer.getPaymentContext()) === null || _this$elementContaine3 === void 0 ? void 0 : _this$elementContaine3.paymentSessionObj,
48
- prefillValue: (extraParam === null || extraParam === void 0 || (_extraParam$originOne = extraParam.originOneAccountQueryResult) === null || _extraParam$originOne === void 0 ? void 0 : _extraParam$originOne.shippings) || []
49
- },
50
- target: 'ADDRESS_ELEMENT'
51
- }
52
- });
53
- }
54
- }, {
55
- key: "parameterInitAndCheck",
56
- value: function parameterInitAndCheck() {
57
- // 实现 parameterInitAndCheck 方法
58
- }
59
- }, {
60
- key: "beforeMount",
61
- value: function beforeMount() {
62
- // 实现 beforeMount 方法
63
- }
64
- }, {
65
- key: "preload",
66
- value: function preload() {
67
- // 实现 preload 方法
68
- }
69
- }, {
70
- key: "generateIframeSrc",
71
- value: function generateIframeSrc(_ref) {
72
- var link = _ref.link,
73
- instanceId = _ref.instanceId;
74
- this.instanceId = instanceId;
75
- var _ref2 = this.elementContainer.getPaymentContext() || {},
76
- paymentSession = _ref2.paymentSession,
77
- paymentSessionObj = _ref2.paymentSessionObj,
78
- sdkMetaData = _ref2.sdkMetaData;
79
- var _this$options = this.options,
80
- environment = _this$options.env.environment,
81
- analytics = _this$options.analytics,
82
- locale = _this$options.locale;
83
- var version = PackageJson.version;
84
- var pageUrl = "/element-address/".concat(version, "/pages/address/index.html");
85
- return _generateIframeSrc({
86
- paymentSession: paymentSession,
87
- paymentSessionObj: paymentSessionObj,
88
- environment: environment,
89
- analytics: analytics,
90
- locale: locale,
91
- link: link,
92
- appVersion: sdkMetaData === null || sdkMetaData === void 0 ? void 0 : sdkMetaData.webAppVersion,
93
- pageUrl: pageUrl,
94
- instanceId: instanceId
95
- });
96
- }
97
- }, {
98
- key: "obtainData",
99
- value: function obtainData() {
100
- // 实现 obtainData 方法
101
- this.obtainDataRes = {};
102
- return {};
103
- }
104
- }, {
105
- key: "getValue",
106
- value: function getValue(hasValidate) {
107
- var _this = this;
108
- return new Promise(function (resolve, reject) {
109
- try {
110
- _this.eventCenter.dispatchToApp({
111
- event: 'getValue',
112
- data: hasValidate
113
- });
114
- _this.eventCenter.listen('onAddressResult', function (res) {
115
- resolve(res);
116
- });
117
- } catch (error) {
118
- reject(error);
119
- }
120
- });
121
- }
122
- }, {
123
- key: "update",
124
- value: function update(_ref3) {
125
- var data = _ref3.data,
126
- paymentSessionData = _ref3.paymentSessionData;
127
- var _parseSessionData = parseSessionData(paymentSessionData),
128
- _parseSessionData2 = _slicedToArray(_parseSessionData, 2),
129
- parseData = _parseSessionData2[0],
130
- sessionData = _parseSessionData2[1];
131
- // 实现 update 方法的具体逻辑
132
- this.eventCenter.dispatchToApp({
133
- event: 'updatePayment',
134
- data: {
135
- paymentSessionData: paymentSessionData,
136
- data: data,
137
- sessionResult: parseData,
138
- sessionData: sessionData
139
- }
140
- });
141
- }
142
- }]);
143
- return AddressProcessor;
144
- }(BaseElementProcessor);
145
- export default AddressProcessor;
@@ -1,20 +0,0 @@
1
- import BaseElementProcessor from './baseElementProcessor';
2
- declare class AuthProcessor extends BaseElementProcessor {
3
- onReady(extraParam: {
4
- [key: string]: any;
5
- }): void;
6
- parameterInitAndCheck(): void;
7
- beforeMount(): void;
8
- preload(): void;
9
- generateIframeSrc({ link, instanceId }: {
10
- link: any;
11
- instanceId: any;
12
- }): string;
13
- obtainData(): any;
14
- getValue(): any;
15
- update({ data, paymentSessionData }: {
16
- data: any;
17
- paymentSessionData: any;
18
- }): void;
19
- }
20
- export default AuthProcessor;