//获取样式
var get_class = function(column,position) {
  //--列的情况
  if(column==1){ return "zs_t"+position; }
  //--俩列的情况
  if(column==2){ return "zs_t"+position+"_2l"; }
  //--三列的情况
  if(column==3){ return "zs_t"+position+"_3l"; }
  //----列表的情况-----
  if(column==4 ){ return "zs_t1_x"+position; }
//--滑动的情况
if(column==5){ return "zs_t"+position+"_3l"; }
}


var g_filters = {
    //判断边框类型
  get_border_type:function(type){
    if(!type) type=0;
    var type=parseInt(type);
    switch(type){
      case 0: return "border_zhijiao";
      case 1: return "border_yuanjiao";   
    }
    return "";
  },

    //-- 判断是不是有等级价 --
    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, 4);
         return min_name;
  },


  get_url_by_type: function(item) {
    var url = '';
    if(item.prom_type == 9) {
      url = '/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + item.goods_id + '&group_id=' + item.prom_id;
    }
    else if(item.prom_type==8){
                 url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id
           }
    else {
      url = '/pages/goods/goodsInfo/goodsInfo?goods_id=' + item.goods_id + '&prom_id=' + item.prom_id + '&prom_type=' + item.prom_type;
    };
    return url;
  },

}


module.exports = {
 get_class: get_class,
 is_has_rank:g_filters.is_has_rank,
 get_card_price:g_filters.get_card_price,
 get_border_type:g_filters.get_border_type,
 get_url_by_type: g_filters.get_url_by_type,
}
