Commit 5a5cd695 authored by 罗成兵's avatar 罗成兵

代码整合

parent db219844
import md5 from 'js-md5'
//常用工具方法
export const ApiUtils = {
isBlank: function (obj) {
if (obj == null || obj == undefined || obj == "" || obj == {} || obj == []) {
return true;
}
if (obj === null || obj === undefined || obj === "" || obj === {} || obj === []) {
return true;
}
return false;
},
isNotBlank: function (obj) {
return !this.isBlank(obj);
},
copyObject: function (obj) {
if (this.isBlank(obj)) {
return null;
}
let jsonData = JSON.stringify(obj);
let newObj = JSON.parse(jsonData);
return newObj;
},
getLoginInfo: function () {
let info = sessionStorage.getItem('loginInfo');
let newObj = JSON.parse(info);
return newObj;
},
getAddDayDate(tempDate, dayCount) {
let resultDate = new Date((tempDate / 1000 + (86400 * dayCount)) * 1000);//增加n天后的日期
let mouth = resultDate.getMonth() + 1;
let day = resultDate.getDate();
if (mouth < 10) {
mouth = "0" + mouth;
}
if (day < 10) {
day = "0" + day;
}
let resultDateStr = resultDate.getFullYear() + "-" + mouth + "-" + day;//将日期转化为字符串格式
return resultDateStr;
},
getDateStr(date) {
let mouth = date.getMonth() + 1;
let day = date.getDate();
if (mouth < 10) {
mouth = "0" + mouth;
}
if (day < 10) {
day = "0" + day;
}
let resultDateStr = date.getFullYear() + "-" + mouth + "-" + day;//将日期转化为字符串格式
return resultDateStr;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment