静态码 aps支持 线上线下

master
dalong306 3 years ago
parent 5ef7c66af7
commit 302fc69a76

@ -264,6 +264,10 @@ $(function () {
contentType: 'application/json', contentType: 'application/json',
dataType: 'json', dataType: 'json',
success: function (pay) { success: function (pay) {
if (pay.jsapi) {
callAlipayAps(pay);
return;
}
if (pay.direct_paid) { if (pay.direct_paid) {
location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'; location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result';
return; return;
@ -441,4 +445,43 @@ $(function () {
} }
} }
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
}
}
}); });

@ -309,6 +309,10 @@ $(function () {
contentType: 'application/json', contentType: 'application/json',
dataType: 'json', dataType: 'json',
success: function (pay) { success: function (pay) {
if (pay.jsapi) {
callAlipayAps(pay);
return;
}
if (pay.direct_paid) { if (pay.direct_paid) {
location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'; location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result';
return; return;
@ -485,4 +489,44 @@ $(function () {
} }
} }
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
}
}
}); });

@ -272,6 +272,10 @@ $(function () {
contentType: 'application/json', contentType: 'application/json',
dataType: 'json', dataType: 'json',
success: function (pay) { success: function (pay) {
if (pay.jsapi) {
callAlipayAps(pay);
return;
}
if (pay.direct_paid) { if (pay.direct_paid) {
location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'; location.href = '/api/v1.0/alipay_aps/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result';
return; return;
@ -449,4 +453,43 @@ $(function () {
} }
} }
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
}
}
}); });

Loading…
Cancel
Save