mirror of
https://gitee.com/technical-laohu/mpay.git
synced 2025-11-14 22:53:43 +08:00
更新支付宝插件
This commit is contained in:
@@ -6,6 +6,44 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>收银台</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<script>
|
||||
function detectBrowserEnvironment() {
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
let environment = 'other';
|
||||
if (userAgent.includes('micromessenger')) {
|
||||
if (userAgent.includes('miniprogram')) {
|
||||
environment = 'wxapp'; // 微信小程序
|
||||
} else if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
|
||||
environment = 'wxphone'; // 手机微信
|
||||
} else {
|
||||
environment = 'wxpc'; // PC微信
|
||||
}
|
||||
} else if (userAgent.includes('aliapp') || userAgent.includes('alipayclient')) {
|
||||
if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
|
||||
environment = 'aliphone'; // 手机支付宝
|
||||
} else {
|
||||
environment = 'alipc'; // PC支付宝
|
||||
}
|
||||
} else if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
|
||||
// 先判断是否是已知的手机APP内置浏览器,如果不是则认为是手机浏览器
|
||||
if (!userAgent.includes('micromessenger') && !userAgent.includes('aliapp') && !userAgent.includes('qq')) {
|
||||
environment = 'phone'; // 手机浏览器
|
||||
}
|
||||
} else {
|
||||
environment = 'pc'; // 剩下的情况认为是PC浏览器
|
||||
}
|
||||
return environment;
|
||||
}
|
||||
const payCode = '<?php echo $payUrl; ?>';
|
||||
const codeType = '<?php echo htmlentities($code_type); ?>';
|
||||
const payType = '<?php echo htmlentities($type); ?>';
|
||||
const order = '<?php echo htmlentities($order_id); ?>';
|
||||
const environment = detectBrowserEnvironment();
|
||||
const payclient = '<?php echo htmlentities($payclient ?? ""); ?>';
|
||||
if (payclient == 'Alipayf' && environment == 'aliphone') {
|
||||
window.location.href = payCode;
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
background: #f7f7f7;
|
||||
@@ -157,39 +195,6 @@
|
||||
<script src="/component/layui/layui.js"></script>
|
||||
<script src="/static/js/awesome-qr.min.js"></script>
|
||||
<script>
|
||||
function detectBrowserEnvironment() {
|
||||
const userAgent = navigator.userAgent.toLowerCase();
|
||||
let environment = 'other';
|
||||
if (userAgent.includes('micromessenger')) {
|
||||
if (userAgent.includes('miniprogram')) {
|
||||
environment = 'wxapp'; // 微信小程序
|
||||
} else if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
|
||||
environment = 'wxphone'; // 手机微信
|
||||
} else {
|
||||
environment = 'wxpc'; // PC微信
|
||||
}
|
||||
} else if (userAgent.includes('aliapp') || userAgent.includes('alipayclient')) {
|
||||
if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
|
||||
environment = 'aliphone'; // 手机支付宝
|
||||
} else {
|
||||
environment = 'alipc'; // PC支付宝
|
||||
}
|
||||
} else if (userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) {
|
||||
// 先判断是否是已知的手机APP内置浏览器,如果不是则认为是手机浏览器
|
||||
if (!userAgent.includes('micromessenger') && !userAgent.includes('aliapp') && !userAgent.includes('qq')) {
|
||||
environment = 'phone'; // 手机浏览器
|
||||
}
|
||||
} else {
|
||||
environment = 'pc'; // 剩下的情况认为是PC浏览器
|
||||
}
|
||||
return environment;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
const payCode = '<?php echo $payUrl; ?>';
|
||||
const codeType = '<?php echo htmlentities($code_type); ?>';
|
||||
const payType = '<?php echo htmlentities($type); ?>';
|
||||
const order = '<?php echo htmlentities($order_id); ?>';
|
||||
const QR = AwesomeQR.AwesomeQR;
|
||||
(async () => {
|
||||
// 支付类型
|
||||
@@ -207,7 +212,16 @@
|
||||
}
|
||||
// 生成二维码
|
||||
if (codeType == 0) {
|
||||
document.getElementById('qrcode').src = await getQrcode(payCode, QR);
|
||||
if (payType === 'alipay' && environment === 'pc') {
|
||||
// 解析网址
|
||||
const url = new URL(payCode);
|
||||
const queryParams = new URLSearchParams(url.search);
|
||||
const qrcode = queryParams.get('qrcode');
|
||||
const decodedQrcode = decodeURIComponent(qrcode);
|
||||
document.getElementById('qrcode').src = await getQrcode(decodedQrcode, QR);
|
||||
} else {
|
||||
document.getElementById('qrcode').src = await getQrcode(payCode, QR);
|
||||
}
|
||||
} else {
|
||||
document.getElementById('qrcode').src = payCode;
|
||||
}
|
||||
@@ -284,7 +298,6 @@
|
||||
/* <?php } ?> */
|
||||
|
||||
// 环境判断
|
||||
const environment = detectBrowserEnvironment();
|
||||
if (payType === 'wxpay' && environment === 'aliphone') {
|
||||
layer.alert('请使用微信打开此页面');
|
||||
} else if (payType === 'alipay' && environment === 'wxphone') {
|
||||
|
||||
Reference in New Issue
Block a user