Skip to content

Let's use AI to Earn!

jiemains

bulaienaofutuojiesenzhang12b8f14739fa
diff --git a/src/app/i18n/locales/zh-CN/vip.json b/src/app/i18n/locales/zh-CN/vip.json
index 443ad85d..be102611 100644
--- a/src/app/i18n/locales/zh-CN/vip.json
+++ b/src/app/i18n/locales/zh-CN/vip.json
@@ -45,8 +45,8 @@
"myMembership": "我的会员",
"basicMembership": "基础会员",
"validUntil": "有效期至",
- "activatedAutoRenewalPlans": "已开通的自动续费套餐",
- "activatedAutoRenewalPlansno": "未开通的自动续费套餐",
+ "activatedAutoRenewalPlans": "已开通自动续费套餐",
+ "activatedAutoRenewalPlansno": "未开通自动续费套餐",
"noAutoRenewalItems": "你还没有开通自动续费项目哦",
"viewMorePlans": "查看更多套餐",
"continuousAnnual": "连续包年",
diff --git a/src/components/modals/SubscriptionManagementModal.tsx b/src/components/modals/SubscriptionManagementModal.tsx
index 1581ca77..b0076a02 100644
--- a/src/components/modals/SubscriptionManagementModal.tsx
+++ b/src/components/modals/SubscriptionManagementModal.tsx
@@ -122,12 +122,9 @@ const SubscriptionManagementModal = memo(({ open, onClose }: SubscriptionManagem
if (response?.code === 0) {
message.success(tProfile('unsubscribeSuccess'));
fetchSubscriptions({ page: subscriptionsPagination.current - 1, size: subscriptionsPagination.pageSize });
- } else {
- message.error(response?.message || tProfile('unsubscribeFailed'));
}
} catch (error) {
console.error('退订失败:', error);
- message.error(tProfile('unsubscribeFailed'));
}
};
@@ -322,8 +319,119 @@ const SubscriptionManagementModal = memo(({ open, onClose }: SubscriptionManagem
// 弹窗打开时加载数据
useEffect(() => {
if (open) {
- fetchOrders({ page: 0, size: 10 });
- fetchSubscriptions({ page: 0, size: 10 });
+ // fetchOrders({ page: 0, size: 10 });
+ // fetchSubscriptions({ page: 0, size: 10 });
+
+ // 添加假数据用于测试样式
+ const mockSubscriptions: Order[] = [
+ {
+ _id: 'mock_sub_1',
+ id: 'sub_1234567890',
+ amount: 2999, // 29.99 元
+ amount_refunded: 0,
+ created: Math.floor(Date.now() / 1000) - 86400 * 30, // 30天前
+ currency: 'cny',
+ customer: null,
+ customer_details: null,
+ expires_at: Math.floor(Date.now() / 1000) + 86400 * 30, // 30天后
+ info: null,
+ metadata: {
+ userId: 'user123',
+ payment: 'month',
+ mode: 'subscription'
+ },
+ mode: 'subscription',
+ payment_intent: 'pi_mock_123',
+ price: 'price_monthly',
+ status: 1, // SUCCEEDED
+ subscription: { id: 'sub_1234567890' },
+ success_url: '/success',
+ url: '',
+ userId: 'user123'
+ },
+ {
+ _id: 'mock_sub_2',
+ id: 'sub_0987654321',
+ amount: 9999, // 99.99 元
+ amount_refunded: 0,
+ created: Math.floor(Date.now() / 1000) - 86400 * 7, // 7天前
+ currency: 'cny',
+ customer: null,
+ customer_details: null,
+ expires_at: Math.floor(Date.now() / 1000) + 86400 * 365, // 365天后
+ info: null,
+ metadata: {
+ userId: 'user123',
+ payment: 'year',
+ mode: 'subscription'
+ },
+ mode: 'subscription',
+ payment_intent: 'pi_mock_456',
+ price: 'price_yearly',
+ status: 1, // SUCCEEDED
+ subscription: { id: 'sub_0987654321' },
+ success_url: '/success',
+ url: '',
+ userId: 'user123'
+ },
+ {
+ _id: 'mock_sub_2',
+ id: 'sub_0987654321',
+ amount: 9999, // 99.99 元
+ amount_refunded: 0,
+ created: Math.floor(Date.now() / 1000) - 86400 * 7, // 7天前
+ currency: 'cny',
+ customer: null,
+ customer_details: null,
+ expires_at: Math.floor(Date.now() / 1000) + 86400 * 365, // 365天后
+ info: null,
+ metadata: {
+ userId: 'user123',
+ payment: 'year',
+ mode: 'subscription'
+ },
+ mode: 'subscription',
+ payment_intent: 'pi_mock_456',
+ price: 'price_yearly',
+ status: 1, // SUCCEEDED
+ subscription: { id: 'sub_0987654321' },
+ success_url: '/success',
+ url: '',
+ userId: 'user123'
+ },
+ {
+ _id: 'mock_sub_2',
+ id: 'sub_0987654321',
+ amount: 9999, // 99.99 元
+ amount_refunded: 0,
+ created: Math.floor(Date.now() / 1000) - 86400 * 7, // 7天前
+ currency: 'cny',
+ customer: null,
+ customer_details: null,
+ expires_at: Math.floor(Date.now() / 1000) + 86400 * 365, // 365天后
+ info: null,
+ metadata: {
+ userId: 'user123',
+ payment: 'year',
+ mode: 'subscription'
+ },
+ mode: 'subscription',
+ payment_intent: 'pi_mock_456',
+ price: 'price_yearly',
+ status: 1, // SUCCEEDED
+ subscription: { id: 'sub_0987654321' },
+ success_url: '/success',
+ url: '',
+ userId: 'user123'
+ }
+ ];
+
+ setSubscriptions(mockSubscriptions);
+ setSubscriptionsPagination({
+ current: 1,
+ pageSize: 10,
+ total: 2
+ });
}
}, [open]);
@@ -388,28 +496,114 @@ const SubscriptionManagementModal = memo(({ open, onClose }: SubscriptionManagem
{
subscriptions.length ?(
- <div className={styles.subscriptionTable}>
- <Table
- columns={subscriptionColumns}
- dataSource={subscriptions}
- loading={subscriptionsLoading}
- rowKey="id"
- pagination={{
- current: subscriptionsPagination.current,
- pageSize: subscriptionsPagination.pageSize,
- total: subscriptionsPagination.total,
- onChange: (page, size) => {
- fetchSubscriptions({ page: page - 1, size: size || 10 });
- },
- showSizeChanger: true,
- showQuickJumper: true,
- showTotal: (total) => tProfile('totalRecords', { total }),
- pageSizeOptions: ['10', '20', '50'],
- }}
- locale={{
- emptyText: subscriptionsLoading ? tProfile('loading') : tProfile('noSubscriptionRecords')
- }}
- />
+ <div className={styles.subscriptionCards}>
+ {subscriptions.map((subscription) => (
+ <div key={subscription._id} className={styles.subscriptionCard}>
+ <div className={styles.subscriptionHeader}>
+ <div className={styles.subscriptionTitle}>{tVip('basicMembership' as any)}</div>
+ </div>
+ <div className={styles.subscriptionDetails}>
+ <div className={styles.subscriptionDetailItem}>
+ <span className={styles.detailLabel}>{tProfile('subscriptionMode')}:</span>
+ <span className={styles.detailValue}>
+ {subscription.metadata?.payment === 'month'
+ ? tVip('modal.vipInfo.monthly' as any)
+ : tVip('modal.vipInfo.yearly' as any)}
+ </span>
+ </div>
+ <div className={styles.subscriptionDetailItem}>
+ <span className={styles.detailLabel}>{tProfile('amount')}:</span>
+ <span className={styles.detailValue}>¥{(subscription.amount / 100).toFixed(2)}</span>
+ </div>
+ <div className={styles.subscriptionDetailItem}>
+ <span className={styles.detailLabel}>{tProfile('createTime')}:</span>
+ <span className={styles.detailValue}>
+ {new Date(subscription.created * 1000).toLocaleString('zh-CN', {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit',
+ hour: '2-digit',
+ minute: '2-digit'
+ })}
+ </span>
+ </div>
+ <div className={styles.subscriptionDetailItem}>
+ <span className={styles.detailLabel}>{tProfile('subscriptionId')}:</span>
+ <span className={styles.detailValue}>
+ {subscription.id}
+ <Button
+ type="text"
+ size="small"
+ className={styles.copyBtn}
+ onClick={() => {
+ navigator.clipboard.writeText(subscription.id);
+ message.success('已复制');
+ }}
+ >
+ 📋
+ </Button>
+ </span>
+ </div>
+ <div className={styles.subscriptionDetailItem}>
+ <span className={styles.detailLabel}>{tProfile('status')}:</span>
+ <span className={styles.detailValue}>
+ {subscription.status === 1 ? (
+ <Tag color="green">{tProfile('subscriptionSuccess')}</Tag>
+ ) : subscription.status === 2 ? (
+ <Tag color="red">{tProfile('subscriptionCancelled')}</Tag>
+ ) : subscription.status === 3 ? (
+ <Tag color="purple">{tProfile('refundSuccess')}</Tag>
+ ) : (
+ <Tag color="orange">{tProfile('orderCancelled')}</Tag>
+ )}
+ </span>
+ </div>
+ <div className={styles.subscriptionDetailItem}>
+ <span className={styles.detailLabel}>{tProfile('actions')}:</span>
+ <span className={styles.detailValue}>
+ {subscription.status === 1 && (
+ <Button
+ size="small"
+ danger
+ onClick={() => handleUnsubscribe(subscription)}
+ >
+ {tProfile('cancelSubscription')}
+ </Button>
+ )}
+ </span>
+ </div>
+ </div>
+ </div>
+ ))}
+ {subscriptionsPagination.total > subscriptionsPagination.pageSize ? (
+ <div className={styles.paginationContainer}>
+ <Button
+ disabled={subscriptionsPagination.current === 1}
+ onClick={() => fetchSubscriptions({
+ page: subscriptionsPagination.current - 2,
+ size: subscriptionsPagination.pageSize
+ })}
+ >
+ {tVip('previousPage' as any)}
+ </Button>
+ <span className={styles.paginationInfo}>
+ {tVip('pageInfo' as any).replace('{current}', subscriptionsPagination.current.toString()).replace('{total}', Math.ceil(subscriptionsPagination.total / subscriptionsPagination.pageSize).toString())}
+ </span>
+ <Button
+ disabled={subscriptionsPagination.current >= Math.ceil(subscriptionsPagination.total / subscriptionsPagination.pageSize)}
+ onClick={() => fetchSubscriptions({
+ page: subscriptionsPagination.current,
+ size: subscriptionsPagination.pageSize
+ })}
+ >
+ {tVip('nextPage' as any)}
+ </Button>
+ </div>
+ ) : (
+ <div className={styles.noMoreContent}>
+ <p>{tVip('noMoreContent' as any)}</p>
+ </div>
+ )}
</div>
) : (
<div className={styles.emptyState}>
diff --git a/src/components/modals/subscriptionManagementModal.module.css b/src/components/modals/subscriptionManagementModal.module.css
index 336b3140..53a36d1d 100644
--- a/src/components/modals/subscriptionManagementModal.module.css
+++ b/src/components/modals/subscriptionManagementModal.module.css
@@ -28,6 +28,8 @@
/* 我的会员区域 */
.myMembership {
min-height: 780px;
+ max-height: 60vh;
+ overflow: scroll;
}
.myMembership h3 {
@@ -124,28 +126,70 @@
margin-left: 16px;
}
-/* 订阅表格样式 */
-.subscriptionTable {
+/* 订阅卡片样式 */
+.subscriptionCards {
margin-top: 16px;
}
-.subscriptionTable .ant-table {
+.subscriptionCard {
background: white;
+ border-radius: 8px;
+ margin-bottom: 16px;
+ padding: 16px;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
-.subscriptionTable .ant-table-thead > tr > th {
- background: #f8f9fa;
- border-bottom: 1px solid #e5e7eb;
+.subscriptionHeader {
+ margin-bottom: 16px;
+ padding-bottom: 12px;
+ border-bottom: 1px solid #f3f4f6;
+}
+
+.subscriptionTitle {
+ font-size: 16px;
font-weight: 600;
- color: #374151;
+ color: #1f2937;
+ margin: 0;
}
-.subscriptionTable .ant-table-tbody > tr > td {
- border-bottom: 1px solid #f3f4f6;
+.subscriptionDetails {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+}
+
+.subscriptionDetailItem {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 4px 0;
+}
+
+.subscriptionDetailItem .detailLabel {
+ font-size: 14px;
+ color: #6b7280;
+ font-weight: 500;
+ min-width: 80px;
}
-.subscriptionTable .ant-table-tbody > tr:hover > td {
- background: #f9fafb;
+.subscriptionDetailItem .detailValue {
+ font-size: 14px;
+ color: #1f2937;
+ font-weight: 400;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.subscriptionDetailItem .copyBtn {
+ padding: 0;
+ height: auto;
+ font-size: 12px;
+ color: #6b7280;
+}
+
+.subscriptionDetailItem .copyBtn:hover {
+ color: #374151;
}
.autoRenewal h3 {
@@ -234,6 +278,8 @@
.purchaseHistory {
padding: 0;
min-height: 780px;
+ max-height: 60vh;
+ overflow: scroll;
}
.loadingContainer {
@@ -255,11 +301,11 @@
}
.orderCard {
- background: #f8f9fa;
- border-radius: 8px;
- padding: 20px;
- border: 1px solid #e5e7eb;
- transition: all 0.2s ease;
+ background: white;
+ border-radius: 8px;
+ margin-bottom: 16px;
+ padding: 16px;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.orderCard:hover {