/** @format */ export function getRequest() { var urlStr = location.href; if (typeof urlStr == "undefined") { var url = decodeURI(location.search); //获取url中"?"符后的字符串 } else { var url = "?" + urlStr.split("?")[1]; } var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); let strs = str.split("&"); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = decodeURIComponent( strs[i].split("=")[1] ); } } return theRequest; } //获取url地址 //获取通讯ID号 export function kg_uuid(len, radix) { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""); var uuid = [], i; radix = radix || chars.length; if (len) { for (i = 0; i < len; i++) uuid[i] = chars[0 | (Math.random() * radix)]; } else { var r; uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-"; uuid[14] = "4"; for (i = 0; i < 36; i++) { if (!uuid[i]) { r = 0 | (Math.random() * 16); uuid[i] = chars[i == 19 ? (r & 0x3) | 0x8 : r]; } } } return uuid.join(""); } export function GetUrlbasePath() { //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp var curWwwPath = window.document.location.href; //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); //获取主机地址,如: http://localhost:8080 var localhostPath = curWwwPath.substring(0, pos); //获取带"/"的项目名,如:/ems var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1); //获取项目的basePath http://localhost:8080/ems/ var basePath = localhostPath + projectName + "/"; return basePath; }