common.js 1.41 KB
/*
 * 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;

  },
  /**
   * 金额转换
   */
  formatMoney:function (val) {
    return val/100;
  }
}