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