在 js 中写这个来判断
window.onload = function() {
$(function() {
//判断手机环境
var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var isiosapp = u.indexOf('Safari') == -1 && u.indexOf('Language') == -1 && u.indexOf('MicroMessenger') == -1;
var isanapp = u.indexOf('igetapp') > -1;
function is_weixn(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger"){
return true;
} else {
return false;
};
};
//图片懒加载
$('.lazyload').lazyload();
if(isiOS && !isiosapp && !is_weixn()) {
//IOS LIU IOS 的操作
$('.btn').click(function(){
window.location.href = 'http://ttts.besttoptoday.com/pay/hyzfZc?ucid=BZSFSLHQIH';
})
} else if(isAndroid && !isanapp && !is_weixn()) {
//android liu
$('.btn').click(function(){
window.location.href = 'http://ttts.besttoptoday.com/pay/hyzfZc?ucid=BZSFSLHQIH';
})
} else if(is_weixn()) {
//weixin
$('.btn').click(function(){
window.location.href = 'http://ttts.besttoptoday.com/pay/hyzfZc?ucid=BZSFSLHQIH';
})
} else if(isiOS && isiosapp && !is_weixn()) {
// ios app
$('.btn').hide();
} else if(isAndroid && isanapp && !is_weixn()) {
//android app
$('.btn').hide();
/* $('.read_btn').click(function(){
window.local_obj.runOnAndroidJS_SpecialColum('134');
}) */
}
if(isAndroid && isanapp){
function toptodayandroid(top){
var bb = top;
$(".bbh_p").text(bb);
if(bb>=43){
var bt = document.title;
var fb = document.getElementById('shortTitle').innerText;
var pic = document.getElementById('picture').src;
function chc(){
window.local_obj.getShareInfo(bt,fb,pic);
};
chc();
};
};
}
if(isiOS && screen.height >= 812 && isiosapp && !is_weixn()){
//iphone x app
$('.wrap').css("margin-top","84px"); // iphone x 的最上面会被遮盖
var oMeta = document.createElement('meta');
oMeta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no,viewport-fit=cover';
oMeta.name = 'viewport';
document.getElementsByTagName('head')[0].appendChild(oMeta);
};
// 小手机适配
if ((screen.width <= 340 && !is_weixn())||(screen.width <= 340 && !is_weixn())) {
//iphone 5 app
var oMeta = document.createElement('meta');
oMeta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no,viewport-fit=cover';
oMeta.name = 'viewport';
document.getElementsByTagName('head')[0].appendChild(oMeta);
$(".content").css({marginTop: '4%'})
$(".rule").css({paddingBottom: '0'})
$(".iddv").css({position: 'relative', bottom: '0', marginTop: '10%' })
$(".btn").css({position: 'relative', bottom: '0', marginTop: '3%'})
};
})
}