error processing

master
yixian 7 years ago
parent c8856db17b
commit c6b7a5d2d4

@ -50,9 +50,16 @@ $(document).ready(function () {
invokePay(paydata); invokePay(paydata);
}, },
error: function (jqXhr) { error: function (jqXhr) {
alert(jqXhr.responseJSON.message); var respText = jqXhr.responseText;
try {
alert(JSON.parse(respText).message);
$('#wdiv').hide(); $('#wdiv').hide();
dataCache.paying = false; dataCache.paying = false;
} catch (e) {
alert("Unexpected Error:" + respText);
$('#wdiv').hide();
dataCache.paying = false;
}
} }
}); });

@ -287,10 +287,19 @@ $(function () {
}) })
}, },
error: function (jqXhr) { error: function (jqXhr) {
weuiAlert(jqXhr.responseJSON.message); var respText = jqXhr.responseText;
try {
weuiAlert(JSON.parse(respText).message);
$('#key_P').removeClass('hidden'); $('#key_P').removeClass('hidden');
$('#key_Loading').addClass('hidden'); $('#key_Loading').addClass('hidden');
dataCache.paying = false; dataCache.paying = false;
} catch (e) {
alert("Unexpected Error:" + respText);
$('#key_P').removeClass('hidden');
$('#key_Loading').addClass('hidden');
dataCache.paying = false;
}
} }
}) })
}); });

@ -4,6 +4,7 @@
$(document).ready(function () { $(document).ready(function () {
'use strict'; 'use strict';
decode(); decode();
function decode() { function decode() {
var redirect = window.redirect; var redirect = window.redirect;
while (redirect.indexOf('://') < 0) { while (redirect.indexOf('://') < 0) {
@ -14,8 +15,10 @@ $(document).ready(function () {
window.redirect = redirect; window.redirect = redirect;
} }
} }
var dataCache = {paying: false}; var dataCache = {paying: false};
$('#key_P').bind('touchstart', startPay); $('#key_P').bind('touchstart', startPay);
function startPay() { function startPay() {
$('#wdiv').show(); $('#wdiv').show();
if (dataCache.paying) { if (dataCache.paying) {
@ -28,18 +31,32 @@ $(document).ready(function () {
method: 'get', method: 'get',
dataType: 'json', dataType: 'json',
success: function (pay) { success: function (pay) {
try {
if (pay.direct_paid) { if (pay.direct_paid) {
dataCache.paying = false; dataCache.paying = false;
location.href = window.redirect; location.href = window.redirect;
} }
var paydata = pay.jsapi; var paydata = pay.jsapi;
invokePay(paydata); invokePay(paydata);
}catch (e) {
alert("Unexpected Error:" + e);
$('#wdiv').hide();
dataCache.paying = false;
}
}, },
error: function (jqXhr) { error: function (jqXhr) {
alert(jqXhr.responseJSON.message); var respText = jqXhr.responseText;
try {
alert(JSON.parse(respText).message);
$('#wdiv').hide();
dataCache.paying = false;
} catch (e) {
alert("Unexpected Error:" + respText);
$('#wdiv').hide(); $('#wdiv').hide();
dataCache.paying = false; dataCache.paying = false;
} }
}
}); });
@ -85,6 +102,7 @@ $(document).ready(function () {
} }
}) })
} }
checkOrderStd(); checkOrderStd();
} }
}); });
Loading…
Cancel
Save