コード例 #1
0
 public function index()
 {
     //组装地址后缀
     if (!isset($_GET['s'])) {
         $this->formatUrl();
     }
     //读取当前分类信息
     $field = $this->db->getOne(Q('cate_id'));
     View::with('field', $field);
     //读取当前分类下的所有品牌
     $brand = new \Home\Model\Brand();
     $brandData = $brand->getRel(Q('cate_id'));
     View::with('brandData', $brandData);
     //读取该分类下所有商品对应的规格属性
     $cateAttr = $this->assignCateAttr();
     View::with('cateAttr', $cateAttr);
     //根据筛选条件分配商品信息
     $goodsData = $this->getGoods();
     View::with('goodsData', $goodsData);
     //全部商品分类
     $cateData = $this->db->getChan();
     // p($cateData);
     View::with('cateData', $cateData);
     //分配相关分类
     $data = $this->db->getAll();
     $d = Data::parentChannel($data, $_GET['cate_id'], 'cate_id', 'pid');
     foreach ($d as $key => $v) {
         if ($v['pid'] == 0) {
             $cateRel = $this->db->getRel($v['cate_id']);
         }
     }
     View::with('cateRel', $cateRel);
     //最近浏览商品
     $goods = new \Home\Model\Goods();
     $viewData = $goods->recentView();
     View::with('viewData', $viewData);
     //最新发布商品
     $new = $goods->getNew();
     View::with('new', $new);
     View::make($this->tpl . 'lists.html');
 }