feat(ui): 个人中心积分统计调整
- 当前积分 -> 剩余积分 - 新增今日消耗统计(基于最近10条交易记录计算)
This commit is contained in:
@@ -207,12 +207,31 @@ export default function Profile() {
|
||||
|
||||
{/* 积分区 */}
|
||||
<div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', padding: '24px 28px' }}>
|
||||
<div>
|
||||
<div style={{ fontSize: '13px', color: 'var(--text-secondary)', marginBottom: '8px' }}>
|
||||
当前积分
|
||||
<div style={{ display: 'flex', gap: '40px' }}>
|
||||
<div>
|
||||
<div style={{ fontSize: '13px', color: 'var(--text-secondary)', marginBottom: '8px' }}>
|
||||
剩余积分
|
||||
</div>
|
||||
<div style={{ fontSize: '40px', fontWeight: 700, color: '#36b26a', lineHeight: 1 }}>
|
||||
{balance?.balance ?? 0}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ fontSize: '40px', fontWeight: 700, color: '#36b26a', lineHeight: 1 }}>
|
||||
{balance?.balance ?? 0}
|
||||
<div>
|
||||
<div style={{ fontSize: '13px', color: 'var(--text-secondary)', marginBottom: '8px' }}>
|
||||
今日消耗
|
||||
</div>
|
||||
<div style={{ fontSize: '40px', fontWeight: 700, color: '#ff6b6b', lineHeight: 1 }}>
|
||||
{(() => {
|
||||
const todayStr = new Date().toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-');
|
||||
return recentTx
|
||||
.filter(tx => {
|
||||
if (tx.type !== 'consume') return false;
|
||||
const txDate = new Date(tx.createdAt).toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-');
|
||||
return txDate === todayStr;
|
||||
})
|
||||
.reduce((sum, tx) => sum + tx.amount, 0);
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user