Goods.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\store\controller\data;
  3. use app\store\controller\Controller;
  4. use app\store\model\Goods as GoodsModel;
  5. use app\store\model\Category as CategoryModel;
  6. /**
  7. * 商品数据控制器
  8. * Class Goods
  9. * @package app\store\controller\data
  10. */
  11. class Goods extends Controller
  12. {
  13. /* @var \app\store\model\Goods $model */
  14. private $model;
  15. /**
  16. * 构造方法
  17. * @throws \app\common\exception\BaseException
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * @throws \think\exception\DbException
  21. */
  22. public function _initialize()
  23. {
  24. parent::_initialize();
  25. $this->model = new GoodsModel;
  26. $this->view->engine->layout(false);
  27. }
  28. /**
  29. * 商品列表
  30. * @return mixed
  31. * @throws \think\exception\DbException
  32. */
  33. public function lists()
  34. {
  35. // 商品分类
  36. $catgory = CategoryModel::getCacheTree();
  37. // 商品列表
  38. $list = $this->model->getList($this->request->param());
  39. return $this->fetch('list', compact('list', 'catgory'));
  40. }
  41. }