GoodsController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace App\Modules\Mini\Controllers;
  3. use App\Base\BaseController;
  4. use App\Modules\Mini\Services\GoodsService;
  5. use Faker\Provider\Image;
  6. class GoodsController extends BaseController
  7. {
  8. protected GoodsService $service;
  9. /**
  10. * @param GoodsService $service
  11. */
  12. public function __construct(GoodsService $service)
  13. {
  14. $this->service = $service;
  15. }
  16. public function goods()
  17. {
  18. $params = $this->valid([
  19. "id" => "required",
  20. ]);
  21. return $this->ok($this->service->info($params));
  22. return $this->ok([
  23. "id" => 1,
  24. "image_list" => [
  25. Image::imageUrl(),
  26. Image::imageUrl(),
  27. ],
  28. "spec" => [
  29. "id" => 1,
  30. "name" => "颜色",
  31. "attr" => [
  32. [
  33. "id" => 1,
  34. "name" => "红色",
  35. ],
  36. ],
  37. ],
  38. "sku" => [
  39. [
  40. "id" => 1,
  41. "sn" => "sn",
  42. "url_3d" => "",
  43. "spec_attr" => [
  44. [
  45. "id" => 1,
  46. "name" => "白色",
  47. ],
  48. [
  49. "id" => 3,
  50. "name" => "大号",
  51. ],
  52. ],
  53. ],
  54. ],
  55. "desc_html" => "<h1>desc_html</h1>",
  56. "spec_attr_html" => "<h1>desc_html</h1>",
  57. "faq_html" => "<h1>desc_html</h1>",
  58. ]);
  59. }
  60. public function search()
  61. {
  62. return $this->ok([
  63. "total" => 1,
  64. "page_total" => 1,
  65. "list" => [
  66. [
  67. "id" => 1,
  68. "name" => "商品名称",
  69. "thumb" => Image::imageUrl(),
  70. ],
  71. ],
  72. "category" => [
  73. [
  74. "id" => 1,
  75. "thumb" => Image::imageUrl(),
  76. "name" => "分类名称",
  77. ],
  78. ],
  79. ]);
  80. }
  81. public function fav()
  82. {
  83. return $this->ok();
  84. }
  85. public function ask()
  86. {
  87. return $this->ok([
  88. "id" => 1,
  89. "thumb" => Image::imageUrl(),
  90. "name" => "商品名称",
  91. "url" => "http://baidu.com/xxxx",
  92. ]);
  93. }
  94. }