diff --git a/src/main/ui/static/templates/skip_wxbrowser_aps.js b/src/main/ui/static/templates/skip_wxbrowser_aps.js new file mode 100644 index 000000000..38df37603 --- /dev/null +++ b/src/main/ui/static/templates/skip_wxbrowser_aps.js @@ -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); + } + } + }) + } +}) +;