PageController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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" => $this->service->categoryTree(),
  70. ]);
  71. }
  72. public function search()
  73. {
  74. return $this->ok([
  75. "total" => 1,
  76. "page_total" => 1,
  77. "list" => [
  78. [
  79. "id" => 1,
  80. "name" => "商品名称",
  81. "thumb" => Image::imageUrl(),
  82. ],
  83. ],
  84. "category" => [
  85. [
  86. "id" => 1,
  87. "thumb" => Image::imageUrl(),
  88. "name" => "分类名称",
  89. ],
  90. ],
  91. ]);
  92. }
  93. }