PageController.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 home()
  17. {
  18. return $this->ok([
  19. "banner" => $this->service->banner(),
  20. "categoryTree" => [
  21. [
  22. "id" => 1,
  23. "name" => "一级分类",
  24. "child" => [
  25. [
  26. "id" => 1,
  27. "name" => "二级分类",
  28. ],
  29. ],
  30. ],
  31. ],
  32. "hot_goods" => [
  33. [
  34. "id" => 1,
  35. "name" => "商品名称",
  36. "thumb" => Image::imageUrl(),
  37. ],
  38. ],
  39. "recommend_goods" => [
  40. [
  41. "id" => 1,
  42. "name" => "商品名称",
  43. "thumb" => Image::imageUrl(),
  44. ],
  45. ],
  46. ]);
  47. }
  48. public function categoryTree()
  49. {
  50. return $this->ok([
  51. "categoryTree" => [
  52. [
  53. "id" => 1,
  54. "name" => "一级分类",
  55. "child" => [
  56. [
  57. "id" => 1,
  58. "name" => "二级分类",
  59. "child" => [
  60. [
  61. "id" => 1,
  62. "name" => "二级分类",
  63. ],
  64. ],
  65. ],
  66. ],
  67. ],
  68. ],
  69. ]);
  70. }
  71. }