var g_filters = {
	    //-- 判断是不是有等级价 --
	    is_has_rank:function(rank_switch,item){
	    	 if(!rank_switch) return false;
	    	 if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
	    	 return false;	 
	    },
       	
	    //-- 判断,不是等级会员时候，要显示的最低等级价和名称 --
		get_card_price:function(goods,all_card,type){		
			     var price1=parseFloat(goods['cardprice1']);
           var price2 = parseFloat(goods['cardprice2']);
           var price3 = parseFloat(goods['cardprice3']);					   
			     if(!all_card){
			         if(type==0) return 0;
			         return "";
			     }	  
				 
			     var min_price=null;
				 var min_name=null;	   
			     //---设置对应的价格名字----	   
				 for(var i=0;i<3;i++) {						
					var vl=all_card[i];			
				   if(!vl) continue;			
							
					if(vl['CorrPrice']=="Price1" && price1>0)
					{	 	 		  
					   if(min_price==null) {
						     min_price=price1;min_name=vl['CardName'];
					   }
					   else if(price1<min_price) {
							min_price=price1;min_name=vl['CardName'];					  
					   }
					}
					if(vl['CorrPrice']=="Price2" && price2>0)
					{
						if(min_price==null) {
							min_price=price2;min_name=vl['CardName'];
						}
						else if(price2<min_price) {
							min_price=price2;min_name=vl['CardName'];					  
						}					
					}
											
					if(vl['CorrPrice']=="Price3" && price3>0)
					{						
						if(min_price==null) {
							min_price=price3;min_name=vl['CardName'];
						}
						else if(price3<min_price) {
							min_price=price3;min_name=vl['CardName'];					  
						}
					}
														
				 } 
				 if(min_price==null){
					 if(type==0) return 0;
					 return "";
				 }	
				 			   
			     if(type==0) return min_price;	
				 if(min_name.length>4 )	min_name=min_name.substring(0, 8);	 
			     return min_name;
		},

		//跳转的接口
                		get_goods_url:function(item){
                		   var url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id
                		   if(item.prom_type==8){
                		       url1="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id
                		    }
                		    if(item.prom_type==1 && item.prom_id>0 ){
                                url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id+"&prom_type=1";
                            }
                		   return url1;
                		}
}
module.exports = {
	  is_has_rank:g_filters.is_has_rank,
	  get_card_price:g_filters.get_card_price,
	   get_goods_url:g_filters.get_goods_url
}