成交行情添加统计区域

This commit is contained in:
甲辰生产 2026-04-11 19:50:41 +08:00
parent 55f0c9aa23
commit 285929024b
1 changed files with 53 additions and 0 deletions

View File

@ -481,6 +481,59 @@ export default function News() {
</div>
) : (
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
{/* 成交行情 - 统计区域 */}
{activeTab === 'deal' && (() => {
//
const stats = { version: {}, packaging: {}, category: {}, platform: {}, date: {}, totalCount: infoList.length, totalAmount: 0 }
infoList.forEach(item => {
const content = item.content || ''
//
const serial = (item.title || '').split('-')[0] || ''
let version = '其他'
if (serial.startsWith('J0')) version = '龙钞'
else if (serial.startsWith('J1')) version = '马钞'
else if (serial.startsWith('J3')) version = '蛇钞'
stats.version[version] = (stats.version[version] || 0) + 1
//
const pkg = content.match(/包装:\s*(.+?)(?:\n|$)/)?.[1]?.trim() || item.packaging || '-'
stats.packaging[pkg] = (stats.packaging[pkg] || 0) + 1
//
const cat = content.match(/分类:\s*(.+?)(?:\n|$)/)?.[1]?.trim() || item.category || '-'
stats.category[cat] = (stats.category[cat] || 0) + 1
//
const plat = content.match(/平台:\s*(.+?)(?:\n|$)/)?.[1]?.trim() || '-'
stats.platform[plat] = (stats.platform[plat] || 0) + 1
//
const date = content.match(/日期:\s*(.+?)(?:\n|$)/)?.[1]?.trim() || item.deal_date || '-'
stats.date[date] = (stats.date[date] || 0) + 1
//
stats.totalAmount += item.deal_price || 0
})
const renderStat = (title, data) => (
<div style={{ marginBottom: '12px' }}>
<div style={{ color: '#94a3b8', fontSize: '12px', marginBottom: '6px' }}>{title}</div>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px' }}>
{Object.entries(data).sort((a,b) => b[1] - a[1]).map(([k, v]) => (
<span key={k} style={{ background: '#3b82f6', color: '#fff', padding: '4px 10px', borderRadius: '6px', fontSize: '12px' }}>{k} ({v})</span>
))}
</div>
</div>
)
return (
<div style={{ background: '#1e293b', borderRadius: '12px', padding: '16px', marginBottom: '12px' }}>
<div style={{ color: '#fff', fontSize: '16px', fontWeight: '600', marginBottom: '12px' }}>📊 成交行情统计</div>
<div style={{ color: '#22c55e', fontSize: '14px', marginBottom: '16px' }}>总成交 {stats.totalCount} 总金额 ¥{stats.totalAmount.toLocaleString()}</div>
{renderStat('版本分布', stats.version)}
{renderStat('包装分布', stats.packaging)}
{renderStat('号码分类', stats.category)}
{renderStat('成交平台', stats.platform)}
{renderStat('成交日期', stats.date)}
</div>
)
})()}
{infoList.map(item => {
// tab -
if (activeTab === 'deal') {