@alipay/ams-checkout 0.0.1730107332-dev.34 → 0.0.1730107332-dev.37
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/channel.js +1 -2
- package/esm/foundation/product-processor/easysafepay/index.js +66 -63
- package/esm/foundation/service/container/index.d.ts +2 -0
- package/esm/foundation/service/container/index.js +42 -1
- package/esm/foundation/service/event-center.js +2 -6
- package/esm/foundation/service/log/index.js +1 -1
- package/esm/foundation/utils/redirect_utils.js +75 -66
- package/esm/foundation/utils/system_events.js +0 -5
- package/package.json +1 -1
package/esm/component/channel.js
CHANGED
@@ -83,6 +83,5 @@ export function getDoubleFaUrl(params) {
|
|
83
83
|
prod: "https://ac.alipay.com/page/antom-web-checkout/src/component-app/doubleFA/index.".concat(sdkVersion, ".html")
|
84
84
|
};
|
85
85
|
var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
|
86
|
-
|
87
|
-
return "".concat(doubleFaBaseUrl, "?scene=cashierResultPage&instanceId=").concat(instanceId, "&paymentSessionData=").concat(encodeURIComponent(shortSessionData), "&isLandscape=").concat(isLandscapeOrientation ? 'true' : '', "&pmt=").concat(paymentMethodType, "&locale=").concat(locale, "&sdkVersion=").concat(sdkVersion);
|
86
|
+
return "".concat(doubleFaBaseUrl, "?scene=cashierResultPage&instanceId=").concat(instanceId, "&paymentSessionData=").concat(encodeURIComponent(paymentSessionData), "&isLandscape=").concat(isLandscapeOrientation ? 'true' : '', "&pmt=").concat(paymentMethodType, "&locale=").concat(locale, "&sdkVersion=").concat(sdkVersion);
|
88
87
|
}
|
@@ -225,7 +225,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
225
225
|
data: {
|
226
226
|
sessionResult: (_this2$paymentContext = _this2.paymentContext) === null || _this2$paymentContext === void 0 ? void 0 : _this2$paymentContext.paymentSessionObj,
|
227
227
|
submitResult: submitRes,
|
228
|
-
paymentSessionData: (_this2$paymentContext2 = _this2.paymentContext) === null || _this2$paymentContext2 === void 0 ? void 0 : _this2$paymentContext2.
|
228
|
+
paymentSessionData: (_this2$paymentContext2 = _this2.paymentContext) === null || _this2$paymentContext2 === void 0 ? void 0 : _this2$paymentContext2.paymentSessionId,
|
229
229
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
230
230
|
renderDisplayType: _this2.paymentContext.displayInfo.type,
|
231
231
|
appearance: (_this2$paymentContext3 = _this2.paymentContext.displayInfo) === null || _this2$paymentContext3 === void 0 ? void 0 : _this2$paymentContext3.appearance,
|
@@ -262,7 +262,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
262
262
|
while (1) switch (_context2.prev = _context2.next) {
|
263
263
|
case 0:
|
264
264
|
submitParams = {
|
265
|
-
paymentSessionData: ((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.
|
265
|
+
paymentSessionData: ((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSessionId) || '',
|
266
266
|
paymentSessionConfig: (_this$paymentContext2 = this.paymentContext) === null || _this$paymentContext2 === void 0 || (_this$paymentContext2 = _this$paymentContext2.paymentSessionObj) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSessionConfig
|
267
267
|
};
|
268
268
|
_ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
|
@@ -280,17 +280,16 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
280
280
|
}
|
281
281
|
}
|
282
282
|
this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
|
283
|
-
console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
|
283
|
+
//console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
|
284
284
|
if (this.allowSubmitPayCallAhead) {
|
285
|
-
_context2.next =
|
285
|
+
_context2.next = 7;
|
286
286
|
break;
|
287
287
|
}
|
288
|
-
console.log('[web-sdk] DO NOT call submitPay');
|
289
288
|
return _context2.abrupt("return", {
|
290
289
|
message: 'sdk no need to make submitPay request',
|
291
290
|
success: true
|
292
291
|
});
|
293
|
-
case
|
292
|
+
case 7:
|
294
293
|
requestBizId = uuid(); // 下面真实发请求
|
295
294
|
this.logger.logInfo({
|
296
295
|
title: 'sdk_event_submitPay'
|
@@ -303,21 +302,20 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
303
302
|
instanceId: this.instanceId,
|
304
303
|
locale: this.initConfig.locale,
|
305
304
|
paymentMethodType: (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentMethodInfoView) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.paymentMethodType,
|
306
|
-
paymentSessionData: this.paymentContext.
|
305
|
+
paymentSessionData: this.paymentContext.paymentSessionId,
|
307
306
|
env: this.initConfig.environment,
|
308
307
|
sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
|
309
308
|
})) || {};
|
310
309
|
extParams.complianceSDK = true;
|
311
310
|
submitParams.extParams = extParams;
|
312
311
|
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
313
|
-
_context2.prev =
|
314
|
-
console.log('[web-sdk] DO call submitPay');
|
312
|
+
_context2.prev = 13;
|
315
313
|
_context2.t0 = requester;
|
316
314
|
_context2.t1 = submitParams;
|
317
315
|
_context2.t2 = this.initConfig.environment;
|
318
|
-
_context2.next =
|
316
|
+
_context2.next = 19;
|
319
317
|
return this.acquireApdidToken();
|
320
|
-
case
|
318
|
+
case 19:
|
321
319
|
_context2.t3 = _context2.sent;
|
322
320
|
_context2.t4 = {
|
323
321
|
deviceId: _context2.t3
|
@@ -331,9 +329,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
331
329
|
needEnvInfo: true,
|
332
330
|
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
333
331
|
};
|
334
|
-
_context2.next =
|
332
|
+
_context2.next = 25;
|
335
333
|
return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
|
336
|
-
case
|
334
|
+
case 25:
|
337
335
|
res = _context2.sent;
|
338
336
|
this.logger.logInfo({
|
339
337
|
title: 'sdk_event_submitPayEnd'
|
@@ -343,9 +341,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
343
341
|
traceId: res.traceId
|
344
342
|
});
|
345
343
|
return _context2.abrupt("return", res);
|
346
|
-
case
|
347
|
-
_context2.prev =
|
348
|
-
_context2.t7 = _context2["catch"](
|
344
|
+
case 30:
|
345
|
+
_context2.prev = 30;
|
346
|
+
_context2.t7 = _context2["catch"](13);
|
349
347
|
this.logger.logError({
|
350
348
|
title: 'sdk_event_submitPay_failed'
|
351
349
|
}, {
|
@@ -355,11 +353,11 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
355
353
|
traceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
|
356
354
|
});
|
357
355
|
throw _context2.t7;
|
358
|
-
case
|
356
|
+
case 34:
|
359
357
|
case "end":
|
360
358
|
return _context2.stop();
|
361
359
|
}
|
362
|
-
}, _callee2, this, [[
|
360
|
+
}, _callee2, this, [[13, 30]]);
|
363
361
|
}));
|
364
362
|
function processSubmitPay() {
|
365
363
|
return _processSubmitPay.apply(this, arguments);
|
@@ -396,7 +394,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
396
394
|
key: "initSecuritySDK",
|
397
395
|
value: function () {
|
398
396
|
var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
399
|
-
var _this$paymentContext$4, _this$paymentContext$5, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay;
|
397
|
+
var _this$paymentContext$4, _this$paymentContext$5, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay, shouldInitSecuritySDK;
|
400
398
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
401
399
|
while (1) switch (_context4.prev = _context4.next) {
|
402
400
|
case 0:
|
@@ -405,61 +403,66 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
405
403
|
nonCompliant = (_this$paymentContext$4 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.nonCompliant;
|
406
404
|
nonInitSecuritySDK = (_this$paymentContext$5 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$5 === void 0 ? void 0 : _this$paymentContext$5.nonInitSecuritySDK;
|
407
405
|
isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
|
408
|
-
|
409
|
-
|
410
|
-
|
406
|
+
shouldInitSecuritySDK = false;
|
407
|
+
if (nonInitSecuritySDK) {
|
408
|
+
// 钱包不依赖风控
|
409
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk when nonInitSecuritySDK is true');
|
410
|
+
shouldInitSecuritySDK = false;
|
411
|
+
} else {
|
412
|
+
if (productSceneVersion === '1.0') {
|
413
|
+
// 1.0 不初始化 SecuritySDK
|
414
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 1.0');
|
415
|
+
shouldInitSecuritySDK = false;
|
416
|
+
} else if (productSceneVersion === '2.0') {
|
417
|
+
if (nonCompliant === true) {
|
418
|
+
// 未切流「隐私合规」
|
419
|
+
// console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and nonCompliant is true');
|
420
|
+
shouldInitSecuritySDK = true;
|
421
|
+
} else {
|
422
|
+
if (isFirstTimeToPay) {
|
423
|
+
// console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 2.0 and when first time to pay');
|
424
|
+
shouldInitSecuritySDK = false;
|
425
|
+
} else {
|
426
|
+
// 切流「隐私合规」且非首次支付
|
427
|
+
// console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and when not first time to pay');
|
428
|
+
shouldInitSecuritySDK = true;
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
411
432
|
}
|
412
|
-
|
413
|
-
console.log('[web-sdk][security-sdk] DO NOT init security sdk when nonInitSecuritySDK is true');
|
414
|
-
return _context4.abrupt("return");
|
415
|
-
case 8:
|
416
|
-
if (!(productSceneVersion === '1.0')) {
|
433
|
+
if (!shouldInitSecuritySDK) {
|
417
434
|
_context4.next = 13;
|
418
435
|
break;
|
419
436
|
}
|
420
|
-
|
421
|
-
console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 1.0');
|
422
|
-
return _context4.abrupt("return");
|
423
|
-
case 13:
|
424
|
-
if (!(productSceneVersion === '2.0')) {
|
425
|
-
_context4.next = 27;
|
426
|
-
break;
|
427
|
-
}
|
428
|
-
if (!(nonCompliant === true)) {
|
429
|
-
_context4.next = 20;
|
430
|
-
break;
|
431
|
-
}
|
432
|
-
// 未切流「隐私合规」
|
433
|
-
console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and nonCompliant is true');
|
434
|
-
_context4.next = 18;
|
437
|
+
_context4.next = 10;
|
435
438
|
return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
|
436
|
-
case
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 2.0 and when first time to pay');
|
445
|
-
_context4.next = 27;
|
439
|
+
case 10:
|
440
|
+
this.logger.logInfo({
|
441
|
+
title: 'start_easypay_with_security_sdk'
|
442
|
+
}, {
|
443
|
+
spmId: 'a3753.b101271.c388193.d514078',
|
444
|
+
riskSdkInfo: 'need'
|
445
|
+
});
|
446
|
+
_context4.next = 14;
|
446
447
|
break;
|
447
|
-
case
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
448
|
+
case 13:
|
449
|
+
this.logger.logInfo({
|
450
|
+
title: 'start_easypay_without_security_sdk'
|
451
|
+
}, {
|
452
|
+
spmId: 'a3753.b101271.c388193.d514078',
|
453
|
+
riskSdkInfo: 'noneed'
|
454
|
+
});
|
455
|
+
case 14:
|
456
|
+
_context4.next = 18;
|
454
457
|
break;
|
455
|
-
case
|
456
|
-
_context4.prev =
|
458
|
+
case 16:
|
459
|
+
_context4.prev = 16;
|
457
460
|
_context4.t0 = _context4["catch"](0);
|
458
|
-
case
|
461
|
+
case 18:
|
459
462
|
case "end":
|
460
463
|
return _context4.stop();
|
461
464
|
}
|
462
|
-
}, _callee4, this, [[0,
|
465
|
+
}, _callee4, this, [[0, 16]]);
|
463
466
|
}));
|
464
467
|
function initSecuritySDK() {
|
465
468
|
return _initSecuritySDK.apply(this, arguments);
|
@@ -9,6 +9,7 @@ export declare class ContainerService implements Service {
|
|
9
9
|
private logService;
|
10
10
|
private displayInfo;
|
11
11
|
private webApp;
|
12
|
+
private _webAppHeartBeatTimeoutFn;
|
12
13
|
private customizedLoadingListener;
|
13
14
|
destroy(): void;
|
14
15
|
init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
@@ -24,5 +25,6 @@ export declare class ContainerService implements Service {
|
|
24
25
|
private addCapabilityToEventCenter;
|
25
26
|
private addCapabilityToApiBusManager;
|
26
27
|
private handleSizeChanged;
|
28
|
+
private handleAppHeartBeat;
|
27
29
|
private changeCloseBtnVisibility;
|
28
30
|
}
|
@@ -13,7 +13,7 @@ import { addInlineLoading, createInlineBaseElement } from "../../../component/co
|
|
13
13
|
import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
|
14
14
|
import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, LOADING_ID, MOCKUP_ID } from "../../../constant";
|
15
15
|
import { ServiceProvider } from "../index";
|
16
|
-
import { EVENT } from "../../../constant";
|
16
|
+
import { EVENT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../../constant";
|
17
17
|
import { PopupManager } from "./popup";
|
18
18
|
/**
|
19
19
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
@@ -31,6 +31,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
31
31
|
_defineProperty(this, "logService", void 0);
|
32
32
|
_defineProperty(this, "displayInfo", void 0);
|
33
33
|
_defineProperty(this, "webApp", void 0);
|
34
|
+
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
34
35
|
// if this variable is true, SDK will invoke listener instead of showing loading
|
35
36
|
_defineProperty(this, "customizedLoadingListener", void 0);
|
36
37
|
}
|
@@ -203,6 +204,9 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
203
204
|
this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
|
204
205
|
_this2.changeCloseBtnVisibility(false);
|
205
206
|
});
|
207
|
+
this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
|
208
|
+
_this2.handleAppHeartBeat();
|
209
|
+
});
|
206
210
|
}
|
207
211
|
}, {
|
208
212
|
key: "addCapabilityToApiBusManager",
|
@@ -242,6 +246,43 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
242
246
|
this.webApp.style.height = "".concat(data.height, "px");
|
243
247
|
}
|
244
248
|
}
|
249
|
+
}, {
|
250
|
+
key: "handleAppHeartBeat",
|
251
|
+
value: function handleAppHeartBeat() {
|
252
|
+
var _this3 = this;
|
253
|
+
try {
|
254
|
+
if (!this._webAppHeartBeatTimeoutFn) {
|
255
|
+
this._webAppHeartBeatTimeoutFn = function () {
|
256
|
+
if (_this3.webApp && _this3.displayInfo) {
|
257
|
+
_this3.logService.logError({
|
258
|
+
title: 'sdk_error_appHeartBeatTimeout'
|
259
|
+
});
|
260
|
+
}
|
261
|
+
};
|
262
|
+
}
|
263
|
+
if (window._webAppHeartBeatTimeoutId) {
|
264
|
+
clearTimeout(window._webAppHeartBeatTimeoutId);
|
265
|
+
window._webAppHeartBeatTimeoutId = null;
|
266
|
+
}
|
267
|
+
if (this._webAppHeartBeatTimeoutFn) {
|
268
|
+
window._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
|
269
|
+
}
|
270
|
+
setTimeout(function () {
|
271
|
+
if (_this3.webApp && _this3.displayInfo) {
|
272
|
+
_this3.eventCenter.dispatchToApp({
|
273
|
+
event: 'sdkHeartBeat',
|
274
|
+
data: {}
|
275
|
+
});
|
276
|
+
}
|
277
|
+
}, TIME_DELAY_SEND_HEART_BEAT);
|
278
|
+
} catch (error) {
|
279
|
+
this.logService.logError({
|
280
|
+
title: 'sdk_error_handleAppHeartBeat'
|
281
|
+
}, {
|
282
|
+
errorMessage: error.message
|
283
|
+
});
|
284
|
+
}
|
285
|
+
}
|
245
286
|
}, {
|
246
287
|
key: "changeCloseBtnVisibility",
|
247
288
|
value: function changeCloseBtnVisibility(isShow) {
|
@@ -91,7 +91,6 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
91
91
|
key: "handleAppMessage",
|
92
92
|
value: function handleAppMessage(e) {
|
93
93
|
var _e$data;
|
94
|
-
// console.log('sdk received message:', e);
|
95
94
|
if (!this.iframes.some(function (iframe) {
|
96
95
|
return iframe.origin === e.origin;
|
97
96
|
})) return;
|
@@ -101,14 +100,12 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
101
100
|
var isJson = isJsonString(e.data);
|
102
101
|
if (isJson) {
|
103
102
|
var _EventPayload = JSON.parse(e.data);
|
104
|
-
console.log('handleAppMessage', _EventPayload);
|
105
103
|
if (_EventPayload.name !== MessageName.APP_TO_SDK) {
|
106
104
|
return;
|
107
105
|
}
|
108
106
|
this._handleAppMessage(_EventPayload);
|
109
107
|
} else {
|
110
|
-
console.
|
111
|
-
// TODO: 异常上报
|
108
|
+
console.error(ERRORMESSAGE.NOT_JSON_FORMAT);
|
112
109
|
}
|
113
110
|
}
|
114
111
|
|
@@ -223,11 +220,10 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
223
220
|
context: payloadContext,
|
224
221
|
instanceId: this.instanceId
|
225
222
|
};
|
226
|
-
console.log('dispatchToApp', payloadContext);
|
227
223
|
(_this$iframes = this.iframes) === null || _this$iframes === void 0 || _this$iframes.forEach(function (iframe) {
|
228
224
|
var _iframe$origin;
|
229
225
|
if (!iframe.ref.contentWindow) {
|
230
|
-
console.
|
226
|
+
console.error('get app contentWindow error', iframe);
|
231
227
|
return;
|
232
228
|
}
|
233
229
|
var _ref = _this.queryParse(iframe.ref.src) || {},
|
@@ -20,75 +20,84 @@ export var redirect = function redirect(payload, instanceId) {
|
|
20
20
|
logService.logInfo({
|
21
21
|
title: 'sdk_event_call_url_start'
|
22
22
|
}, _objectSpread({}, payload)).send();
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
});
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
// 支持 target: _blank,新开tab页打开
|
40
|
-
if (payload.browserLinkTarget === TargetEnum.BLANK) {
|
41
|
-
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
42
|
-
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
43
|
-
window.open(payload.url);
|
44
|
-
return;
|
45
|
-
}
|
46
|
-
if (payload.browserLinkTarget === TargetEnum.REPLACE && !(payload !== null && payload !== void 0 && payload.applinkUrl) && !(payload !== null && payload !== void 0 && payload.schemeUrl)) {
|
47
|
-
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
48
|
-
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
49
|
-
window.location.replace(payload.url);
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
if (isPC()) {
|
53
|
-
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
54
|
-
window.location.href = payload.url;
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
if (!payload.schemeUrl && !payload.applinkUrl) {
|
58
|
-
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
59
|
-
window.location.href = payload.url;
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
// Use callApp lib to evoke
|
63
|
-
var callAppLib = new CallApp({
|
64
|
-
successCb: function successCb(evokeAppBy) {
|
65
|
-
var type = evokeAppBy.type == 'Scheme' ? RedirectType.SchemeUrl : RedirectType.ApplinkUrl;
|
66
|
-
successCallback(payload, type, evokeAppBy.url, serviceProvider);
|
67
|
-
}
|
68
|
-
});
|
69
|
-
var callSchemeUrl = function callSchemeUrl() {
|
70
|
-
callAppLib.open({
|
71
|
-
scheme: payload.schemeUrl,
|
72
|
-
fallback: function fallback() {
|
73
|
-
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
74
|
-
if (payload.url) {
|
75
|
-
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
76
|
-
window.location.href = payload.url;
|
23
|
+
try {
|
24
|
+
if (payload.isCallApp && payload.schemeUrl) {
|
25
|
+
var detectSuccessDelay = payload.callAppDetectSuccessDelay;
|
26
|
+
var _callAppLib = new CallApp({
|
27
|
+
successCb: function successCb() {
|
28
|
+
successCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
29
|
+
},
|
30
|
+
resultJudgmentTime: detectSuccessDelay
|
31
|
+
});
|
32
|
+
_callAppLib.open({
|
33
|
+
scheme: payload.schemeUrl,
|
34
|
+
fallback: function fallback() {
|
35
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
77
36
|
}
|
37
|
+
});
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
// 支持 target: _blank,新开tab页打开
|
41
|
+
if (payload.browserLinkTarget === TargetEnum.BLANK) {
|
42
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
43
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
44
|
+
window.open(payload.url);
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
if (payload.browserLinkTarget === TargetEnum.REPLACE && !(payload !== null && payload !== void 0 && payload.applinkUrl) && !(payload !== null && payload !== void 0 && payload.schemeUrl)) {
|
48
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
49
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
50
|
+
window.location.replace(payload.url);
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
if (isPC()) {
|
54
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
55
|
+
window.location.href = payload.url;
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
if (!payload.schemeUrl && !payload.applinkUrl) {
|
59
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
60
|
+
window.location.href = payload.url;
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
// Use callApp lib to evoke
|
64
|
+
var callAppLib = new CallApp({
|
65
|
+
successCb: function successCb(evokeAppBy) {
|
66
|
+
var type = evokeAppBy.type == 'Scheme' ? RedirectType.SchemeUrl : RedirectType.ApplinkUrl;
|
67
|
+
successCallback(payload, type, evokeAppBy.url, serviceProvider);
|
78
68
|
}
|
79
69
|
});
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
70
|
+
var callSchemeUrl = function callSchemeUrl() {
|
71
|
+
callAppLib.open({
|
72
|
+
scheme: payload.schemeUrl,
|
73
|
+
fallback: function fallback() {
|
74
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
75
|
+
if (payload.url) {
|
76
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
77
|
+
window.location.href = payload.url;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
});
|
81
|
+
};
|
82
|
+
if (payload.applinkUrl) {
|
83
|
+
callAppLib.open({
|
84
|
+
link: payload.applinkUrl,
|
85
|
+
fallback: function fallback() {
|
86
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
87
|
+
// Applink evoke failed, try to use scheme url
|
88
|
+
callSchemeUrl();
|
89
|
+
}
|
90
|
+
});
|
91
|
+
} else if (payload.schemeUrl) {
|
92
|
+
callSchemeUrl();
|
93
|
+
}
|
94
|
+
} catch (e) {
|
95
|
+
serviceProvider.getService('Log').logInfo({
|
96
|
+
title: 'sdk_event_call_url_failed'
|
97
|
+
}, {
|
98
|
+
redirectInfo: JSON.stringify(payload),
|
99
|
+
errorMessage: JSON.stringify(e)
|
100
|
+
}).send();
|
92
101
|
}
|
93
102
|
};
|
94
103
|
var successCallback = function successCallback(payload, type, url, serviceProvider) {
|
@@ -22,9 +22,6 @@ export var registerSystemEvents = function registerSystemEvents(eventCenter) {
|
|
22
22
|
form.submit();
|
23
23
|
}, 0);
|
24
24
|
};
|
25
|
-
var handleHeartBeat = function handleHeartBeat(data) {
|
26
|
-
// TODO:
|
27
|
-
};
|
28
25
|
var handleBeforeSubmit = function handleBeforeSubmit(data) {
|
29
26
|
if (eventCenter.isExist(EVENT.beforeSubmit.name)) {
|
30
27
|
eventCenter.emit(EVENT.beforeSubmit.name, data);
|
@@ -52,7 +49,6 @@ export var registerSystemEvents = function registerSystemEvents(eventCenter) {
|
|
52
49
|
});
|
53
50
|
};
|
54
51
|
eventCenter.listen(EVENT.submitForm.name, handleSubmitForm);
|
55
|
-
eventCenter.listen(EVENT.appHeartBeat.name, handleHeartBeat);
|
56
52
|
eventCenter.listen(EVENT.beforeSubmit.name, handleBeforeSubmit);
|
57
53
|
eventCenter.listen(EVENT.sendBroadcast.name, handleSendBroadcast);
|
58
54
|
// deprecated
|
@@ -60,7 +56,6 @@ export var registerSystemEvents = function registerSystemEvents(eventCenter) {
|
|
60
56
|
};
|
61
57
|
export var unRegisterSystemEvents = function unRegisterSystemEvents(eventCenter) {
|
62
58
|
eventCenter.unlisten(EVENT.submitForm.name);
|
63
|
-
eventCenter.unlisten(EVENT.appHeartBeat.name);
|
64
59
|
eventCenter.unlisten(EVENT.beforeSubmit.name);
|
65
60
|
eventCenter.unlisten(EVENT.sendBroadcast.name);
|
66
61
|
eventCenter.unlisten(EVENT.sendMuitiAppEventToSdk.name);
|