PageController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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" => [
  48. [
  49. "id" => 1,
  50. "name" => "一级分类",
  51. "child" => [
  52. [
  53. "id" => 1,
  54. "name" => "二级分类",
  55. ],
  56. ],
  57. ],
  58. ],
  59. "hot_goods" => [
  60. [
  61. "id" => 1,
  62. "name" => "商品名称",
  63. "thumb" => Image::imageUrl(),
  64. ],
  65. ],
  66. "recommend_goods" => [
  67. [
  68. "id" => 1,
  69. "name" => "商品名称",
  70. "thumb" => Image::imageUrl(),
  71. ],
  72. ],
  73. ]);
  74. }
  75. public function categoryGoods()
  76. {
  77. return $this->ok([
  78. "total" => 1,
  79. "page_total" => 1,
  80. "list" => [
  81. [
  82. "id" => 1,
  83. "name" => "商品名称",
  84. "thumb" => Image::imageUrl(),
  85. ],
  86. ],
  87. ]);
  88. }
  89. public function categoryTree()
  90. {
  91. return $this->ok([
  92. "categoryTree" => [
  93. [
  94. "id" => 1,
  95. "name" => "一级分类",
  96. "child" => [
  97. [
  98. "id" => 1,
  99. "name" => "二级分类",
  100. "child" => [
  101. [
  102. "id" => 1,
  103. "name" => "二级分类",
  104. ],
  105. ],
  106. ],
  107. ],
  108. ],
  109. ],
  110. ]);
  111. }
  112. public function goods()
  113. {
  114. return $this->ok([
  115. "id" => 1,
  116. "image_list" => [
  117. Image::imageUrl(),
  118. Image::imageUrl(),
  119. ],
  120. "spec" => [
  121. "id" => 1,
  122. "name" => "颜色",
  123. "attr" => [
  124. [
  125. "id" => 1,
  126. "name" => "红色",
  127. ],
  128. ],
  129. ],
  130. "sku" => [
  131. [
  132. "id" => 1,
  133. "sn" => "sn",
  134. "url_3d" => "",
  135. "spec_attr" => [
  136. [
  137. "id" => 1,
  138. "name" => "白色",
  139. ],
  140. [
  141. "id" => 3,
  142. "name" => "大号",
  143. ],
  144. ],
  145. ],
  146. ],
  147. "desc_html" => "<h1>desc_html</h1>",
  148. "spec_attr_html" => "<h1>desc_html</h1>",
  149. "faq_html" => "<h1>desc_html</h1>",
  150. ]);
  151. }
  152. }