29 lines
884 B
TypeScript
29 lines
884 B
TypeScript
|
|
/**
|
|||
|
|
* 判断传入的值是否有值(不为null,'',undefined)
|
|||
|
|
* 有则返回true,没有则返回false
|
|||
|
|
* @param {number | string | object} value
|
|||
|
|
* @return boolean
|
|||
|
|
*/
|
|||
|
|
export function hasValue(value : number | string | { [key: string]: any}):boolean{
|
|||
|
|
if(typeof value == 'number' || typeof value == 'string'){
|
|||
|
|
if(value != null && value != '' && value != undefined) return true
|
|||
|
|
}
|
|||
|
|
if(typeof value === 'object'){
|
|||
|
|
for(let i in value){
|
|||
|
|
if(value[i] != null && value[i] != '' && value[i] != undefined) return true
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return false
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 获取当前北京时间
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
export function getBeijingTime():string{
|
|||
|
|
//获取当前北京时间的时间戳(单位为毫秒)
|
|||
|
|
const stamp= new Date().getTime() + 8 * 60 * 60 * 1000;
|
|||
|
|
const beijingTime = new Date(stamp).toISOString().replace(/T/, ' ').replace(/\..+/, '').substring(0, 19);
|
|||
|
|
return beijingTime
|
|||
|
|
}
|