判断当前机型
export function judgePlatform() {
if (navigator.userAgent.match(/Android/i)) {
return 'android'
} else if ((navigator.userAgent.indexOf('iPhone') != -1)) {
return 'iphone'
} else {
return 'other'
}
}
当前浏览器
export function getWebviewType() {
let webviewType = ''
const u = navigator.userAgent.toLowerCase()
if (u.match(/MicroMessenger/i) == 'micromessenger') {
webviewType = 'weixin'
} else if (u.match(/qq/i) == 'qq') {
webviewType = 'qq'
} else if (u.match('weibo') == 'weibo') {
webviewType = 'weibo'
} else {
webviewType = 'web'
}
return webviewType
}
获取手机操作系统 如果获取不到默认Android
export function getMobileSystem() {
const u = navigator.userAgent.toLowerCase()
if (u.indexOf('windows phone') > -1) {
return 'WP'
} else if (u.indexOf('android') > -1 || u.indexOf('Linux') > -1) {
return 'Android'
} else if (u.indexOf('iphone') > -1 || u.indexOf('ipad') > -1) {
return 'iOS'
}
return 'Android'
}