fix(评论弹窗): 修复评论总数未实时更新的问题
在提交评论和打开评论弹窗时,确保评论总数实时更新,以保持UI与数据一致性
Showing
1 changed file
with
22 additions
and
2 deletions
| ... | @@ -86,7 +86,7 @@ | ... | @@ -86,7 +86,7 @@ |
| 86 | <div class="flex flex-col h-full"> | 86 | <div class="flex flex-col h-full"> |
| 87 | <!-- 固定头部 --> | 87 | <!-- 固定头部 --> |
| 88 | <div class="flex-none px-4 py-3 border-b bg-white sticky top-0 z-10"> | 88 | <div class="flex-none px-4 py-3 border-b bg-white sticky top-0 z-10"> |
| 89 | - <div class="text-lg font-medium">全部评论 ({{ popupCommentList.length }})</div> | 89 | + <div class="text-lg font-medium">全部评论 ({{ commentCount }})</div> |
| 90 | </div> | 90 | </div> |
| 91 | 91 | ||
| 92 | <!-- 可滚动的评论列表 --> | 92 | <!-- 可滚动的评论列表 --> |
| ... | @@ -445,6 +445,15 @@ const submitPopupComment = async () => { | ... | @@ -445,6 +445,15 @@ const submitPopupComment = async () => { |
| 445 | 445 | ||
| 446 | // 更新评论数量和清空输入 | 446 | // 更新评论数量和清空输入 |
| 447 | commentCount.value = data.comment_count; | 447 | commentCount.value = data.comment_count; |
| 448 | + // 更新弹框标题中的评论总数 | ||
| 449 | + const comment = await getGroupCommentListAPI({ | ||
| 450 | + group_id: course.value.group_id, | ||
| 451 | + schedule_id: course.value.id | ||
| 452 | + }); | ||
| 453 | + if (comment.code) { | ||
| 454 | + commentList.value = comment.data.comment_list; | ||
| 455 | + commentCount.value = comment.data.comment_count; | ||
| 456 | + } | ||
| 448 | popupComment.value = ''; | 457 | popupComment.value = ''; |
| 449 | } | 458 | } |
| 450 | } catch (error) { | 459 | } catch (error) { |
| ... | @@ -452,13 +461,24 @@ const submitPopupComment = async () => { | ... | @@ -452,13 +461,24 @@ const submitPopupComment = async () => { |
| 452 | } | 461 | } |
| 453 | }; | 462 | }; |
| 454 | // 监听弹窗显示状态变化 | 463 | // 监听弹窗显示状态变化 |
| 455 | -watch(showCommentPopup, (newVal) => { | 464 | +watch(showCommentPopup, async (newVal) => { |
| 456 | if (newVal) { | 465 | if (newVal) { |
| 457 | // 打开弹窗时重置状态 | 466 | // 打开弹窗时重置状态 |
| 458 | popupCommentList.value = []; | 467 | popupCommentList.value = []; |
| 459 | popupPage.value = 0; | 468 | popupPage.value = 0; |
| 460 | popupFinished.value = false; | 469 | popupFinished.value = false; |
| 461 | popupLoading.value = true; | 470 | popupLoading.value = true; |
| 471 | + | ||
| 472 | + // 获取最新的评论总数 | ||
| 473 | + const comment = await getGroupCommentListAPI({ | ||
| 474 | + group_id: course.value.group_id, | ||
| 475 | + schedule_id: course.value.id | ||
| 476 | + }); | ||
| 477 | + if (comment.code) { | ||
| 478 | + commentList.value = comment.data.comment_list; | ||
| 479 | + commentCount.value = comment.data.comment_count; | ||
| 480 | + } | ||
| 481 | + | ||
| 462 | // 加载第一页数据 | 482 | // 加载第一页数据 |
| 463 | onPopupLoad(); | 483 | onPopupLoad(); |
| 464 | } | 484 | } | ... | ... |
-
Please register or login to post a comment