From 4d3feeae45723338a6aba0eeb6c08267124662a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Sat, 28 Mar 2026 11:10:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BB=E5=8F=B7=E5=8A=9F=E8=83=BDv1.2.21?= =?UTF-8?q?=E6=9C=80=E7=BB=88=E7=89=88=EF=BC=9A=201.=20=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=AF=BB=E5=8F=B7=E9=9D=A2=E6=9D=BF=EF=BC=9A=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=8C=B9=E9=85=8D=E5=BA=A6=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=8C=E6=A0=87=E9=A2=98=E5=9C=A8=E6=AD=A3=E6=96=87=E5=89=8D?= =?UTF-8?q?=E9=9D=A2=202.=20=E8=81=94=E7=B3=BB=E6=96=B9=E5=BC=8F=E9=BB=98?= =?UTF-8?q?=E8=AE=A4***=E9=9A=90=E8=97=8F=203.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E7=8A=B6=E6=80=81=E3=80=81=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E5=B9=B6=E8=81=94=E7=B3=BB=E8=97=8F=E5=8F=8B=E3=80=81=E7=95=99?= =?UTF-8?q?=E8=A8=80=E8=97=8F=E5=8F=8B=E6=8C=89=E9=92=AE=204.=20=E7=95=99?= =?UTF-8?q?=E8=A8=80=E5=8A=9F=E8=83=BD=E6=89=80=E6=9C=89=E4=BA=BA=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=205.=20=E6=88=91=E7=9A=84=E5=AF=BB=E5=8F=B7/=E6=88=91?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E5=8F=B7=E7=AD=9B=E9=80=89=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=88=E4=B8=BB=E9=A1=B5=E9=9D=A2=E7=AD=9B=E9=80=89=EF=BC=89?= =?UTF-8?q?=206.=20=E8=AE=B0=E4=BD=8F=E7=94=A8=E6=88=B7=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E7=9A=84=E6=A0=87=E7=AD=BE=E9=A1=B5=207.=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0matched=5Fcontact=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/models/models.py | 3 +++ backend/app/routers/information.py | 5 ++++ frontend/src/pages/News.jsx | 42 ++++++++++++++++++++++++------ 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/backend/app/models/models.py b/backend/app/models/models.py index b35b456..40811e7 100644 --- a/backend/app/models/models.py +++ b/backend/app/models/models.py @@ -188,6 +188,9 @@ class Information(Base): # 匹配的用户ID(当用户愿意交换联系方式时) matched_user_id = Column(String(36), ForeignKey("users.f99_90_id", ondelete="SET NULL"), nullable=True) + # 匹配者的联系方式(只有发布者和匹配者可见) + matched_contact = Column(String(100), nullable=True) + # 浏览/联系次数 view_count = Column(Integer, default=0) contact_count = Column(Integer, default=0) diff --git a/backend/app/routers/information.py b/backend/app/routers/information.py index 04fa8b9..1135447 100644 --- a/backend/app/routers/information.py +++ b/backend/app/routers/information.py @@ -60,6 +60,7 @@ class InformationResponse(BaseModel): status: str is_matched: str = "pending" matched_user_id: Optional[str] = None + matched_contact: Optional[str] = None view_count: int contact_count: int created_at: datetime @@ -130,6 +131,7 @@ def get_information_list( status=item.status, is_matched=item.is_matched, matched_user_id=item.matched_user_id, + matched_contact=item.matched_contact, view_count=item.view_count, contact_count=item.contact_count, created_at=item.created_at, @@ -536,6 +538,7 @@ def get_my_seeks( status=item.status, is_matched=item.is_matched, matched_user_id=item.matched_user_id, + matched_contact=item.matched_contact, view_count=item.view_count, contact_count=item.contact_count, created_at=item.created_at, @@ -651,6 +654,7 @@ def get_my_information_list( status=item.status, is_matched=item.is_matched, matched_user_id=item.matched_user_id, + matched_contact=item.matched_contact, view_count=item.view_count, contact_count=item.contact_count, created_at=item.created_at, @@ -695,6 +699,7 @@ def get_my_information( class MatchSeekRequest(BaseModel): info_id: str collection_id: Optional[str] = None + contact: Optional[str] = None @router.post("/seek/match-confirm") diff --git a/frontend/src/pages/News.jsx b/frontend/src/pages/News.jsx index 833eae3..19aa7b3 100644 --- a/frontend/src/pages/News.jsx +++ b/frontend/src/pages/News.jsx @@ -16,6 +16,7 @@ export default function News() { edition: '龙钞', type: '', category: '寻号', price: '', matchType: '模糊', features: '', content: '', title: '', contact: '' }) const [infoList, setInfoList] = useState([]) + const [viewMode, setViewMode] = useState('all') const [loading, setLoading] = useState(false) const API_BASE = localStorage.getItem('API_BASE') || '' @@ -142,8 +143,18 @@ export default function News() { } } + // 获取当前用户ID + const getUserId = () => { + try { + const user = JSON.parse(localStorage.getItem('user') || '{}') + return user.id || user.user_id || user.f99_90_id || null + } catch { return null } + } + const currentUserId = getUserId() + // 获取我的寻号列表 const [mySeekList, setMySeekList] = useState([]) + const [myMatchedList, setMyMatchedList] = useState([]) const [editingSeek, setEditingSeek] = useState(null) const fetchMySeeks = async () => { const token = localStorage.getItem('token') @@ -153,9 +164,26 @@ export default function News() { headers: { Authorization: `Bearer ${token}` } }) const data = await res.json() - // 过滤出寻号类型的 - const seeks = Array.isArray(data) ? data.filter(item => item.info_type === 'seek') : [] + // 过滤出寻号类型的并筛选当前用户 + const seeks = Array.isArray(data) ? data.filter(item => item.info_type === 'seek' && item.user_id === currentUserId) : [] setMySeekList(seeks) + setInfoList(seeks) // 在主列表显示 + } catch (e) { console.error(e) } + } + + // 获取我已匹配的寻号列表 + const fetchMyMatches = async () => { + const token = localStorage.getItem('token') + if (!token) { alert('请先登录'); return } + try { + const res = await fetch(`${API_BASE}/api/information/list?info_type=seek`, { + headers: { Authorization: `Bearer ${token}` } + }) + const data = await res.json() + // 筛选我已匹配的(matched_user_id等于当前用户ID) + const matched = data.filter(item => item.is_matched === 'matched' && item.matched_user_id === currentUserId) + setMyMatchedList(matched) + setInfoList(matched) // 在主列表显示 } catch (e) { console.error(e) } } @@ -335,12 +363,10 @@ export default function News() { {activeTab === 'seek' ? '🔍 寻配号信息' : '💰 成交行情信息'} {activeTab === 'seek' && (
- - + + + +
)}