市北党建引领小程序初始化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.7 KiB

2 years ago
var formatTime = function (strDate, format = "yyyy-MM-dd hh:mm:ss") {
// 解决ios出现NaN问题
var realDate = strDate ? getDate(strDate.replace(getRegExp('-', 'g'), '/')) : getDate();
var regYear = getRegExp("(y+)", "i");
var date = [
["M+", realDate.getMonth() + 1],
["d+", realDate.getDate()],
["h+", realDate.getHours()],
["m+", realDate.getMinutes()],
["s+", realDate.getSeconds()],
["q+", Math.floor((realDate.getMonth() + 3) / 3)],
["S+", realDate.getMilliseconds()],
];
var reg1 = regYear.exec(format);
if (reg1) {
format = format.replace(reg1[1], (realDate.getFullYear() + '').substring(4 - reg1[1].length));
}
for (var i = 0; i < date.length; i++) {
var reg2 = getRegExp("(" + date[i][0] + ")").exec(format);
if (reg2) {
format = format.replace(reg2[1], reg2[1].length == 1 ? v : ("00" + date[i][1]).substring(("" + date[i][1]).length));
}
}
return format;
}
// 首页新闻时间格式截取
function formatTimestamp (value) {
if (value) {
return value.substring(0, 10)
} else {
return value
}
}
// 首页项目项目状态
function formatState (value) {
if (value == '已结案') {
return '../../../../images/home/project-end.png'
} else if (value == '已关闭') {
return '../../../../images/home/project-close.png'
} else if (value == '处理中') {
return '../../../../images/home/project-handle.png'
} else {
return '../../../../images/home/project-end.png'
}
}
module.exports = {
formatTime: formatTime, // 日期格式化
formatTimestamp: formatTimestamp,
formatState: formatState
}