From 4caba62bf8c970a130446e0b2d22b2c41e7eafdb Mon Sep 17 00:00:00 2001 From: yixian Date: Fri, 14 May 2021 11:40:25 +0800 Subject: [PATCH] =?UTF-8?q?3ds=20=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/static/templates/payment/v1/card_pay.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/ui/static/templates/payment/v1/card_pay.js b/src/main/ui/static/templates/payment/v1/card_pay.js index cd161aabf..83c405f7b 100644 --- a/src/main/ui/static/templates/payment/v1/card_pay.js +++ b/src/main/ui/static/templates/payment/v1/card_pay.js @@ -4,6 +4,7 @@ $(function () { let cardFrame = new CardInputFrame($container, window.card_input_appid, window.card_input_token); let $errorMsgBox = $('#errorMsgBox'); let loading = $('.loading-container'); + function bindEvent(element, eventName, eventHandler) { if (element.addEventListener) { element.addEventListener(eventName, eventHandler, true); @@ -11,23 +12,24 @@ $(function () { element.attachEvent('on' + eventName, eventHandler); } } - bindEvent(window,'message',function (evt){ - if (!evt.data){ + + bindEvent(window, 'message', function (evt) { + if (!evt.data) { return } - let msg = JSON.parse(evt.data); - if (msg && msg.type=='3dsResult'){ + let msg = typeof evt.data == 'string' ? JSON.parse(evt.data) : evt.data; + if (msg && msg.type == '3dsResult') { evt.stopPropagation(); evt.stopImmediatePropagation(); $('.threeds-container').addClass('hide'); - if (msg.success){ + if (msg.success) { location.href = './result' - }else { + } else { $errorMsgBox.text('[' + evt.errCode + ']' + evt.errMsg).show(); } } }) - if (window.three_ds_params){ + if (window.three_ds_params) { handleThreeDs(window.three_ds_params) }