diff --git a/src/main/ui/static/templates/payment/v1/gateway_jsapi.js b/src/main/ui/static/templates/payment/v1/gateway_jsapi.js index fc837d49c..119411cd9 100644 --- a/src/main/ui/static/templates/payment/v1/gateway_jsapi.js +++ b/src/main/ui/static/templates/payment/v1/gateway_jsapi.js @@ -50,9 +50,16 @@ $(document).ready(function () { invokePay(paydata); }, error: function (jqXhr) { - alert(jqXhr.responseJSON.message); - $('#wdiv').hide(); - dataCache.paying = false; + var respText = jqXhr.responseText; + try { + alert(JSON.parse(respText).message); + $('#wdiv').hide(); + dataCache.paying = false; + } catch (e) { + alert("Unexpected Error:" + respText); + $('#wdiv').hide(); + dataCache.paying = false; + } } }); diff --git a/src/main/ui/static/templates/payment/v1/payment.js b/src/main/ui/static/templates/payment/v1/payment.js index 60ee79934..cbc8f374b 100644 --- a/src/main/ui/static/templates/payment/v1/payment.js +++ b/src/main/ui/static/templates/payment/v1/payment.js @@ -198,7 +198,7 @@ $(function () { $('
').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.surcharge).appendTo(bd); } if (parseFloat(dataCache.tax) > 0) { - $('').html('GST(10%):'+currencySymbol+dataCache.tax).appendTo(bd); + $('').html('GST(10%):' + currencySymbol + dataCache.tax).appendTo(bd); } $(dataCache.discounts).each(function () { $('').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd); @@ -287,10 +287,19 @@ $(function () { }) }, error: function (jqXhr) { - weuiAlert(jqXhr.responseJSON.message); - $('#key_P').removeClass('hidden'); - $('#key_Loading').addClass('hidden'); - dataCache.paying = false; + var respText = jqXhr.responseText; + try { + weuiAlert(JSON.parse(respText).message); + $('#key_P').removeClass('hidden'); + $('#key_Loading').addClass('hidden'); + dataCache.paying = false; + } catch (e) { + alert("Unexpected Error:" + respText); + $('#key_P').removeClass('hidden'); + $('#key_Loading').addClass('hidden'); + dataCache.paying = false; + } + } }) }); diff --git a/src/main/ui/static/templates/payment/v1/retail_jsapi.js b/src/main/ui/static/templates/payment/v1/retail_jsapi.js index 6c42a8d43..d31f1e94b 100644 --- a/src/main/ui/static/templates/payment/v1/retail_jsapi.js +++ b/src/main/ui/static/templates/payment/v1/retail_jsapi.js @@ -4,18 +4,21 @@ $(document).ready(function () { 'use strict'; decode(); + function decode() { var redirect = window.redirect; - while(redirect.indexOf('://')<0){ + while (redirect.indexOf('://') < 0) { redirect = decodeURIComponent(redirect); - if(redirect==window.redirect){ + if (redirect == window.redirect) { break; } window.redirect = redirect; } } + var dataCache = {paying: false}; $('#key_P').bind('touchstart', startPay); + function startPay() { $('#wdiv').show(); if (dataCache.paying) { @@ -28,17 +31,31 @@ $(document).ready(function () { method: 'get', dataType: 'json', success: function (pay) { - if(pay.direct_paid){ + try { + if (pay.direct_paid) { + dataCache.paying = false; + location.href = window.redirect; + } + var paydata = pay.jsapi; + invokePay(paydata); + }catch (e) { + alert("Unexpected Error:" + e); + $('#wdiv').hide(); dataCache.paying = false; - location.href = window.redirect; } - var paydata = pay.jsapi; - invokePay(paydata); }, error: function (jqXhr) { - alert(jqXhr.responseJSON.message); - $('#wdiv').hide(); - dataCache.paying = false; + var respText = jqXhr.responseText; + try { + alert(JSON.parse(respText).message); + $('#wdiv').hide(); + dataCache.paying = false; + } catch (e) { + alert("Unexpected Error:" + respText); + $('#wdiv').hide(); + dataCache.paying = false; + } + } }); @@ -85,6 +102,7 @@ $(document).ready(function () { } }) } + checkOrderStd(); } }); \ No newline at end of file