diff --git a/docs/业务进度管理.md b/docs/业务进度管理.md index d62fdbc0..54c72879 100644 --- a/docs/业务进度管理.md +++ b/docs/业务进度管理.md @@ -2558,6 +2558,23 @@ 涉及模块: - `server/public/dongqiudi-crawler/lottery_community.py` +### 9. 社区“我的评论”列表 + +- 状态:已完成 - 时间:2026-08-03 + +完成内容: +- 用户中心“我的评论”入口由占位提示改为真实页面,支持分页展示本人发布的根评论和回复。 +- 新增 `GET /api/community/myCommentLists`,仅返回当前登录用户的有效评论,并批量补齐原帖、被回复评论及用户昵称,避免列表 N+1 查询。 +- 评论卡可跳转至原帖详情;原帖已删除或下架时保留评论记录并明确显示不可查看。 +- 支持在列表中删除本人评论,沿用既有删除接口及权限校验。 + +涉及模块: +- `server/app/api/controller/CommunityController.php` +- `uniapp/src/api/community.ts` +- `uniapp/src/pages/user/user.vue` +- `uniapp/src/pages/my_comments/my_comments.vue` +- `uniapp/src/pages.json` + ## 四、避坑记录 - **跨模型批量更新前必须逐表核对字段**:`la_community_post`、`la_community_post_category` 有 `update_time`,但 `la_community_tag` 只有 `create_time`;复用计数刷新写法时不能默认所有业务表都有更新时间字段,否则 ThinkPHP 模型会直接返回 `fields not exists` 并导致事务回滚。 diff --git a/docs/设计稿映射.md b/docs/设计稿映射.md index a856ff39..5d4c2b59 100644 --- a/docs/设计稿映射.md +++ b/docs/设计稿映射.md @@ -31,8 +31,9 @@ | 彩票中心 | `uniapp/src/pages/lottery_analysis/lottery_analysis.vue`、`uniapp/src/packages_lottery/pages/detail.vue` | 🚧 部分完成 | 2026-08-03 按彩票中心设计稿重构顶部品牌导航、开奖大厅/关注/日历导航、横向彩种胶囊、风险提示及最新开奖卡片;保留开奖结果、倒计时、详情与历史开奖入口。开奖详情已改为复用首页品牌导航、风险提示、彩种主卡和号码球视觉,并动态展示彩票资讯,待 H5 页面验收 | | 社区广场 | `uniapp/src/pages/community/community.vue` | 🚧 部分完成 | 2026-08-02 已按优化设计稿重构为社区信息流;入口路径调整为 `/pages/community/community`,旧 `/pages/empty/empty` 与旧分包入口会自动跳转;顶部积分入口已在频道导航栏内上下居中;付费帖子未解锁区域已调整为上深下浅纵向渐变面板和底部居中描边按钮;锁定付费卡片的付费提示与积分状态改为顶部左右同排,免费及积分状态均固定右上角顶对齐;帖子卡片互动栏仅保留浏览、评论、点赞并按三等分排列,计数支持去除 `.0` 及 `k / 万 / 亿` 紧凑显示,待 H5 发布后验收实际效果 | | 社区帖子详情 | `uniapp/src/packages_community/pages/post_detail.vue` | 🚧 部分完成 | 2026-08-03 解锁卡已按设计稿优化为浅蓝渐变、同心圆实心锁、积分信息区、渐变解锁按钮与居中提示;“积分规则”复用通用富文本协议页,并由管理端协议设置配置内容;页面主体、解锁卡、互动评论与输入栏已压缩字号及间距;互动统计与评论区改为连续卡片层级,评论点赞置于正文右侧并统一使用紧凑计数;未解锁帖子始终显示免费预览“展开”按钮,折叠态按钮位于摘要末行右侧;已有译文的帖子按标点短语进行原文/译文一对一交错显示;430px H5 页面已复核,App/小程序与正式构建待验收 | +| 社区我的评论 | `uniapp/src/pages/my_comments/my_comments.vue` | ✅ 已完成 | 2026-08-03 用户中心入口可查看本人根评论和回复、跳转原帖,并支持删除自己的评论 | | 新闻详情 | `uniapp/src/pages/news_detail/news_detail.vue` | 待核对 | 富文本与图片渲染已存在相关实现 | -| 个人中心 | `uniapp/src/pages/user/user.vue` | 🚧 部分完成 | 2026-08-03 按设计稿重排顶部资料、统计、我的权益、内容与服务、账户与支持;页面仅保留设计稿中的入口,未具备独立页面的评论、通知暂提供提示 | +| 个人中心 | `uniapp/src/pages/user/user.vue` | 🚧 部分完成 | 2026-08-03 按设计稿重排顶部资料、统计、我的权益、内容与服务、账户与支持;“我的帖子 / 我的评论 / 我的收藏”已接入独立页面,消息通知暂提供提示 | | AI 分析 | 待补充 | 待核对 | 需核对实际页面路径 | | 世博头条 AI 助手 | `uniapp/src/pages/ai_assistant/ai_assistant.vue` | ⚠️ 仅需求备注(无视觉导出) | 2026-06-11 按产品方案新增免费对话助手,入口位于首页与个人中心 | | 私聊聊天室 | `uniapp/src/pages/private_chat/room.vue` | ⚠️ 仅需求备注(无视觉导出) | 2026-06-11 新增 App 端语音输入面板,语音识别结果填入文字输入框后手动发送 | diff --git a/server/app/api/controller/CommunityController.php b/server/app/api/controller/CommunityController.php index faa9b2d9..80795749 100644 --- a/server/app/api/controller/CommunityController.php +++ b/server/app/api/controller/CommunityController.php @@ -307,6 +307,81 @@ class CommunityController extends BaseApiController ]); } + // 我的评论列表 + public function myCommentLists() + { + $page = max($this->request->get('page_no/d', 1), 1); + $size = min(max($this->request->get('page_size/d', 20), 1), 50); + + $query = CommunityComment::where('user_id', $this->userId)->where('status', 1); + $total = (clone $query)->count(); + $list = $query->field('id,post_id,parent_id,reply_user_id,content,create_time') + ->order('create_time desc') + ->page($page, $size) + ->select() + ->toArray(); + + $postIds = array_values(array_unique(array_filter(array_column($list, 'post_id')))); + $postMap = []; + if (!empty($postIds)) { + $posts = CommunityPost::whereIn('id', $postIds) + ->field('id,status') + ->select() + ->toArray(); + foreach ($posts as $post) { + $postMap[$post['id']] = $post; + } + } + + $parentIds = array_values(array_unique(array_filter(array_column($list, 'parent_id')))); + $parentMap = []; + if (!empty($parentIds)) { + $parents = CommunityComment::whereIn('id', $parentIds) + ->where('status', 1) + ->field('id,user_id,content') + ->select() + ->toArray(); + foreach ($parents as $parent) { + $parentMap[$parent['id']] = $parent; + } + } + + $replyUserIds = array_values(array_unique(array_filter(array_merge( + array_column($list, 'reply_user_id'), + array_column($parentMap, 'user_id') + )))); + $userMap = []; + if (!empty($replyUserIds)) { + $users = User::whereIn('id', $replyUserIds)->field('id,nickname')->select()->toArray(); + foreach ($users as $user) { + $userMap[$user['id']] = $user; + } + } + + foreach ($list as &$item) { + $post = $postMap[$item['post_id']] ?? null; + $item['post'] = $post && (int) $post['status'] === 1 ? [ + 'id' => $post['id'], + ] : null; + + $parent = $parentMap[$item['parent_id']] ?? null; + $replyUserId = $item['reply_user_id'] ?: ($parent['user_id'] ?? 0); + $item['reply_to'] = $parent ? [ + 'id' => $parent['id'], + 'content' => $parent['content'], + 'user' => $userMap[$replyUserId] ?? null, + ] : null; + } + unset($item); + + return $this->data([ + 'lists' => $list, + 'count' => $total, + 'page_no' => $page, + 'page_size' => $size, + ]); + } + // 发评论 public function addComment() { diff --git a/uniapp/src/api/community.ts b/uniapp/src/api/community.ts index 3516ff95..a1e027a4 100644 --- a/uniapp/src/api/community.ts +++ b/uniapp/src/api/community.ts @@ -22,6 +22,11 @@ export function getCommentLists(data: { post_id: number; page_no?: number; page_ return request.get({ url: '/community/commentLists', data }) } +// 我的评论列表 +export function getMyCommentLists(data?: { page_no?: number; page_size?: number }) { + return request.get({ url: '/community/myCommentLists', data }) +} + // 发评论 export function addComment(data: { post_id: number diff --git a/uniapp/src/pages.json b/uniapp/src/pages.json index 51e7c8ac..e3f34346 100644 --- a/uniapp/src/pages.json +++ b/uniapp/src/pages.json @@ -114,6 +114,16 @@ "auth": true } }, + { + "path": "pages/my_comments/my_comments", + "style": { + "navigationStyle": "default", + "navigationBarTitleText": "我的评论" + }, + "meta": { + "auth": true + } + }, { "path": "pages/my_follow/my_follow", "style": { diff --git a/uniapp/src/pages/my_comments/my_comments.vue b/uniapp/src/pages/my_comments/my_comments.vue new file mode 100644 index 00000000..69529d1b --- /dev/null +++ b/uniapp/src/pages/my_comments/my_comments.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/uniapp/src/pages/user/user.vue b/uniapp/src/pages/user/user.vue index 2c6a498b..1aeb0d34 100644 --- a/uniapp/src/pages/user/user.vue +++ b/uniapp/src/pages/user/user.vue @@ -135,7 +135,7 @@ const stats = reactive({ const contentMenus = [ { key: 'posts', label: '我的帖子', icon: 'file-text', url: '/pages/my_posts/my_posts' }, - { key: 'comments', label: '我的评论', icon: 'chat', toast: '我的评论功能即将上线' }, + { key: 'comments', label: '我的评论', icon: 'chat', url: '/pages/my_comments/my_comments' }, { key: 'collection', label: '我的收藏', icon: 'star', url: '/pages/collection/collection' }, { key: 'notice', label: '消息通知', icon: 'bell', toast: '消息通知功能即将上线' } ]