From 05c5f6c8e3cfc2ebac454cc51734eb1b0e4c9c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Tue, 13 May 2025 11:15:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E5=9F=9F=E6=93=8D=E7=9B=98=E6=89=8B?= =?UTF-8?q?=20-=20=E4=BF=AE=E5=A4=8D=E6=B5=81=E9=87=8F=E6=B1=A0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=82=B9=E5=87=BB=E2=80=9D=E5=85=A8=E9=83=A8=E6=9D=A5?= =?UTF-8?q?=E6=BA=90=E2=80=9C=E5=92=8C=E5=85=A8=E9=83=A8=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=9A=84select=E6=A1=86=EF=BC=8C=E9=A1=B5=E9=9D=A2=E8=A2=AB?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/app/traffic-pool/page.tsx | 356 +++++++++++---------- Cunkebao/app/wechat-accounts/[id]/page.tsx | 109 +++---- 2 files changed, 234 insertions(+), 231 deletions(-) diff --git a/Cunkebao/app/traffic-pool/page.tsx b/Cunkebao/app/traffic-pool/page.tsx index 4f0ab297..38b71742 100644 --- a/Cunkebao/app/traffic-pool/page.tsx +++ b/Cunkebao/app/traffic-pool/page.tsx @@ -85,7 +85,7 @@ export default function TrafficPoolPage() { }) // 检查是否有来源参数 - const sourceParam = searchParams.get("source") + const sourceParam = searchParams?.get("source") if (sourceParam) { params.append("wechatSource", sourceParam) } @@ -162,7 +162,7 @@ export default function TrafficPoolPage() { } return ( -
+
@@ -177,195 +177,197 @@ export default function TrafficPoolPage() {
-
- {/* 搜索和筛选区域 */} -
-
- - { - setSearchQuery(e.target.value) +
+
+ {/* 搜索和筛选区域 */} +
+
+ + { + setSearchQuery(e.target.value) + setCurrentPage(1) + }} + className="pl-9" + /> +
+ +
+ + {/* 统计卡片 */} +
+ +
流量池总数
+
{stats.total}
+
+ +
今日新增
+
{stats.todayNew}
+
+
+ + {/* 分类标签页 */} + { + setActiveCategory(value) + setCurrentPage(1) + }} + > + + 潜在客户 + 已转化 + + + + {/* 筛选器 */} +
+ + +
- -
- {/* 统计卡片 */} -
- -
流量池总数
-
{stats.total}
-
- -
今日新增
-
{stats.todayNew}
-
-
+ {/* 用户列表 */} +
+ {loading ? ( +
+ +
加载中...
+
+ ) : users.length === 0 ? ( +
+
暂无数据
+ +
+ ) : ( + users.map((user) => ( + handleUserClick(user)} + > +
+ +
+
+
{user.nickname}
+
+ {user.status === "added" ? "已添加" : user.status === "pending" ? "待处理" : "已失败"} +
+
+
微信号: {user.wechatId}
+
来源: {user.source}
+
添加时间: {new Date(user.addTime).toLocaleString()}
- {/* 分类标签页 - 移除了"全部"选项 */} - { - setActiveCategory(value) - setCurrentPage(1) - }} - > - - 潜在客户 - 已转化 - - - - {/* 筛选器 */} -
- - - -
- - {/* 用户列表 - 改进加载状态显示 */} -
- {loading ? ( -
- -
加载中...
-
- ) : users.length === 0 ? ( -
-
暂无数据
- -
- ) : ( - users.map((user) => ( - handleUserClick(user)} - > -
- -
-
-
{user.nickname}
-
- {user.status === "added" ? "已添加" : user.status === "pending" ? "待处理" : "已失败"} + {/* 标签展示 */} +
+ {user.tags.slice(0, 2).map((tag) => ( + + {tag.name} + + ))} + {user.tags.length > 2 && ( + + +{user.tags.length - 2} + + )}
-
微信号: {user.wechatId}
-
来源: {user.source}
-
添加时间: {new Date(user.addTime).toLocaleString()}
- - {/* 标签展示 */} -
- {user.tags.slice(0, 2).map((tag) => ( - - {tag.name} - - ))} - {user.tags.length > 2 && ( - - +{user.tags.length - 2} - - )} -
-
- - )) - )} -
+
+ )) + )} +
- {/* 分页 */} - {!loading && users.length > 0 && ( - - - - { - e.preventDefault() - setCurrentPage((prev) => Math.max(1, prev - 1)) - }} - /> - - {Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => ( - - 0 && ( + + + + { e.preventDefault() - setCurrentPage(page) + setCurrentPage((prev) => Math.max(1, prev - 1)) }} - > - {page} - + /> - ))} - - { - e.preventDefault() - setCurrentPage((prev) => Math.min(totalPages, prev + 1)) - }} - /> - - - - )} + {Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => ( + + { + e.preventDefault() + setCurrentPage(page) + }} + > + {page} + + + ))} + + { + e.preventDefault() + setCurrentPage((prev) => Math.min(totalPages, prev + 1)) + }} + /> + + + + )} +
{/* 用户详情弹窗 */} diff --git a/Cunkebao/app/wechat-accounts/[id]/page.tsx b/Cunkebao/app/wechat-accounts/[id]/page.tsx index f00f9182..5837e6cb 100644 --- a/Cunkebao/app/wechat-accounts/[id]/page.tsx +++ b/Cunkebao/app/wechat-accounts/[id]/page.tsx @@ -398,17 +398,17 @@ export default function WechatAccountDetailPage() { setIsFetchingFriends(true); setHasFriendLoadError(false); - const response = await api.get>(`/v1/wechats/${id}/friends?page=${page}&limit=30${searchQuery ? `&search=${encodeURIComponent(searchQuery)}` : ''}`, true); + const data = await api.get>(`/v1/wechats/${id}/friends?page=${page}&limit=30`, true); - if (response && response.code === 200 && response.data) { + if (data && data.code === 200) { // 更新总数计数 if (isNewSearch || friendsTotal === 0) { - setFriendsTotal(response.data.total || 0); + setFriendsTotal(data.data.total || 0); } - const newFriends = response.data.list.map((friend) => ({ + const newFriends = data.data.list.map((friend) => ({ id: friend.id.toString(), - avatar: friend.avatar || '/placeholder.svg', + avatar: friend.avatar, nickname: friend.nickname, wechatId: friend.wechatId, remark: friend.memo || '', @@ -433,12 +433,13 @@ export default function WechatAccountDetailPage() { setFriendsPage(page); // 判断是否还有更多数据 - setHasMoreFriends(page * 30 < response.data.total); + setHasMoreFriends(page * 30 < data.data.total); + } else { setHasFriendLoadError(true); toast({ title: "获取好友列表失败", - description: response?.msg || "请稍后再试", + description: data?.msg || "请稍后再试", variant: "destructive" }); } @@ -453,7 +454,7 @@ export default function WechatAccountDetailPage() { } finally { setIsFetchingFriends(false); } - }, [account, id, friendsTotal, searchQuery]); + }, [account, id, friendsTotal]); // 处理搜索 const handleSearch = useCallback(() => { @@ -528,21 +529,21 @@ export default function WechatAccountDetailPage() { const response = await fetchWechatAccountSummary(id); if (response.code === 200) { setAccountSummary(response.data); - } else { - toast({ + } else { + toast({ title: "获取账号概览失败", description: response.msg || "请稍后再试", - variant: "destructive" + variant: "destructive" }); - } - } catch (error) { + } + } catch (error) { console.error("获取账号概览失败:", error); - toast({ + toast({ title: "获取账号概览失败", - description: "请检查网络连接或稍后再试", - variant: "destructive" + description: "请检查网络连接或稍后再试", + variant: "destructive" }); - } finally { + } finally { setIsLoading(false); } }, [id]); @@ -726,9 +727,9 @@ export default function WechatAccountDetailPage() { 账号概览 - + 好友列表{activeTab === "friends" && friendsTotal > 0 ? ` (${friendsTotal})` : ''} - + @@ -775,33 +776,33 @@ export default function WechatAccountDetailPage() { {accountSummary && (
{accountSummary.accountWeight.scope} - -
+ +
)}
{accountSummary && ( <>

{getWeightDescription(accountSummary.accountWeight.scope)}

-
+
账号年龄
-
+
{accountSummary.accountWeight.ageWeight}% -
+
活跃度
-
+
{accountSummary.accountWeight.activityWeigth}% -
+
限制影响
-
+
{accountSummary.accountWeight.restrictWeight}%
@@ -833,29 +834,29 @@ export default function WechatAccountDetailPage() {
{accountSummary && ( -
-
- 今日已添加 +
+
+ 今日已添加 {accountSummary.statistics.todayAdded} -
-
-
- 添加进度 - +
+
+
+ 添加进度 + {accountSummary.statistics.todayAdded}/{accountSummary.statistics.addLimit} - -
- +
-
+ +
+
根据当前账号权重({accountSummary.accountWeight.scope}分),每日最多可添加{" "} {accountSummary.statistics.addLimit}{" "} - 个好友 -
+ 个好友
+
)} @@ -867,24 +868,24 @@ export default function WechatAccountDetailPage() { 限制记录
{accountSummary && ( - setShowRestrictions(true)}> + setShowRestrictions(true)}> 共 {accountSummary.restrictions.length} 次 - + )}
{accountSummary && ( -
+
{accountSummary.restrictions.slice(0, 2).map((record) => ( -
-
+
+
{record.reason} {formatDateTime(record.date)} -
- ))} -
+
+ ))} +
)} @@ -1010,7 +1011,7 @@ export default function WechatAccountDetailPage() {
{record.reason} -
+
{formatDateTime(record.date)}
恢复时间:{formatDateTime(record.date)}
@@ -1186,7 +1187,7 @@ export default function WechatAccountDetailPage() { 标签
- {selectedFriend.tags.map((tag: FriendTag) => ( + {selectedFriend.tags.map((tag: FriendTag) => ( {tag.name}