|
|
|
export function deprecate(){
|
|
|
|
console.warn("这个方法或界面被弃用了");
|
|
|
|
}
|
|
|
|
export function getFormatDate(date){
|
|
|
|
date = date||new Date();
|
|
|
|
let sep = "-";
|
|
|
|
let year = date.getFullYear();
|
|
|
|
let month = date.getMonth() + 1;
|
|
|
|
let strDate = date.getDate();
|
|
|
|
if (month >= 1 && month <= 9)
|
|
|
|
month = "0" + month;
|
|
|
|
if (strDate >= 0 && strDate <= 9)
|
|
|
|
strDate = "0" + strDate;
|
|
|
|
var currentdate = year + sep + month + sep + strDate;
|
|
|
|
return currentdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getFormatTime(date){
|
|
|
|
date = date || new Date();
|
|
|
|
let hour = date.getHours();
|
|
|
|
let minu = date.getMinutes();
|
|
|
|
let sec = date.getSeconds();
|
|
|
|
if (hour < 10) hour = "0" + hour;
|
|
|
|
if (minu < 10) minu = "0" + minu;
|
|
|
|
if (sec < 10) sec = "0" + sec;
|
|
|
|
return hour + ":" + minu + ":" + sec;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getFormatDatetime(date){
|
|
|
|
date = date||new Date();
|
|
|
|
return getFormatDate(date) + " " + getFormatTime(date);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function getNowFormatDate() {
|
|
|
|
deprecate();
|
|
|
|
return getFormatDate();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getNextWeekFormatDate(date) {
|
|
|
|
var date = date||new Date();
|
|
|
|
var date = new Date(date.getTime() + 7 * 24 * 3600 * 1000);
|
|
|
|
return getFormatDate(date);
|
|
|
|
}
|
|
|
|
export function getNowFormatTime() {
|
|
|
|
deprecate();
|
|
|
|
return getFormatTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function getResConstruction(res = "") {
|
|
|
|
switch ((res || "").constructor) {
|
|
|
|
case Array:
|
|
|
|
return "[" + getResConstruction(res[0] || "") + "]";
|
|
|
|
case Object:
|
|
|
|
return "{" + Object.keys(res).map(key => {
|
|
|
|
let value = getResConstruction(res[key]);
|
|
|
|
return key + (value ? ":" + value : "")
|
|
|
|
}).join(",") + "}"
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|