util.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. const globalData = {
  2. publicUrl: 'https://sqdx.jiaxintech.com'//测试地址
  3. // publicUrl: 'https://sqpx.jiaxintech.com'//正式地址
  4. // publicUrl:'http://10.16.10.139'//ly
  5. // publicUrl:'http://10.16.4.19:80'//hyb
  6. // publicUrl:'http://10.16.4.26:80'//zxq
  7. // publicUrl:'http://10.20.1.207:80'//dailin
  8. };
  9. const formatTime = date => {
  10. const year = date.getFullYear()
  11. const month = date.getMonth() + 1
  12. const day = date.getDate()
  13. const hour = date.getHours()
  14. const minute = date.getMinutes()
  15. const second = date.getSeconds()
  16. return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  17. }
  18. const formatNumber = n => {
  19. n = n.toString()
  20. return n[1] ? n : '0' + n
  21. }
  22. const dateFilter=function(date){
  23. return date.replace(/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/g,function(){
  24. 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])+"日";
  25. })
  26. }
  27. module.exports = {
  28. globalData,
  29. formatTime,
  30. dateFilter
  31. }