H5跳转下载页面,苹果跳转appstore应用商店,安卓跳转应用宝或者直接下载安装包,也可以去其他应用商店

<!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>未安装&nbsp&nbspAPP</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 Playhttps://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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

巨蟹座守护骑士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值