Пример #1
0
 public function index()
 {
     //商品分类
     $cate = new \Home\Model\Cate();
     $cateData = $cate->getChan();
     // p($cateData);
     View::with('cateData', $cateData);
     //创建商品对象
     $goods = new \Home\Model\Goods();
     //最新发布商品
     $new = $goods->getNew();
     View::with('new', $new);
     //重组分类列表,并去取出8件商品
     $cateTree = $cateData;
     foreach ($cateData as $k => $v) {
         $a = array();
         //取该分组下的三级分类
         foreach ($v['_data'] as $m => $n) {
             $a = array_merge($a, array_keys($n['_data']));
         }
         unset($cateTree[$k]['_data']);
         $cateTree[$k]['three'] = $a;
         if ($a) {
             $level_goods = $goods->whereIn('cate_id', $a)->limit(8)->get();
             $cateTree[$k]['level_goods'] = $level_goods;
         }
     }
     // p($cateTree);
     View::with('cateTree', $cateTree);
     View::make($this->tpl . 'index.html');
 }
Пример #2
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');
 }