Skip to content

Let's use AI to Earn!

多语言和积分报错

daoyianc93ae24b0129
diff --git a/@types/resources.d.ts b/@types/resources.d.ts
index dba77d06..beed552b 100644
--- a/@types/resources.d.ts
+++ b/@types/resources.d.ts
@@ -765,6 +765,21 @@ interface Resources {
"unlimitedTime": "无限时长",
"fastExperience": "极速体验",
"morePrivileges": "更多特权"
+ },
+ "points": {
+ "title": "积分记录",
+ "myPoints": "我的积分",
+ "pointsDescription": "查看您的积分变动记录和使用情况",
+ "pointsChange": "积分变动",
+ "changeType": "变动类型",
+ "description": "描述",
+ "time": "时间",
+ "earn": "获得",
+ "spend": "消费",
+ "refund": "退还",
+ "expire": "过期",
+ "noPointsRecords": "暂无积分记录",
+ "totalRecords": "共 {{total}} 条记录"
}
},
"publish": {
diff --git a/src/api/apiReq.ts b/src/api/apiReq.ts
index 5ad1665e..377bb39f 100644
--- a/src/api/apiReq.ts
+++ b/src/api/apiReq.ts
@@ -86,3 +86,11 @@ export interface GoogleLoginParams {
export const googleLoginApi = (data: GoogleLoginParams) => {
return http.post<LoginResponse>("login/google", data);
};
+
+// 积分记录相关API
+export const getPointsRecordsApi = async (params: { page: number; pageSize: number }) => {
+ const res = await http.get<any>(`user/points/records`,
+ params,
+ );
+ return res;
+};
diff --git a/src/app/[lng]/profile/page.tsx b/src/app/[lng]/profile/page.tsx
index 6b167191..f7720da0 100644
--- a/src/app/[lng]/profile/page.tsx
+++ b/src/app/[lng]/profile/page.tsx
@@ -2,10 +2,10 @@
import { useEffect, useState } from "react";
import { Card, Descriptions, Button, message, Modal, Form, Input, Tabs, Table, Tag, Popconfirm, DatePicker, Select, Space } from "antd";
-import { CrownOutlined, TrophyOutlined, GiftOutlined, StarOutlined, RocketOutlined, ThunderboltOutlined, HistoryOutlined, DollarOutlined, ShoppingCartOutlined, UserOutlined } from "@ant-design/icons";
+import { CrownOutlined, TrophyOutlined, GiftOutlined, StarOutlined, RocketOutlined, ThunderboltOutlined, HistoryOutlined, DollarOutlined, ShoppingCartOutlined, UserOutlined, GiftFilled } from "@ant-design/icons";
import { useRouter } from "next/navigation";
import { useUserStore } from "@/store/user";
-import { getUserInfoApi, updateUserInfoApi } from "@/api/apiReq";
+import { getUserInfoApi, updateUserInfoApi, getPointsRecordsApi } from "@/api/apiReq";
import { getOrderListApi, getOrderDetailApi, getSubscriptionListApi, refundOrderApi, unsubscribeApi } from "@/api/payment";
import type { Order, OrderListParams, SubscriptionListParams, RefundParams, UnsubscribeParams } from "@/api/types/payment";
import { OrderStatus, PaymentType } from "@/api/types/payment";
@@ -44,6 +44,15 @@ export default function ProfilePage() {
const [orderDetailLoading, setOrderDetailLoading] = useState(false);
const [currentOrderDetail, setCurrentOrderDetail] = useState<Order | null>(null);
+ // 积分记录相关状态
+ const [pointsRecords, setPointsRecords] = useState<any[]>([]);
+ const [pointsLoading, setPointsLoading] = useState(false);
+ const [pointsPagination, setPointsPagination] = useState({
+ current: 1,
+ pageSize: 10,
+ total: 0
+ });
+
// 获取会员状态和过期时间
const isVip = userInfo?.vipInfo?.cycleType && userInfo.vipInfo.cycleType > 0 &&
userInfo?.vipInfo?.expireTime ? new Date(userInfo.vipInfo.expireTime) > new Date() : false;
@@ -144,6 +153,29 @@ export default function ProfilePage() {
}
};
+ // 获取积分记录
+ const fetchPointsRecords = async (params: { page: number; pageSize: number }) => {
+ setPointsLoading(true);
+ try {
+ const response = await getPointsRecordsApi(params);
+ if (response?.code === 0 && response.data) {
+ const paginatedData = response.data;
+ setPointsRecords(paginatedData.list || []);
+ setPointsPagination({
+ current: params.page,
+ pageSize: params.pageSize,
+ total: paginatedData.count || 0
+ });
+ } else {
+ message.error(response?.message || '获取积分记录失败');
+ }
+ } catch (error) {
+ message.error('获取积分记录失败');
+ } finally {
+ setPointsLoading(false);
+ }
+ };
+
// 处理退款
const handleRefund = async (order: Order) => {
try {
@@ -416,6 +448,47 @@ export default function ProfilePage() {
},
];
+ // 积分记录表格列
+ const pointsColumns = [
+ {
+ title: t('points.pointsChange'),
+ dataIndex: 'points',
+ key: 'points',
+ render: (points: number) => (
+ <span style={{ color: points > 0 ? '#52c41a' : '#ff4d4f', fontWeight: 'bold' }}>
+ {points > 0 ? '+' : ''}{points}
+ </span>
+ ),
+ },
+ {
+ title: t('points.changeType'),
+ dataIndex: 'type',
+ key: 'type',
+ render: (type: string) => {
+ const typeMap: { [key: string]: { color: string; text: string } } = {
+ 'earn': { color: 'green', text: t('points.earn') },
+ 'spend': { color: 'red', text: t('points.spend') },
+ 'refund': { color: 'blue', text: t('points.refund') },
+ 'expire': { color: 'orange', text: t('points.expire') }
+ };
+ const config = typeMap[type] || { color: 'default', text: type };
+ return <Tag color={config.color}>{config.text}</Tag>;
+ },
+ },
+ {
+ title: t('points.description'),
+ dataIndex: 'description',
+ key: 'description',
+ ellipsis: true,
+ },
+ {
+ title: t('points.time'),
+ dataIndex: 'createdAt',
+ key: 'createdAt',
+ render: (timestamp: string) => new Date(timestamp).toLocaleString(),
+ },
+ ];
+
// 个人信息内容
const renderProfileContent = () => (
<>
@@ -452,6 +525,22 @@ export default function ProfilePage() {
</div>
</div>
+ {/* 积分记录卡片 */}
+ <div className={styles.pointsCard}>
+ <div className={styles.pointsContent}>
+ <div className={styles.pointsHeader}>
+ <div>
+ <span style={{ marginRight: '8px' }}><GiftFilled /></span>
+ <span className={styles.pointsTitle}>{t('points.myPoints')}</span>
+ </div>
+ <span className={styles.pointsCount}>{userInfo?.score || 0}</span>
+ </div>
+ <p className={styles.pointsDescription}>
+ {t('points.pointsDescription')}
+ </p>
+ </div>
+ </div>
+
<Card
title={t('personalInfo')}
className={styles.card}
@@ -560,6 +649,36 @@ export default function ProfilePage() {
</div>
);
+ // 积分记录内容
+ const renderPointsContent = () => (
+ <div className={styles.orderContent}>
+ <Card>
+ <Table
+ columns={pointsColumns}
+ dataSource={pointsRecords}
+ loading={pointsLoading}
+ rowKey="id"
+ className={styles.pointsTable}
+ pagination={{
+ current: pointsPagination.current,
+ pageSize: pointsPagination.pageSize,
+ total: pointsPagination.total,
+ onChange: (page, size) => {
+ fetchPointsRecords({ page, pageSize: size || 10 });
+ },
+ showSizeChanger: true,
+ showQuickJumper: true,
+ showTotal: (total) => t('points.totalRecords', { total }),
+ pageSizeOptions: ['10', '20', '50'],
+ }}
+ locale={{
+ emptyText: pointsLoading ? t('loading') : t('points.noPointsRecords')
+ }}
+ />
+ </Card>
+ </div>
+ );
+
if (loading) {
return null;
}
@@ -573,6 +692,8 @@ export default function ProfilePage() {
if (key === 'orders') {
fetchOrders({ page: 0, size: 10 });
fetchSubscriptions({ page: 0, size: 10 });
+ } else if (key === 'points') {
+ fetchPointsRecords({ page: 1, pageSize: 10 });
}
}}
>
@@ -598,6 +719,17 @@ export default function ProfilePage() {
>
{renderOrderContent()}
</TabPane>
+ <TabPane
+ tab={
+ <span>
+ <GiftFilled />
+ {t('points.title')}
+ </span>
+ }
+ key="points"
+ >
+ {renderPointsContent()}
+ </TabPane>
</Tabs>
<Modal
diff --git a/src/app/[lng]/profile/profile.module.css b/src/app/[lng]/profile/profile.module.css
index 61a12b94..ff6e23d2 100644
--- a/src/app/[lng]/profile/profile.module.css
+++ b/src/app/[lng]/profile/profile.module.css
@@ -1,28 +1,29 @@
.container {
padding: 24px;
- margin: 2px auto;
}
.card {
- margin-bottom: 24px;
+ margin-bottom: 16px;
+ border-radius: 8px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.actions {
display: flex;
- gap: 12px;
+ gap: 8px;
}
/* 会员卡片样式 */
.vipCard {
background: url('/assets/images/vipcard.png') no-repeat center center;
background-size: cover;
- border-radius: 12px;
- padding: 24px;
- margin-bottom: 24px;
+ border-radius: 8px;
+ padding: 16px;
+ margin-bottom: 16px;
color: #fff;
position: relative;
overflow: hidden;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.vipCard::before {
@@ -34,7 +35,7 @@
bottom: 0;
background: linear-gradient(to right, #2B2F36, #4E4C4D);
z-index: 0;
- border-radius: 12px;
+ border-radius: 8px;
}
.vipContent {
@@ -48,38 +49,38 @@
.vipHeader {
display: flex;
align-items: center;
- margin-bottom: 16px;
+ margin-bottom: 12px;
}
.vipIcon {
- width: 32px;
- height: 32px;
- margin-right: 8px;
+ width: 24px;
+ height: 24px;
+ margin-right: 6px;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
- font-size: 20px;
+ font-size: 16px;
}
.vipTitle {
- font-size: 24px;
+ font-size: 18px;
font-weight: bold;
color: #fce2a9; /* 金色 */
}
.vipDescription {
- font-size: 14px;
+ font-size: 12px;
color: rgba(255, 255, 255, 0.8);
- margin-bottom: 24px;
+ margin-bottom: 16px;
}
.benefitsGrid {
display: grid;
grid-template-columns: repeat(4, 1fr);
- gap: 16px;
- margin-bottom: 32px;
+ gap: 12px;
+ margin-bottom: 20px;
}
.benefitItem {
@@ -87,19 +88,19 @@
}
.benefitIcon {
- width: 48px;
- height: 48px;
+ width: 36px;
+ height: 36px;
background-color: rgba(255, 255, 255, 0.15);
- border-radius: 8px;
- margin: 0 auto 8px auto;
+ border-radius: 6px;
+ margin: 0 auto 6px auto;
display: flex;
align-items: center;
justify-content: center;
- font-size: 24px;
+ font-size: 18px;
}
.benefitName {
- font-size: 13px;
+ font-size: 11px;
color: rgba(255, 255, 255, 0.9);
}
@@ -107,9 +108,9 @@
background: linear-gradient(to right, #6a5acd, #a64dd8); /* 紫色渐变 */
border: none;
color: white;
- padding: 12px 24px;
- border-radius: 8px;
- font-size: 18px;
+ padding: 8px 16px;
+ border-radius: 6px;
+ font-size: 14px;
font-weight: bold;
cursor: pointer;
width: 100%;
@@ -117,33 +118,89 @@
&:hover {
opacity: 0.9;
- transform: translateY(-2px);
+ transform: translateY(-1px);
}
}
.normalUserCallToAction {
background-color: #f0f2f5;
- padding: 20px;
- border-radius: 8px;
+ padding: 16px;
+ border-radius: 6px;
text-align: center;
- margin-top: 24px;
+ margin-top: 16px;
}
.normalUserCallToAction p {
- font-size: 16px;
+ font-size: 14px;
color: #555;
+ margin-bottom: 12px;
+}
+
+/* 积分记录卡片样式 */
+.pointsCard {
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ border-radius: 8px;
+ padding: 16px;
margin-bottom: 16px;
+ color: #fff;
+ position: relative;
+ overflow: hidden;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+}
+
+.pointsCard::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
+ z-index: 0;
+ border-radius: 8px;
+}
+
+.pointsContent {
+ position: relative;
+ z-index: 1;
+}
+
+.pointsHeader {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 12px;
+}
+
+.pointsTitle {
+ font-size: 16px;
+ font-weight: bold;
+ color: #fff;
+}
+
+.pointsCount {
+ font-size: 20px;
+ font-weight: bold;
+ color: #fce2a9;
+}
+
+.pointsDescription {
+ font-size: 12px;
+ color: rgba(255, 255, 255, 0.8);
+ margin-bottom: 12px;
}
/* 订单管理样式 */
.orderContent {
- margin-top: 16px;
+ margin-top: 12px;
}
.orderContent .ant-table-thead > tr > th {
background-color: #fafafa;
color: #262626;
font-weight: 600;
+ font-size: 12px;
+ padding: 8px 12px;
}
.orderContent .ant-table-tbody > tr:hover > td {
@@ -154,10 +211,16 @@
cursor: pointer;
}
+.orderContent .ant-table-tbody > tr > td {
+ padding: 8px 12px;
+ font-size: 12px;
+}
+
.orderContent .ant-btn-link {
- padding: 4px 8px;
+ padding: 2px 6px;
height: auto;
border-radius: 4px;
+ font-size: 12px;
}
.orderContent .ant-btn-link.ant-btn-dangerous {
@@ -171,25 +234,47 @@
.orderContent .ant-tag {
border-radius: 4px;
- font-size: 12px;
- padding: 2px 8px;
+ font-size: 11px;
+ padding: 1px 6px;
}
/* 订单详情弹窗样式 */
.orderDetailModal .ant-descriptions-item-label {
background-color: #fafafa;
font-weight: 600;
- width: 120px;
+ width: 100px;
+ font-size: 12px;
}
.orderDetailModal .ant-descriptions-item-content {
background-color: #fff;
+ font-size: 12px;
+}
+
+/* 积分记录表格样式 */
+.pointsTable .ant-table-thead > tr > th {
+ background-color: #fafafa;
+ color: #262626;
+ font-weight: 600;
+ font-size: 12px;
+ padding: 8px 12px;
+}
+
+.pointsTable .ant-table-tbody > tr > td {
+ padding: 8px 12px;
+ font-size: 12px;
+}
+
+.pointsTable .ant-tag {
+ border-radius: 4px;
+ font-size: 11px;
+ padding: 1px 6px;
}
/* 标签页样式 */
.container .ant-tabs > .ant-tabs-nav .ant-tabs-tab {
- padding: 12px 16px;
- font-size: 16px;
+ padding: 8px 12px;
+ font-size: 14px;
font-weight: 500;
}
@@ -198,40 +283,77 @@
}
.container .ant-tabs-content-holder {
- padding-top: 16px;
+ padding-top: 12px;
+}
+
+/* 积分记录表格样式 */
+.pointsTable .ant-table-thead > tr > th {
+ background-color: #fafafa;
+ color: #262626;
+ font-weight: 600;
+ font-size: 12px;
+ padding: 8px 12px;
+}
+
+.pointsTable .ant-table-tbody > tr > td {
+ padding: 8px 12px;
+ font-size: 12px;
+}
+
+.pointsTable .ant-tag {
+ border-radius: 4px;
+ font-size: 11px;
+ padding: 1px 6px;
}
/* 移动端适配 */
@media (max-width: 768px) {
.container {
- padding: 16px;
+ padding: 12px;
}
.card {
- margin-top: 16px;
+ margin-bottom: 12px;
}
.actions {
flex-direction: column;
- gap: 8px;
+ gap: 6px;
}
.benefitsGrid {
grid-template-columns: repeat(2, 1fr);
- gap: 12px;
+ gap: 8px;
}
.orderContent .ant-table {
- font-size: 12px;
+ font-size: 11px;
}
.orderContent .ant-table-thead > tr > th,
.orderContent .ant-table-tbody > tr > td {
- padding: 8px 4px;
+ padding: 6px 4px;
}
.container .ant-tabs > .ant-tabs-nav .ant-tabs-tab {
- padding: 8px 12px;
+ padding: 6px 8px;
+ font-size: 12px;
+ }
+
+ .vipCard,
+ .pointsCard {
+ padding: 12px;
+ }
+
+ .vipTitle {
+ font-size: 16px;
+ }
+
+ .pointsTitle {
font-size: 14px;
}
+
+ .pointsCount {
+ font-size: 18px;
+ }
}
\ No newline at end of file
diff --git a/src/app/i18n/locales/en/profile.json b/src/app/i18n/locales/en/profile.json
index 8efe8447..7c1a9649 100644
--- a/src/app/i18n/locales/en/profile.json
+++ b/src/app/i18n/locales/en/profile.json
@@ -86,5 +86,20 @@
"unlimitedTime": "Unlimited",
"fastExperience": "Fast",
"morePrivileges": "More"
+ },
+ "points": {
+ "title": "Points Records",
+ "myPoints": "My Points",
+ "pointsDescription": "View your points change history and usage",
+ "pointsChange": "Points Change",
+ "changeType": "Change Type",
+ "description": "Description",
+ "time": "Time",
+ "earn": "Earn",
+ "spend": "Spend",
+ "refund": "Refund",
+ "expire": "Expire",
+ "noPointsRecords": "No points records",
+ "totalRecords": "{{total}} records total"
}
}
\ No newline at end of file
diff --git a/src/app/i18n/locales/zh-CN/profile.json b/src/app/i18n/locales/zh-CN/profile.json
index 4ac8ef40..f6bc0ffe 100644
--- a/src/app/i18n/locales/zh-CN/profile.json
+++ b/src/app/i18n/locales/zh-CN/profile.json
@@ -86,5 +86,20 @@
"unlimitedTime": "无限时长",
"fastExperience": "极速体验",
"morePrivileges": "更多特权"
+ },
+ "points": {
+ "title": "积分记录",
+ "myPoints": "我的积分",
+ "pointsDescription": "查看您的积分变动记录和使用情况",
+ "pointsChange": "积分变动",
+ "changeType": "变动类型",
+ "description": "描述",
+ "time": "时间",
+ "earn": "获得",
+ "spend": "消费",
+ "refund": "退还",
+ "expire": "过期",
+ "noPointsRecords": "暂无积分记录",
+ "totalRecords": "共 {{total}} 条记录"
}
}
\ No newline at end of file
diff --git a/src/app/layout/LyaoutHeader.tsx b/src/app/layout/LyaoutHeader.tsx
index fe47d365..87ee7137 100644
--- a/src/app/layout/LyaoutHeader.tsx
+++ b/src/app/layout/LyaoutHeader.tsx
@@ -42,18 +42,18 @@ function UserInfo() {
</div>
),
},
- {
- key: "2",
- label: (
- <div
- onClick={() => {
- router.push("/notification");
- }}
- >
- {t("header.messages")}
- </div>
- ),
- },
+ // {
+ // key: "2",
+ // label: (
+ // <div
+ // onClick={() => {
+ // router.push("/notification");
+ // }}
+ // >
+ // {t("header.messages")}
+ // </div>
+ // ),
+ // },
{
key: "3",
label: (