3ds 流程优化

master
yixian 4 years ago
parent a4b4c53ce9
commit 4caba62bf8

@ -4,6 +4,7 @@ $(function () {
let cardFrame = new CardInputFrame($container, window.card_input_appid, window.card_input_token); let cardFrame = new CardInputFrame($container, window.card_input_appid, window.card_input_token);
let $errorMsgBox = $('#errorMsgBox'); let $errorMsgBox = $('#errorMsgBox');
let loading = $('.loading-container'); let loading = $('.loading-container');
function bindEvent(element, eventName, eventHandler) { function bindEvent(element, eventName, eventHandler) {
if (element.addEventListener) { if (element.addEventListener) {
element.addEventListener(eventName, eventHandler, true); element.addEventListener(eventName, eventHandler, true);
@ -11,23 +12,24 @@ $(function () {
element.attachEvent('on' + eventName, eventHandler); element.attachEvent('on' + eventName, eventHandler);
} }
} }
bindEvent(window,'message',function (evt){
if (!evt.data){ bindEvent(window, 'message', function (evt) {
if (!evt.data) {
return return
} }
let msg = JSON.parse(evt.data); let msg = typeof evt.data == 'string' ? JSON.parse(evt.data) : evt.data;
if (msg && msg.type=='3dsResult'){ if (msg && msg.type == '3dsResult') {
evt.stopPropagation(); evt.stopPropagation();
evt.stopImmediatePropagation(); evt.stopImmediatePropagation();
$('.threeds-container').addClass('hide'); $('.threeds-container').addClass('hide');
if (msg.success){ if (msg.success) {
location.href = './result' location.href = './result'
}else { } else {
$errorMsgBox.text('[' + evt.errCode + ']' + evt.errMsg).show(); $errorMsgBox.text('[' + evt.errCode + ']' + evt.errMsg).show();
} }
} }
}) })
if (window.three_ds_params){ if (window.three_ds_params) {
handleThreeDs(window.three_ds_params) handleThreeDs(window.three_ds_params)
} }

Loading…
Cancel
Save