@alipay/ams-checkout 0.0.1743078169-dev.6 → 0.0.1744265398-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/component.inline.style.js +1 -1
- package/esm/component/popupWindow.style.js +1 -4
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +0 -3
- package/esm/constant/index.js +0 -3
- package/esm/core/component/element/index.d.ts +46 -8
- package/esm/core/component/element/index.js +922 -28
- package/esm/core/component/element/type.d.ts +1 -29
- package/esm/core/component/index.d.ts +1 -5
- package/esm/core/component/index.js +2 -1
- package/esm/foundation/core/index.d.ts +1 -6
- package/esm/foundation/core/index.js +34 -68
- package/esm/foundation/index.d.ts +0 -7
- package/esm/foundation/index.js +2 -10
- package/esm/foundation/service/container/index.d.ts +3 -6
- package/esm/foundation/service/container/index.js +14 -34
- package/esm/foundation/service/container/popup.d.ts +1 -1
- package/esm/foundation/service/event-center.js +0 -1
- package/esm/index.js +0 -1
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/index.js +1 -1
- package/esm/types/index.d.ts +1 -1
- package/esm/types/index.js +1 -1
- package/package.json +1 -1
- package/esm/core/component/element/elementContainerService/containerService.d.ts +0 -30
- package/esm/core/component/element/elementContainerService/containerService.js +0 -107
- package/esm/core/component/element/elementContainerService/index.d.ts +0 -19
- package/esm/core/component/element/elementContainerService/index.js +0 -55
- package/esm/core/component/element/elementController/index.d.ts +0 -22
- package/esm/core/component/element/elementController/index.js +0 -370
- package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +0 -17
- package/esm/core/component/element/elementProcessor/addressProcessor.js +0 -122
- package/esm/core/component/element/elementProcessor/authProcessor.d.ts +0 -14
- package/esm/core/component/element/elementProcessor/authProcessor.js +0 -70
- package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +0 -36
- package/esm/core/component/element/elementProcessor/baseElementProcessor.js +0 -79
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +0 -20
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +0 -299
- package/esm/core/component/element/util.d.ts +0 -59
- package/esm/core/component/element/util.js +0 -327
- package/esm/core/component/oldElement/index.d.ts +0 -59
- package/esm/core/component/oldElement/index.js +0 -956
- package/esm/core/component/oldElement/type.d.ts +0 -351
- package/esm/core/component/oldElement/type.js +0 -81
- package/esm/foundation/product-processor/element/index.d.ts +0 -7
- package/esm/foundation/product-processor/element/index.js +0 -24
- /package/esm/core/component/{oldElement → element}/components/address.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/address.js +0 -0
- /package/esm/core/component/{oldElement → element}/components/auth.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/auth.js +0 -0
- /package/esm/core/component/{oldElement → element}/components/payment.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/payment.js +0 -0
- /package/esm/core/component/{oldElement → element}/mock.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/mock.js +0 -0
- /package/esm/core/component/{oldElement → element}/utils.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/utils.js +0 -0
@@ -1,107 +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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
|
-
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); } }
|
4
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
5
|
-
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; }
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
|
-
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); }
|
8
|
-
import { EVENT } from "../../../../constant";
|
9
|
-
import { ServiceProvider } from "./../../../../foundation/service";
|
10
|
-
import { DisplayTypeEnum, PlatformEnum, ProductSceneEnum } from "./../../../../types";
|
11
|
-
export var IContainerStatus = /*#__PURE__*/function (IContainerStatus) {
|
12
|
-
IContainerStatus["UNINIT"] = "UNINIT";
|
13
|
-
IContainerStatus["INITING"] = "INITING";
|
14
|
-
IContainerStatus["READY"] = "READY";
|
15
|
-
IContainerStatus["IN_BIZ_FLOW"] = "IN_BIZ_FLOW";
|
16
|
-
IContainerStatus["DESTROYED"] = "DESTROYED";
|
17
|
-
return IContainerStatus;
|
18
|
-
}({});
|
19
|
-
export var ContainerController = /*#__PURE__*/function () {
|
20
|
-
function ContainerController(_ref) {
|
21
|
-
var _options$debugProps;
|
22
|
-
var type = _ref.type,
|
23
|
-
instanceId = _ref.instanceId,
|
24
|
-
selector = _ref.selector,
|
25
|
-
processor = _ref.processor,
|
26
|
-
options = _ref.options;
|
27
|
-
_classCallCheck(this, ContainerController);
|
28
|
-
_defineProperty(this, "containerStatus", void 0);
|
29
|
-
_defineProperty(this, "instanceId", void 0);
|
30
|
-
_defineProperty(this, "containerService", void 0);
|
31
|
-
_defineProperty(this, "eventService", void 0);
|
32
|
-
_defineProperty(this, "_globalData", void 0);
|
33
|
-
this._globalData = new Map();
|
34
|
-
this.switchContainerStatus(IContainerStatus.INITING);
|
35
|
-
this.instanceId = "".concat(instanceId, "-").concat(type);
|
36
|
-
this.containerService = ServiceProvider.getInstance(this.instanceId).getService('Container');
|
37
|
-
ServiceProvider.getInstance(this.instanceId).init({}, {
|
38
|
-
productScene: ProductSceneEnum.ELEMENT_PAYMENT,
|
39
|
-
sdkVersion: '',
|
40
|
-
webAppVersion: ''
|
41
|
-
});
|
42
|
-
this.containerService.load({
|
43
|
-
type: DisplayTypeEnum.inline,
|
44
|
-
platform: PlatformEnum.desktop,
|
45
|
-
isRetention: false,
|
46
|
-
selector: selector,
|
47
|
-
appendAliasContainerId: true
|
48
|
-
}, processor.generateIframeSrc({
|
49
|
-
link: options === null || options === void 0 || (_options$debugProps = options.debugProps) === null || _options$debugProps === void 0 ? void 0 : _options$debugProps.localLink,
|
50
|
-
instanceId: this.instanceId
|
51
|
-
}));
|
52
|
-
this.eventService = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
53
|
-
this.addEventListener();
|
54
|
-
}
|
55
|
-
_createClass(ContainerController, [{
|
56
|
-
key: "addEventListener",
|
57
|
-
value: function addEventListener() {
|
58
|
-
var _this = this;
|
59
|
-
this.eventService.listen(EVENT.setGlobalData.name, function (result) {
|
60
|
-
_this._globalData.set(result === null || result === void 0 ? void 0 : result.dataKey, result === null || result === void 0 ? void 0 : result.data);
|
61
|
-
});
|
62
|
-
this.eventService.listen(EVENT.getGlobalData.name, function (data, result) {
|
63
|
-
var context = result.context;
|
64
|
-
if (context !== null && context !== void 0 && context.eventCallbackId) {
|
65
|
-
var _context$data;
|
66
|
-
var targetData = _this._globalData.get((_context$data = context.data) === null || _context$data === void 0 ? void 0 : _context$data.dataKey);
|
67
|
-
_this.eventService.dispatchToApp({
|
68
|
-
event: 'appEventCallback',
|
69
|
-
eventCallbackId: context === null || context === void 0 ? void 0 : context.eventCallbackId,
|
70
|
-
data: targetData
|
71
|
-
});
|
72
|
-
}
|
73
|
-
});
|
74
|
-
}
|
75
|
-
}, {
|
76
|
-
key: "createWebLaunchPromise",
|
77
|
-
value: function createWebLaunchPromise() {
|
78
|
-
var _this2 = this;
|
79
|
-
return new Promise(function (resolve) {
|
80
|
-
_this2.eventService.listen('onLaunch', function (res) {
|
81
|
-
resolve(res);
|
82
|
-
});
|
83
|
-
});
|
84
|
-
}
|
85
|
-
}, {
|
86
|
-
key: "switchContainerStatus",
|
87
|
-
value: function switchContainerStatus(status) {
|
88
|
-
this.containerStatus = status;
|
89
|
-
}
|
90
|
-
}, {
|
91
|
-
key: "getContainerStatus",
|
92
|
-
value: function getContainerStatus() {
|
93
|
-
return this.containerStatus;
|
94
|
-
}
|
95
|
-
}, {
|
96
|
-
key: "getEventService",
|
97
|
-
value: function getEventService() {
|
98
|
-
return this.eventService;
|
99
|
-
}
|
100
|
-
}, {
|
101
|
-
key: "getContainerService",
|
102
|
-
value: function getContainerService() {
|
103
|
-
return this.containerService;
|
104
|
-
}
|
105
|
-
}]);
|
106
|
-
return ContainerController;
|
107
|
-
}();
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { ElementType } from '../type';
|
2
|
-
import { ContainerController } from './containerService';
|
3
|
-
export declare class ElementContainerService {
|
4
|
-
private containerServices;
|
5
|
-
private instanceId;
|
6
|
-
constructor({ instanceId }: {
|
7
|
-
instanceId: any;
|
8
|
-
});
|
9
|
-
addContainerService(name: ElementType, service: ContainerController): void;
|
10
|
-
getContainerService(name: ElementType): ContainerController | undefined;
|
11
|
-
getContainerServices(): Map<ElementType, ContainerController>;
|
12
|
-
mount({ type, selector, processor, options }: {
|
13
|
-
type: any;
|
14
|
-
selector: any;
|
15
|
-
processor: any;
|
16
|
-
options: any;
|
17
|
-
}): void;
|
18
|
-
getEventService(name: ElementType): import("../../../../foundation/service/event-center").EventCenter;
|
19
|
-
}
|
@@ -1,55 +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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
|
-
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); } }
|
4
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
5
|
-
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; }
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
|
-
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); }
|
8
|
-
import { ContainerController } from "./containerService";
|
9
|
-
export var ElementContainerService = /*#__PURE__*/function () {
|
10
|
-
function ElementContainerService(_ref) {
|
11
|
-
var instanceId = _ref.instanceId;
|
12
|
-
_classCallCheck(this, ElementContainerService);
|
13
|
-
_defineProperty(this, "containerServices", void 0);
|
14
|
-
_defineProperty(this, "instanceId", void 0);
|
15
|
-
this.containerServices = new Map();
|
16
|
-
this.instanceId = instanceId;
|
17
|
-
}
|
18
|
-
_createClass(ElementContainerService, [{
|
19
|
-
key: "addContainerService",
|
20
|
-
value: function addContainerService(name, service) {
|
21
|
-
this.containerServices.set(name, service);
|
22
|
-
}
|
23
|
-
}, {
|
24
|
-
key: "getContainerService",
|
25
|
-
value: function getContainerService(name) {
|
26
|
-
return this.containerServices.get(name);
|
27
|
-
}
|
28
|
-
}, {
|
29
|
-
key: "getContainerServices",
|
30
|
-
value: function getContainerServices() {
|
31
|
-
return this.containerServices;
|
32
|
-
}
|
33
|
-
}, {
|
34
|
-
key: "mount",
|
35
|
-
value: function mount(_ref2) {
|
36
|
-
var type = _ref2.type,
|
37
|
-
selector = _ref2.selector,
|
38
|
-
processor = _ref2.processor,
|
39
|
-
options = _ref2.options;
|
40
|
-
this.addContainerService(type, new ContainerController({
|
41
|
-
type: type,
|
42
|
-
instanceId: this.instanceId,
|
43
|
-
selector: selector,
|
44
|
-
processor: processor,
|
45
|
-
options: options
|
46
|
-
}));
|
47
|
-
}
|
48
|
-
}, {
|
49
|
-
key: "getEventService",
|
50
|
-
value: function getEventService(name) {
|
51
|
-
return this.getContainerService(name).getEventService();
|
52
|
-
}
|
53
|
-
}]);
|
54
|
-
return ElementContainerService;
|
55
|
-
}();
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { AddressMountOptions, IElementOptions, LinkAuthMountOptions, PaymentMountOptions } from '../type';
|
2
|
-
declare class ElementController {
|
3
|
-
private options;
|
4
|
-
private elementContainer;
|
5
|
-
private serviceMap;
|
6
|
-
private loading;
|
7
|
-
private elementProcessors;
|
8
|
-
private elementContainerService;
|
9
|
-
constructor(options: IElementOptions);
|
10
|
-
private initService;
|
11
|
-
private initElementProcessors;
|
12
|
-
private onEventCallback;
|
13
|
-
mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string, cashier?: boolean): any;
|
14
|
-
private onValidateFunc;
|
15
|
-
submitPayment(): void;
|
16
|
-
private changeLoading;
|
17
|
-
private addEventListener;
|
18
|
-
private sendRequestAndWaitWebLaunch;
|
19
|
-
updatePayment(paymentSessionData: any): Promise<unknown>;
|
20
|
-
destroy(): void;
|
21
|
-
}
|
22
|
-
export default ElementController;
|
@@ -1,370 +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 { ElementPaymentEvent, ElementType, EventCallbackCode } from "../type";
|
33
|
-
import { checkCanMount, checkCanUpdate, handleRedirect } from "../util";
|
34
|
-
var ElementController = /*#__PURE__*/function () {
|
35
|
-
// 新增变量
|
36
|
-
|
37
|
-
function ElementController(options) {
|
38
|
-
_classCallCheck(this, ElementController);
|
39
|
-
_defineProperty(this, "options", void 0);
|
40
|
-
_defineProperty(this, "elementContainer", void 0);
|
41
|
-
_defineProperty(this, "serviceMap", void 0);
|
42
|
-
_defineProperty(this, "loading", void 0);
|
43
|
-
_defineProperty(this, "elementProcessors", void 0);
|
44
|
-
_defineProperty(this, "elementContainerService", void 0);
|
45
|
-
_defineProperty(this, "onValidateFunc", function (event, params) {
|
46
|
-
return new Promise(function (resolve) {
|
47
|
-
event.emitAndListen({
|
48
|
-
event: ElementPaymentEvent.VALIDATE,
|
49
|
-
data: {
|
50
|
-
params: _objectSpread({}, params)
|
51
|
-
}
|
52
|
-
}, function (result) {
|
53
|
-
resolve(result);
|
54
|
-
});
|
55
|
-
});
|
56
|
-
});
|
57
|
-
this.options = options;
|
58
|
-
this.elementContainer = new AntomSDKCore();
|
59
|
-
this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor());
|
60
|
-
this.elementContainer.init(this.options, ProductSceneEnum.ELEMENT_PAYMENT);
|
61
|
-
this.initService();
|
62
|
-
this.elementContainerService = new ElementContainerService({
|
63
|
-
instanceId: this.elementContainer.getInstanceId()
|
64
|
-
});
|
65
|
-
this.elementContainer.setStatus(IContainerStatus.READY);
|
66
|
-
}
|
67
|
-
_createClass(ElementController, [{
|
68
|
-
key: "initService",
|
69
|
-
value: function initService() {
|
70
|
-
this.serviceMap = {
|
71
|
-
Log: this.elementContainer.getServiceProvider().getService('Log'),
|
72
|
-
EventCenter: this.elementContainer.getServiceProvider().getService('EventCenter'),
|
73
|
-
Requester: this.elementContainer.getServiceProvider().getService('Requester')
|
74
|
-
};
|
75
|
-
}
|
76
|
-
}, {
|
77
|
-
key: "initElementProcessors",
|
78
|
-
value: function initElementProcessors(elementType) {
|
79
|
-
var processorMap = {
|
80
|
-
auth: new AuthProcessor(this.options),
|
81
|
-
address: new AddressProcessor(this.options),
|
82
|
-
payment: new PaymentProcessor(this.options)
|
83
|
-
};
|
84
|
-
this.elementProcessors = _objectSpread(_objectSpread({}, this.elementProcessors), {}, _defineProperty({}, elementType, processorMap[elementType]));
|
85
|
-
this.elementProcessors[elementType].registerElementContainer(this.elementContainer);
|
86
|
-
}
|
87
|
-
}, {
|
88
|
-
key: "onEventCallback",
|
89
|
-
value: function onEventCallback(_ref) {
|
90
|
-
var code = _ref.code,
|
91
|
-
message = _ref.message;
|
92
|
-
this.options.onEventCallback({
|
93
|
-
code: code,
|
94
|
-
message: message
|
95
|
-
});
|
96
|
-
}
|
97
|
-
}, {
|
98
|
-
key: "mount",
|
99
|
-
value: function mount(renderOptions, sdkSelector, cashier) {
|
100
|
-
var _this = this;
|
101
|
-
var _checkCanMount = checkCanMount({
|
102
|
-
sdkSelector: sdkSelector,
|
103
|
-
status: this.elementContainer.getStatus(),
|
104
|
-
containerService: this.elementContainerService.getContainerService(renderOptions.type)
|
105
|
-
}),
|
106
|
-
success = _checkCanMount.success,
|
107
|
-
errorMsg = _checkCanMount.errorMsg;
|
108
|
-
if (!success) {
|
109
|
-
this.onEventCallback({
|
110
|
-
code: EventCallbackCode.SDK_CREATE_COMPONENT_ERROR,
|
111
|
-
message: errorMsg
|
112
|
-
});
|
113
|
-
return;
|
114
|
-
}
|
115
|
-
this.changeLoading(true);
|
116
|
-
var startBizFlowData = {
|
117
|
-
paymentSession: this.options.sessionData,
|
118
|
-
displayInfo: _objectSpread(_objectSpread({}, renderOptions), {}, {
|
119
|
-
appendAliasContainerId: true
|
120
|
-
})
|
121
|
-
};
|
122
|
-
if (cashier && renderOptions.sessionData) {
|
123
|
-
startBizFlowData.paymentSession = renderOptions.sessionData;
|
124
|
-
}
|
125
|
-
this.elementContainer.startBizFlow(startBizFlowData).catch(function (error) {
|
126
|
-
_this.onEventCallback({
|
127
|
-
code: EventCallbackCode.SDK_CREATEPAYMENT_PARAMETER_ERROR,
|
128
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || 'Initialization parameter exception.'
|
129
|
-
});
|
130
|
-
_this.changeLoading(false);
|
131
|
-
return;
|
132
|
-
});
|
133
|
-
this.initElementProcessors(renderOptions.type);
|
134
|
-
this.elementContainerService.mount({
|
135
|
-
type: renderOptions.type,
|
136
|
-
selector: sdkSelector,
|
137
|
-
processor: this.elementProcessors[renderOptions.type],
|
138
|
-
options: renderOptions
|
139
|
-
});
|
140
|
-
this.elementProcessors[renderOptions.type].registerEventCenter(this.elementContainerService.getEventService(renderOptions.type));
|
141
|
-
this.elementProcessors[renderOptions.type].beforeMount();
|
142
|
-
this.sendRequestAndWaitWebLaunch(renderOptions);
|
143
|
-
this.addEventListener();
|
144
|
-
this.serviceMap.EventCenter.addIFrame(this.elementContainerService.getContainerService(renderOptions.type).getContainerService().getWebApp());
|
145
|
-
return {
|
146
|
-
getValue: this.elementProcessors[renderOptions.type].getValue.bind(this.elementProcessors[renderOptions.type]),
|
147
|
-
on: function on(event, callback) {
|
148
|
-
_this.elementProcessors[renderOptions.type].registerEventListener(event, callback);
|
149
|
-
}
|
150
|
-
};
|
151
|
-
}
|
152
|
-
}, {
|
153
|
-
key: "submitPayment",
|
154
|
-
value: function submitPayment() {
|
155
|
-
var _this2 = this;
|
156
|
-
this.changeLoading(true);
|
157
|
-
new Promise( /*#__PURE__*/function () {
|
158
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
|
159
|
-
var params, _this2$elementProcess, _result$data, _result$data2, result, _this2$elementProcess2, _result$data3, _result$data4, _result, _this2$elementProcess3;
|
160
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
161
|
-
while (1) switch (_context.prev = _context.next) {
|
162
|
-
case 0:
|
163
|
-
params = {};
|
164
|
-
if (!_this2.elementProcessors[ElementType.auth]) {
|
165
|
-
_context.next = 8;
|
166
|
-
break;
|
167
|
-
}
|
168
|
-
_context.next = 4;
|
169
|
-
return _this2.onValidateFunc((_this2$elementProcess = _this2.elementProcessors[ElementType.auth]) === null || _this2$elementProcess === void 0 ? void 0 : _this2$elementProcess.eventCenter);
|
170
|
-
case 4:
|
171
|
-
result = _context.sent;
|
172
|
-
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;
|
173
|
-
if (result !== null && result !== void 0 && (_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.success) {
|
174
|
-
_context.next = 8;
|
175
|
-
break;
|
176
|
-
}
|
177
|
-
return _context.abrupt("return", resolve(undefined));
|
178
|
-
case 8:
|
179
|
-
if (!_this2.elementProcessors[ElementType.address]) {
|
180
|
-
_context.next = 15;
|
181
|
-
break;
|
182
|
-
}
|
183
|
-
_context.next = 11;
|
184
|
-
return _this2.onValidateFunc((_this2$elementProcess2 = _this2.elementProcessors[ElementType.address]) === null || _this2$elementProcess2 === void 0 ? void 0 : _this2$elementProcess2.eventCenter);
|
185
|
-
case 11:
|
186
|
-
_result = _context.sent;
|
187
|
-
params.shipping = (_result$data3 = _result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
|
188
|
-
if (_result !== null && _result !== void 0 && (_result$data4 = _result.data) !== null && _result$data4 !== void 0 && _result$data4.success) {
|
189
|
-
_context.next = 15;
|
190
|
-
break;
|
191
|
-
}
|
192
|
-
return _context.abrupt("return", resolve(undefined));
|
193
|
-
case 15:
|
194
|
-
if (!_this2.elementProcessors[ElementType.payment]) {
|
195
|
-
_context.next = 25;
|
196
|
-
break;
|
197
|
-
}
|
198
|
-
_context.prev = 16;
|
199
|
-
_context.next = 19;
|
200
|
-
return _this2.onValidateFunc((_this2$elementProcess3 = _this2.elementProcessors[ElementType.payment]) === null || _this2$elementProcess3 === void 0 ? void 0 : _this2$elementProcess3.eventCenter, params);
|
201
|
-
case 19:
|
202
|
-
return _context.abrupt("return", resolve(undefined));
|
203
|
-
case 22:
|
204
|
-
_context.prev = 22;
|
205
|
-
_context.t0 = _context["catch"](16);
|
206
|
-
return _context.abrupt("return", resolve(undefined));
|
207
|
-
case 25:
|
208
|
-
resolve(params);
|
209
|
-
case 26:
|
210
|
-
case "end":
|
211
|
-
return _context.stop();
|
212
|
-
}
|
213
|
-
}, _callee, null, [[16, 22]]);
|
214
|
-
}));
|
215
|
-
return function (_x) {
|
216
|
-
return _ref2.apply(this, arguments);
|
217
|
-
};
|
218
|
-
}()).then(function () {
|
219
|
-
_this2.changeLoading(false);
|
220
|
-
}, function () {
|
221
|
-
_this2.changeLoading(false);
|
222
|
-
});
|
223
|
-
}
|
224
|
-
}, {
|
225
|
-
key: "changeLoading",
|
226
|
-
value: function changeLoading(loading) {
|
227
|
-
if (loading) {
|
228
|
-
var _this$options$loading;
|
229
|
-
if ((_this$options$loading = this.options.loading) !== null && _this$options$loading !== void 0 && _this$options$loading.onStartLoading && !this.loading) {
|
230
|
-
var _this$options$loading2, _this$options$loading3;
|
231
|
-
this.loading = true;
|
232
|
-
(_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);
|
233
|
-
}
|
234
|
-
} else {
|
235
|
-
var _this$options$loading4;
|
236
|
-
if ((_this$options$loading4 = this.options.loading) !== null && _this$options$loading4 !== void 0 && _this$options$loading4.onEndLoading && this.loading) {
|
237
|
-
var _this$options$loading5, _this$options$loading6;
|
238
|
-
(_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);
|
239
|
-
}
|
240
|
-
this.loading = false;
|
241
|
-
}
|
242
|
-
}
|
243
|
-
}, {
|
244
|
-
key: "addEventListener",
|
245
|
-
value: function addEventListener() {
|
246
|
-
var _this3 = this;
|
247
|
-
this.serviceMap.EventCenter.listen(ElementPaymentEvent.CALLBACK, function (data) {
|
248
|
-
if (_this3.elementProcessors[data.source].eventListener[data.event]) {
|
249
|
-
var _this3$elementProcess, _this3$elementProcess2;
|
250
|
-
(_this3$elementProcess = (_this3$elementProcess2 = _this3.elementProcessors[data.source].eventListener)[data.event]) === null || _this3$elementProcess === void 0 || _this3$elementProcess.call(_this3$elementProcess2, data.data);
|
251
|
-
}
|
252
|
-
});
|
253
|
-
this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
|
254
|
-
_this3.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
255
|
-
_this3.changeLoading(false);
|
256
|
-
// 遍历containerService中的所有container查看是否所有状态都是IN_BIZ_FLOW
|
257
|
-
// const allContainersInBizFlow = Object.values(this.elementContainerService.getContainerServices()).every(
|
258
|
-
// (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
|
259
|
-
// );
|
260
|
-
// if (allContainersInBizFlow) {
|
261
|
-
// this.elementContainer.setStatus(IContainerStatus.IN_BIZ_FLOW);
|
262
|
-
// }
|
263
|
-
});
|
264
|
-
this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
|
265
|
-
handleRedirect(data);
|
266
|
-
});
|
267
|
-
}
|
268
|
-
}, {
|
269
|
-
key: "sendRequestAndWaitWebLaunch",
|
270
|
-
value: function sendRequestAndWaitWebLaunch(renderOptions) {
|
271
|
-
var _this4 = this;
|
272
|
-
var type = renderOptions.type,
|
273
|
-
options = _objectWithoutProperties(renderOptions, _excluded);
|
274
|
-
var webLaunchPromise = this.elementContainerService.getContainerService(type).createWebLaunchPromise();
|
275
|
-
Promise.all([webLaunchPromise, this.elementProcessors[type].obtainData()]).then(function (_ref3) {
|
276
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
277
|
-
_webLaunchRes = _ref4[0],
|
278
|
-
_obtainDataRes = _ref4[1];
|
279
|
-
_this4.elementProcessors[type].onReady(_objectSpread(_objectSpread({}, options), {}, {
|
280
|
-
queryResult: _obtainDataRes.originActionQuery
|
281
|
-
}));
|
282
|
-
});
|
283
|
-
}
|
284
|
-
}, {
|
285
|
-
key: "updatePayment",
|
286
|
-
value: function () {
|
287
|
-
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(paymentSessionData) {
|
288
|
-
var _this5 = this;
|
289
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
290
|
-
while (1) switch (_context3.prev = _context3.next) {
|
291
|
-
case 0:
|
292
|
-
return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
|
293
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
|
294
|
-
var prePaymentSessionData, data;
|
295
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
296
|
-
while (1) switch (_context2.prev = _context2.next) {
|
297
|
-
case 0:
|
298
|
-
if (checkCanUpdate({
|
299
|
-
status: _this5.elementContainer.getStatus(),
|
300
|
-
paymentContainerService: _this5.elementContainerService.getContainerService(ElementType.payment),
|
301
|
-
newPaymentSessionData: paymentSessionData,
|
302
|
-
oldPaymentSessionData: _this5.options.sessionData
|
303
|
-
})) {
|
304
|
-
_context2.next = 2;
|
305
|
-
break;
|
306
|
-
}
|
307
|
-
return _context2.abrupt("return", resolve(false));
|
308
|
-
case 2:
|
309
|
-
prePaymentSessionData = _this5.elementContainer.getPaymentContext().paymentSession;
|
310
|
-
_this5.elementContainer.updatePaymentSessionData(paymentSessionData);
|
311
|
-
// 1、数据获取
|
312
|
-
_context2.next = 6;
|
313
|
-
return _this5.elementProcessors[ElementType.payment].obtainData();
|
314
|
-
case 6:
|
315
|
-
data = _context2.sent;
|
316
|
-
// 2、发送update消息
|
317
|
-
Object.values(_this5.elementProcessors).forEach(function (processor) {
|
318
|
-
processor.update({
|
319
|
-
data: {
|
320
|
-
originActionQuery: data.originActionQuery
|
321
|
-
},
|
322
|
-
paymentSessionData: paymentSessionData
|
323
|
-
});
|
324
|
-
});
|
325
|
-
// 3、返回更新结果
|
326
|
-
_this5.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
|
327
|
-
// 若更新不成功,还原core.paymentContext信息
|
328
|
-
if (!data.success) {
|
329
|
-
_this5.elementContainer.updatePaymentSessionData(prePaymentSessionData);
|
330
|
-
}
|
331
|
-
return resolve(data.success || false);
|
332
|
-
});
|
333
|
-
case 9:
|
334
|
-
case "end":
|
335
|
-
return _context2.stop();
|
336
|
-
}
|
337
|
-
}, _callee2);
|
338
|
-
}));
|
339
|
-
return function (_x3) {
|
340
|
-
return _ref5.apply(this, arguments);
|
341
|
-
};
|
342
|
-
}()));
|
343
|
-
case 1:
|
344
|
-
case "end":
|
345
|
-
return _context3.stop();
|
346
|
-
}
|
347
|
-
}, _callee3);
|
348
|
-
}));
|
349
|
-
function updatePayment(_x2) {
|
350
|
-
return _updatePayment.apply(this, arguments);
|
351
|
-
}
|
352
|
-
return updatePayment;
|
353
|
-
}()
|
354
|
-
}, {
|
355
|
-
key: "destroy",
|
356
|
-
value: function destroy() {
|
357
|
-
this.elementContainerService.getContainerServices().forEach(function (value) {
|
358
|
-
value.getContainerService().getWebApp().remove();
|
359
|
-
});
|
360
|
-
// popup未注册会报错,但element不需要感知popup是否被注册
|
361
|
-
try {
|
362
|
-
destroyModal(); // 关闭popup弹窗
|
363
|
-
} catch (error) {}
|
364
|
-
this.elementContainer.destroy();
|
365
|
-
this.elementContainer.setStatus(IContainerStatus.DESTROYED);
|
366
|
-
}
|
367
|
-
}]);
|
368
|
-
return ElementController;
|
369
|
-
}();
|
370
|
-
export default ElementController;
|
@@ -1,17 +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: any): void;
|
16
|
-
}
|
17
|
-
export default AddressProcessor;
|