diff --git a/server/app/api/controller/CommunityController.php b/server/app/api/controller/CommunityController.php index e011469..88d9ee5 100644 --- a/server/app/api/controller/CommunityController.php +++ b/server/app/api/controller/CommunityController.php @@ -7,6 +7,7 @@ use app\common\model\community\CommunityPost; use app\common\model\community\CommunityComment; use app\common\model\community\CommunityLike; use app\common\model\community\CommunityFollow; +use app\common\model\community\CommunityCategory; use app\common\model\community\CommunityTag; use app\common\model\user\User; use app\common\model\ai\AiAnalysis; @@ -24,7 +25,7 @@ class CommunityController extends BaseApiController { private const LIUHE_TAGS = ['旧澳六合', '新澳六合']; - public array $notNeedLogin = ['postLists', 'postDetail', 'commentLists', 'tagLists', 'userProfile', 'followList', 'fansList']; + public array $notNeedLogin = ['postLists', 'postDetail', 'commentLists', 'tagLists', 'categoryLists', 'userProfile', 'followList', 'fansList']; // 帖子列表 public function postLists() @@ -423,6 +424,18 @@ class CommunityController extends BaseApiController return $this->data($list); } + // 分类列表 + public function categoryLists() + { + $list = CommunityCategory::where('status', 1) + ->order('sort desc') + ->order('id desc') + ->field('id,name,icon,post_count') + ->select() + ->toArray(); + return $this->data($list); + } + // 购买帖子 // confirm=0 探测是否已购买;confirm=1 确认扣分购买 public function purchasePost() diff --git a/uniapp/src/api/community.ts b/uniapp/src/api/community.ts index 03574be..3516ff9 100644 --- a/uniapp/src/api/community.ts +++ b/uniapp/src/api/community.ts @@ -57,6 +57,11 @@ export function getTagLists() { return request.get({ url: '/community/tagLists' }) } +// 社区分类列表 +export function getCommunityCategoryLists() { + return request.get({ url: '/community/categoryLists' }) +} + // 社区用户统计(积分、关注等) export function getCommunityUserStats() { return request.get({ url: '/community/userStats' }) diff --git a/uniapp/src/pages/community/community.vue b/uniapp/src/pages/community/community.vue index 200936c..67bc673 100644 --- a/uniapp/src/pages/community/community.vue +++ b/uniapp/src/pages/community/community.vue @@ -31,11 +31,12 @@ - - - {{ tag.name }} + + + {{ category.name }} @@ -47,7 +48,7 @@ SPORTS COMMUNITY {{ feedTitle }} - # {{ activeTagName }} + {{ activeCategoryName }} @@ -83,7 +84,13 @@