export const openApp = (url, callback) => { window.location.href = url var _clickTime = +new Date() function check(elsTime) { if (elsTime > 3000 || document.hidden || document.webkitHidden) {} else { callback && callback() } } //启动间隔20ms运行的定时器,并检测累计消耗时间是否超过3000ms,超过则结束 var _count = 0, intHandle intHandle = setInterval(function() { _count++ var elsTime = +new Date() - _clickTime if (_count >= 100 || elsTime > 3000) { clearInterval(intHandle) check(elsTime) } }, 20) } // 去下载 export const goConfirmAddr = (url) => { // 是否是安卓QQ打开 if (isIosPad) { window.location = url } else if (isAndroidPad) { window.location =url } else if (isIos) { window.location = url } else { window.location = url } } export const browser = { versions: function() { let u = navigator.userAgent; let app = navigator.appVersion; return { trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核 mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 || u.indexOf('Linux') > -1, //android终端 iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器 iPad: u.indexOf('iPad') > -1, //是否iPad webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部 weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增) qq: u.match(/\sQQ/i) == " qq", //是否QQ browser: navigator.userAgent.indexOf('MQQBrowser') > -1 }; }(), language: (navigator.browserLanguage || navigator.language).toLowerCase() }