PageController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. $this->service->categoryGoods($params);
  59. return $this->ok([
  60. "total" => 1,
  61. "page_total" => 1,
  62. "list" => [
  63. [
  64. "id" => 1,
  65. "name" => "商品名称",
  66. "thumb" => Image::imageUrl(),
  67. ],
  68. ],
  69. ]);
  70. }
  71. public function categoryTree()
  72. {
  73. return $this->ok([
  74. "categoryTree" => $this->service->categoryTree(),
  75. ]);
  76. }
  77. public function search()
  78. {
  79. return $this->ok([
  80. "total" => 1,
  81. "page_total" => 1,
  82. "list" => [
  83. [
  84. "id" => 1,
  85. "name" => "商品名称",
  86. "thumb" => Image::imageUrl(),
  87. ],
  88. ],
  89. "category" => [
  90. [
  91. "id" => 1,
  92. "thumb" => Image::imageUrl(),
  93. "name" => "分类名称",
  94. ],
  95. ],
  96. ]);
  97. }
  98. }