diff --git a/Cunkebao/api/wechat-accounts.ts b/Cunkebao/api/wechat-accounts.ts index 33ddf464..cbbd6f84 100644 --- a/Cunkebao/api/wechat-accounts.ts +++ b/Cunkebao/api/wechat-accounts.ts @@ -166,4 +166,37 @@ export const fetchWechatAccountSummary = async (id: string): Promise => { + try { + return api.get(`/v1/wechats/${wechatId}/friend/${friendId}`); + } catch (error) { + console.error("获取好友详情失败:", error); + throw error; + } }; \ No newline at end of file diff --git a/Cunkebao/app/wechat-accounts/[id]/page.tsx b/Cunkebao/app/wechat-accounts/[id]/page.tsx index 2849cbd5..88da5874 100644 --- a/Cunkebao/app/wechat-accounts/[id]/page.tsx +++ b/Cunkebao/app/wechat-accounts/[id]/page.tsx @@ -4,7 +4,7 @@ import { useState, useEffect, useRef, useCallback } from "react" import { useParams } from "next/navigation" import { useRouter } from "next/navigation" import { api } from "@/lib/api" -import { fetchWechatAccountSummary } from "@/api/wechat-accounts" +import { fetchWechatAccountSummary, fetchWechatFriendDetail, WechatFriendDetail } from "@/api/wechat-accounts" import { Card } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" @@ -47,7 +47,6 @@ import { PaginationNext, PaginationPrevious, } from "@/components/ui/pagination" -import { fetchWechatFriends } from "@/api/wechat-accounts" interface ApiResponse { code: number; @@ -177,6 +176,9 @@ export default function WechatAccountDetailPage() { const [showTransferConfirm, setShowTransferConfirm] = useState(false) const [showFriendDetail, setShowFriendDetail] = useState(false) const [selectedFriend, setSelectedFriend] = useState(null) + const [friendDetail, setFriendDetail] = useState(null) + const [isLoadingFriendDetail, setIsLoadingFriendDetail] = useState(false) + const [friendDetailError, setFriendDetailError] = useState(null) const [searchQuery, setSearchQuery] = useState("") const [activeTab, setActiveTab] = useState("overview") const [isLoading, setIsLoading] = useState(false) @@ -614,9 +616,25 @@ export default function WechatAccountDetailPage() { setShowTransferConfirm(false) } - const handleFriendClick = (friend: Friend) => { + const handleFriendClick = async (friend: Friend) => { setSelectedFriend(friend) setShowFriendDetail(true) + setIsLoadingFriendDetail(true) + setFriendDetailError(null) + + try { + const response = await fetchWechatFriendDetail(account?.wechatId || id, friend.id) + if (response.code === 200) { + setFriendDetail(response.data) + } else { + setFriendDetailError(response.msg || "获取好友详情失败") + } + } catch (error) { + console.error("获取好友详情失败:", error) + setFriendDetailError("获取好友详情失败,请稍后再试") + } finally { + setIsLoadingFriendDetail(false) + } } // 修改获取限制等级颜色的函数 @@ -1043,7 +1061,92 @@ export default function WechatAccountDetailPage() { 好友详情 - {selectedFriend && ( + {isLoadingFriendDetail ? ( +
+ +
+ ) : friendDetailError ? ( +
+

{friendDetailError}

+ +
+ ) : friendDetail ? ( +
+
+ + + {friendDetail.nickname[0]} + +
+
{friendDetail.nickname}
+
{friendDetail.wechatId}
+ {friendDetail.memo && ( +
备注: {friendDetail.memo}
+ )} +
+
+ +
+
+
添加时间
+
{friendDetail.addDate}
+
+
+
最近互动
+
{friendDetail.playDate}
+
+ {friendDetail.region && ( +
+
地区
+
{friendDetail.region || '未知地区'}
+
+ )} +
+
来源
+
微信好友
+
+
+ +
+
+ + 标签 +
+
+ {friendDetail.tags.map((tag, index) => ( + + {tag} + + ))} + {friendDetail.tags.length === 0 && 暂无标签} +
+
+ +
+ + +
+
+ ) : selectedFriend && (
@@ -1084,7 +1187,7 @@ export default function WechatAccountDetailPage() { 标签
- {selectedFriend.tags.map((tag: FriendTag) => ( + {selectedFriend.tags.map((tag: FriendTag) => ( {tag.name} @@ -1128,3 +1231,4 @@ export default function WechatAccountDetailPage() { ) } + diff --git a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php b/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php index 72a759a1..95274bc1 100644 --- a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php +++ b/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php @@ -19,7 +19,7 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController */ protected function getLastPlayTime(string $wechatId): string { - return date('Y-m-d H:i:s', strtotime('-1 day')); + return date('Y-m-d', strtotime('-1 day')); } /** @@ -36,7 +36,7 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController [ 'w.id', 'w.avatar', 'w.nickname', 'w.region', 'w.wechatId', 'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatId', - 'f.createTime addTime', 'f.tags' + 'f.createTime addTime', 'f.tags', 'f.memo' ] ) ->join('wechat_friendship f', 'w.wechatId=f.wechatId') @@ -63,8 +63,9 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController return ResponseHelper::success( array_merge($results, [ - 'play' => $this->getLastPlayTime($results['wechatId']), - 'tags' => json_decode($results['tags'], true) + 'playDate' => $this->getLastPlayTime($results['wechatId']), + 'tags' => json_decode($results['tags'], true), + 'addDate' => date('Y-m-d', $results['addTime']), ]) ); } catch (\Exception $e) {