|
@@ -95,7 +95,7 @@ export const toggleClass = (ele: HTMLElement, className: string) => {
|
|
|
}
|
|
|
ele.className = classString
|
|
|
}
|
|
|
-export const setQueryConfig = function(queryConfig: any) {
|
|
|
+export const setQueryConfig = function (queryConfig: any) {
|
|
|
let _str = ''
|
|
|
for (const o in queryConfig) {
|
|
|
if (queryConfig[o] !== -1) {
|
|
@@ -107,7 +107,7 @@ export const setQueryConfig = function(queryConfig: any) {
|
|
|
}
|
|
|
|
|
|
// 获取用户信息
|
|
|
-export const getUserInfo = function() {
|
|
|
+export const getUserInfo = function () {
|
|
|
let userInfo = store.state.user
|
|
|
const paramsInfo: any = {
|
|
|
openid: Keys.openid,
|
|
@@ -124,7 +124,7 @@ export const getUserInfo = function() {
|
|
|
}
|
|
|
|
|
|
// 地址通用参赛携带
|
|
|
-export const getComparams = function() {
|
|
|
+export const getComparams = function () {
|
|
|
let userInfo = store.state.user
|
|
|
let paramsInfo: any = {
|
|
|
openid: Keys.openid,
|
|
@@ -144,7 +144,7 @@ export const getComparams = function() {
|
|
|
return paramsInfo
|
|
|
}
|
|
|
|
|
|
-export const formatDate = function(split: string = 'YYYYMMDD', date: any = new Date()) {
|
|
|
+export const formatDate = function (split: string = 'YYYYMMDD', date: any = new Date()) {
|
|
|
//三目运算符
|
|
|
const dates = date ? date : new Date()
|
|
|
//年份
|
|
@@ -174,14 +174,14 @@ export const formatDate = function(split: string = 'YYYYMMDD', date: any = new D
|
|
|
}
|
|
|
|
|
|
// 把字符串 (yyyymmdd) 转换成日期格式(yyyy-mm-dd)
|
|
|
-export const formatDateStr = function(date: any) {
|
|
|
- if(date){
|
|
|
+export const formatDateStr = function (date: any) {
|
|
|
+ if (date) {
|
|
|
return date.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1-$2-$3')
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return ''
|
|
|
}
|
|
|
}
|
|
|
-export const getTomorrow = function(split: any = '') {
|
|
|
+export const getTomorrow = function (split: any = '') {
|
|
|
let dates = new Date()
|
|
|
dates.setTime(dates.getTime() + 24 * 60 * 60 * 1000)
|
|
|
const Year: number = dates.getFullYear()
|
|
@@ -263,7 +263,7 @@ export function getPreMonth(formatType: any = '') {
|
|
|
/**
|
|
|
* 格式化日期 3月21日
|
|
|
*/
|
|
|
-export const formatEnergyDate = function(time: any) {
|
|
|
+export const formatEnergyDate = function (time: any) {
|
|
|
//三目运算符
|
|
|
const dates = time ? new Date(time) : new Date()
|
|
|
//月份下标是0-11
|
|
@@ -282,14 +282,14 @@ export const formatEnergyDate = function(time: any) {
|
|
|
]
|
|
|
}
|
|
|
|
|
|
-export const setSession = function(key: any = '', obj: any = '') {
|
|
|
+export const setSession = function (key: any = '', obj: any = '') {
|
|
|
if (obj) {
|
|
|
let str = JSON.stringify(obj)
|
|
|
sessionStorage.setItem(key, str)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export const getSession = function(key: any = '') {
|
|
|
+export const getSession = function (key: any = '') {
|
|
|
if (key) {
|
|
|
let obj: any = sessionStorage.getItem(key)
|
|
|
if (obj) {
|
|
@@ -304,7 +304,7 @@ export const getSession = function(key: any = '') {
|
|
|
* @param key
|
|
|
* @param obj
|
|
|
*/
|
|
|
-export const setLocalStorage = function(key: any = '', obj: any = '') {
|
|
|
+export const setLocalStorage = function (key: any = '', obj: any = '') {
|
|
|
if (obj) {
|
|
|
if (obj instanceof Object) {
|
|
|
let str = JSON.stringify(obj)
|
|
@@ -319,7 +319,7 @@ export const setLocalStorage = function(key: any = '', obj: any = '') {
|
|
|
* 获取本地存储
|
|
|
* @param key
|
|
|
*/
|
|
|
-export const getLocalStorage = function(key: any) {
|
|
|
+export const getLocalStorage = function (key: any) {
|
|
|
if (key) {
|
|
|
let obj: any = localStorage.getItem(key)
|
|
|
if (obj) {
|
|
@@ -335,14 +335,14 @@ export const getLocalStorage = function(key: any) {
|
|
|
* 存储最新的空间信息
|
|
|
* @param spaceInfo
|
|
|
*/
|
|
|
-export const setLocalNewSpaceInfo = function(spaceInfo: any) {
|
|
|
+export const setLocalNewSpaceInfo = function (spaceInfo: any) {
|
|
|
setLocalStorage(Keys.storageSpaceInfoKey, spaceInfo)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取最新的空间信息
|
|
|
*/
|
|
|
-export const getLocalNewSpaceInfo = function() {
|
|
|
+export const getLocalNewSpaceInfo = function () {
|
|
|
let spaceInfo: any = getLocalStorage(Keys.storageSpaceInfoKey)
|
|
|
return spaceInfo
|
|
|
}
|
|
@@ -350,13 +350,13 @@ export const getLocalNewSpaceInfo = function() {
|
|
|
/**
|
|
|
* 本地缓存建筑,楼层,空间
|
|
|
*/
|
|
|
-export const localStorageSpaceId = function(buildingId: any, floorId: any, spaceId: any) {
|
|
|
+export const localStorageSpaceId = function (buildingId: any, floorId: any, spaceId: any) {
|
|
|
let spaceMap: any = getLocalStorage(Keys.storageSpaceKey) ? getLocalStorage(Keys.storageSpaceKey) : {}
|
|
|
let key: any = `${buildingId},${floorId}`
|
|
|
spaceMap[key] = spaceId
|
|
|
setLocalStorage(Keys.storageSpaceKey, spaceMap)
|
|
|
}
|
|
|
-export const getStorageSpaceId = function() {
|
|
|
+export const getStorageSpaceId = function () {
|
|
|
let spaceMap: any = getLocalStorage(Keys.storageSpaceKey)
|
|
|
return spaceMap
|
|
|
}
|
|
@@ -364,7 +364,7 @@ export const getStorageSpaceId = function() {
|
|
|
/**
|
|
|
* 本地缓存建筑对应的楼层
|
|
|
*/
|
|
|
-export const localStorageFloor = function(buildingId: any, floorId: any) {
|
|
|
+export const localStorageFloor = function (buildingId: any, floorId: any) {
|
|
|
let floorMap: any = getLocalStorage(Keys.storageFloorKey) ? getLocalStorage(Keys.storageFloorKey) : {}
|
|
|
floorMap[buildingId] = floorId
|
|
|
setLocalStorage(Keys.storageFloorKey, floorMap)
|
|
@@ -374,7 +374,7 @@ export const localStorageFloor = function(buildingId: any, floorId: any) {
|
|
|
* @param buildingId
|
|
|
* @param floorId
|
|
|
*/
|
|
|
-export const getLocalStorageFloor = function() {
|
|
|
+export const getLocalStorageFloor = function () {
|
|
|
let floorMap: any = getLocalStorage(Keys.storageFloorKey)
|
|
|
return floorMap
|
|
|
}
|
|
@@ -383,7 +383,7 @@ export const getLocalStorageFloor = function() {
|
|
|
* 缓存搜索页面最近查找的数据
|
|
|
* @param item
|
|
|
*/
|
|
|
-export const setLocalSearchSpace = function(item: any) {
|
|
|
+export const setLocalSearchSpace = function (item: any) {
|
|
|
let historySearch: any = getLocalStorage(Keys.historySearchSpaceKey)
|
|
|
let flag = false
|
|
|
historySearch = historySearch ? historySearch : []
|
|
@@ -401,14 +401,14 @@ export const setLocalSearchSpace = function(item: any) {
|
|
|
/**
|
|
|
* 获取搜索页面最近查找的数据
|
|
|
*/
|
|
|
-export const getLocalSearchSpace = function() {
|
|
|
+export const getLocalSearchSpace = function () {
|
|
|
return getLocalStorage(Keys.historySearchSpaceKey) ? getLocalStorage(Keys.historySearchSpaceKey) : []
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*存储当前项目id
|
|
|
*/
|
|
|
-export const setLocalProjectId = function(projectId: any) {
|
|
|
+export const setLocalProjectId = function (projectId: any) {
|
|
|
setLocalStorage(Keys.projectId, projectId)
|
|
|
}
|
|
|
|
|
@@ -416,20 +416,20 @@ export const setLocalProjectId = function(projectId: any) {
|
|
|
* 获取当前项目id
|
|
|
* @param projectId
|
|
|
*/
|
|
|
-export const getLocalProjectId = function() {
|
|
|
+export const getLocalProjectId = function () {
|
|
|
return localStorage.getItem(Keys.projectId)
|
|
|
}
|
|
|
/**
|
|
|
* 清楚当前所有的存储数据
|
|
|
*/
|
|
|
-export const clearAllLocalData = function() {
|
|
|
+export const clearAllLocalData = function () {
|
|
|
localStorage.clear()
|
|
|
Cookies.remove('userInfo')
|
|
|
Cookies.remove('projectId')
|
|
|
Cookies.remove('accessToken')
|
|
|
}
|
|
|
|
|
|
-export const doHandleMonth = function(month: any) {
|
|
|
+export const doHandleMonth = function (month: any) {
|
|
|
let m: any = month
|
|
|
if (month.toString().length == 1) {
|
|
|
m = '0' + month
|
|
@@ -437,7 +437,7 @@ export const doHandleMonth = function(month: any) {
|
|
|
return m
|
|
|
}
|
|
|
|
|
|
-export const getWeekDate = function(day: any) {
|
|
|
+export const getWeekDate = function (day: any) {
|
|
|
let weeks: any = new Array(
|
|
|
'周日',
|
|
|
'周一',
|
|
@@ -451,14 +451,14 @@ export const getWeekDate = function(day: any) {
|
|
|
return week
|
|
|
}
|
|
|
|
|
|
-export const getDate = function(date: any) {
|
|
|
+export const getDate = function (date: any) {
|
|
|
return date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化24:00
|
|
|
*/
|
|
|
-export const getTimers = function() {
|
|
|
+export const getTimers = function () {
|
|
|
let timers: any = new Array()
|
|
|
for (let i = 0; i <= 24; i++) {
|
|
|
let str: any = '00'
|
|
@@ -475,7 +475,7 @@ export const getTimers = function() {
|
|
|
return timers
|
|
|
}
|
|
|
|
|
|
-export const getNowTime = function() {
|
|
|
+export const getNowTime = function () {
|
|
|
let date: any = new Date()
|
|
|
let hours: any = date.getHours()
|
|
|
let minute: any = date.getMinutes()
|
|
@@ -489,3 +489,41 @@ export const getNowTime = function() {
|
|
|
}
|
|
|
return [hours, index]
|
|
|
}
|
|
|
+
|
|
|
+// 获取当前真实时间
|
|
|
+export const getRelNowTime = function () {
|
|
|
+ let date: any = new Date()
|
|
|
+ let hours: any = date.getHours()
|
|
|
+ let minute: any = date.getMinutes()
|
|
|
+ return hours + "" + minute + "00"
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @returns js获取mac地址
|
|
|
+ */
|
|
|
+export const getMacAddress = function () {
|
|
|
+ let obj: any = new ActiveXObject("WbemScripting.SWbemLocator");
|
|
|
+ let s: any = obj.ConnectServer(".");
|
|
|
+ let properties: any = s.ExecQuery("Select * from Win32_NetworkAdapterConfiguration");
|
|
|
+ let e: any = new Enumerator(properties);
|
|
|
+ let output: any = '';
|
|
|
+ while (!e.atEnd()) {
|
|
|
+ e.moveNext();
|
|
|
+ var p = e.item();
|
|
|
+ if (!p) continue;
|
|
|
+ if (p.IPEnabled) return p.MACAddress;
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 19000转成19:00
|
|
|
+ */
|
|
|
+export const formatTimerStr = function (timer: any) {
|
|
|
+ if (timer) {
|
|
|
+ return (timer / 10000).toFixed(2)
|
|
|
+ } else {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+}
|