<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>ChargeVip</title>
</head>
<script type="text/javascript" src="../index/js/jquery-2.2.3.min.js"></script>
<body>
<div id="weixin" class="bgimg1 hide" align="center">
</div>
<div id="charge_morefun" class="bgimg hide">
</div>
<span id="phone"></span>
<script type="text/javascript">
is_weixin();
function is_weixin() {
//判断是否是微信
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
$('#weixin').removeClass('hide');
$('#charge_morefun').addClass('hide');
} else {
$('#weixin').addClass('hide');
$('#charge_morefun').removeClass('hide');
open_or_download_app();
}
}
//<![CDATA[
function open_or_download_app() {
var str=location.href; //取得整个地址栏
var num=str.indexOf("?")
str=str.substr(num+1); //取得所有参数 stringvar.substr(start [, length ]
var arr=str.split("&"); //各个参数放到数组里
for(var i=0;i < arr.length;i++){
num=arr[i].indexOf("=");
if(num>0){
name=arr[i].substring(0,num);
value=arr[i].substr(num+1);
this[name]=value;
}
};
//this[name] 为请求链接获取参数
var phone = document.getElementById("phone");
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
phone.innerHTML = "ios设备";
// 判断当前设备为ios设备
var loadTime = new Date();
// 在规定时间里面没有打开对应App的话,直接去App store进行下载。
window.setTimeout(function() {
var OutTime = new Date();
if (OutTime - loadTime <2200) {
window.location = "xxxx"; // ios下载地址
} else {
window.close();
}
},5000);
window.location = "xxxx?page=charge_vip_create&phone="+this[name]; // ios端URL Schema
} else if (navigator.userAgent.match(/android/i)) {
phone.innerHTML = "Android设备";
// 判断当前设备为Android设备
var loadTime = new Date();
// 在规定时间里面没有打开对应App的话,直接去Android对应市场进行下载。
window.setTimeout(function() {
var OutTime = new Date();
if (OutTime - loadTime < 2200) {
window.location = "xxxx"; // Android下载地址
} else {
window.close();
}
},5000);
window.location = "xxxx?page=charge_vip_create&phone="+this[name]; // Android端URL Schema
}
}
//]]>
</script>
</body>
</html>