<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0 , maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui, viewport-fit=cover">
<title>下载页面</title>
<style>
body {
margin: 0;
padding: 0;
}
img {
position: fixed;
top: 0;
left: 0;
display: block;
padding: 0;
margin: 0
}
.download {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 50px;
background: rgba(0, 0, 0, 0.7);
color: #fff;
display: flex;
justify-content: space-between;
padding: 0 20px;
align-items: center;
box-sizing: border-box;
/*适配iPhone X的底部安全区域 在上面加viewport-fit=cover配合使用*/
margin-bottom: env(safe-area-inset-bottom);
}
.download p {
font-size: 14px;
}
.download botton {
background: #C4302C;
padding: 5px 15px;
font-size: 14px;
border-radius: 6px;
}
</style>
</head>
<body>
<img width="100%" src="https://phadcalc.com/app-code/img/android.jpg" alt="">
<!-- 点击下载 -->
<div class="download">
<p>未安装  APP</p>
<botton onclick="downloadApp()">去app store下载</button>
</div>
</body>
<script>
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
const platform = navigator.platform || '';
// 判断是否苹果
function isIOSDevice() {
return (
(/iPhone|iPod|iPad/.test(userAgent) && !window.MSStream) ||
/iPhone|iPad|iPod/.test(platform)
);
}
// 判断是否微信浏览器
function isWeixinBrowser() {
return /MicroMessenger/i.test(userAgent);
}
// 改变背景图
(function redirectToAppStore() {
document.querySelector('botton').innerHTML = isIOSDevice() ? "去app store下载" : "去下载"
//微信浏览器跳转不了应用商店隐藏下载
document.querySelector('.download').style.display = isIOSDevice() ? 'none' : 'flex'
if (isWeixinBrowser()) {
document.querySelector('img').src = isIOSDevice() ? "https://phadcalc.com/app-code/img/apple.jpg" : "https://phadcalc.com/app-code/img/android.jpg"
} else {
document.querySelector('img').src = "/img/app.jpg"
}
})()
// 下载
function downloadApp() {
if (isWeixinBrowser()) {
// 苹果端微信浏览器跳转不了应用商店
window.location.href = isIOSDevice() ? 'https://itunes.apple.com/app/id6743391396?mt=8' :
"https://sj.qq.com/myapp/detail.htm?apkName=com.phadscholar"; // 安卓微信浏览在应用宝下载com.phadscholar是打包名
} else {
window.location.href = isIOSDevice() ? "https://itunes.apple.com/app/id6743391396?mt=8" : //苹果浏览器跳转appstore应用商店 id后面的数字是appid
// "https://xxxx.com/xxxx.apk"; // 系统浏览器直接下载安装包
"https://sj.qq.com/myapp/detail.htm?apkName=com.phadscholar"; // 系统浏览器在应用宝下载
}
}
</script>
</html>
<PACKAGE_NAME>就是你打包的名称
com.phadscholar
腾讯应用宝 https://sj.qq.com/myapp/detail.htm?apkName=<PACKAGE_NAME>
Google Play https://play.google.com/store/apps/details?id=<PACKAGE_NAME>
华为应用市场 https://appgallery.cloud.huawei.com/marketshare/app/C<APP_ID>
小米应用商店 https://app.mi.com/details?id=<PACKAGE_NAME>
OPPO 应用商店 https://store.oppomobile.com/product/<PACKAGE_NAME>.html
VIVO 应用商店 https://sj.qq.com/myapp/detail.htm?apkName=<PACKAGE_NAME>
三星 Galaxy Store
samsungapps://ProductDetail/<PACKAGE_NAME>
注意:这种
samsungapps://
协议只能在三星设备上生效。如果用户未安装三星应用商店,则需要提供一个备用的 HTTPS 链接。
苹果appid