Sfoglia il codice sorgente

fix(matchmaker-workbench): 调整签到积分奖励为1分并优化签到逻辑

- 将签到奖励从5积分调整为1积分
- 修复签到状态判断逻辑,使用日期字符串精确匹配
- 优化日历渲染逻辑,支持跨月份签到状态展示
- 添加formatDate方法统一日期格式处理
- 完善签到成功后的状态更新和界面反馈
- 调整签到日历样式,区分今日、已签到等不同状态视觉效果
- 修复月份切换时的数据加载问题
- 增加currentMonthText计算属性用于月份显示
- 补充signedDates类型注
李思佳 3 settimane fa
parent
commit
89009b89cf

+ 2 - 2
LiangZhiYUMao/pages/matchmaker-workbench/mine.vue

@@ -173,7 +173,7 @@
 
           <view class="sign-in-reward">
             <text class="reward-title">签到奖励</text>
-            <text class="reward-points">+5积分</text>
+            <text class="reward-points">+1积分</text>
           </view>
         </view>
         <view class="popup-footer">
@@ -531,7 +531,7 @@ export default {
 
         if (success) {
           uni.showToast({
-            title: '签到成功,+5积分',
+            title: '签到成功,+1积分',
             icon: 'success'
           })
           this.isSignedToday = true

+ 61 - 21
LiangZhiYUMao/pages/matchmaker-workbench/sign-in.vue

@@ -103,7 +103,8 @@ export default {
 			makerId: null,
 			isSigned: false,
 			calendarDays: [],
-			signedDates: [] // 已签到的日期
+			signedDates: [], // 已签到的日期字符串数组,格式:YYYY-MM-DD
+			currentMonthText: '' // 当前月份显示文本
 		}
 	},
 	computed: {
@@ -170,6 +171,16 @@ export default {
 				const balanceRes = await api.pointsMall.getBalance(this.makerId)
 				this.availablePoints = balanceRes.balance || 0
 				
+				// 获取本月所有签到日期
+				const checkinInfoRes = await api.matchmaker.checkinInfo(this.makerId, this.currentYear, this.currentMonth)
+				let checkinInfo = checkinInfoRes
+				if (checkinInfoRes && checkinInfoRes.data) {
+					checkinInfo = checkinInfoRes.data
+				}
+				
+				// 获取已签到日期列表
+				this.signedDates = checkinInfo.checkedDates || []
+				
 				// 检查今日签到状态
 				const statusRes = await api.matchmaker.checkinStatus(this.makerId)
 				let statusData = statusRes
@@ -177,14 +188,6 @@ export default {
 					statusData = statusRes.data
 				}
 				this.isSigned = statusData === true || statusData?.isCheckedIn === true || statusData?.checked === true
-				
-				// 如果今日已签到,添加到已签到日期
-				if (this.isSigned) {
-					const today = new Date().getDate()
-					if (!this.signedDates.includes(today)) {
-						this.signedDates.push(today)
-					}
-				}
 			} catch (e) {
 				console.error('加载签到数据失败:', e)
 			}
@@ -193,6 +196,9 @@ export default {
 			const year = this.currentYear
 			const month = this.currentMonth
 			
+			// 更新月份显示文本
+			this.currentMonthText = `${year}年${month}月`
+			
 			// 获取当月第一天是星期几
 			const firstDay = new Date(year, month - 1, 1).getDay()
 			// 获取当月天数
@@ -200,6 +206,10 @@ export default {
 			// 获取上月天数
 			const prevMonthDays = new Date(year, month - 1, 0).getDate()
 			
+			// 获取今天的日期字符串
+			const today = new Date()
+			const todayStr = this.formatDate(today)
+			
 			const days = []
 			
 			// 添加上月日期
@@ -213,15 +223,16 @@ export default {
 			}
 			
 			// 添加当月日期
-			const today = new Date().getDate()
-			const currentMonthNow = new Date().getMonth() + 1
-			
 			for (let i = 1; i <= daysInMonth; i++) {
+				const date = new Date(year, month - 1, i)
+				const dateStr = this.formatDate(date)
+				const isToday = dateStr === todayStr
+				
 				days.push({
 					day: i,
 					isOtherMonth: false,
-					isSigned: this.signedDates.includes(i),
-					isToday: i === today && month === currentMonthNow
+					isSigned: this.signedDates.includes(dateStr),
+					isToday: isToday
 				})
 			}
 			
@@ -238,6 +249,13 @@ export default {
 			
 			this.calendarDays = days
 		},
+		// 格式化日期为YYYY-MM-DD
+		formatDate(date) {
+			const year = date.getFullYear()
+			const month = String(date.getMonth() + 1).padStart(2, '0')
+			const day = String(date.getDate()).padStart(2, '0')
+			return `${year}-${month}-${day}`
+		},
 		async handleSignIn() {
 			if (this.isSigned) {
 				uni.showToast({
@@ -254,7 +272,7 @@ export default {
 			
 			try {
 				// 调用后端签到接口
-				await api.matchmaker.doCheckin(this.makerId)
+				const signRes = await api.matchmaker.doCheckin(this.makerId)
 				
 				// 签到成功后更新状态
 				this.isSigned = true
@@ -262,9 +280,10 @@ export default {
 				this.consecutiveDays++
 				
 				// 更新今天的签到状态
-				const today = new Date().getDate()
-				if (!this.signedDates.includes(today)) {
-					this.signedDates.push(today)
+				const today = new Date()
+				const todayStr = this.formatDate(today)
+				if (!this.signedDates.includes(todayStr)) {
+					this.signedDates.push(todayStr)
 				}
 				this.generateCalendar()
 				
@@ -272,6 +291,10 @@ export default {
 				const balanceRes = await api.pointsMall.getBalance(this.makerId)
 				this.availablePoints = balanceRes.balance || 0
 				
+				// 重新加载签到信息,确保数据最新
+				await this.loadSignInData()
+				this.generateCalendar()
+				
 				uni.showToast({
 					title: '签到成功 +5积分',
 					icon: 'success'
@@ -427,16 +450,33 @@ export default {
 			}
 
 			&.signed {
-				background: linear-gradient(135deg, #CE93D8 0%, #BA68C8 100%);
+				background: #F3E5F5;
+				border: 2rpx solid #CE93D8;
 
 				.day-number {
-					color: #FFFFFF;
+					color: #7B1FA2;
 					font-weight: bold;
 				}
 			}
 
 			&.today {
-				border: 2rpx solid #9C27B0;
+				background: #9C27B0;
+				border: 2rpx solid #7B1FA2;
+
+				.day-number {
+					color: #FFFFFF;
+					font-weight: bold;
+				}
+			}
+
+			&.today.signed {
+				background: #9C27B0;
+				border: 2rpx solid #7B1FA2;
+
+				.day-number {
+					color: #FFFFFF;
+					font-weight: bold;
+				}
 			}
 
 			.day-number {