var platform = navigator.platform || '';
if (platform.indexOf("Win")==0) {
terrace_type="windows";
terrace =3;
terrace_detail=9999;
}else if(platform.indexOf("Mac")==0){
terrace_type="mac";
terrace =3;
terrace_detail=9999;
}else if ((platform == "X11") || (platform.indexOf("Linux") == 0)) {
terrace_type="linux";
terrace =3;
terrace_detail=9999;
};
var ua = /msie (\d+\.\d+)/i.test(navigator.userAgent)//手机ua
function ios() {
var phone = {
"iPhoneOS102": "26",
"iPhoneOS101": "25",
"iPhoneOS100": "24",
"iPhoneOS93": "23",
"iPhoneOS92": "22",
"iPhoneOS91": "21",
"iPhoneOS90": "20",
"iPhoneOS84": "19",
"iPhoneOS83": "18",
"iPhoneOS82": "17",
"iPhoneOS81": "16",
"iPhoneOS80": "15",
"iPhoneOS71": "14",
"iPhoneOS70": "13",
"iPhoneOS62": "12",
"iPhoneOS61": "11",
"iPhoneOS60": "10",
"iPhoneOS51": "9",
"iPhoneOS50": "8",
"iPhoneOS43": "7",
"iPhoneOS42": "6",
"iPhoneOS41": "5",
"iPhoneOS40": "4",
"iPhoneOS32": "3",
"iPhoneOS31": "2",
"iPhoneOS30": "1",
}
return phone;
}
function android() {
var Android = {
"Android7.0": "18",
"Android6.0": "17",
"Android5.1": "16",
"Android5.0": "15",
"Android4.4": "14",
"Android4.3": "13",
"Android4.2": "12",
"Android4.1": "11",
"Android4.0": "10",
"Android3.2": "9",
"Android3.1": "8",
"Android3.0": "7",
"Android2.3": "6",
"Android2.2": "5",
"Android2.1": "4",
"Android2.0": "3",
"Android1.6": "2",
"Android1.5": "1",
}
return Android;
}
exports.mobilePhone = function(ua){
var phoneType = ua.match(/(iPhone\sOS)\s([\d_]+)/);
var androidType = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
var ipadType = ua.match(/(iPad).*OS\s([\d_]+)/);
var phone = ios();
var Android = android();
if (phoneType || ipadType) {//苹果手机
terrace_type="ios";
terrace =2;
if (phoneType && !ipadType) {//iphone手机
var ipe = phoneType[0].replace(/\s/ig,'')
var b = ipe.replace(/\_/ig,"");
if (phone[b]==undefined) {
if(b.length == 11 || b.length==12){
b = b.substring(0,b.length - 1);
}
};
return phone[b];
}else{//为ipad平板
var pad = ipadType[0].replace(/\s/ig,'')
var padC = pad.replace(/\_/ig,"")
var padTwo = padC.substring(8,padC.length);
var padOne = "iPhone"+padTwo
if(padOne.length == 11||padOne.length == 12){
padOne = padOne.substring(0,padOne.length - 1);
}
return phone[padOne];
}
}else if(androidType){
terrace_type="android";
terrace =1;
var and = androidType[0].replace(/[\/]/ig,'');
var andr = and.replace(/\s/ig,'');
if(andr.length == 12){
andr = andr.substring(0,andr.length - 2);
return Android[andr];
}else{
return Android[andr];
}
if(andr.length == 8){//这里只有"android"
return 18;
}
//terrace_detail = Android[add];
}else if (!(phoneType && androidType && terrace)) { //如果设备不是安卓,也不是ios,也不是pc,则报错;
//errmsg.addErr("304","手机类型判断错误",site_id);
console.log("手机类型判断错误");
response.write("504");
response.end();
return;
};
}
手机型号系统
最新推荐文章于 2021-05-26 11:57:09 发布