// 是否是移动版
export function isMobile() {
// || || navigator.userAgent.match(/iPad/i) ipad暂时放到PC
if (navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
) {
return true
} else {
return false
}
}
//浏览器类型及版本
export function getBrowserInfo() {
var agent = navigator.userAgent.toLowerCase();
var regStr_ie = /msie [\d.]+;/gi;
var regStr_ff = /firefox\/[\d.]+/gi
var regStr_chrome = /chrome\/[\d.]+/gi;
var regStr_saf = /safari\/[\d.]+/gi;
var isIE = agent.indexOf("compatible") > -1 && agent.indexOf("msie" > -1); //判断是否IE<11浏览器
var isEdge = agent.indexOf("edge") > -1 && !isIE; //判断是否IE的Edge浏览器
var isIE11 = agent.indexOf('trident') > -1 && agent.indexOf("rv:11.0") > -1;
if (isIE) {
var reIE = new RegExp("msie (\\d+\\.\\d+);");
reIE.test(agent);
var fIEVersion = parseFloat(RegExp["$1"]);
if (fIEVersion == 7) {
return "IE/7";
} else if (fIEVersion == 8) {
return "IE/8";
} else if (fIEVersion == 9) {
return "IE/9";
} else if (fIEVersion == 10) {
return "IE/10";
}
} //isIE end
if (isIE11) {
return "IE/11";
}
//firefox
if (agent.indexOf("firefox") > 0) {
return agent.match(regStr_ff);
}
//Safari
if (agent.indexOf("safari") > 0 && agent.indexOf("chrome") < 0) {
return agent.match(regStr_saf);
}
//Chrome
if (agent.indexOf("chrome") > 0) {
return agent.match(regStr_chrome);
}
if (agent.indexOf("micromessenger") > 0) {
return 'weixin';
}
}
// 修复苹果下代码input 焦点失真的问题
export function fiexIosPositon() {
window.scrollTo(0, 0);
}