12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Modules\Mini\Controllers;
- use App\Base\BaseController;
- use App\Modules\Mini\Services\PageService;
- use Faker\Provider\Image;
- class PageController extends BaseController
- {
- protected PageService $service;
- /**
- * @param PageService $service
- */
- public function __construct(PageService $service)
- {
- $this->service = $service;
- }
- public function filterConfig()
- {
- return $this->ok([
- [
- "id" => 1,
- "name" => "类目示例",
- "type" => "category",
- "child" => [
- [
- "id" => 1,
- "name" => "名称",
- ],
- ],
- ],
- [
- "id" => 1,
- "name" => "属性示例",
- "type" => "attr",
- "child" => [
- [
- "id" => 1,
- "name" => "名称",
- ],
- ],
- ],
- ]);
- }
- public function home()
- {
- return $this->ok([
- "banner" => $this->service->banner(),
- "categoryTree" => $this->service->categoryTree(),
- "hot_goods" => $this->service->hotGoods(10),
- "recommend_goods" => $this->service->recommendedGoods(10),
- ]);
- }
- public function categoryGoods()
- {
- $params = $this->valid([
- "id" => "required",
- "page_size" => "int",
- ]);
- return $this->ok($this->service->categoryGoods($params));
- }
- public function categoryTree()
- {
- return $this->ok([
- "categoryTree" => $this->service->categoryTree(),
- ]);
- }
- public function search()
- {
- return $this->ok([
- "total" => 1,
- "page_total" => 1,
- "list" => [
- [
- "id" => 1,
- "name" => "商品名称",
- "thumb" => Image::imageUrl(),
- ],
- ],
- "category" => [
- [
- "id" => 1,
- "thumb" => Image::imageUrl(),
- "name" => "分类名称",
- ],
- ],
- ]);
- }
- }
|