var g_filters = {
	has_char:function(url,key){
	  if(!url)	return -1;
	  return url.indexOf(key);		
	},
	beg_time:function(beg_date){
	    var fmt1 = beg_date.substring(0, 19);
        var reg = getRegExp("-", "g");
        var fmt2 = fmt1.replace(reg, '/');
        var t1 = getDate(fmt2);
        var tnow=getDate();
        if(t1<=tnow) return 1;
        return 0;
	},
	end_time:function(end_date){
	        var fmt1 = end_date.substring(0, 19);
            var reg = getRegExp("-", "g");
            var fmt2 = fmt1.replace(reg, '/');
            var t1 = getDate(fmt2);
            var tnow=getDate();
            if(t1>=tnow) return 1;
            return 0;
	},

	toFix: function (val, count) {
    		if(!val){
    			return parseFloat(0).toFixed(count);
    		}
    		val = parseFloat(val);
    		return val.toFixed(count)
    },

	//判断商品是不是有活动切换
	is_more_act:function (items,show_can_cx){
		if([1,2,4,6,8,9].indexOf(items.prom_type)>-1) return false;
        if(!show_can_cx) return false;
        return true;
	},

	//判断一下文件末尾的|号,促销显示送的内容
	map_str:function (content){
		var string='';
		if(content.is_money==1) string+='免'+content.money+'元|';
		if(content.is_sale==1) string+="打"+content.sale+"折|";
		if(content.is_past==1) string+= "包邮|";
		if(content.is_coupon==1) string+="送优惠券|";
		if(content.is_int==1) string+="送积分|";
		if(content.is_gift==1) string+="送赠品|";
		if(content.is_libao==1) string+="送礼包|";
		if(content.is_zxlibao==1) string+="送专享礼包|";
		if(content.is_monthgiftbag==1) string+="送每月礼包|";
		string=string.substring(0,string.length-1);
		return string
	}

}
module.exports = {
	has_char: g_filters.has_char,
	beg_time: g_filters.beg_time,
	end_time: g_filters.end_time,
	toFix: g_filters.toFix,
	is_more_act: g_filters.is_more_act,
	check_show:g_filters.check_show,
	map_str:g_filters.map_str
}