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.
 
 
 
 
 
 

62 lines
1.3 KiB

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