初始化
缺陷:主题配色需要优化整体的同风格
This commit is contained in:
37
app/Service/wx/WxHomeService.php
Normal file
37
app/Service/wx/WxHomeService.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\wx;
|
||||
|
||||
use App\BaseApp\BaseWxService;
|
||||
use App\Models\business\CarouselModel;
|
||||
use App\Models\business\CategoryModel;
|
||||
|
||||
/**
|
||||
* 小程序首页:轮播与一级分类,都不要求登录
|
||||
*/
|
||||
class WxHomeService extends BaseWxService
|
||||
{
|
||||
protected bool $needLogin = false;
|
||||
|
||||
public function carousel(): mixed
|
||||
{
|
||||
// 只返回启用中的轮播;后台 status=1 表示隐藏
|
||||
return CarouselModel::where('deleted_at', 0)
|
||||
->where('status', 0)
|
||||
->orderBy('sort', 'asc')
|
||||
->get(['id', 'url', 'to_path', 'sort']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类列表,pid=0 为一级
|
||||
* 按 sort 升序,同值按 id(需已执行 05_cc_category_add_sort.sql)
|
||||
*/
|
||||
public function categoryList(int $pid = 0): mixed
|
||||
{
|
||||
return CategoryModel::where('pid', $pid)
|
||||
->where('deleted_at', 0)
|
||||
->orderBy('sort', 'asc')
|
||||
->orderBy('id', 'asc')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user