@alipay/ams-checkout 1.38.0 → 1.40.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.d.ts +4 -1
- package/esm/component/popupWindow.style.js +33 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +7 -0
- package/esm/constant/index.js +7 -0
- package/esm/core/component/element/elementController/index.js +22 -14
- package/esm/core/component/element/type.d.ts +29 -15
- package/esm/core/component/element/type.js +20 -12
- package/esm/core/component/index.d.ts +1 -1
- package/esm/foundation/product-processor/autoDebit/deps.d.ts +14 -0
- package/esm/foundation/product-processor/autoDebit/deps.js +12 -0
- package/esm/foundation/product-processor/autoDebit/index.d.ts +48 -0
- package/esm/foundation/product-processor/autoDebit/index.js +466 -0
- package/esm/foundation/service/container/index.d.ts +2 -0
- package/esm/foundation/service/container/index.js +48 -24
- package/esm/foundation/service/container/popup.d.ts +9 -6
- package/esm/foundation/service/container/popup.js +3 -1
- package/esm/foundation/service/requester/requester.js +2 -2
- package/esm/foundation/utils/web_app_url_utils.d.ts +3 -3
- package/esm/foundation/utils/web_app_url_utils.js +15 -11
- package/esm/index.d.ts +7 -4
- package/esm/index.js +96 -47
- package/esm/plugin/component/cashierApp.js +2 -2
- package/esm/request/index.js +2 -2
- package/esm/types/index.d.ts +9 -2
- package/esm/types/index.js +2 -1
- package/esm/util/index.d.ts +8 -1
- package/esm/util/index.js +31 -3
- package/esm/util/spm-map.d.ts +18 -4
- package/esm/util/spm-map.js +20 -6
- package/package.json +1 -1
@@ -0,0 +1,466 @@
|
|
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 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; }
|
3
|
+
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; }
|
4
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
5
|
+
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."); }
|
6
|
+
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); }
|
7
|
+
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; }
|
8
|
+
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; } }
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
10
|
+
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; }
|
11
|
+
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); } }
|
12
|
+
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); }); }; }
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
14
|
+
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); } }
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
16
|
+
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; }
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
18
|
+
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); }
|
19
|
+
import { ComponentSignEnum, COMPONENT_CONTAINER_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, eventCodeEnum, getComponentSign, getWebAppV2Url, isLocalMock, isPC, LOADTIME_LIMIT, PlatformEnum, ServiceProvider } from "./deps";
|
20
|
+
var defaultActionQueryResponse = {
|
21
|
+
message: 'sdk no need to make query request',
|
22
|
+
success: true
|
23
|
+
};
|
24
|
+
export var AutoDebitProcessor = /*#__PURE__*/function () {
|
25
|
+
function AutoDebitProcessor() {
|
26
|
+
_classCallCheck(this, AutoDebitProcessor);
|
27
|
+
_defineProperty(this, "paymentContext", void 0);
|
28
|
+
_defineProperty(this, "initConfig", void 0);
|
29
|
+
_defineProperty(this, "logger", void 0);
|
30
|
+
_defineProperty(this, "eventCenter", void 0);
|
31
|
+
_defineProperty(this, "securityService", void 0);
|
32
|
+
_defineProperty(this, "instanceId", void 0);
|
33
|
+
_defineProperty(this, "componentSign", void 0);
|
34
|
+
// 服务端接口区域信息,请求时决定API域名
|
35
|
+
_defineProperty(this, "hostSign", void 0);
|
36
|
+
_defineProperty(this, "_performanceData", []);
|
37
|
+
// 安全SDK初始化超时时间
|
38
|
+
_defineProperty(this, "SECURITY_SDK_INIT_TIMEOUT", 1500);
|
39
|
+
}
|
40
|
+
_createClass(AutoDebitProcessor, [{
|
41
|
+
key: "init",
|
42
|
+
value: function init(config, instanceId, sdkMetaData) {
|
43
|
+
this.initConfig = config;
|
44
|
+
this.instanceId = instanceId;
|
45
|
+
this.logger = ServiceProvider.getInstance(this.instanceId).getService('Log');
|
46
|
+
this.eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
47
|
+
this.securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
48
|
+
this._performanceData.push({
|
49
|
+
key: 'sdk_init',
|
50
|
+
value: Date.now()
|
51
|
+
});
|
52
|
+
}
|
53
|
+
}, {
|
54
|
+
key: "startBizFlow",
|
55
|
+
value: function () {
|
56
|
+
var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentContext) {
|
57
|
+
var _this$paymentContext;
|
58
|
+
var _this$paymentContext$, action, _this$paymentContext$2, authUrlInfo, _action$web, _action$wap, signType, requireFastSdk, webAppUrl, renderBehavior;
|
59
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
60
|
+
while (1) switch (_context.prev = _context.next) {
|
61
|
+
case 0:
|
62
|
+
this.paymentContext = paymentContext;
|
63
|
+
this.componentSign = getComponentSign((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionObj);
|
64
|
+
this.hostSign = ((paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSession) || '').split('&&')[1] || '';
|
65
|
+
_this$paymentContext$ = this.paymentContext.paymentSessionObj, action = _this$paymentContext$.action, _this$paymentContext$2 = _this$paymentContext$.authUrlInfo, authUrlInfo = _this$paymentContext$2 === void 0 ? {} : _this$paymentContext$2;
|
66
|
+
if (!(this.componentSign === ComponentSignEnum.AUTO_DEBIT_WALLET)) {
|
67
|
+
_context.next = 9;
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
71
|
+
requireFastSdk = (action === null || action === void 0 ? void 0 : action.requireFastSdk) || false;
|
72
|
+
if (!(signType === 'REDIRECT' && requireFastSdk === true)) {
|
73
|
+
_context.next = 9;
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
return _context.abrupt("return", this.buildRedirectResult(authUrlInfo));
|
77
|
+
case 9:
|
78
|
+
webAppUrl = this.buildWebAppUrl();
|
79
|
+
renderBehavior = {
|
80
|
+
url: webAppUrl,
|
81
|
+
allowClickPopupOutsideClose: this.componentSign === ComponentSignEnum.AUTO_DEBIT_WALLET
|
82
|
+
};
|
83
|
+
this.sendRequestAndWaitWebLaunch();
|
84
|
+
return _context.abrupt("return", {
|
85
|
+
behaviorType: 'RENDER',
|
86
|
+
payload: renderBehavior
|
87
|
+
});
|
88
|
+
case 13:
|
89
|
+
case "end":
|
90
|
+
return _context.stop();
|
91
|
+
}
|
92
|
+
}, _callee, this);
|
93
|
+
}));
|
94
|
+
function startBizFlow(_x) {
|
95
|
+
return _startBizFlow.apply(this, arguments);
|
96
|
+
}
|
97
|
+
return startBizFlow;
|
98
|
+
}()
|
99
|
+
}, {
|
100
|
+
key: "acquireApdidToken",
|
101
|
+
value: function () {
|
102
|
+
var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
103
|
+
var _this$paymentContext$3;
|
104
|
+
var productScene, deviceId;
|
105
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
106
|
+
while (1) switch (_context2.prev = _context2.next) {
|
107
|
+
case 0:
|
108
|
+
productScene = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentSessionConfig) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.productScene;
|
109
|
+
deviceId = this.securityService.getDeviceId({
|
110
|
+
productScene: productScene
|
111
|
+
});
|
112
|
+
return _context2.abrupt("return", deviceId);
|
113
|
+
case 3:
|
114
|
+
case "end":
|
115
|
+
return _context2.stop();
|
116
|
+
}
|
117
|
+
}, _callee2, this);
|
118
|
+
}));
|
119
|
+
function acquireApdidToken() {
|
120
|
+
return _acquireApdidToken.apply(this, arguments);
|
121
|
+
}
|
122
|
+
return acquireApdidToken;
|
123
|
+
}()
|
124
|
+
/**
|
125
|
+
* 获取SDK操作查询请求
|
126
|
+
* @returns {Promise<CashierSdkActionQueryRequest | { message?: string; success: boolean }>} 返回SDK操作查询请求或错误信息
|
127
|
+
*/
|
128
|
+
}, {
|
129
|
+
key: "getSdkActionQuery",
|
130
|
+
value: (function () {
|
131
|
+
var _getSdkActionQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
132
|
+
var requestService, _this$paymentContext2, paymentSession, paymentSessionObj, _this$initConfig, environment, locale, _ref, paymentSessionConfig, action, web, wap, signType, params, res;
|
133
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
134
|
+
while (1) switch (_context3.prev = _context3.next) {
|
135
|
+
case 0:
|
136
|
+
// 获取请求服务实例
|
137
|
+
requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
138
|
+
_this$paymentContext2 = this.paymentContext, paymentSession = _this$paymentContext2.paymentSession, paymentSessionObj = _this$paymentContext2.paymentSessionObj; // 获取初始化配置中的环境和区域设置
|
139
|
+
_this$initConfig = this.initConfig, environment = _this$initConfig.environment, locale = _this$initConfig.locale;
|
140
|
+
_ref = paymentSessionObj || {}, paymentSessionConfig = _ref.paymentSessionConfig, action = _ref.action;
|
141
|
+
if (!(this.componentSign === ComponentSignEnum.AUTO_DEBIT_WALLET)) {
|
142
|
+
_context3.next = 11;
|
143
|
+
break;
|
144
|
+
}
|
145
|
+
web = action.web, wap = action.wap;
|
146
|
+
signType = isPC() ? web === null || web === void 0 ? void 0 : web.signType : wap === null || wap === void 0 ? void 0 : wap.signType; // 如果签名类型为SMS,则返回默认操作查询响应
|
147
|
+
if (!(signType === 'SMS')) {
|
148
|
+
_context3.next = 9;
|
149
|
+
break;
|
150
|
+
}
|
151
|
+
return _context3.abrupt("return", Promise.resolve(defaultActionQueryResponse));
|
152
|
+
case 9:
|
153
|
+
if (!(!signType || signType !== 'REDIRECT')) {
|
154
|
+
_context3.next = 11;
|
155
|
+
break;
|
156
|
+
}
|
157
|
+
return _context3.abrupt("return", Promise.resolve({
|
158
|
+
success: false
|
159
|
+
}));
|
160
|
+
case 11:
|
161
|
+
if (!isLocalMock()) {
|
162
|
+
_context3.next = 13;
|
163
|
+
break;
|
164
|
+
}
|
165
|
+
return _context3.abrupt("return", Promise.resolve(defaultActionQueryResponse));
|
166
|
+
case 13:
|
167
|
+
this._performanceData.push({
|
168
|
+
key: 'sdk_action_query_start',
|
169
|
+
value: Date.now()
|
170
|
+
});
|
171
|
+
// 构造请求参数
|
172
|
+
params = {
|
173
|
+
paymentSessionConfig: paymentSessionConfig,
|
174
|
+
paymentSessionData: paymentSession
|
175
|
+
};
|
176
|
+
_context3.prev = 15;
|
177
|
+
_context3.t0 = requestService;
|
178
|
+
_context3.t1 = params;
|
179
|
+
_context3.t2 = environment;
|
180
|
+
_context3.t3 = locale;
|
181
|
+
_context3.next = 22;
|
182
|
+
return this.acquireApdidToken();
|
183
|
+
case 22:
|
184
|
+
_context3.t4 = _context3.sent;
|
185
|
+
_context3.t5 = {
|
186
|
+
locale: _context3.t3,
|
187
|
+
deviceId: _context3.t4
|
188
|
+
};
|
189
|
+
_context3.t6 = this.hostSign;
|
190
|
+
_context3.t7 = {
|
191
|
+
env: _context3.t2,
|
192
|
+
envInfo: _context3.t5,
|
193
|
+
hostSign: _context3.t6,
|
194
|
+
needEnvInfo: true,
|
195
|
+
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
196
|
+
};
|
197
|
+
_context3.next = 28;
|
198
|
+
return _context3.t0.request.call(_context3.t0, _context3.t1, _context3.t7);
|
199
|
+
case 28:
|
200
|
+
res = _context3.sent;
|
201
|
+
this._performanceData.push({
|
202
|
+
key: 'sdk_action_query_end',
|
203
|
+
value: Date.now()
|
204
|
+
});
|
205
|
+
// 记录日志
|
206
|
+
this.logger.logInfo({
|
207
|
+
title: 'sdk_event_sdkQueryEnd'
|
208
|
+
}, {
|
209
|
+
config: JSON.stringify(paymentSessionConfig),
|
210
|
+
rpcTraceId: res.traceId
|
211
|
+
});
|
212
|
+
return _context3.abrupt("return", res);
|
213
|
+
case 34:
|
214
|
+
_context3.prev = 34;
|
215
|
+
_context3.t8 = _context3["catch"](15);
|
216
|
+
// 记录错误日志
|
217
|
+
this.logger.logError({
|
218
|
+
title: 'sdk_event_sdkQuery_failed'
|
219
|
+
}, {
|
220
|
+
config: JSON.stringify(paymentSessionConfig),
|
221
|
+
errorMessage: JSON.stringify(_context3.t8),
|
222
|
+
rpcTraceId: _context3.t8 === null || _context3.t8 === void 0 ? void 0 : _context3.t8.traceId
|
223
|
+
});
|
224
|
+
return _context3.abrupt("return", Promise.reject());
|
225
|
+
case 38:
|
226
|
+
case "end":
|
227
|
+
return _context3.stop();
|
228
|
+
}
|
229
|
+
}, _callee3, this, [[15, 34]]);
|
230
|
+
}));
|
231
|
+
function getSdkActionQuery() {
|
232
|
+
return _getSdkActionQuery.apply(this, arguments);
|
233
|
+
}
|
234
|
+
return getSdkActionQuery;
|
235
|
+
}()
|
236
|
+
/**
|
237
|
+
* webLaunchPromise方法用于返回一个Promise对象,用于异步加载Web App
|
238
|
+
* @returns {Promise} 返回一个Promise对象
|
239
|
+
*/
|
240
|
+
)
|
241
|
+
}, {
|
242
|
+
key: "webLaunchPromise",
|
243
|
+
value: function webLaunchPromise() {
|
244
|
+
var _this = this;
|
245
|
+
this._performanceData.push({
|
246
|
+
key: 'sdk_onLaunch',
|
247
|
+
value: Date.now()
|
248
|
+
});
|
249
|
+
return new Promise(function (resolve, reject) {
|
250
|
+
var t = setTimeout(function () {
|
251
|
+
// 超时处理
|
252
|
+
reject(new Error('Load resource timeout'));
|
253
|
+
_this.eventCenter.dispatchToApp({
|
254
|
+
event: EVENT.error.name,
|
255
|
+
data: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT
|
256
|
+
});
|
257
|
+
_this.logger.logError({
|
258
|
+
title: 'sdk_error_web_app_timeout'
|
259
|
+
});
|
260
|
+
}, LOADTIME_LIMIT);
|
261
|
+
// 监听onLaunch事件,清除超时计时器
|
262
|
+
_this.eventCenter.listen('onLaunch', function (res) {
|
263
|
+
clearTimeout(t);
|
264
|
+
resolve(res);
|
265
|
+
});
|
266
|
+
});
|
267
|
+
}
|
268
|
+
}, {
|
269
|
+
key: "sendRequestAndWaitWebLaunch",
|
270
|
+
value: function sendRequestAndWaitWebLaunch() {
|
271
|
+
var _this2 = this;
|
272
|
+
var _ref2 = this.paymentContext || {},
|
273
|
+
_ref2$paymentSessionO = _ref2.paymentSessionObj,
|
274
|
+
paymentSessionObj = _ref2$paymentSessionO === void 0 ? {} : _ref2$paymentSessionO,
|
275
|
+
paymentSessionId = _ref2.paymentSessionId,
|
276
|
+
displayInfo = _ref2.displayInfo,
|
277
|
+
startBizFlowOptions = _ref2.startBizFlowOptions;
|
278
|
+
// 等请求和 Web启动都Ready之后,发送renderComponent
|
279
|
+
Promise.all([this.webLaunchPromise(), this.getSdkActionQuery(), this.initSecuritySDK()]).then(function (_ref3) {
|
280
|
+
var _startBizFlowOptions$, _startBizFlowOptions$2;
|
281
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
282
|
+
_webLaunchPromise = _ref4[0],
|
283
|
+
actionQuery = _ref4[1];
|
284
|
+
_this2._performanceData.push({
|
285
|
+
key: 'sdk_render_component',
|
286
|
+
value: Date.now()
|
287
|
+
});
|
288
|
+
var logMetaData = _this2.logger.getLogConfig().mdata;
|
289
|
+
_this2.eventCenter.dispatchToApp({
|
290
|
+
event: 'renderComponent',
|
291
|
+
data: {
|
292
|
+
queryResult: actionQuery,
|
293
|
+
sessionResult: paymentSessionObj,
|
294
|
+
paymentSessionData: paymentSessionId,
|
295
|
+
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
296
|
+
renderDisplayType: displayInfo.type,
|
297
|
+
appearance: displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.appearance,
|
298
|
+
notRedirectAfterComplete: ((_startBizFlowOptions$ = startBizFlowOptions.submitPayRequestExtra) === null || _startBizFlowOptions$ === void 0 ? void 0 : _startBizFlowOptions$.notRedirectAfterComplete) === true,
|
299
|
+
isAppWebview: startBizFlowOptions.isAppWebview,
|
300
|
+
merchantAppointParam: (_startBizFlowOptions$2 = startBizFlowOptions.submitPayRequestExtra) === null || _startBizFlowOptions$2 === void 0 ? void 0 : _startBizFlowOptions$2.merchantAppointParam,
|
301
|
+
envInfo: {
|
302
|
+
screenHeight: screen.height,
|
303
|
+
screenWidth: screen.width
|
304
|
+
},
|
305
|
+
logMetaData: _objectSpread(_objectSpread({
|
306
|
+
trackId: logMetaData.requestSeq,
|
307
|
+
platform: logMetaData.platform,
|
308
|
+
firstLogTime: logMetaData.firstLogTime
|
309
|
+
}, (paymentSessionObj === null || paymentSessionObj === void 0 ? void 0 : paymentSessionObj.paymentSessionConfig) || {}), {}, {
|
310
|
+
renderDisplayType: logMetaData.renderDisplayType,
|
311
|
+
sdkVersion: logMetaData.sdkVersion,
|
312
|
+
merchantId: logMetaData.merchantId,
|
313
|
+
instanceId: logMetaData.instanceId,
|
314
|
+
paymentMethodType: logMetaData.paymentMethodType
|
315
|
+
})
|
316
|
+
}
|
317
|
+
});
|
318
|
+
_this2.logger.logInfo({
|
319
|
+
title: 'sdk_event_renderComponent'
|
320
|
+
});
|
321
|
+
_this2.eventCenter.dispatchToApp({
|
322
|
+
event: 'web-sdk-performance',
|
323
|
+
data: {
|
324
|
+
performanceData: _this2._performanceData
|
325
|
+
}
|
326
|
+
});
|
327
|
+
_this2.setAchAutoDebitContainerWidth();
|
328
|
+
}).catch(function (error) {
|
329
|
+
_this2.eventCenter.emit(EVENT.destroy.name, {});
|
330
|
+
_this2.eventCenter.emit(EVENT.eventCallback.name, {
|
331
|
+
code: eventCodeEnum.SDK_INTERNAL_ERROR,
|
332
|
+
message: error === null || error === void 0 ? void 0 : error.message
|
333
|
+
});
|
334
|
+
});
|
335
|
+
}
|
336
|
+
}, {
|
337
|
+
key: "buildRedirectResult",
|
338
|
+
value: function buildRedirectResult(authUrlInfo) {
|
339
|
+
var data;
|
340
|
+
if (!(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.normalUrl) && !(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.schemeUrl) && !(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.applinkUrl) && authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.authUrl) {
|
341
|
+
data = {
|
342
|
+
url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
|
343
|
+
schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
|
344
|
+
applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl
|
345
|
+
};
|
346
|
+
} else {
|
347
|
+
data = {
|
348
|
+
url: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.normalUrl,
|
349
|
+
schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.schemeUrl,
|
350
|
+
applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl
|
351
|
+
};
|
352
|
+
}
|
353
|
+
var result = {
|
354
|
+
behaviorType: 'REDIRECT',
|
355
|
+
payload: data
|
356
|
+
};
|
357
|
+
return result;
|
358
|
+
}
|
359
|
+
|
360
|
+
/**
|
361
|
+
* 构建 Web App 的 URL
|
362
|
+
* @returns {string} Web App 的 URL
|
363
|
+
*/
|
364
|
+
}, {
|
365
|
+
key: "buildWebAppUrl",
|
366
|
+
value: function buildWebAppUrl() {
|
367
|
+
var _paymentSessionObj$pa, _paymentSessionObj$pa2, _paymentSessionObj$pa3, _this$initConfig$anal;
|
368
|
+
var _this$paymentContext3 = this.paymentContext,
|
369
|
+
displayInfo = _this$paymentContext3.displayInfo,
|
370
|
+
sdkMetaData = _this$paymentContext3.sdkMetaData,
|
371
|
+
paymentSessionObj = _this$paymentContext3.paymentSessionObj;
|
372
|
+
var paymentMethodCategoryType = (_paymentSessionObj$pa = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa === void 0 ? void 0 : _paymentSessionObj$pa.paymentMethodCategoryType;
|
373
|
+
var productScene = (_paymentSessionObj$pa2 = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa2 === void 0 ? void 0 : _paymentSessionObj$pa2.productScene;
|
374
|
+
var productSceneVersion = (_paymentSessionObj$pa3 = paymentSessionObj.paymentSessionConfig) === null || _paymentSessionObj$pa3 === void 0 ? void 0 : _paymentSessionObj$pa3.productSceneVersion;
|
375
|
+
var hostSign = this.hostSign;
|
376
|
+
var mid = paymentSessionObj.clientId;
|
377
|
+
var extendInfo = paymentSessionObj.extendInfo;
|
378
|
+
// 构建 Web App 的 URL
|
379
|
+
var webAppUrl = getWebAppV2Url({
|
380
|
+
environment: this.initConfig.environment,
|
381
|
+
paymentMethodCategoryType: paymentMethodCategoryType,
|
382
|
+
sdkMetaData: sdkMetaData,
|
383
|
+
productScene: productScene,
|
384
|
+
productSceneVersion: productSceneVersion,
|
385
|
+
isPreload: false,
|
386
|
+
query: {
|
387
|
+
analyticsEnabled: (_this$initConfig$anal = this.initConfig.analytics) === null || _this$initConfig$anal === void 0 ? void 0 : _this$initConfig$anal.enabled,
|
388
|
+
displayType: displayInfo.type,
|
389
|
+
instanceId: this.instanceId,
|
390
|
+
locale: this.initConfig.locale,
|
391
|
+
hostSign: hostSign
|
392
|
+
},
|
393
|
+
mid: mid,
|
394
|
+
extendInfo: extendInfo
|
395
|
+
});
|
396
|
+
return webAppUrl;
|
397
|
+
// // 调试地址
|
398
|
+
// const urlObj = new URL(webAppUrl);
|
399
|
+
// return `${`http://svc-2qdwgpbkf7s1rw3k.cloudide.svc.et15-sqa.alipay.net:5175/auto-debit/src/pages/trustly/index.html`}?${urlObj.searchParams.toString()}`;
|
400
|
+
}
|
401
|
+
|
402
|
+
/**
|
403
|
+
* 初始化安全SDK
|
404
|
+
* @returns {Promise}
|
405
|
+
*/
|
406
|
+
}, {
|
407
|
+
key: "initSecuritySDK",
|
408
|
+
value: (function () {
|
409
|
+
var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
410
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
411
|
+
while (1) switch (_context4.prev = _context4.next) {
|
412
|
+
case 0:
|
413
|
+
_context4.prev = 0;
|
414
|
+
_context4.next = 3;
|
415
|
+
return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
|
416
|
+
case 3:
|
417
|
+
return _context4.abrupt("return", _context4.sent);
|
418
|
+
case 6:
|
419
|
+
_context4.prev = 6;
|
420
|
+
_context4.t0 = _context4["catch"](0);
|
421
|
+
return _context4.abrupt("return", Promise.resolve());
|
422
|
+
case 9:
|
423
|
+
case "end":
|
424
|
+
return _context4.stop();
|
425
|
+
}
|
426
|
+
}, _callee4, this, [[0, 6]]);
|
427
|
+
}));
|
428
|
+
function initSecuritySDK() {
|
429
|
+
return _initSecuritySDK.apply(this, arguments);
|
430
|
+
}
|
431
|
+
return initSecuritySDK;
|
432
|
+
}()
|
433
|
+
/**
|
434
|
+
* 设置容器宽度
|
435
|
+
* 如果是 Trustly 支付方式,并且显示平台为桌面端,则设置组件区块和容器的最大宽度为 656px
|
436
|
+
*/
|
437
|
+
)
|
438
|
+
}, {
|
439
|
+
key: "setAchAutoDebitContainerWidth",
|
440
|
+
value: function setAchAutoDebitContainerWidth() {
|
441
|
+
// 判断是否为 Trustly 支付方式
|
442
|
+
if (this.isTrustly) {
|
443
|
+
var _this$paymentContext4;
|
444
|
+
// 判断显示平台是否为桌面端
|
445
|
+
if (((_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 || (_this$paymentContext4 = _this$paymentContext4.displayInfo) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.platform) === PlatformEnum.desktop) {
|
446
|
+
var _document$getElementB, _document$getElementB2;
|
447
|
+
// 设置组件区块的最大宽度为 656px
|
448
|
+
(_document$getElementB = document.getElementById(COMPONENT_SECTION_ID)) === null || _document$getElementB === void 0 || _document$getElementB.setAttribute('style', 'max-width: 656px');
|
449
|
+
// 设置容器的最大宽度为 656px
|
450
|
+
(_document$getElementB2 = document.getElementById(COMPONENT_CONTAINER_ID)) === null || _document$getElementB2 === void 0 || _document$getElementB2.setAttribute('style', 'max-width: 656px');
|
451
|
+
}
|
452
|
+
}
|
453
|
+
}
|
454
|
+
|
455
|
+
/**
|
456
|
+
* 判断是否为Trustly支付方式
|
457
|
+
* @returns {boolean} true 表示是Trustly支付方式
|
458
|
+
*/
|
459
|
+
}, {
|
460
|
+
key: "isTrustly",
|
461
|
+
get: function get() {
|
462
|
+
return this.componentSign === ComponentSignEnum.AUTO_DEBIT_APM;
|
463
|
+
}
|
464
|
+
}]);
|
465
|
+
return AutoDebitProcessor;
|
466
|
+
}();
|
@@ -35,5 +35,7 @@ export declare class ContainerService implements Service {
|
|
35
35
|
private changeCloseBtnVisibility;
|
36
36
|
private handleMaskCloseBtnShow;
|
37
37
|
private handleCloseButtonTheme;
|
38
|
+
private handlePopupWindow;
|
39
|
+
private handlePopWindow;
|
38
40
|
getWebApp(): HTMLIFrameElement;
|
39
41
|
}
|
@@ -46,9 +46,10 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
46
46
|
}, {
|
47
47
|
key: "init",
|
48
48
|
value: function init(initOptions, instanceId, sdkMetaData) {
|
49
|
+
var _window;
|
49
50
|
this.instanceId = instanceId;
|
50
51
|
this.sdkMetaData = sdkMetaData;
|
51
|
-
this.clientHeight = Math.max(window.innerHeight, window.visualViewport.height);
|
52
|
+
this.clientHeight = Math.max(window.innerHeight, ((_window = window) === null || _window === void 0 || (_window = _window.visualViewport) === null || _window === void 0 ? void 0 : _window.height) || 0);
|
52
53
|
this.eventCenter = ServiceProvider.getInstance(instanceId).getService('EventCenter');
|
53
54
|
this.logService = ServiceProvider.getInstance(instanceId).getService('Log');
|
54
55
|
this.popupManager = new PopupManager();
|
@@ -164,10 +165,10 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
164
165
|
}, {
|
165
166
|
key: "handleAccountFocus",
|
166
167
|
value: function handleAccountFocus(focus) {
|
167
|
-
var _window$visualViewpor,
|
168
|
+
var _window$visualViewpor, _window2;
|
168
169
|
// 失焦时v2会走默认的sizeChange还原高度,这里仅移除监听
|
169
170
|
(_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 || _window$visualViewpor.removeEventListener('resize', this.boundFocusResizeChange);
|
170
|
-
(
|
171
|
+
(_window2 = window) === null || _window2 === void 0 || _window2.removeEventListener('resize', this.boundFocusResizeChange);
|
171
172
|
// 只有聚焦才监听,失焦后移除,避免影响别的场景
|
172
173
|
if (focus) {
|
173
174
|
var _window$visualViewpor2;
|
@@ -195,19 +196,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
195
196
|
});
|
196
197
|
});
|
197
198
|
this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
|
198
|
-
|
199
|
-
if (data.paymentElementOldModel) return;
|
200
|
-
insertStyleSheet();
|
201
|
-
_this.popupManager.popup(_objectSpread({
|
202
|
-
platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
|
203
|
-
}, data)).then(function () {
|
204
|
-
_this.eventCenter.addIFrame(_this.popupManager.popupApp);
|
205
|
-
}).catch(function (error) {
|
206
|
-
_this.logService.logError({
|
207
|
-
title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
|
208
|
-
}, error);
|
209
|
-
_this.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
210
|
-
});
|
199
|
+
_this.handlePopupWindow(data);
|
211
200
|
});
|
212
201
|
this.eventCenter.listen(EVENT.popWindow.name, function () {
|
213
202
|
_this.popupManager.pop();
|
@@ -266,9 +255,9 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
266
255
|
}, {
|
267
256
|
key: "handleSizeChanged",
|
268
257
|
value: function handleSizeChanged(data) {
|
269
|
-
var _this$
|
270
|
-
appendAliasContainerId = _this$
|
271
|
-
selector = _this$
|
258
|
+
var _this$displayInfo2 = this.displayInfo,
|
259
|
+
appendAliasContainerId = _this$displayInfo2.appendAliasContainerId,
|
260
|
+
selector = _this$displayInfo2.selector;
|
272
261
|
var cashierId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : COMPONENT_CONTAINER_ID;
|
273
262
|
if (!this.webApp || !this.displayInfo) {
|
274
263
|
return;
|
@@ -309,12 +298,12 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
309
298
|
}, {
|
310
299
|
key: "focusResizeChange",
|
311
300
|
value: function focusResizeChange() {
|
312
|
-
var
|
301
|
+
var _window3;
|
313
302
|
// 计算出当前iframe应有的高度,需要和顶部留有距离
|
314
303
|
var webPageHeightRatio = 0.9;
|
315
304
|
var browserPageHeightFocusRatio = 0.9;
|
316
305
|
// sdk层才能拿到当前键盘弹起后页面的高度
|
317
|
-
var height = ((
|
306
|
+
var height = ((_window3 = window) === null || _window3 === void 0 || (_window3 = _window3.visualViewport) === null || _window3 === void 0 ? void 0 : _window3.height) || window.innerHeight;
|
318
307
|
height = height * webPageHeightRatio;
|
319
308
|
height = height * browserPageHeightFocusRatio;
|
320
309
|
// 调用handleSizeChanged修改iframe高度
|
@@ -329,9 +318,9 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
329
318
|
key: "focusScrollFixed",
|
330
319
|
value: function focusScrollFixed(focus) {
|
331
320
|
// 获取iframe dom元素
|
332
|
-
var _this$
|
333
|
-
appendAliasContainerId = _this$
|
334
|
-
selector = _this$
|
321
|
+
var _this$displayInfo3 = this.displayInfo,
|
322
|
+
appendAliasContainerId = _this$displayInfo3.appendAliasContainerId,
|
323
|
+
selector = _this$displayInfo3.selector;
|
335
324
|
var cashierId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : COMPONENT_CONTAINER_ID;
|
336
325
|
if (!this.webApp || !this.displayInfo) {
|
337
326
|
return;
|
@@ -422,6 +411,41 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
422
411
|
maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.remove("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
|
423
412
|
}
|
424
413
|
}
|
414
|
+
|
415
|
+
// SDK主动打开弹框
|
416
|
+
}, {
|
417
|
+
key: "handlePopupWindow",
|
418
|
+
value: function handlePopupWindow(data) {
|
419
|
+
var _this$displayInfo4,
|
420
|
+
_this3 = this;
|
421
|
+
if (data.paymentElementOldModel) return;
|
422
|
+
insertStyleSheet();
|
423
|
+
this.popupManager.popup(_objectSpread({
|
424
|
+
platform: (_this$displayInfo4 = this.displayInfo) === null || _this$displayInfo4 === void 0 ? void 0 : _this$displayInfo4.platform,
|
425
|
+
showCloseOnLoading: data.showCloseOnLoading,
|
426
|
+
onCloseOnLoading: function onCloseOnLoading() {
|
427
|
+
return _this3.handlePopWindow(data);
|
428
|
+
}
|
429
|
+
}, data)).then(function () {
|
430
|
+
_this3.eventCenter.addIFrame(_this3.popupManager.popupApp);
|
431
|
+
}).catch(function (error) {
|
432
|
+
_this3.logService.logError({
|
433
|
+
title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
|
434
|
+
}, error);
|
435
|
+
_this3.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
436
|
+
});
|
437
|
+
}
|
438
|
+
|
439
|
+
// SDK主动关闭弹框
|
440
|
+
}, {
|
441
|
+
key: "handlePopWindow",
|
442
|
+
value: function handlePopWindow(data) {
|
443
|
+
this.popupManager.pop();
|
444
|
+
this.eventCenter.dispatchToApp({
|
445
|
+
event: EVENT.popWindow.name,
|
446
|
+
data: data
|
447
|
+
});
|
448
|
+
}
|
425
449
|
}, {
|
426
450
|
key: "getWebApp",
|
427
451
|
value: function getWebApp() {
|
@@ -1,4 +1,12 @@
|
|
1
1
|
import { PlatformEnum } from '../../../types';
|
2
|
+
export type IPopUpParams = {
|
3
|
+
url: string;
|
4
|
+
widthPadding: number;
|
5
|
+
heightPadding: number;
|
6
|
+
platform: PlatformEnum;
|
7
|
+
showCloseOnLoading: boolean;
|
8
|
+
onCloseOnLoading: () => void;
|
9
|
+
};
|
2
10
|
/**
|
3
11
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
4
12
|
* @date 2024/9/22
|
@@ -7,11 +15,6 @@ export declare class PopupManager {
|
|
7
15
|
private popupUrlQuery;
|
8
16
|
popupApp: HTMLIFrameElement;
|
9
17
|
setPopupUrlQuery(queryParams: string): void;
|
10
|
-
popup(data:
|
11
|
-
url: string;
|
12
|
-
widthPadding: number;
|
13
|
-
heightPadding: number;
|
14
|
-
platform: PlatformEnum;
|
15
|
-
}): Promise<void>;
|
18
|
+
popup(data: IPopUpParams): Promise<void>;
|
16
19
|
pop(): void;
|
17
20
|
}
|
@@ -53,7 +53,9 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
53
53
|
widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
|
54
54
|
device: data === null || data === void 0 ? void 0 : data.platform,
|
55
55
|
url: pageUrl,
|
56
|
-
loadingConfig: undefined
|
56
|
+
loadingConfig: undefined,
|
57
|
+
showCloseOnLoading: data.showCloseOnLoading,
|
58
|
+
onCloseOnLoading: data.onCloseOnLoading
|
57
59
|
});
|
58
60
|
case 11:
|
59
61
|
this.popupApp = _context.sent;
|