You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

57 lines
1.1 KiB

  1. <?php
  2. namespace addons\unishop\controller;
  3. use app\common\controller\Api;
  4. class Category extends Api
  5. {
  6. protected $noNeedLogin = ['all','menu','inlist'];
  7. protected $noNeedRight = ['*'];
  8. public function _initialize()
  9. {
  10. parent::_initialize();
  11. $this->model = new \addons\unishop\model\Category();
  12. }
  13. /**
  14. * 全部分类数据
  15. */
  16. public function all(){
  17. $all = $this->model
  18. ->where('type','product')
  19. ->where('status','normal')
  20. ->field('id,name,pid,image,type,flag,weigh')
  21. ->order('weigh ASC')
  22. ->cache(20)
  23. ->select();
  24. if ($all) {
  25. $all = collection($all)->toArray();
  26. }
  27. $this->success('',$all);
  28. }
  29. /**
  30. * 首页广告下面的分类
  31. */
  32. public function menu()
  33. {
  34. $list = $this->model
  35. ->where('flag','index')
  36. ->where('status','normal')
  37. ->cache(20)
  38. ->select();
  39. if ($list) {
  40. $list = collection($list)->toArray();
  41. }
  42. $this->success('菜单',$list);
  43. }
  44. }