This commit is contained in:
张成
2025-10-01 01:55:09 +08:00
parent a5539bd219
commit 274c2e4b16
3 changed files with 145 additions and 26 deletions

View File

@@ -23,6 +23,7 @@ interface CommentReplyItem {
const CommentReply = () => {
const [commentList, setCommentList] = useState<CommentReplyItem[]>([]);
const [loading, setLoading] = useState(false);
const [refreshing, setRefreshing] = useState(false);
useEffect(() => {
getCommentReplyList();
@@ -111,6 +112,42 @@ const CommentReply = () => {
Taro.navigateBack();
};
// 处理下拉刷新
const handleRefresh = async () => {
setRefreshing(true);
try {
const res = await commentService.getMyActivities({
page: 1,
pageSize: 20,
});
if (res.code === 0 && res.data) {
const mappedList = res.data.rows.map((item: CommentActivity) => ({
id: item.id,
user_avatar: item.user?.avatar_url || "",
user_nickname: item.user?.nickname || "匿名用户",
action_type: item.type === "reply" ? "reply" as const : "comment" as const,
time: item.create_time,
content: item.content || "",
original_comment: item.parent_comment?.content || "",
activity_image: item.game?.image_list?.[0] || "",
activity_id: item.game_id,
activity_title: item.game?.title || "",
}));
setCommentList(mappedList);
}
} catch (e) {
Taro.showToast({
title: "刷新失败",
icon: "none",
duration: 2000,
});
} finally {
setRefreshing(false);
}
};
// 渲染评论/回复项
const renderCommentItem = (item: CommentReplyItem) => {
const actionText = item.action_type === "comment" ? "评论了你的球局" : "回复了你的评论";
@@ -183,6 +220,9 @@ const CommentReply = () => {
scrollWithAnimation
enhanced
showScrollbar={false}
refresherEnabled={true}
refresherTriggered={refreshing}
onRefresherRefresh={handleRefresh}
>
{commentList.length > 0 ? (
<View className="comment-list">