From 4f442a6dbf997a0bc83312a4d3ea70072afcea88 Mon Sep 17 00:00:00 2001 From: dalong306 <304592994@qq.com> Date: Mon, 27 Dec 2021 10:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A6=E5=8D=95=E7=A0=81aps=E6=B8=A0?= =?UTF-8?q?=E9=81=93=20=E8=B7=B3=E8=BD=AC=E5=9C=B0=E5=9D=80=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/static/templates/skip_wxbrowser_aps.js | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/main/ui/static/templates/skip_wxbrowser_aps.js 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); + } + } + }) + } +}) +;