From ad91b2a91f5db3de17e165409e4faada04d05317 Mon Sep 17 00:00:00 2001 From: dalong306 <304592994@qq.com> Date: Thu, 20 Jan 2022 17:53:42 +0800 Subject: [PATCH] =?UTF-8?q?normal=5Furl=E6=94=BE=E5=9C=A8=E5=89=8D?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/templates/alipayaps/v1/payment.js | 2 +- .../static/templates/alipayaps/v4/payment.js | 2 +- .../static/templates/alipayaps/v5/payment.js | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/main/ui/static/templates/alipayaps/v1/payment.js b/src/main/ui/static/templates/alipayaps/v1/payment.js index d28df875c..901912491 100644 --- a/src/main/ui/static/templates/alipayaps/v1/payment.js +++ b/src/main/ui/static/templates/alipayaps/v1/payment.js @@ -473,7 +473,7 @@ $(function () { } function callAlipayAps(order) { if(order.jsapi){ - let try_sequence = [order.jsapi.scheme_url, order.jsapi.applink_url, order.jsapi.normal_url] + let try_sequence = [order.jsapi.normal_url,order.jsapi.scheme_url, order.jsapi.applink_url] try_sequence = try_sequence.filter(v => v != null) callApp(try_sequence, 0, 5000).then(() => { alert('redirect success') diff --git a/src/main/ui/static/templates/alipayaps/v4/payment.js b/src/main/ui/static/templates/alipayaps/v4/payment.js index 536543928..19ed5b9ed 100644 --- a/src/main/ui/static/templates/alipayaps/v4/payment.js +++ b/src/main/ui/static/templates/alipayaps/v4/payment.js @@ -517,7 +517,7 @@ $(function () { } function callAlipayAps(order) { if(order.jsapi){ - let try_sequence = [order.jsapi.scheme_url, order.jsapi.applink_url, order.jsapi.normal_url] + let try_sequence = [order.jsapi.normal_url,order.jsapi.scheme_url, order.jsapi.applink_url] try_sequence = try_sequence.filter(v => v != null) callApp(try_sequence, 0, 5000).then(() => { alert('redirect success') diff --git a/src/main/ui/static/templates/alipayaps/v5/payment.js b/src/main/ui/static/templates/alipayaps/v5/payment.js index c21e947d7..f5d4c4543 100644 --- a/src/main/ui/static/templates/alipayaps/v5/payment.js +++ b/src/main/ui/static/templates/alipayaps/v5/payment.js @@ -453,5 +453,45 @@ $(function () { } } + function callApp(scheme_seq, index, timeout) { + let timer, start = new Date().getTime() + let promise = new Promise(((resolve, reject) => { + location.href = scheme_seq[index] + // alert("====>scheme_seq[index]:"+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.normal_url,order.jsapi.scheme_url, order.jsapi.applink_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 + } + } });