小程序首页配置
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Mini;
|
||||
|
||||
use App\Models\HomeBannerModel;
|
||||
use App\Models\HomeNavModel;
|
||||
use App\Models\HomePromoModel;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Modules\AnnoRoute\Attribute\GetRoute;
|
||||
use Modules\AnnoRoute\Attribute\RequestAttribute;
|
||||
|
||||
/**
|
||||
* 小程序首页配置(轮播图 + 宫格导航 + 促销推荐卡片,仅返回启用项)
|
||||
*/
|
||||
#[RequestAttribute('/mini', 'mini', authGuard: 'users')]
|
||||
class HomeController extends BaseMiniController
|
||||
{
|
||||
/** 首页配置聚合:banners / navs / promos,按 sort 升序 */
|
||||
#[GetRoute('/home', authorize: false)]
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$banners = HomeBannerModel::query()
|
||||
->where('status', HomeBannerModel::STATUS_NORMAL)
|
||||
->orderBy('sort')
|
||||
->orderBy('id')
|
||||
->get(['id', 'title', 'image_id', 'link', 'sort']);
|
||||
|
||||
$navs = HomeNavModel::query()
|
||||
->where('status', HomeNavModel::STATUS_NORMAL)
|
||||
->orderBy('sort')
|
||||
->orderBy('id')
|
||||
->get(['id', 'name', 'image_id', 'link', 'sort']);
|
||||
|
||||
$promos = HomePromoModel::query()
|
||||
->where('status', HomePromoModel::STATUS_NORMAL)
|
||||
->orderBy('sort')
|
||||
->orderBy('id')
|
||||
->get(['id', 'title', 'sub_title', 'image_id', 'link', 'sort']);
|
||||
|
||||
return $this->success([
|
||||
'banners' => $banners,
|
||||
'navs' => $navs,
|
||||
'promos' => $promos,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -57,10 +57,8 @@ class ProductController extends BaseMiniController
|
||||
|
||||
/**
|
||||
* 商品列表:价格取当前门店客户等级价;
|
||||
* 未绑定门店/门店未设客户等级 → 仍可浏览,price 为 null(不可见价格,加购/下单另由前置校验拦截);
|
||||
* ?category_id=&keyword=&page=&pageSize=
|
||||
*/
|
||||
#[GetRoute('/product/list', authorize: true)]
|
||||
#[GetRoute('/product/list', authorize: false)]
|
||||
public function products(Request $request): JsonResponse
|
||||
{
|
||||
$user = $this->currentUser($request);
|
||||
|
||||
Reference in New Issue
Block a user