前端判断当前浏览器环境
VARS.UA = window.navigator.userAgent;
VARS.IsAndroid = !!(/Android|HTC|Adr/i.test(VARS.UA) || !!(window.navigator.platform + '').match(/Linux/i));
VARS.IsIpad = !VARS.IsAndroid && /iPad/i.test(VARS.UA);
VARS.IsIphone = !VARS.IsAndroid && /iPod|iPhone/i.test(VARS.UA);
var osversion = VARS.UA.match(/iPhone OS (\d*)/);
if (osversion && osversion[1] >= 9) {
VARS.IsIphone9Plus = true;
} else {
VARS.IsIphone9Plus = false;
}
VARS.IsWindowsPhone = /Windows Phone/i.test(VARS.UA);
VARS.IsOldWindowsPhone = /Windows\sPhone\s([1234567]\.|8\.0)/i.test(VARS.UA);
VARS.IsWindows = /Windows/i.test(VARS.UA);
VARS.IsVivoPhone = /vivo/i.test(VARS.UA);
if (VARS.IsAndroid) {
if ((window['screen']['width'] / window['innerWidth']).toFixed(2) === VARS.PixelRatio.toFixed(2)) {
VARS.ScreenSizeCorrect = 1 / VARS.PixelRatio;
}
}
VARS.AdrPadRegex = /pad|XiaoMi\/MiPad|lepad|YOGA|MediaPad|GT-P|SM-T|GT-N5100|sch-i800|HUAWEI\s?[MTS]\d+-\w+|Nexus\s7|Nexus\s8|Nexus\s11|Kindle Fire HD|Tablet|tab/i;
VARS.ScreenSize = Math.floor(window.screen['width'] * VARS.ScreenSizeCorrect) + 'x' + Math.floor(window.screen['height'] * VARS.ScreenSizeCorrect);
VARS.IsWeixinBrowser = !!(window['WeixinJSBridge'] || /MicroMessenger/i.test(VARS.UA));
VARS.IsMiBrowser = !!(/MiuiBrowser/i.test(VARS.UA));
VARS.IsTouch = 'ontouchstart' in window;
VARS.IsXiaoMI = /MI/i.test(VARS.UA);
VARS.IsSonyPhone = /Sony/i.test(VARS.UA);
VARS.IsPC = !VARS.IsIOS && !VARS.IsAndroid && !VARS.IsWindowsPhone && !VARS.IsWindowsPad && !/Mobile/i.test(VARS.UA);
VARS.IsMiniProgramWebview = !!((window['WeixinJSBridge'] || /MicroMessenger/i.test(VARS.UA)) && /miniprogram/i.test(VARS.UA));