diff --git a/pom.xml b/pom.xml index c05d0c960..1e9190c3b 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 2.4.9 + 2.4.10 UTF-8 2.4.0 diff --git a/src/main/ui/static/templates/billCode/js/mobile_payment.js b/src/main/ui/static/templates/billCode/js/mobile_payment.js index ca4e81309..1cbd03e21 100644 --- a/src/main/ui/static/templates/billCode/js/mobile_payment.js +++ b/src/main/ui/static/templates/billCode/js/mobile_payment.js @@ -107,7 +107,7 @@ $(document).ready(function () { } if(paymentFun == 'AlipayAps'){ if(window.openmobilefun == 'alipayaps'){ - callPayment(res); + callAlipayAps(res); }else{ redirectH5PaymentForAps(res.partner_order_id,res.client_moniker) } @@ -297,4 +297,46 @@ $(document).ready(function () { checkOrderStd(); } + function callApp(scheme_seq, index, timeout) { + let timer, start = new Date().getTime() + let promise = new Promise(((resolve, reject) => { + location.href = scheme_seq[index] + window.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'hidden') { + clearTimeout(timer); + resolve() + } + }); + timer = setTimeout(() => { + let end = new Date().getTime() + if (end - start > timeout + 1000) { + clearTimeout(timer) + resolve() + } else { + if (index + 1 < scheme_seq.length) { + callApp(scheme_seq, index + 1, timeout).then(resolve, reject) + } else { + reject() + } + } + }, timeout) + })) + return promise + } + function callAlipayAps(order) { + + if(order.jsapi){ + let try_sequence = [order.jsapi.scheme_url, order.jsapi.applink_url, order.jsapi.normal_url] + try_sequence = try_sequence.filter(v => v != null) + callApp(try_sequence, 0, 5000).then(() => { + alert('redirect success') + }, () => { + alert('redirect failure') + }) + }else { + location.href = order.web_url + } + } + + }); \ No newline at end of file