common.js
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* songcxa
* 2018-10-24
* 功能接口
* */
export default {
/**
* 获取当前时间
* 格式YYYY-MM-DD 00:00
*/
getNowFormatDate:function(){
var date = new Date();
var year=date.getFullYear();
/* 在日期格式中,月份是从0开始的,因此要加0
* 使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
* */
var month= date.getMonth()+1<10 ? "0"+(date.getMonth()+1) : date.getMonth()+1;
var day=date.getDate()<10 ? "0"+date.getDate() : date.getDate();
var hours=date.getHours()<10 ? "0"+date.getHours() : date.getHours();
var minutes=date.getMinutes()<10 ? "0"+date.getMinutes() : date.getMinutes();
var seconds=date.getSeconds()<10 ? "0"+date.getSeconds() : date.getSeconds();
// 拼接
return year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
},
getYea:function(){
return 1;
},
/**
* 格式化数字为单个字符
*/
formatNumToStr:function(val){
const tmpVal=val.toString().split("");
let tmpHtml="";
for(let i=0;i<tmpVal.length;i++){
tmpHtml +="<div class='eleNumBg'>" +tmpVal[i]+"</div>";
let tmpStr="<div class='eleVerHorCenter-tableCell' style='width: 3px;'></div>";
if(i!==(tmpVal.length-1)){
tmpHtml +=tmpStr
}
}
return tmpHtml;
},
}