$(function () {
var APPCommon = {
iphoneSchema: $("#get_ios_key").val(),
iphoneDownUrl: "{$ios_url|default=''}",
androidSchema: 'scheme://open.app/?code='+$("#get_code").val(),
androidDownUrl: "{$android_url|default=''}",
openApp: function(){
var this_ = this;
//微信
if(this_.isWeixin()){
$(".weixin-tip").css("height",$(window).height());
$(".weixin-tip").show();
$('.weixin-tip').on('touchstart', function () {
$(".weixin-tip").hide();
});
}
else
{
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
var loadDateTime = new Date();
window.setTimeout(function() {
var timeOutDateTime = new Date();
if (timeOutDateTime - loadDateTime < 5000) {
//window.location = this_.iphoneDownUrl;//ios下载地址
} else {
window.close();
}
},25);
window.location = this.iphoneSchema;
}else if (navigator.userAgent.match(/android/i)) {
try {
window.location = this_.androidSchema;
setTimeout(function(){
//swindow.location=this_.androidDownUrl; //android下载地址
},500);
} catch(e) {}
}
}
},
isWeixin: function(){ //判断是否是微信
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
}
};
APPCommon.openApp();
})
JS打开APP
最新推荐文章于 2024-07-18 10:13:27 发布