短信链接或者微信链接跳转到app

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="stylesheet" href="css/dialog.css">
  <title>XXX</title>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

  <style>
      * {
          margin: 0;
          padding: 0;
      }
         /* .wrap-dialog {
                      position: fixed;
                      top: 0;
                      left: 0;
                      width: 100%;
                      height: 100%;
                      font-size: 16px;
                      text-align: center;
                      background-color: rgba(0, 0, 0, .4);
                      z-index: 999;
                  }
         .dialog {
                      position: relative;
                      margin: 15% auto;
                      width: 50%;
                      background-color: #FFFFFF;
                  }
         .dialog .dialog-header {
                      height: 20px;
                      padding: 10px;
                      background-color: lightskyblue;
                  }
         .dialog .dialog-body {
                      height: 60px;
                      padding: 20px;
                  }
          .dialog-footer {
                    display: flex;
                    justify-content: center;
                    padding: 8px;
                    background-color: whitesmoke;
                  }
         .btn {
                      width: 70px;
                      padding: 2px;
                  }
         .hide {
                      display: none;
                  }
         .ml50 {
                      margin-left: 50px;
                  } */
     </style>

</head>
<body class="hold-transition login-page">

<script type="text/javascript" src="https://passport.cnblogs.com/scripts/jsencrypt.min.js"></script>
<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/dialog.js"></script>    
<script>

    function dialogBox(message, yesCallback, noCallback){
    
        $.dialog({
            type : 'confirm',
            titleText: '是否打开XXXAPP查看通知',
            contentHtml : message,
            buttonText: {
                cancel: '去下载',
                ok: '是'
            },
            onClickOk: function() {
                yesCallback();
            },
            onClickCancel: function() {
                noCallback();
            }

        });
    }

    $(function () {
        var name,value;
        var str=location.href; //取得整个地址栏
        var num=str.indexOf("?");
        str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]
        var array = str.split("=");
        if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
            
            var message = "若未安装XXXAPP,请点击'去下载' ";
            dialogBox(message,
                function () {
                    // 判断useragent,当前设备为ios设备
                    window.location.href = "baidu://msgType="+array[1]; // iOS端URL Schema
                },
                function(){
                    window.location = "https://itunes.apple.com/cn/app/XXX/id1436564607?l=zh&ls=1&mt=8/"; // appstore下载地址
                }
            );

        } else if (navigator.userAgent.match(/(android|Android);?/i)) {

            var message = "点'是'若不能跳转XXXAPP,可能因为浏览器设置导致,请手动打开XXXAPP ";
            dialogBox(message,
                function () {
                    window.location.href = "scheme://post/noticeListActivity?msgType="+array[1]; /***打开app的协议,有安卓同事提供***/
                },
                function(){
                    window.location = "http://www.baidu.com/app/android.apk"; /***打开app的协议,有安卓同事提供***/
                }
            );
        }

    });

</script>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/damoneric_guo/article/details/93753488