12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- const globalData = {
- version:'3.1.0',
- imgUrl:'https://edu-mp-img-1254259530.cos.ap-nanjing.myqcloud.com',
- publicUrl: 'https://sqdx.jiaxintech.com'//测试地址
- // publicUrl: 'https://sqpx.jiaxintech.com'//正式地址
- // publicUrl:'http://10.16.10.139'//ly
- // publicUrl:'http://10.16.4.19:80'//hyb
- // publicUrl:'http://10.16.4.26:80'//zxq
- // publicUrl:'http://10.20.1.207:80'//dailin
-
- };
- const formatTime = date => {
- const year = date.getFullYear()
- const month = date.getMonth() + 1
- const day = date.getDate()
- const hour = date.getHours()
- const minute = date.getMinutes()
- const second = date.getSeconds()
- return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
- }
- const formatNumber = n => {
- n = n.toString()
- return n[1] ? n : '0' + n
- }
- const dateFilter=function(date){
- return date.replace(/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/g,function(){
- return arguments[1]+"年"+(arguments[2].length>1&&arguments[2][0]=="0"?arguments[2][1]:arguments[2])+"月"+(arguments[3].length>1&&arguments[3][0]=="0"?arguments[3][1]:arguments[3])+"日";
- })
-
- }
- const timeFilter=function(date){
- console.log(date);
- return date.replace(/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})[\s]+([0-9]{1,2}):([0-9]{1,2})(:[0-9]{1,2})/g,function(){
- console.log(arguments);
- return arguments[1]+"/"+(arguments[2].length>1&&arguments[2][0]=="0"?arguments[2][1]:arguments[2])+"/"+(arguments[3].length>1&&arguments[3][0]=="0"?arguments[3][1]:arguments[3])+" "+(arguments[4].length>1&&arguments[4][0]=="0"?arguments[4][1]:arguments[4])+":"+(arguments[5].length>1&&arguments[5][0]=="0"?arguments[5][1]:arguments[5]);
- })
-
- }
-
- const timeFmt= function(str,fmt){
- let trexp=str.replace(/([0-9\-]+)[\s]+([0-9:+])/g,function(){return arguments[1]+"T"+arguments[2]})
- let d=new Date(trexp!=""?trexp:str)
- console.log("str:",str)
- console.log(d);
- let o = {
- "M+" : d.getMonth()+1, //月份
- "d+" : d.getDate(), //日
- "h+" : d.getHours(), //小时
- "m+" : d.getMinutes(), //分
- "s+" : d.getSeconds(), //秒
- "q+" : Math.floor((d.getMonth()+3)/3), //季度
- "S" : d.getMilliseconds() //毫秒
- };
- if(/(y+)/.test(fmt))
- fmt=fmt.replace(RegExp.$1, (d.getFullYear()+"").substr(4 - RegExp.$1.length));
- for(var k in o)
- if(new RegExp("("+ k +")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
- return fmt;
- }
- module.exports = {
- globalData,
- formatTime,
- dateFilter,
- timeFilter,
- timeFmt
- }
|