|
|
@@ -1,160 +1,36 @@
|
|
|
-// function versions() {
|
|
|
-// var u = window.navigator.userAgent;
|
|
|
-// return {
|
|
|
-// // IE内核
|
|
|
-// trident: u.indexOf("Trident") > -1,
|
|
|
-// // Firefox
|
|
|
-// firefox: u.indexOf("Firefox") > -1,
|
|
|
-// // edge
|
|
|
-// edge: u.indexOf("Edge") > -1,
|
|
|
-// // opera内核
|
|
|
-// presto: u.indexOf("Presto") > -1,
|
|
|
-// // 苹果、谷歌内核
|
|
|
-// webKit: u.indexOf("AppleWebKit") > -1,
|
|
|
-// // 火狐内核
|
|
|
-// gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") === -1,
|
|
|
-// // 是否为移动终端
|
|
|
-// mobile: /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent),
|
|
|
-// // ios终端
|
|
|
-// ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
|
|
|
-// // android终端或者uc浏览器
|
|
|
-// android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1,
|
|
|
-// // 是否为iPhone或者安卓QQ浏览器
|
|
|
-// iPhone: u.indexOf("iPhone") > -1 || u.indexOf("Mac") > -1,
|
|
|
-// // 是否为iPad
|
|
|
-// iPad: u.indexOf("iPad") > -1,
|
|
|
-// // 是否为web应用程序,没有头部与底部
|
|
|
-// webApp: u.indexOf("Safari") === -1,
|
|
|
-// // 是否为微信浏览器
|
|
|
-// weixin: ~u.indexOf("MicroMessenger"),
|
|
|
-// // 获取浏览器语言
|
|
|
-// language: (navigator.browserLanguage || navigator.language).toLowerCase(),
|
|
|
-// };
|
|
|
-// }
|
|
|
+function versions() {
|
|
|
+ var u = window.navigator.userAgent;
|
|
|
+ return {
|
|
|
+ // IE内核
|
|
|
+ trident: u.indexOf("Trident") > -1,
|
|
|
+ // Firefox
|
|
|
+ firefox: u.indexOf("Firefox") > -1,
|
|
|
+ // edge
|
|
|
+ edge: u.indexOf("Edge") > -1,
|
|
|
+ // opera内核
|
|
|
+ presto: u.indexOf("Presto") > -1,
|
|
|
+ // 苹果、谷歌内核
|
|
|
+ webKit: u.indexOf("AppleWebKit") > -1,
|
|
|
+ // 火狐内核
|
|
|
+ gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") === -1,
|
|
|
+ // 是否为移动终端
|
|
|
+ mobile: /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent),
|
|
|
+ // ios终端
|
|
|
+ ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
|
|
|
+ // android终端或者uc浏览器
|
|
|
+ android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1,
|
|
|
+ // 是否为iPhone或者安卓QQ浏览器
|
|
|
+ iPhone: u.indexOf("iPhone") > -1 || u.indexOf("Mac") > -1,
|
|
|
+ // 是否为iPad
|
|
|
+ iPad: u.indexOf("iPad") > -1,
|
|
|
+ // 是否为web应用程序,没有头部与底部
|
|
|
+ webApp: u.indexOf("Safari") === -1,
|
|
|
+ // 是否为微信浏览器
|
|
|
+ weixin: ~u.indexOf("MicroMessenger"),
|
|
|
+ // 获取浏览器语言
|
|
|
+ language: (navigator.browserLanguage || navigator.language).toLowerCase(),
|
|
|
+ };
|
|
|
+}
|
|
|
|
|
|
-// export default versions();
|
|
|
-export default {
|
|
|
- hasURLParam: function (key) {
|
|
|
- let querys = window.location.search.substring(1).split("&");
|
|
|
- for (let i = 0; i < querys.length; i++) {
|
|
|
- let keypair = querys[i].split("=");
|
|
|
- if (keypair[0] == key) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- },
|
|
|
- getLang() {
|
|
|
- return this.getURLParam("lang") || "zh";
|
|
|
- },
|
|
|
- getURLParam: function (key) {
|
|
|
- let querys = window.location.search.substring(1).split("&");
|
|
|
- for (let i = 0; i < querys.length; i++) {
|
|
|
- let keypair = querys[i].split("=");
|
|
|
- if (keypair.length === 2 && keypair[0] === key) {
|
|
|
- try {
|
|
|
- return decodeURIComponent(keypair[1]);
|
|
|
- } catch (error) {
|
|
|
- return keypair[1];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return "";
|
|
|
- },
|
|
|
- valueFromUrl(key) {
|
|
|
- return this.urlHasValue(key, true);
|
|
|
- },
|
|
|
- urlHasValue: function (key, isGetValue) {
|
|
|
- if (
|
|
|
- key === "m" &&
|
|
|
- window.__ProjectNum &&
|
|
|
- window.__ProjectNum != "__ProjectNum__"
|
|
|
- ) {
|
|
|
- return window.__ProjectNum;
|
|
|
- }
|
|
|
+export default versions();
|
|
|
|
|
|
- let querys = window.location.search.substr(1).split("&");
|
|
|
- if (isGetValue) {
|
|
|
- for (let i = 0; i < querys.length; i++) {
|
|
|
- let keypair = querys[i].split("=");
|
|
|
- if (keypair.length === 2 && keypair[0] === key) {
|
|
|
- return keypair[1];
|
|
|
- }
|
|
|
- }
|
|
|
- return "";
|
|
|
- } else {
|
|
|
- //return window.location.search.match("&" + key + "|\\?" + key) != null 有bug
|
|
|
- for (let i = 0; i < querys.length; i++) {
|
|
|
- let keypair = querys[i].split("=");
|
|
|
- if (keypair[0] == key) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- },
|
|
|
- detectWeixin: function () {
|
|
|
- //微信 包括PC的微信
|
|
|
- return (
|
|
|
- window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) ==
|
|
|
- "micromessenger"
|
|
|
- );
|
|
|
- },
|
|
|
- detectWeixinMiniProgram: function () {
|
|
|
- return window.navigator.userAgent.match("miniProgram");
|
|
|
- },
|
|
|
- detectIOS: function () {
|
|
|
- return this.detectIPhone() || this.detectIPad() || this.detectIPod();
|
|
|
- },
|
|
|
- detectIPhone: function () {
|
|
|
- var e = window.navigator.userAgent,
|
|
|
- t = /iPhone/;
|
|
|
- return t.test(e);
|
|
|
- },
|
|
|
- detectIPad: function () {
|
|
|
- if (
|
|
|
- window.navigator.platform === "MacIntel" &&
|
|
|
- window.navigator.maxTouchPoints > 1
|
|
|
- ) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- var e = window.navigator.userAgent,
|
|
|
- t = /iPad/;
|
|
|
- return t.test(e);
|
|
|
- },
|
|
|
- detectIPod: function () {
|
|
|
- var e = window.navigator.userAgent,
|
|
|
- t = /iPod/;
|
|
|
- return t.test(e);
|
|
|
- },
|
|
|
- detectAndroid: function () {
|
|
|
- var e = window.navigator.userAgent;
|
|
|
- return e.indexOf("Android") !== -1;
|
|
|
- },
|
|
|
- detectIE: function () {
|
|
|
- var e = window.navigator.userAgent,
|
|
|
- t = e.indexOf("MSIE ");
|
|
|
- return t !== -1 || !!navigator.userAgent.match(/Trident.*rv\:11\./);
|
|
|
- },
|
|
|
- detectOpera: function () {
|
|
|
- var e = window.navigator.userAgent;
|
|
|
- return e.indexOf("OPR") !== -1;
|
|
|
- },
|
|
|
- detectSafari: function () {
|
|
|
- var e = window.navigator.userAgent,
|
|
|
- t = e.indexOf("Safari");
|
|
|
- return t !== -1 && !this.detectOpera() && !this.detectChrome(); //xzw add detectOpera
|
|
|
- },
|
|
|
- detectFirefox: function () {
|
|
|
- var e = window.navigator.userAgent;
|
|
|
- return e.indexOf("Firefox") !== -1;
|
|
|
- },
|
|
|
- detectChrome: function () {
|
|
|
- var e = window.navigator.userAgent;
|
|
|
- return e.indexOf("Chrome") !== -1 && !this.detectOpera();
|
|
|
- },
|
|
|
- detectAndroidMobile: function () {
|
|
|
- var e = window.navigator.userAgent;
|
|
|
- return this.detectAndroid() && e.indexOf("Mobile") !== -1;
|
|
|
- },
|
|
|
-};
|