From c813e82232850b8e2c8bb6e7d9431f6824346659 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, 11 Apr 2026 22:47:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=B7=BB=E5=8A=A0=E4=BB=8A?= =?UTF-8?q?=E6=97=A5=E6=88=90=E4=BA=A4=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/Home.jsx | 142 ++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index 90c9aab..83a91e0 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -9,8 +9,47 @@ export default function Home() { const [seekStats, setSeekStats] = useState({ seekCount: 0, matchedCount: 0 }) const [recentPosts, setRecentPosts] = useState([]) const [dragonStats, setDragonStats] = useState({}) + const [dealStats, setDealStats] = useState({ total: 0, items: [] }) + const [dealVersion, setDealVersion] = useState('龙钞') + const [dealDetailItems, setDealDetailItems] = useState(null) const currentPath = window.location.hash.slice(1) || '/' + // 成交行情数据处理 + const categoryOrder = ['带4号', '带7号', '永恒号', '天马号', '天马王', '金山号', '金山王', '钻石号', '朦胧号', '朦胧王', '金马号', '金马王', '倒置号', '圆圆号'] + + const normalizeCat = (c) => { + if (c === '通货') return '带4号' + if (c === '无4') return '带7号' + return c + } + + const calcDealAvg = (pkg, cat) => { + const items = dealStats.items.filter(item => { + const content = item.content || '' + const p = content.includes('包装:') ? content.split('包装:')[1].split('\n')[0].trim() : (item.packaging || '') + let c = content.includes('分类:') ? content.split('分类:')[1].split('\n')[0].trim() : (item.category || '') + c = normalizeCat(c) + return p === pkg && c === cat + }) + if (items.length === 0) return null + const sum = items.reduce((a, b) => a + (b.deal_price || 0), 0) + return { avg: Math.round(sum / items.length), count: items.length, items } + } + + // 获取今日成交数据 + useEffect(() => { + const today = new Date() + const dealDate = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}` + fetch(`/api/information/list?info_type=deal&deal_date=${dealDate}&page_size=500`) + .then(res => res.json()) + .then(data => { + if (Array.isArray(data)) { + setDealStats({ total: data.length, items: data }) + } + }) + .catch(() => {}) + }, []) + useEffect(() => { const token = localStorage.getItem('token') const userData = localStorage.getItem('user') @@ -232,6 +271,60 @@ export default function Home() { + {/* 今日成交数据统计 */} + {dealStats && dealStats.total > 0 && ( +
+
📈 今日成交数据统计
+
+
+ {['龙钞', '马钞', '蛇钞', '其他'].map(v => ( + + ))} +
+
+ + + + + {['标百', '标十', '单张'].map(p => ( + + ))} + + + + {categoryOrder.map(cat => { + const rowData = ['标百', '标十', '单张'].map(pkg => calcDealAvg(pkg, cat)) + const hasData = rowData.some(d => d !== null) + if (!hasData) return null + return ( + + + {rowData.map((d, i) => ( + + ))} + + ) + })} + +
{p}
{cat} + {d ? ( +
setDealDetailItems(d.items)}> + ¥{d.avg.toLocaleString()} + ({d.count}) +
+ ) : -} +
+
+
+
+ )} + {/* 一尘今日数据 */}
📊 一尘今日连体纪念钞数据
@@ -389,6 +482,55 @@ export default function Home() { ))}
+ + {/* 成交详情弹窗 */} + {dealDetailItems && ( +
setDealDetailItems(null)}> +
e.stopPropagation()}> +
+
成交详情列表
+ +
+
+ {([...dealDetailItems].sort((a, b) => (a.deal_price || 0) - (b.deal_price || 0))).map((item, idx) => { + const content = item.content || '' + const grade = content.includes('评级:') ? content.split('评级:')[1].split('\n')[0].trim() : (item.grading_score || '') + const sizeMatch = content.match(/大小号:\s*(.+?)(?:\n|$)/) + const size = sizeMatch ? sizeMatch[1].trim() : '' + const platformMatch = content.match(/平台:\s*(.+?)(?:\n|$)/) + const platform = platformMatch ? platformMatch[1].trim() : '-' + return ( +
+
+
+ {(item.title || '').split('-')[0]} + {size && | {size}} + {grade && | {grade}} +
+
+ {item.deal_date} | {item.category} | {item.packaging} | {platform} +
+
+
+ ¥{item.deal_price?.toLocaleString()} +
+
+ ) + })} +
+
+
+ )} ) }