Goods.php 1.2 KB

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