feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面

This commit is contained in:
zhanjunhao
2026-11-04 19:59:06 +08:00
parent 472e534fe1
commit e6c41e7587
576 changed files with 18075 additions and 18912 deletions
@@ -24,50 +24,18 @@ import React, {
useRef,
useMemo,
} from 'react';
import {
Modal,
Table,
Tag,
Empty,
Typography,
Pagination,
Toast,
} from '@douyinfe/semi-ui';
import { Crown, Clock, CheckCircle, XCircle, Calendar } from 'lucide-react';
import { Empty as AntEmpty, Tag as AntTag } from 'antd';
import { Modal, Table, Typography, Pagination, Toast } from '@/components/ui';
import { API, renderQuota } from '../../helpers';
import {
IllustrationNoResult,
IllustrationNoResultDark,
} from '../common/illustrations';
const { Text } = Typography;
// 会员状态配置
// 会员状态配置(Ant Design 预设标签色)
const STATUS_CONFIG = {
active: {
label: '生效中',
type: 'success',
icon: CheckCircle,
color: 'text-emerald-500',
},
expired: {
label: '已过期',
type: 'default',
icon: XCircle,
color: 'text-gray-400',
},
pending: {
label: '待生效',
type: 'warning',
icon: Clock,
color: 'text-amber-500',
},
canceled: {
label: '已取消',
type: 'default',
icon: XCircle,
color: 'text-red-400',
},
active: { label: '生效中', color: 'success' },
expired: { label: '已过期', color: undefined },
pending: { label: '待生效', color: 'warning' },
canceled: { label: '已取消', color: 'error' },
};
// 方案类型映射
@@ -83,7 +51,11 @@ const TIER_MAP = {
pro: '重度版',
};
const MembershipHistoryModal = ({ visible, onClose, t }) => {
/**
* 会员购买记录内容:数据加载、统计、表格与分页。
* 弹窗与在线充值页“会员购买记录”页签共用;visible 为 true 时按原逻辑加载。
*/
export const MembershipHistoryContent = ({ visible, t, inline = false }) => {
const [loading, setLoading] = useState(false);
const [memberships, setMemberships] = useState([]);
const [total, setTotal] = useState(0);
@@ -181,13 +153,10 @@ const MembershipHistoryModal = ({ visible, onClose, t }) => {
const renderStatusTag = (membership) => {
const status = getMembershipStatus(membership);
const config = STATUS_CONFIG[status] || STATUS_CONFIG.expired;
const IconComponent = config.icon;
return (
<div className={`flex items-center gap-1.5 ${config.color}`}>
<IconComponent size={14} />
<span className='text-xs font-medium'>{t(config.label)}</span>
</div>
<AntTag bordered={false} color={config.color}>
{t(config.label)}
</AntTag>
);
};
@@ -200,19 +169,12 @@ const MembershipHistoryModal = ({ visible, onClose, t }) => {
key: 'plan_name',
width: 180,
render: (text, record) => (
<div className='flex items-center gap-2'>
<div className='w-8 h-8 rounded-lg bg-gradient-to-br from-brand-from to-brand-to flex items-center justify-center flex-shrink-0'>
<Crown size={14} className='text-white' />
</div>
<div>
<Text strong className='text-sm block'>
{text || '-'}
</Text>
<Text className='text-xs text-gray-400'>
{PLAN_TYPE_MAP[record.plan_type] || record.plan_type} ·{' '}
{TIER_MAP[record.tier] || record.tier}
</Text>
</div>
<div>
<Text>{text || '-'}</Text>
<Text type='tertiary' size='small' className='block'>
{PLAN_TYPE_MAP[record.plan_type] || record.plan_type} ·{' '}
{TIER_MAP[record.tier] || record.tier}
</Text>
</div>
),
},
@@ -221,11 +183,7 @@ const MembershipHistoryModal = ({ visible, onClose, t }) => {
dataIndex: 'daily_quota',
key: 'daily_quota',
width: 120,
render: (quota) => (
<Text strong className='text-emerald-600 text-sm'>
{renderQuota(quota)}
</Text>
),
render: (quota) => renderQuota(quota),
},
{
title: t('天数'),
@@ -238,12 +196,7 @@ const MembershipHistoryModal = ({ visible, onClose, t }) => {
record.end_date && record.start_date
? Math.round((record.end_date - record.start_date) / 86400)
: '-';
return (
<Tag color='blue' size='small'>
{days}
{t('天')}
</Tag>
);
return `${days} ${t('天')}`;
},
},
{
@@ -251,39 +204,21 @@ const MembershipHistoryModal = ({ visible, onClose, t }) => {
dataIndex: 'price_paid',
key: 'price_paid',
width: 100,
render: (price) => (
<Text type='danger' className='text-sm'>
¥{price?.toFixed(2) || '0.00'}
</Text>
),
render: (price) => `¥${price?.toFixed(2) || '0.00'}`,
},
{
title: t('生效日期'),
dataIndex: 'start_date',
key: 'start_date',
width: 110,
render: (date) => (
<div className='flex items-center gap-1'>
<Calendar size={12} className='text-gray-400' />
<Text size='small' type='tertiary'>
{formatDate(date)}
</Text>
</div>
),
render: (date) => formatDate(date),
},
{
title: t('到期日期'),
dataIndex: 'end_date',
key: 'end_date',
width: 110,
render: (date) => (
<div className='flex items-center gap-1'>
<Calendar size={12} className='text-gray-400' />
<Text size='small' type='tertiary'>
{formatDate(date)}
</Text>
</div>
),
render: (date) => formatDate(date),
},
{
title: t('状态'),
@@ -296,110 +231,94 @@ const MembershipHistoryModal = ({ visible, onClose, t }) => {
dataIndex: 'created_at',
key: 'created_at',
width: 140,
render: (time) => (
<Text size='small' type='tertiary'>
{formatDateTime(time)}
</Text>
),
render: (time) => formatDateTime(time),
},
],
[t, formatDate, formatDateTime],
);
return (
<Modal
title={
<div className='flex items-center gap-2'>
<div className='w-8 h-8 rounded-lg bg-gradient-to-br from-brand-from to-brand-to flex items-center justify-center'>
<Crown size={16} className='text-white' />
</div>
<span>{t('会员购买记录')}</span>
<div className={inline ? 'rc-member-history' : 'flex flex-col h-full'}>
{/* 统计信息 */}
{(inline || total > 0) && (
<div
className={inline ? 'rc-member-counts' : 'px-6 pt-4 rc-member-counts'}
>
{!inline && (
<span>
{t('总购买次数')}
<strong>{total}</strong>
</span>
)}
<span>
{t('生效中')}
<strong>{activeCount}</strong>
</span>
<span>
{t('待生效')}
<strong>{pendingCount}</strong>
</span>
</div>
}
visible={visible}
onCancel={onClose}
footer={null}
width={1100}
bodyStyle={{ padding: 0, maxHeight: '70vh' }}
style={{ top: 40 }}
>
<div className='flex flex-col h-full'>
{/* 统计信息 */}
{total > 0 && (
<div className='px-6 py-4 bg-gradient-to-r from-brand-from/5 to-brand-to/5 dark:from-brand-from/20 dark:to-brand-to/20 border-b border-gray-200 dark:border-gray-700'>
<div className='flex items-center gap-6'>
<div className='flex items-center gap-2'>
<Text className='text-gray-500 text-sm'>
{t('总购买次数')}:
</Text>
<Text strong className='text-lg text-brand-deep'>
{total}
</Text>
</div>
<div className='flex items-center gap-2'>
<Text className='text-gray-500 text-sm'>{t('生效中')}:</Text>
<Text strong className='text-lg text-emerald-600'>
{activeCount}
</Text>
</div>
<div className='flex items-center gap-2'>
<Text className='text-gray-500 text-sm'>{t('待生效')}:</Text>
<Text strong className='text-lg text-amber-600'>
{pendingCount}
</Text>
</div>
</div>
</div>
)}
)}
{/* 表格区域 */}
<div className='flex-1 overflow-auto p-6'>
<Table
columns={columns}
dataSource={memberships}
loading={loading}
rowKey='id'
{/* 表格区域 */}
<div className={inline ? undefined : 'flex-1 overflow-auto px-6 pb-4'}>
<Table
columns={columns}
dataSource={memberships}
loading={loading}
rowKey='id'
scroll={{ x: 'max-content' }}
size='middle'
pagination={false}
empty={
<AntEmpty
image={AntEmpty.PRESENTED_IMAGE_SIMPLE}
description={t('暂无会员购买记录')}
/>
}
/>
</div>
{/* 分页器 */}
{total > 0 && (
<div
className={
inline ? 'rc-history-pagination' : 'px-6 pb-4 rc-history-pagination'
}
>
<Pagination
total={total}
currentPage={page}
pageSize={pageSize}
showSizeChanger
pageSizeOpts={[10, 20, 50]}
onPageChange={(p) => setPage(p)}
onPageSizeChange={(size) => {
setPageSize(size);
setPage(1);
}}
size='small'
pagination={false}
empty={
<Empty
image={
<IllustrationNoResult style={{ width: 100, height: 100 }} />
}
darkModeImage={
<IllustrationNoResultDark
style={{ width: 100, height: 100 }}
/>
}
description={t('暂无会员购买记录')}
style={{ padding: 40 }}
/>
}
showTotal={(count) => t('共 {{total}} 条', { total: count })}
/>
</div>
{/* 分页器 */}
{total > 0 && (
<div className='px-6 py-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-neutral-900'>
<Pagination
total={total}
currentPage={page}
pageSize={pageSize}
showSizeChanger
pageSizeOpts={[10, 20, 50]}
onPageChange={(p) => setPage(p)}
onPageSizeChange={(size) => {
setPageSize(size);
setPage(1);
}}
showTotal
style={{ justifyContent: 'flex-end' }}
/>
</div>
)}
</div>
</Modal>
)}
</div>
);
};
const MembershipHistoryModal = ({ visible, onClose, t }) => (
<Modal
title={t('会员购买记录')}
visible={visible}
onCancel={onClose}
footer={null}
width={1100}
bodyStyle={{ padding: 0, maxHeight: '70vh' }}
style={{ top: 40 }}
>
<MembershipHistoryContent visible={visible} t={t} />
</Modal>
);
export default MembershipHistoryModal;