Skip to content

Let's use AI to Earn!

积分哟豪华啊

daoyian86cef0fa5b43
diff --git a/src/api/apiReq.ts b/src/api/apiReq.ts
index 377bb39f..b35ded6f 100644
--- a/src/api/apiReq.ts
+++ b/src/api/apiReq.ts
@@ -18,7 +18,7 @@ export interface RegistCheckParams {
}
// 获取用户信息
-export const getUserInfoApi = () => {
+export const getUserInfoApi = () => {
return http.get<UserInfo>("user/mine");
};
diff --git a/src/api/signIn.ts b/src/api/signIn.ts
index 0fc5621b..05043778 100644
--- a/src/api/signIn.ts
+++ b/src/api/signIn.ts
@@ -11,28 +11,24 @@ export enum SignInType {
PUL_VIDEO = "pul_video",
}
+export interface SignInResponse {
+ success: boolean;
+ message?: string;
+ score?: number; // 签到后更新的积分
+ data?: any;
+}
+
export const signInApi = {
/**
* 创建签到
*/
- async createSignInRecord(type: SignInType = SignInType.PUL_VIDEO) {
- const res = await http.post<any>(`reward/signIn`, {
+ async createSignInRecord(type: SignInType = SignInType.PUL_VIDEO): Promise<SignInResponse> {
+ const res = await http.post<SignInResponse>(`reward/signIn`, {
type,
});
return res!.data;
},
- /**
- * 获取签到列表
- */
- async getSignInList(params: { type: SignInType; time?: [Date, Date] }) {
- const res = await http.get<any>(`reward/signIn/list`, {
- isToken: true,
- params,
- });
- return res!.data;
- },
-
/**
* 获取签到日历数据
*/
@@ -44,13 +40,5 @@ export const signInApi = {
return res!.data;
},
- /**
- * 获取用户积分信息
- */
- async getUserPoints() {
- const res = await http.get<any>(`reward/points`, {
- isToken: true,
- });
- return res!.data;
- },
+
};
diff --git a/src/components/SignInCalendar/SignInCalendar.module.scss b/src/components/SignInCalendar/SignInCalendar.module.scss
index 185c1896..aee75b7c 100644
--- a/src/components/SignInCalendar/SignInCalendar.module.scss
+++ b/src/components/SignInCalendar/SignInCalendar.module.scss
@@ -24,9 +24,9 @@
padding: 16px 24px;
}
- .ant-modal-body {
- padding: 24px;
- }
+ .ant-modal-body {
+ padding: 28px;
+ }
}
.modalHeader {
@@ -34,6 +34,7 @@
justify-content: space-between;
align-items: center;
width: 100%;
+ padding-top: 20px;
span {
font-size: 16px;
@@ -54,6 +55,7 @@
}
.calendarContainer {
+ padding-top: 0px;
.ant-picker-calendar {
border: none;
@@ -62,28 +64,28 @@
margin-bottom: 16px;
}
- .ant-picker-calendar-date {
- border: none;
- padding: 4px;
- height: 32px;
- display: flex;
- align-items: center;
- justify-content: center;
-
- &:hover {
- background-color: #f5f5f5;
- }
- }
+ .ant-picker-calendar-date {
+ border: none;
+ padding: 6px;
+ height: 40px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+
+ &:hover {
+ background-color: #f5f5f5;
+ }
+ }
.ant-picker-calendar-date-today {
background-color: #e6f7ff;
border: 1px solid #1890ff;
}
- .ant-picker-calendar-date-value {
- font-size: 12px;
- line-height: 1;
- }
+ .ant-picker-calendar-date-value {
+ font-size: 14px;
+ line-height: 1;
+ }
.ant-picker-calendar-date-content {
height: auto;
@@ -94,10 +96,10 @@
.calendarHeader {
text-align: center;
- font-size: 16px;
+ font-size: 18px;
font-weight: 600;
color: #333;
- padding: 8px 0;
+ padding: 10px 0;
}
.calendarCell {
@@ -114,19 +116,19 @@
top: 2px;
right: 2px;
- .ant-badge-count {
- background: #52c41a;
- box-shadow: none;
- min-width: 16px;
- height: 16px;
- line-height: 16px;
- border-radius: 50%;
- font-size: 10px;
- }
+ .ant-badge-count {
+ background: #52c41a;
+ box-shadow: none;
+ min-width: 18px;
+ height: 18px;
+ line-height: 18px;
+ border-radius: 50%;
+ font-size: 12px;
+ }
}
.dateText {
- font-size: 12px;
+ font-size: 14px;
color: #333;
&.today {
@@ -136,52 +138,52 @@
}
.signInRules {
- margin: 20px 0;
- padding: 16px;
+ margin: 24px 0;
+ padding: 20px;
background-color: #f8f9fa;
border-radius: 8px;
- h4 {
- margin: 0 0 12px 0;
- font-size: 14px;
- font-weight: 600;
- color: #333;
- }
-
- ul {
- margin: 0;
- padding-left: 16px;
-
- li {
- margin-bottom: 8px;
- font-size: 12px;
- color: #666;
- line-height: 1.4;
-
- &:last-child {
- margin-bottom: 0;
- }
- }
- }
+ h4 {
+ margin: 0 0 12px 0;
+ font-size: 16px;
+ font-weight: 600;
+ color: #333;
+ }
+
+ ul {
+ margin: 0;
+ padding-left: 16px;
+
+ li {
+ margin-bottom: 8px;
+ font-size: 14px;
+ color: #666;
+ line-height: 1.4;
+
+ &:last-child {
+ margin-bottom: 0;
+ }
+ }
+ }
}
.signInInfo {
display: flex;
justify-content: space-between;
- margin-bottom: 20px;
- padding: 12px 16px;
+ margin-bottom: 24px;
+ padding: 16px 20px;
background-color: #f0f8ff;
border-radius: 6px;
- .infoItem {
- font-size: 13px;
- color: #1890ff;
- font-weight: 500;
- }
+ .infoItem {
+ font-size: 15px;
+ color: #1890ff;
+ font-weight: 500;
+ }
}
.signInActionButton {
- height: 44px;
+ height: 48px;
font-size: 16px;
font-weight: 600;
border-radius: 8px;
@@ -207,19 +209,19 @@
.signInModal {
.ant-modal {
width: 90% !important;
- max-width: 450px;
+ max-width: 550px;
}
}
- .calendarContainer {
- .ant-picker-calendar-date {
- height: 28px;
- }
-
- .dateText {
- font-size: 11px;
- }
- }
+ .calendarContainer {
+ .ant-picker-calendar-date {
+ height: 36px;
+ }
+
+ .dateText {
+ font-size: 13px;
+ }
+ }
.signInInfo {
flex-direction: column;
diff --git a/src/components/SignInCalendar/index.tsx b/src/components/SignInCalendar/index.tsx
index 5d8f161c..5441f39b 100644
--- a/src/components/SignInCalendar/index.tsx
+++ b/src/components/SignInCalendar/index.tsx
@@ -4,7 +4,8 @@ import React, { useState, useEffect, useMemo } from 'react';
import { Button, Modal, Calendar, Badge, message } from 'antd';
import { CalendarOutlined, CheckOutlined } from '@ant-design/icons';
import { useTransClient } from '@/app/i18n/client';
-import { signInApi, SignInType } from '@/api/signIn';
+import { signInApi, SignInType, SignInResponse } from '@/api/signIn';
+import { useUserStore } from '@/store/user';
import styles from './SignInCalendar.module.scss';
interface SignInCalendarProps {
@@ -15,18 +16,17 @@ interface CalendarData {
signedDates: string[]; // 已签到的日期数组,格式: "YYYY-MM-DD"
todaySigned: boolean; // 今天是否已签到
consecutiveDays: number; // 连续签到天数
- totalPoints: number; // 总积分
}
const SignInCalendar: React.FC<SignInCalendarProps> = ({ className }) => {
const { t } = useTransClient('common');
+ const userStore = useUserStore();
const [visible, setVisible] = useState(false);
const [loading, setLoading] = useState(false);
const [calendarData, setCalendarData] = useState<CalendarData>({
signedDates: [],
todaySigned: false,
- consecutiveDays: 0,
- totalPoints: 0
+ consecutiveDays: 0
});
const [currentDate, setCurrentDate] = useState(new Date());
@@ -56,8 +56,17 @@ const SignInCalendar: React.FC<SignInCalendarProps> = ({ className }) => {
try {
setLoading(true);
- await signInApi.createSignInRecord(SignInType.PUL_VIDEO);
+ const result: SignInResponse = await signInApi.createSignInRecord(SignInType.PUL_VIDEO);
message.success(t('signIn.signInSuccess'));
+
+ // 如果签到成功返回了新的积分,更新用户信息
+ if (result && result.score !== undefined) {
+ userStore.setUserInfo({
+ ...userStore.userInfo,
+ score: result.score
+ } as any);
+ }
+
// 重新获取日历数据
await fetchCalendarData();
} catch (error) {
@@ -76,12 +85,12 @@ const SignInCalendar: React.FC<SignInCalendarProps> = ({ className }) => {
return (
<div className={styles.calendarCell}>
- {isSigned && (
- <Badge
- count={<CheckOutlined style={{ color: '#52c41a', fontSize: '12px' }} />}
- className={styles.signInBadge}
- />
- )}
+ {isSigned && (
+ <Badge
+ count={<CheckOutlined style={{ color: '#52c41a', fontSize: '14px' }} />}
+ className={styles.signInBadge}
+ />
+ )}
<span className={`${styles.dateText} ${isToday ? styles.today : ''}`}>
{isToday ? t('signIn.today') : value.date()}
</span>
@@ -119,8 +128,8 @@ const SignInCalendar: React.FC<SignInCalendarProps> = ({ className }) => {
type="link"
className={styles.pointsLink}
onClick={() => {
- // 跳转到积分页面
- window.open('/points', '_blank');
+ // 跳转到个人中心页面
+ window.open('/profile', '_blank');
}}
>
{t('signIn.myPoints')} &gt;
@@ -130,7 +139,7 @@ const SignInCalendar: React.FC<SignInCalendarProps> = ({ className }) => {
open={visible}
onCancel={() => setVisible(false)}
footer={null}
- width={500}
+ width={600}
className={styles.signInModal}
>
<div className={styles.calendarContainer}>
@@ -163,7 +172,7 @@ const SignInCalendar: React.FC<SignInCalendarProps> = ({ className }) => {
<span>{t('signIn.consecutiveDays')}: {calendarData.consecutiveDays}</span>
</div>
<div className={styles.infoItem}>
- <span>{t('signIn.totalPoints')}: {calendarData.totalPoints}</span>
+ <span>{t('signIn.totalPoints')}: {userStore.userInfo?.score || 0}</span>
</div>
</div>