PageController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Modules\Mini\Controllers;
  3. use App\Base\BaseController;
  4. use App\Modules\Mini\Services\PageService;
  5. use Faker\Provider\Image;
  6. class PageController extends BaseController
  7. {
  8. protected PageService $service;
  9. /**
  10. * @param PageService $service
  11. */
  12. public function __construct(PageService $service)
  13. {
  14. $this->service = $service;
  15. }
  16. public function filterConfig()
  17. {
  18. return $this->ok([
  19. [
  20. "id" => 1,
  21. "name" => "类目示例",
  22. "type" => "category",
  23. "child" => [
  24. [
  25. "id" => 1,
  26. "name" => "名称",
  27. ],
  28. ],
  29. ],
  30. [
  31. "id" => 1,
  32. "name" => "属性示例",
  33. "type" => "attr",
  34. "child" => [
  35. [
  36. "id" => 1,
  37. "name" => "名称",
  38. ],
  39. ],
  40. ],
  41. ]);
  42. }
  43. public function home()
  44. {
  45. return $this->ok([
  46. "banner" => $this->service->banner(),
  47. "categoryTree" => $this->service->categoryTree(),
  48. "hot_goods" => $this->service->hotGoods(10),
  49. "recommend_goods" => $this->service->recommendedGoods(10),
  50. ]);
  51. }
  52. public function categoryGoods()
  53. {
  54. $params = $this->valid([
  55. "id" => "required",
  56. "page_size" => "int",
  57. ]);
  58. return $this->ok($this->service->categoryGoods($params));
  59. }
  60. public function categoryTree()
  61. {
  62. return $this->ok([
  63. "categoryTree" => $this->service->categoryTree(),
  64. ]);
  65. }
  66. public function search()
  67. {
  68. return $this->ok([
  69. "total" => 1,
  70. "page_total" => 1,
  71. "list" => [
  72. [
  73. "id" => 1,
  74. "name" => "商品名称",
  75. "thumb" => Image::imageUrl(),
  76. ],
  77. ],
  78. "category" => [
  79. [
  80. "id" => 1,
  81. "thumb" => Image::imageUrl(),
  82. "name" => "分类名称",
  83. ],
  84. ],
  85. ]);
  86. }
  87. }