26 lines
915 B
JavaScript
26 lines
915 B
JavaScript
module.exports = {
|
|
// 获取日期 传一个时间戳 转为YY-MM-DD hh-mm-ss 格式
|
|
getDate(date) {
|
|
var date = new Date(date);
|
|
var YY = date.getFullYear() + '-';
|
|
var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
|
|
var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
|
|
var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
|
|
var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
|
|
var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
|
|
return YY + MM + DD + " " + hh + mm + ss;
|
|
},
|
|
|
|
// 分页切割数组(数组,分割个数)
|
|
getMapping(list, num) {
|
|
let len = list.length
|
|
let newList = []
|
|
if (len) {
|
|
var chunk = num
|
|
for (var i = 0, j = len; i < j; i += chunk) {
|
|
newList.push(list.slice(i, i + chunk))
|
|
}
|
|
}
|
|
return newList
|
|
},
|
|
} |