//获取样式
var get_dark_type = function(column) {
   switch(column){
       case 0:return "轻度";
       case 1:return "中度";
       case 2:return "重度";
   }
   return "无"
}

//跳转的接口
var get_goods_url=function(item,skinface_id){
        		   var url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&skinface_id="+skinface_id;

        		   if(item.prom_type == 9) {
                   		url1 = '/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + item.goods_id + '&group_id=' + item.prom_id+"&skinface_id="+skinface_id;
                   }
        		   if(item.prom_type==8){
        		       url1="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id+"&skinface_id="+skinface_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&skinface_id="+skinface_id;
                    }
        		   return url1;
        		}
var guige=function(item){
     var gg='';
     if (item.goods_spec != "" && item.goods_color != "") {
                                gg = item.goods_spec + "/" + item.goods_color;
                            } else if (item.goods_spec != "" || item.goods_color != "") {
                                gg = item.goods_spec + item.goods_color;
                            } else {
                                gg = "规格1";
                            }
     return gg;
}

var dryoil_check=function(skin_dryoil_check){
    var num_all=skin_dryoil_check[0]+skin_dryoil_check[1]+skin_dryoil_check[2]+skin_dryoil_check[3]+skin_dryoil_check[4];
    num_all= num_all/5;
    switch(num_all){
        case 0:return '干性';
        case 1:return '中性';
        case 2:return '油性';
        case 3:return '混合性';
    }
    return '';
}


//-- 判断是不是有等级价 --
var is_has_rank=function(rank_switch,item){
	    	 if(!rank_switch) return false;
	    	 if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
	    	 return false;
	    }

	    //-- 判断,不是等级会员时候，要显示的最低等级价和名称 --
var 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;
		}

var get_nai_shou=function(type){

 switch(type){
        case 0:return '耐受';
        case 1:return '中性';
        case 2:return '敏感';
    }
    return '';
}

//获取样式
var get_dryoil_check = function(column) {
   switch(column){
       case 0:return "干性";
       case 1:return "中性";
       case 2:return "油性";
       case 3:return "混合型";
   }
   return "无"
}

//是否包含
var is_has= function(num,arr){
  if(arr.indexOf(num)!=-1){
     return true;
  }
  return false;
}

module.exports = {
   get_dark_type: get_dark_type,
   get_goods_url: get_goods_url,
   guige:guige,
   dryoil_check:dryoil_check,
   is_has_rank:is_has_rank,
   get_card_price:get_card_price,
   get_nai_shou:get_nai_shou,
   get_dryoil_check:get_dryoil_check,
   is_has:is_has
}
