xlb-main-login
Version:
``` yarn install ```
43 lines (39 loc) • 1.05 kB
JavaScript
import moment from 'moment'
let timeout = null
let default_img = process.env.VUE_APP_IMG_URL+'/img/'
export function urlInhttp(url) {
if (url.indexOf('http')===-1){
url = default_img + url
}
window.open(url)
}
// 获取当前日期和前七天日期
export function getTodayAndSeventDay() {
const start = moment().subtract('7', 'days').format('YYYY-MM-DD')
const end = moment().subtract('1', 'days').format('YYYY-MM-DD')
const startTime = start.replace(/-/g, '')
const endTime = end.replace(/-/g, '')
return startTime
}
export function debounce(fn, wait) {
if (timeout !== null) clearTimeout(timeout)
timeout = setTimeout(fn, wait)
}
export const SessionStorageUtil = {
get(key) {
const data = sessionStorage.getItem(key)
if (data) {
return JSON.parse(data)
}
return null
},
set(key, data) {
const value = JSON.stringify(data)
sessionStorage.setItem(key, value)
},
clear(key) {
if (key === 'ALL') {
sessionStorage.clear()
}
},
}