账单码aps渠道 跳转地址调整

master
dalong306 4 years ago
parent 3f53b494bf
commit 4f442a6dbf

@ -0,0 +1,63 @@
window = {};
$(function () {
'use strict';
var winHeight = $(window).height();
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') >= 0) {
$(".weixin-tip").show().css("height", winHeight);
} else {
callAlipayAps();
}
decode();
$('.close-weixin-tip').bind('touchstart', function () {
$(".weixin-tip").hide();
checkOrderStd(window.client_moniker, window.partner_order_id, true);
});
$('#complete').bind('touchstart', function () {
checkOrderStd(window.client_moniker, window.partner_order_id, false);
});
$('#continue_use_browser').bind('touchstart', function () {
callAlipayAps();
});
function decode() {
var redirect = window.redirect;
while (redirect.indexOf('://') < 0) {
redirect = decodeURIComponent(redirect);
if (redirect == window.redirect) {
break;
}
window.redirect = redirect;
}
}
function checkOrderStd(clientMoniker, merchantOrderId, needLoop) {
if (!clientMoniker || !merchantOrderId) {
return;
}
$.ajax({
url: '/api/v1.0/payment/clients/' + clientMoniker + '/orders/' + merchantOrderId + '/status',
method: 'GET',
dataType: 'json',
success: function (res) {
if (res.paid) {
location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true&time=' + res.time + '&nonce_str=' + res.nonce_str + '&sign=' + res.sign;
} else {
if (needLoop) {
setTimeout(checkOrderStd(clientMoniker, merchantOrderId, needLoop), 3000);
}
if (!needLoop && !res.paid) {
alert("订单未支付,请稍后再试");
}
}
},
error: function (res) {
if (needLoop && res.message) {
alert(res.message);
}
}
})
}
})
;
Loading…
Cancel
Save