| | |
| | | /*和业务有关的辅助类*/ |
| | | class IStationCommon { |
| | | |
| | | |
| | | |
| | | static getCorpID() { |
| | | var corpID = ""; |
| | |
| | | return themeType; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /*和业务无关的辅助类*/ |
| | | class Utils { |
| | | constructor() { |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /*检测类名*/ |
| | | static hasClassStyle(ele, name) { |
| | | static hasClassStyle(ele, name) { |
| | | return ele.className.match(new RegExp('(\\s|^)' + name + '(\\s|$)')); |
| | | } |
| | | |
| | |
| | | } |
| | | return eleMatch; |
| | | } |
| | | |
| | | |
| | | //创建存储唯一键名的函数 |
| | | static createUniqueKey() { |
| | | return new Date().getTime() + Math.random(); |
| | |
| | | return false |
| | | } |
| | | } |
| | | static isPC() { //是否为PC端 |
| | | static isPC() { //是否为PC端 |
| | | var userAgentInfo = navigator.userAgent; |
| | | var Agents = ["Android", "iPhone", |
| | | "SymbianOS", "Windows Phone", |
| | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 格式化数字 解决小数精度 解决一般问题 |
| | | * @param {any} n |
| | | */ |
| | | static formatNumber(n) { |
| | | return parseFloat(parseFloat(n).toFixed(12)) |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | * |
| | | * @example formatTime('2018-1-29', 'yyyy-MM-dd hh:mm:ss') // -> 2018/01/29 00:00:00 |
| | | */ |
| | | static formatTime(template, date) { |
| | | static formatTime(template, date) { |
| | | var today = date ? new Date(date) : new Date(); |
| | | var o = { |
| | | "M+": today.getMonth() + 1, //月份 |
| | |
| | | * |
| | | * @example formatTime('2018-1-29', '{y}/{m}/{d} {h}:{i}:{s}') // -> 2018/01/29 00:00:00 |
| | | */ |
| | | static formatTime2(time, cFormat) { |
| | | static formatTime2(time, cFormat) { |
| | | if (arguments.length === 0) return null |
| | | if ((time + '').length === 10) { |
| | | time = +time * 1000 |
| | |
| | | static containsInArray(arr, val) { |
| | | return arr.indexOf(val) != -1 ? true : false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param {arr} 数组 |
| | | * @param {type} 1:从小到大 2:从大到小 3:随机 |
| | |
| | | return arr; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /*最大值*/ |
| | | static maxInArray(arr) { |
| | |
| | | } |
| | | |
| | | /*过滤html代码(把<>转换)*/ |
| | | static filterHtmlTag(str) { |
| | | static filterHtmlTag(str) { |
| | | str = str.replace(/&/ig, "&"); |
| | | str = str.replace(/</ig, "<"); |
| | | str = str.replace(/>/ig, ">"); |
| | |
| | | return 0; |
| | | |
| | | if (value > 100) |
| | | return value.toFixed(1); |
| | | return value.toFixed(1); |
| | | else if (value > 10) |
| | | return value.toFixed(2); |
| | | else |
| | |
| | | } |
| | | |
| | | /*删除cookie*/ |
| | | static removeCookie(name) { |
| | | static removeCookie(name) { |
| | | this.setCookie(name, 1, -1); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /*移除所有localStorage*/ |
| | | static clearLocalStorage() { |
| | | static clearLocalStorage() { |
| | | window.localStorage.clear() |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //获取客户端ip地址需创建id为address的标签 |
| | | static getYourIP() { |
| | |
| | | |
| | | //Other |
| | | /*获取网址参数,name为网址中的参数键值*/ |
| | | static getURL(name) { |
| | | static getURL(name) { |
| | | var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); |
| | | var r = window.location.search.substr(1).match(reg); |
| | | if (r != null) return r[2]; return null; |
| | |
| | | } |
| | | |
| | | /*删除url指定参数,返回url*/ |
| | | static delParamsUrl(url, name) { |
| | | static delParamsUrl(url, name) { |
| | | var baseUrl = url.split('?')[0] + '?'; |
| | | var query = url.split('?')[1]; |
| | | if (query.indexOf(name) > -1) { |