版权声明: https://blog.csdn.net/caoyan0829/article/details/86085210
正常代码都很好写,就是打开APP的链接,和客户端开发联调了一下。由于我们的APP的很多东西都是后台可配置的,所以要沟通清楚,参数一定要一致才行。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no, viewport-fit=cover">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="screen-orientation" content="portrait">
<meta name="full-screen" content="yes">
<meta name="browsermode" content="application">
<meta name="x5-orientation" content="portrait">
<meta name="x5-fullscreen" content="true">
<meta name="x5-page-mode" content="app">
<meta name="HandheldFriendly" content="true">
<meta name="MobileOptimized" content="320">
<meta http-equiv="pragma" content="no-cache" />
<meta name="format-detection" content="telephone=no, email=no"/>
<title>活动指引</title>
<style>
html,body{
margin:0;
padding:0;
min-height: 100%;
overflow-x: hidden;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
a {text-decoration: none;}
img{width: 100%;}
p{
text-align: center;
color: red;
font-size: 30px;
position: fixed;
top: 50%;
width: 100%;
font-weight: bold;
}
</style>
</head>
<body>
<a id="click_a">
<img src="https://img.cdn.zhaoshang800.com/img/2019/01/07/broker/808eefa2-7e70-4f0f-8d7f-cb3b713e5f1c.gif" />
<p>点击参与</p>
</a>
</body>
<script>
var click_a = document.getElementById("click_a");
var url_ios = "***; //苹果打开app的链接(由苹果开发提供)
var url_ios_download = '***';//苹果下载的链接(由苹果开发提供)
var url_android = "***";//安卓打开app的链接(由安卓开发提供)
var url_android_download = '***';//安卓下载app的链接(由安卓开发提供)
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
click_a.onclick= function(){
if(isiOS){
location.href = url_ios;
var l = Date.now();
// 如果打开超时说明是没有安装,则跳到下载的地址
setTimeout(function(){
if (Date.now() - l < 1200) {
location.href = url_ios_download;
}
},1000)
}else{
location.href = url_android;
var t = Date.now();
setTimeout(function(){
if (Date.now() - t < 1200) {
location.href = url_android_download;
}
}, 1000);
}
}
</script>
</html>
最后使用短连接,然后后台去配置发送短信http://c7.gg/bU8Lu