PageController.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. return $this->ok([
  55. "total" => 1,
  56. "page_total" => 1,
  57. "list" => [
  58. [
  59. "id" => 1,
  60. "name" => "商品名称",
  61. "thumb" => Image::imageUrl(),
  62. ],
  63. ],
  64. ]);
  65. }
  66. public function categoryTree()
  67. {
  68. return $this->ok([
  69. "categoryTree" => [
  70. [
  71. "id" => 1,
  72. "name" => "一级分类",
  73. "child" => [
  74. [
  75. "id" => 1,
  76. "name" => "二级分类",
  77. "child" => [
  78. [
  79. "id" => 1,
  80. "name" => "二级分类",
  81. ],
  82. ],
  83. ],
  84. ],
  85. ],
  86. ],
  87. ]);
  88. }
  89. public function search()
  90. {
  91. return $this->ok([
  92. "total" => 1,
  93. "page_total" => 1,
  94. "list" => [
  95. [
  96. "id" => 1,
  97. "name" => "商品名称",
  98. "thumb" => Image::imageUrl(),
  99. ],
  100. ],
  101. "category" => [
  102. [
  103. "id" => 1,
  104. "thumb" => Image::imageUrl(),
  105. "name" => "分类名称",
  106. ],
  107. ],
  108. ]);
  109. }
  110. }