<?php
/**
 * 商品列表
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaol <1094186793@qq.com>
 */

namespace Home\Controller;
use Think\Controller;
class CateController extends BaseController {
    public function index(){
        $map=array();
        $join=$order='';
        $param=I('param.');
        $param['cat_id']=$param['id'];unset($param['id']);
        if(empty($param['brand_id']))$param['brand_id']=0;
        if(empty($param['cat_id']))$param['cat_id']=0;
        $p=$param['p'];
        $catid=$param['cat_id'];
        /*取排序开始*/
        $orders=D('Common/Goods')->cate_order($param);
        /*取排序结束*/
        /*标签筛选开始*/
        $labels_map=D('Common/Goods')->get_label_map($param);
        $labels=$labels_map['labels'];
        if(!empty($labels_map['map']))$map=$labels_map['map'];
        /*标签筛选结束*/
        /*价格分级开始*/
        $price_list = get_price_map($catid,$param['price']);
        if(!empty($price_list['shop_price']))$map['shop_price']=$price_list['shop_price'];
        /*价格分级结束*/
        /*属性筛选开始*/
        $type_id=get_cate_type($catid);//类型ID
        $attr_list=D('Common/GoodsAttr')->get_attr($param,$type_id);
        if(!empty($attr_list)){
            $map['_string']=$attr_list['_string'];
        }
        /*属性筛选结束*/
        //关键词
        if(!empty($param['keyword'])){
            $map['goods_name']=array('like','%'.$param['keyword'].'%');
            $symbol=' &gt; ';
            $catpos_title=$symbol.'<a>搜索结果</a>';
        }
        //分类
        if(!empty($param['cat_id']))$map['cat_id']=$param['cat_id'];
        //品牌
        if(!empty($param['brand_id']))$map['brand_id']=$param['brand_id'];
        //排序
        if($param[$param['order_name']]==1){$order_type='desc';
		}elseif($param[$param['order_name']]==2){$order_type='asc';}
        if(!empty($param['order_name']) && $order_type)$order=$param['order_name'].' '.$order_type;
        $goodslist=D('Common/Goods')->get_goods_list(0,$map,$join,$order,$p);
       // print_r($goodslist);
        /*seo开始*/
        $seodata=D('Common/Goods')->format_listseotile($param['brand_id'],$catid,0,0,0,$param['keyword']);
        /*seo结束*/
        $this->assign('pricelist', empty($price_list['pricelist'])?array():$price_list['pricelist']);
        $this->assign('param',$param);
        $this->assign($param);
        $this->assign('orders',$orders);
        $this->assign('labels',$labels);
        $this->assign('type_id',$type_id);
        $this->assign($seodata);
        $this->assign($goodslist);
        $this->assign('catpos_title',$catpos_title);
        $this->display();
    }
    public function add_listcart(){
        $goods_id=I('id');
        $number=I('number');
        $data=D("Common/cart")->add_carts();
    }
}
?>