添加 消息 页面更新
This commit is contained in:
4
src/other_pages/comment_reply/index.config.ts
Normal file
4
src/other_pages/comment_reply/index.config.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationStyle: "custom",
|
||||
navigationBarTitleText: "收到的评论和回复",
|
||||
});
|
||||
246
src/other_pages/comment_reply/index.scss
Normal file
246
src/other_pages/comment_reply/index.scss
Normal file
@@ -0,0 +1,246 @@
|
||||
@use '~@/scss/images.scss' as img;
|
||||
|
||||
.comment-reply-container {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #FFFFFF;
|
||||
|
||||
// 顶部导航栏
|
||||
.navbar {
|
||||
height: 100px;
|
||||
background: #FFFFFF;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
|
||||
.navbar-content {
|
||||
height: 56px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 15px;
|
||||
margin-top: 44px;
|
||||
position: relative;
|
||||
|
||||
.back-button {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
|
||||
.back-icon {
|
||||
width: 8px;
|
||||
height: 16px;
|
||||
position: relative;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-left: 2.67px solid #000000;
|
||||
border-bottom: 2.67px solid #000000;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-title {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 20px;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.019em;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 评论列表滚动区域
|
||||
.comment-scroll {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
// 评论列表
|
||||
.comment-list {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
// 评论项
|
||||
.comment-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 16px 0;
|
||||
border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
|
||||
|
||||
.comment-left {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.user-avatar {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 999px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.comment-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.user-nickname {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
line-height: 1.43;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.action-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.action-text,
|
||||
.time-text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 10px;
|
||||
line-height: 1.6;
|
||||
color: rgba(60, 60, 67, 0.6);
|
||||
}
|
||||
}
|
||||
|
||||
.comment-text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: #000000;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
// 被回复的评论
|
||||
.original-comment {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
margin-top: 4px;
|
||||
|
||||
.quote-line {
|
||||
width: 2px;
|
||||
height: 14px;
|
||||
background: rgba(120, 120, 128, 0.12);
|
||||
border-radius: 7px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.original-text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: rgba(60, 60, 67, 0.6);
|
||||
word-break: break-word;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 回复按钮
|
||||
.reply-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 8px;
|
||||
background: rgba(120, 120, 128, 0.12);
|
||||
border-radius: 20px;
|
||||
width: fit-content;
|
||||
margin-top: 4px;
|
||||
cursor: pointer;
|
||||
|
||||
&:active {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.reply-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
position: relative;
|
||||
|
||||
// 绘制回复图标(使用SVG路径)
|
||||
&::before,
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
background: #333333;
|
||||
}
|
||||
|
||||
&::before {
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
width: 10px;
|
||||
height: 8.75px;
|
||||
clip-path: polygon(0% 0%, 100% 0%, 100% 20%, 20% 20%, 20% 100%, 0% 100%);
|
||||
}
|
||||
|
||||
&::after {
|
||||
width: 0;
|
||||
height: 0.75px;
|
||||
background: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
.reply-text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 10px;
|
||||
line-height: 1.6;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 右侧球局图片
|
||||
.activity-image {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 9px;
|
||||
background: #F5F5F5;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 到底了提示
|
||||
.bottom-tip {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 24px 0 12px;
|
||||
|
||||
.tip-text {
|
||||
font-family: 'PingFang SC';
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
line-height: 1.71;
|
||||
color: rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
}
|
||||
}
|
||||
188
src/other_pages/comment_reply/index.tsx
Normal file
188
src/other_pages/comment_reply/index.tsx
Normal file
@@ -0,0 +1,188 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { View, Text, ScrollView, Image } from "@tarojs/components";
|
||||
import { Avatar } from "@nutui/nutui-react-taro";
|
||||
import { withAuth, EmptyState } from "@/components";
|
||||
import noticeService from "@/services/noticeService";
|
||||
import Taro from "@tarojs/taro";
|
||||
import "./index.scss";
|
||||
|
||||
// 评论/回复类型定义
|
||||
interface CommentReplyItem {
|
||||
id: string;
|
||||
user_avatar: string;
|
||||
user_nickname: string;
|
||||
action_type: "comment" | "reply"; // 评论了你的球局 / 回复了你的评论
|
||||
time: string;
|
||||
content: string;
|
||||
original_comment?: string; // 被回复的评论内容
|
||||
activity_image: string;
|
||||
activity_id?: string;
|
||||
is_read: number;
|
||||
}
|
||||
|
||||
const CommentReply = () => {
|
||||
const [commentList, setCommentList] = useState<CommentReplyItem[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
getCommentReplyList();
|
||||
}, []);
|
||||
|
||||
// 获取评论和回复列表
|
||||
const getCommentReplyList = async () => {
|
||||
if (loading) return;
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await noticeService.getNotificationList({
|
||||
notification_type: "comment", // 筛选评论类型
|
||||
});
|
||||
|
||||
if (res.code === 0) {
|
||||
// 映射数据
|
||||
const mappedList = res.data.list.map((item: any) => ({
|
||||
id: item.id,
|
||||
user_avatar: item.related_user_avatar || "",
|
||||
user_nickname: item.related_user_nickname || "匿名用户",
|
||||
action_type: (item.notification_type === "reply" ? "reply" : "comment") as "comment" | "reply",
|
||||
time: item.created_at,
|
||||
content: item.content || "",
|
||||
original_comment: item.original_content || "",
|
||||
activity_image: item.activity_image || "",
|
||||
activity_id: item.related_activity_id || "",
|
||||
is_read: item.is_read,
|
||||
}));
|
||||
|
||||
setCommentList(mappedList);
|
||||
}
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: "获取列表失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 格式化时间显示
|
||||
const formatTime = (timeStr: string) => {
|
||||
if (!timeStr) return "";
|
||||
|
||||
const date = new Date(timeStr);
|
||||
const now = new Date();
|
||||
const diff = now.getTime() - date.getTime();
|
||||
const minutes = Math.floor(diff / (1000 * 60));
|
||||
const hours = Math.floor(diff / (1000 * 60 * 60));
|
||||
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (minutes < 60) {
|
||||
return `${minutes}分钟前`;
|
||||
} else if (hours < 24) {
|
||||
return `${hours}小时前`;
|
||||
} else if (days === 1) {
|
||||
return "1天前";
|
||||
} else if (days < 7) {
|
||||
return `${days}天前`;
|
||||
} else {
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
return `${month}月${day}日`;
|
||||
}
|
||||
};
|
||||
|
||||
// 处理回复
|
||||
const handleReply = (item: CommentReplyItem) => {
|
||||
console.log("回复:", item);
|
||||
// TODO: 跳转到回复页面或弹出回复框
|
||||
};
|
||||
|
||||
// 处理返回
|
||||
const handleBack = () => {
|
||||
Taro.navigateBack();
|
||||
};
|
||||
|
||||
// 渲染评论/回复项
|
||||
const renderCommentItem = (item: CommentReplyItem) => {
|
||||
const actionText = item.action_type === "comment" ? "评论了你的球局" : "回复了你的评论";
|
||||
|
||||
return (
|
||||
<View className="comment-item" key={item.id}>
|
||||
<View className="comment-left">
|
||||
<Avatar
|
||||
className="user-avatar"
|
||||
src={item.user_avatar || "https://img.yzcdn.cn/vant/cat.jpeg"}
|
||||
size="48px"
|
||||
/>
|
||||
|
||||
<View className="comment-content">
|
||||
<Text className="user-nickname">{item.user_nickname}</Text>
|
||||
|
||||
<View className="action-row">
|
||||
<Text className="action-text">{actionText}</Text>
|
||||
<Text className="time-text">{formatTime(item.time)}</Text>
|
||||
</View>
|
||||
|
||||
<Text className="comment-text">{item.content}</Text>
|
||||
|
||||
{/* 如果是回复,显示被回复的评论 */}
|
||||
{item.action_type === "reply" && item.original_comment && (
|
||||
<View className="original-comment">
|
||||
<View className="quote-line"></View>
|
||||
<Text className="original-text">{item.original_comment}</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 回复按钮 */}
|
||||
<View className="reply-button" onClick={() => handleReply(item)}>
|
||||
<View className="reply-icon"></View>
|
||||
<Text className="reply-text">回复</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 右侧球局图片 */}
|
||||
<Image className="activity-image" src={item.activity_image} mode="aspectFill" />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<View className="comment-reply-container">
|
||||
{/* 顶部导航栏 */}
|
||||
<View className="navbar">
|
||||
<View className="navbar-content">
|
||||
<View className="back-button" onClick={handleBack}>
|
||||
<View className="back-icon"></View>
|
||||
</View>
|
||||
<Text className="navbar-title">收到的评论和回复</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 评论列表 */}
|
||||
<ScrollView
|
||||
scrollY
|
||||
className="comment-scroll"
|
||||
scrollWithAnimation
|
||||
enhanced
|
||||
showScrollbar={false}
|
||||
>
|
||||
{commentList.length > 0 ? (
|
||||
<View className="comment-list">
|
||||
{commentList.map(renderCommentItem)}
|
||||
|
||||
{/* 到底了提示 */}
|
||||
<View className="bottom-tip">
|
||||
<Text className="tip-text">到底了</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : (
|
||||
<EmptyState text="暂无评论和回复" />
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default withAuth(CommentReply);
|
||||
Reference in New Issue
Block a user