var filters = {
        toFix:function(val,count){
            if(!val) return parseFloat(0).toFixed(count);
            return val.toFixed(count)
        },
        format_time:function(ts,isFull) {
           var d = getDate(ts*1000)
           var fm=[d.getFullYear(), d.getMonth()+1, d.getDate()].join('-');
           if(isFull==1)
              fm=fm + ' '+ [d.getHours(), d.getMinutes(), d.getSeconds()].join(':')
           return fm;
        },
        setcolor:function(ind){
          if (ind == 0 || ind ==null) return "red";
          if(ind==1 ) return "green";
          if(ind==2) return "blue";
          if(ind==11) return "green";
          if(ind==13) return "red";
          if(ind==12) return "blue";
          if(ind==20) return "green";
          if(ind==14) return "red";
          return "";
        },
      setbgcolor: function (ind) {
        if (ind == 0 || ind == null) return "#ffa1b9";
        if (ind == 1) return "#59e1d2";
        if (ind == 2) return "#a3bcff";
        if (ind == 11) return "#59e1d2";
        if (ind == 12) return "#a3bcff";
        if (ind == 20) return "#6d87cd";
        if (ind==13) return "#ffa1b9";
        return "";
      },
  
        get_type:function(ind){
          if (ind == 0 || ind == null) return "全场通用";
          if (ind == 1) return "品牌";
          if (ind == 2) return "品类";
          if (ind == 11) return "用途";
          if (ind == 12) return "分类1";
          if (ind == 13) return "自定义";
          if (ind == 14) return "分类2";
          if (ind == 20) return "指定单品";
          return "";
        },
         get_type_card:function(ind){
           if (ind == 0 || ind == null) return "全场通用";
                  if (ind == 1) return "指定品牌";
                  if (ind == 2) return "指定品类";
                  if (ind == 11) return "指定用途";
                  if (ind == 12) return "指定分类1";
                  if (ind == 13) return "自定义";
                  if (ind == 20) return "指定单品";
                  return "";
                },
       format_huiche:function (text) {
        if (!text) {
          return "";
        }
        var reg = getRegExp('\\\\n', 'g')
        return text.replace(reg, '\n')
      }
}

module.exports = {
  toFix: filters.toFix,
	format_time:filters.format_time,
	setcolor:filters.setcolor,
  setbgcolor: filters.setbgcolor,
  get_type: filters.get_type,
  get_split_name: filters.get_split_name,
  get_type_card: filters.get_type_card,
  format_huiche: filters.format_huiche,
}