79 lines
2.5 KiB
PHP
79 lines
2.5 KiB
PHP
<html>
|
|
<head>
|
|
<title>打开<?= $title ?>小程序</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
|
|
<!-- 生成二维码 -->
|
|
<script src="https://qs.liche.cn/web/javascript/qrcode.min.js"></script>
|
|
</head>
|
|
<style>
|
|
.fn-hidden {
|
|
display: none;
|
|
}
|
|
|
|
.box-center-middle {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
width: 100%;
|
|
text-align: center;
|
|
transform: translate(-50%, -50%);
|
|
font-size: 14px;
|
|
color: #999;
|
|
}
|
|
|
|
#qrcode {
|
|
width: 200px;
|
|
margin: 0 auto;
|
|
padding-bottom: 10px;
|
|
}
|
|
</style>
|
|
<body>
|
|
<div id="isPc" class="box-center-middle fn-hidden">
|
|
<div id="qrcode"></div>
|
|
<div>请在手机打开网页链接</div>
|
|
</div>
|
|
<div id="isWeixin" class="box-center-middle fn-hidden">请点击右上角・・・用浏览器打开</div>
|
|
<div id="isMobile" class="box-center-middle fn-hidden">正在打开 “<?= $title ?>”...</div>
|
|
<script>
|
|
let ua = navigator.userAgent.toLowerCase()
|
|
// 企业微信
|
|
let isWXWork = ua.match(/wxwork/i) == 'wxwork'
|
|
// 微信浏览器
|
|
let isWeixin = !isWXWork && ua.match(/MicroMessenger/i) == 'micromessenger'
|
|
let isMobile = false
|
|
let isDesktop = false
|
|
if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i)) {
|
|
isMobile = true
|
|
} else {
|
|
isDesktop = true
|
|
}
|
|
if (isDesktop) {
|
|
// 在 pc 上则给提示引导到手机端打开
|
|
let isPcCon = document.getElementById('isPc')
|
|
isPcCon.style.display = "block";
|
|
// 生成当前页面二维码
|
|
new QRCode('qrcode', {
|
|
text: document.URL,
|
|
width: 200,
|
|
height: 200,
|
|
colorDark: '#000000',
|
|
colorLight: '#ffffff',
|
|
correctLevel: QRCode.CorrectLevel.H
|
|
});
|
|
} else if (isWeixin) {
|
|
//如果微信浏览器上则给提示引导到原生浏览器打开
|
|
let isWeixinCon = document.getElementById('isWeixin')
|
|
isWeixinCon.style.display = "block";
|
|
} else {
|
|
let isMobileCon = document.getElementById('isMobile')
|
|
isMobileCon.remove('hidden')
|
|
isMobileCon.style.display = "block";
|
|
let query = window.location.search.substring(1);
|
|
setTimeout(() => {
|
|
location.href = 'weixin://dl/business/?' + query
|
|
}, 10);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|