| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- // 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;
- }
- 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;
- },
- };
|