diff --git a/frontend/src/pages/News.jsx b/frontend/src/pages/News.jsx index a5ff477..11fd7ee 100644 --- a/frontend/src/pages/News.jsx +++ b/frontend/src/pages/News.jsx @@ -4,6 +4,7 @@ import React, { useState, useEffect } from 'react' export default function News() { const [activeTab, setActiveTab] = useState(localStorage.getItem('news_activeTab') || 'seek') const [showSeekPublish, setShowSeekPublish] = useState(false) + const [customModal, setCustomModal] = useState({show: false, title: '', content: ''}) const [showMySeeks, setShowMySeeks] = useState(false) // 我的寻号 const [showContactId, setShowContactId] = useState(null) // 显示联系方式的寻号ID const [showCommentId, setShowCommentId] = useState(null) // 显示评论输入的寻号ID @@ -117,7 +118,7 @@ export default function News() { if (data.message === '匹配成功,已通知发布者') { setMatchedStatus(prev => ({...prev, [infoId]: 'matched'})) setShowContactId(infoId) // 显示联系方式 - alert('匹配成功!') + setCustomModal({show: true, title: '匹配成功', content: '已通知发布者,请等待对方联系'}) fetchInfoList() // 刷新列表 } } catch (e) { @@ -130,7 +131,7 @@ export default function News() { try { const res = await fetch(`${API_BASE}/api/information/seek/matched-user/${infoId}`, { headers: { Authorization: `Bearer ${token}` } }) const data = await res.json() - if (data.matched_user_id) alert(`匹配者: ${data.user_name}, 联系方式: ${data.matched_contact || '未提供'}`) + if (data.matched_user_id) setCustomModal({show: true, title: '匹配者信息', content: `用户名: ${data.user_name}\n联系方式: ${data.matched_contact || '未提供'}`}) } catch (e) { console.error(e) } } const fetchPublisherInfo = async (infoId) => { @@ -139,7 +140,7 @@ export default function News() { try { const res = await fetch(`${API_BASE}/api/information/seek/publisher/${infoId}`, { headers: { Authorization: `Bearer ${token}` } }) const data = await res.json() - if (data.user_id) alert(`发布者: ${data.user_name}, 联系方式: ${data.contact || '未提供'}`) + if (data.user_id) setCustomModal({show: true, title: '发布者信息', content: `用户名: ${data.user_name}\n联系方式: ${data.contact || '未提供'}`}) } catch (e) { console.error(e) } } const fetchMatchCollections = async (infoId) => { @@ -504,7 +505,7 @@ export default function News() { : 1 }}> {(item.is_matched === 'matched' || matchedStatus[item.id] === 'matched') ? '已经匹配' : '尚未匹配'} - {(item.is_matched === 'matched' || matchedStatus[item.id] === 'matched') && } + {(item.is_matched === 'matched' || matchedStatus[item.id] === 'matched') && } )} @@ -768,6 +769,24 @@ export default function News() { )} + {customModal.show && ( +
+
+
+

{customModal.title}

+
+
+ {customModal.content.split('\n').map((line, i) => ( +
+ {line.split(':')[0]} + {line.split(':')[1]} +
+ ))} +
+ +
+
+ )} ) }