添加粉丝关注页面

This commit is contained in:
张成
2025-10-01 01:48:36 +08:00
parent 78d8ec659e
commit a5539bd219
7 changed files with 187 additions and 62 deletions

View File

@@ -182,29 +182,6 @@
.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 {
@@ -225,6 +202,11 @@
border-radius: 9px;
background: #F5F5F5;
flex-shrink: 0;
cursor: pointer;
&:active {
opacity: 0.8;
}
}
}

View File

@@ -2,13 +2,13 @@ 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 commentService, { CommentActivity } from "@/services/commentService";
import Taro from "@tarojs/taro";
import "./index.scss";
// 评论/回复类型定义
interface CommentReplyItem {
id: string;
id: number;
user_avatar: string;
user_nickname: string;
action_type: "comment" | "reply"; // 评论了你的球局 / 回复了你的评论
@@ -16,8 +16,8 @@ interface CommentReplyItem {
content: string;
original_comment?: string; // 被回复的评论内容
activity_image: string;
activity_id?: string;
is_read: number;
activity_id: number;
activity_title: string;
}
const CommentReply = () => {
@@ -34,23 +34,24 @@ const CommentReply = () => {
setLoading(true);
try {
const res = await noticeService.getNotificationList({
notification_type: "comment", // 筛选评论类型
const res = await commentService.getMyActivities({
page: 1,
pageSize: 20,
});
if (res.code === 0) {
if (res.code === 0 && res.data) {
// 映射数据
const mappedList = res.data.list.map((item: any) => ({
const mappedList = res.data.rows.map((item: CommentActivity) => ({
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,
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.original_content || "",
activity_image: item.activity_image || "",
activity_id: item.related_activity_id || "",
is_read: item.is_read,
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);
@@ -98,6 +99,13 @@ const CommentReply = () => {
// TODO: 跳转到回复页面或弹出回复框
};
// 处理点击球局
const handleGameClick = (gameId: number) => {
Taro.navigateTo({
url: `/game_pages/detail/index?id=${gameId}`,
});
};
// 处理返回
const handleBack = () => {
Taro.navigateBack();
@@ -136,14 +144,22 @@ const CommentReply = () => {
{/* 回复按钮 */}
<View className="reply-button" onClick={() => handleReply(item)}>
<View className="reply-icon"></View>
<Image
className="reply-icon"
src={require('@/static/message/reply-icon.svg')}
/>
<Text className="reply-text"></Text>
</View>
</View>
</View>
{/* 右侧球局图片 */}
<Image className="activity-image" src={item.activity_image} mode="aspectFill" />
<Image
className="activity-image"
src={item.activity_image}
mode="aspectFill"
onClick={() => handleGameClick(item.activity_id)}
/>
</View>
);
};

View File

@@ -2,20 +2,21 @@ import { useState, useEffect } from "react";
import { View, Text, ScrollView } from "@tarojs/components";
import { Avatar } from "@nutui/nutui-react-taro";
import { withAuth, EmptyState } from "@/components";
import noticeService from "@/services/noticeService";
import FollowService from "@/services/followService";
import Taro from "@tarojs/taro";
import "./index.scss";
// 关注项类型定义
interface FollowItem {
id: string;
user_id: string;
id: number;
user_id: number;
user_avatar: string;
user_nickname: string;
user_signature?: string;
city?: string;
ntrp_level?: string;
time: string;
is_mutual: boolean; // 是否互相关注
is_read: number;
}
const NewFollow = () => {
@@ -32,21 +33,20 @@ const NewFollow = () => {
setLoading(true);
try {
const res = await noticeService.getNotificationList({
notification_type: "follow", // 筛选关注类型
});
const res = await FollowService.get_new_fans_list(1, 20);
if (res.code === 0) {
if (res.list) {
// 映射数据
const mappedList = res.data.list.map((item: any) => ({
const mappedList = res.list.map((item: any) => ({
id: item.id,
user_id: item.related_user_id || "",
user_avatar: item.related_user_avatar || "",
user_nickname: item.related_user_nickname || "匿名用户",
user_signature: item.related_user_signature || "",
time: item.created_at,
is_mutual: item.is_mutual_follow || false,
is_read: item.is_read,
user_id: item.id,
user_avatar: item.avatar_url || "",
user_nickname: item.nickname || "匿名用户",
user_signature: item.personal_profile || "",
city: item.city || "",
ntrp_level: item.ntrp_level || "",
time: item.follow_time,
is_mutual: item.is_mutual || false,
}));
setFollowList(mappedList);
@@ -93,8 +93,7 @@ const NewFollow = () => {
}
try {
// TODO: 调用关注接口
// await userService.followUser({ user_id: item.user_id });
await FollowService.follow_back(item.user_id);
Taro.showToast({
title: "关注成功",
@@ -125,7 +124,7 @@ const NewFollow = () => {
};
// 处理点击用户
const handleUserClick = (userId: string) => {
const handleUserClick = (userId: number) => {
Taro.navigateTo({
url: `/user_pages/other/index?user_id=${userId}`,
});