完善每日签到功能
This commit is contained in:
1
miniprogram/note.md
Normal file
1
miniprogram/note.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
当前版本:2.1.8
|
||||||
@@ -1,189 +1,178 @@
|
|||||||
// 定义日历日期类型
|
// pages/checkin/checkin.ts
|
||||||
|
|
||||||
interface CalendarDay {
|
interface CalendarDay {
|
||||||
type: 'current' | 'empty'; // current:当月日期, empty:空占位(上月/下月)
|
day: number | string; // 日期数字或空字符串
|
||||||
day: number; // 日期数字
|
fullDate?: string; // 完整日期字符串,如 'YYYY-MM-DD'
|
||||||
date: string; // 完整日期(YYYY-MM-DD)
|
isPrevMonth?: boolean; // 是否上月日期
|
||||||
isChecked: boolean; // 是否已签到
|
isNextMonth?: boolean; // 是否下月日期
|
||||||
isToday: boolean; // 是否是今天
|
isToday?: boolean; // 是否今天
|
||||||
}
|
isCheckedIn?: boolean; // 是否已签到
|
||||||
|
|
||||||
Page({
|
|
||||||
data: {
|
|
||||||
currentYear: new Date().getFullYear(), // 当前年
|
|
||||||
currentMonth: new Date().getMonth(), // 当前月(0-11)
|
|
||||||
calendarDays: [] as CalendarDay[], // 日历日期列表
|
|
||||||
checkinHistory: [] as string[], // 签到历史(存储YYYY-MM-DD格式日期)
|
|
||||||
continuousCheckinDays: 0, // 连续签到天数
|
|
||||||
totalCheckinDays: 0, // 本月总签到天数
|
|
||||||
isCheckedToday: false, // 今日是否已签到
|
|
||||||
isAnimating: false // 是否正在执行签到动画
|
|
||||||
},
|
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
// 从本地缓存加载签到历史
|
|
||||||
this.loadCheckinHistory();
|
|
||||||
// 生成当月日历数据
|
|
||||||
this.generateCalendarDays();
|
|
||||||
// 计算签到统计数据
|
|
||||||
this.calculateCheckinStats();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从本地缓存加载签到历史
|
|
||||||
*/
|
|
||||||
loadCheckinHistory() {
|
|
||||||
const history = wx.getStorageSync('checkinHistory') || [];
|
|
||||||
this.setData({ checkinHistory: history });
|
|
||||||
|
|
||||||
// 检查今日是否已签到
|
|
||||||
const today = this.formatDate(new Date());
|
|
||||||
const isCheckedToday = history.includes(today);
|
|
||||||
this.setData({ isCheckedToday });
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成当月日历数据
|
|
||||||
*/
|
|
||||||
generateCalendarDays() {
|
|
||||||
const { currentYear, currentMonth, checkinHistory } = this.data;
|
|
||||||
const calendarDays: CalendarDay[] = [];
|
|
||||||
|
|
||||||
// 获取当月第一天是星期几(0=周日,1=周一...6=周六)
|
|
||||||
const firstDayOfMonth = new Date(currentYear, currentMonth, 1).getDay();
|
|
||||||
// 获取当月总天数
|
|
||||||
const totalDaysOfMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
|
|
||||||
// 获取今日日期(YYYY-MM-DD)
|
|
||||||
const today = this.formatDate(new Date());
|
|
||||||
|
|
||||||
// 添加上月残留日期(空占位)
|
|
||||||
for (let i = 0; i < firstDayOfMonth; i++) {
|
|
||||||
calendarDays.push({
|
|
||||||
type: 'empty',
|
|
||||||
day: 0,
|
|
||||||
date: '',
|
|
||||||
isChecked: false,
|
|
||||||
isToday: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加当月日期
|
|
||||||
for (let day = 1; day <= totalDaysOfMonth; day++) {
|
|
||||||
const date = new Date(currentYear, currentMonth, day);
|
|
||||||
const dateStr = this.formatDate(date);
|
|
||||||
const isChecked = checkinHistory.includes(dateStr);
|
|
||||||
const isToday = dateStr === today;
|
|
||||||
|
|
||||||
calendarDays.push({
|
|
||||||
type: 'current',
|
|
||||||
day,
|
|
||||||
date: dateStr,
|
|
||||||
isChecked,
|
|
||||||
isToday
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加下月占位日期(确保日历满6行,共42个格子)
|
|
||||||
const totalCells = 42; // 6行×7列=42个格子
|
|
||||||
const remainingCells = totalCells - calendarDays.length;
|
|
||||||
for (let i = 0; i < remainingCells; i++) {
|
|
||||||
calendarDays.push({
|
|
||||||
type: 'empty',
|
|
||||||
day: 0,
|
|
||||||
date: '',
|
|
||||||
isChecked: false,
|
|
||||||
isToday: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setData({ calendarDays });
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 计算签到统计数据
|
|
||||||
*/
|
|
||||||
calculateCheckinStats() {
|
|
||||||
const { checkinHistory, currentYear, currentMonth } = this.data;
|
|
||||||
const today = new Date();
|
|
||||||
|
|
||||||
// 计算本月总签到天数
|
|
||||||
const monthStart = new Date(currentYear, currentMonth, 1);
|
|
||||||
const monthEnd = new Date(currentYear, currentMonth + 1, 0);
|
|
||||||
const monthStartStr = this.formatDate(monthStart);
|
|
||||||
const monthEndStr = this.formatDate(monthEnd);
|
|
||||||
|
|
||||||
const monthlyCheckins = checkinHistory.filter(date => {
|
|
||||||
return date >= monthStartStr && date <= monthEndStr;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 计算连续签到天数
|
|
||||||
let continuousDays = 0;
|
|
||||||
const sortedHistory = [...checkinHistory].sort();
|
|
||||||
|
|
||||||
// 从今天开始往前查连续签到
|
|
||||||
const checkDate = new Date(today);
|
|
||||||
while (true) {
|
|
||||||
const dateStr = this.formatDate(checkDate);
|
|
||||||
if (sortedHistory.includes(dateStr)) {
|
|
||||||
continuousDays++;
|
|
||||||
// 往前推一天
|
|
||||||
checkDate.setDate(checkDate.getDate() - 1);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setData({
|
|
||||||
totalCheckinDays: monthlyCheckins.length,
|
|
||||||
continuousCheckinDays: continuousDays
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理签到逻辑
|
|
||||||
*/
|
|
||||||
handleCheckin() {
|
|
||||||
if (this.data.isCheckedToday || this.data.isAnimating) return;
|
|
||||||
|
|
||||||
// 开始动画
|
|
||||||
this.setData({ isAnimating: true });
|
|
||||||
|
|
||||||
// 记录当前日期
|
|
||||||
const today = this.formatDate(new Date());
|
|
||||||
const { checkinHistory } = this.data;
|
|
||||||
|
|
||||||
// 添加到签到历史
|
|
||||||
const newHistory = [...checkinHistory, today];
|
|
||||||
wx.setStorageSync('checkinHistory', newHistory);
|
|
||||||
|
|
||||||
// 更新数据
|
|
||||||
setTimeout(() => {
|
|
||||||
this.setData({
|
|
||||||
checkinHistory: newHistory,
|
|
||||||
isCheckedToday: true,
|
|
||||||
isAnimating: false
|
|
||||||
});
|
|
||||||
|
|
||||||
// 更新日历和统计
|
|
||||||
this.generateCalendarDays();
|
|
||||||
this.calculateCheckinStats();
|
|
||||||
|
|
||||||
// 显示成功提示
|
|
||||||
wx.showToast({
|
|
||||||
title: '签到成功!',
|
|
||||||
icon: 'success',
|
|
||||||
duration: 1500
|
|
||||||
});
|
|
||||||
}, 1000); // 动画持续1秒
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化日期为YYYY-MM-DD
|
|
||||||
*/
|
|
||||||
formatDate(date: Date): string {
|
|
||||||
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}`;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
|
||||||
|
currentYear: 0,
|
||||||
|
currentMonth: 0, // 1-12月
|
||||||
|
calendarDays: [] as CalendarDay[], // 日历日期数据
|
||||||
|
|
||||||
|
consecutiveCheckInDays: 0, // 连续签到天数
|
||||||
|
monthCheckInDays: 0, // 本月签到天数
|
||||||
|
todayCheckedIn: false, // 今日是否已签到
|
||||||
|
|
||||||
|
// 假设这些是用户已签到的日期(仅日期数字),在真实项目中从后端获取
|
||||||
|
checkedInDates: [] as number[], // [1, 5, 18, 29] 表示当月哪些天已签到
|
||||||
|
|
||||||
|
// 用于保存当前显示的月份的Date对象,方便计算
|
||||||
|
displayMonthDate: new Date(),
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
this.initCalendar();
|
||||||
|
this.fetchCheckInStats(); // 模拟从后端获取签到数据
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化日历,生成当前月份的日期
|
||||||
|
*/
|
||||||
|
initCalendar() {
|
||||||
|
const today = new Date();
|
||||||
|
this.data.displayMonthDate = new Date(today.getFullYear(), today.getMonth(), 1); // 设置为当前月的第一天
|
||||||
|
|
||||||
|
this.renderCalendar(this.data.displayMonthDate);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染指定月份的日历
|
||||||
|
* @param date 当前月份的任意一天,例如 new Date(2025, 8, 1) 表示 2025年9月
|
||||||
|
*/
|
||||||
|
renderCalendar(date: Date) {
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = date.getMonth(); // 0-11
|
||||||
|
|
||||||
|
this.setData({
|
||||||
|
currentYear: year,
|
||||||
|
currentMonth: month + 1, // 显示给用户是1-12月
|
||||||
|
});
|
||||||
|
|
||||||
|
const calendarDays: CalendarDay[] = [];
|
||||||
|
const firstDayOfMonth = new Date(year, month, 1);
|
||||||
|
const lastDayOfMonth = new Date(year, month + 1, 0); // 当月最后一天
|
||||||
|
|
||||||
|
// 补充上个月的日期(如果需要)
|
||||||
|
const startDayOfWeek = firstDayOfMonth.getDay(); // 0-6,0是周日
|
||||||
|
for (let i = 0; i < startDayOfWeek; i++) {
|
||||||
|
calendarDays.push({ day: '', isPrevMonth: true }); // 用空字符串占位或显示上月日期
|
||||||
|
}
|
||||||
|
|
||||||
|
// 填充当前月份的日期
|
||||||
|
for (let i = 1; i <= lastDayOfMonth.getDate(); i++) {
|
||||||
|
const currentDay = new Date(year, month, i);
|
||||||
|
const isToday = this.isSameDay(currentDay, new Date());
|
||||||
|
const isCheckedIn = this.data.checkedInDates.includes(i); // 判断是否已签到
|
||||||
|
|
||||||
|
calendarDays.push({
|
||||||
|
day: i,
|
||||||
|
fullDate: this.formatDate(currentDay),
|
||||||
|
isToday: isToday,
|
||||||
|
isCheckedIn: isCheckedIn,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 补充下个月的日期(如果需要,凑够6行或7的倍数)
|
||||||
|
const totalDays = calendarDays.length;
|
||||||
|
const remainingDays = 42 - totalDays; // 假设日历固定6行7列,共42个格子
|
||||||
|
for (let i = 0; i < remainingDays; i++) {
|
||||||
|
calendarDays.push({ day: '', isNextMonth: true }); // 用空字符串占位
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setData({
|
||||||
|
calendarDays: calendarDays,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模拟从后端获取签到统计数据和已签到日期
|
||||||
|
*/
|
||||||
|
fetchCheckInStats() {
|
||||||
|
// 真实项目中这里会发起 wx.request 到您的后端接口
|
||||||
|
// 假设后端返回的数据格式如下:
|
||||||
|
const mockApiResponse = {
|
||||||
|
consecutiveCheckInDays: 29, // 连续签到天数
|
||||||
|
monthCheckInDays: 15, // 本月签到天数
|
||||||
|
todayCheckedIn: false, // 假设今天未签到
|
||||||
|
checkedInDaysInMonth: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 29], // 当月已签到的日期数字
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setData({
|
||||||
|
consecutiveCheckInDays: mockApiResponse.consecutiveCheckInDays,
|
||||||
|
monthCheckInDays: mockApiResponse.monthCheckInDays,
|
||||||
|
todayCheckedIn: mockApiResponse.todayCheckedIn,
|
||||||
|
checkedInDates: mockApiResponse.checkedInDaysInMonth,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 重新渲染日历以应用新的签到状态
|
||||||
|
this.renderCalendar(this.data.displayMonthDate);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理签到按钮点击
|
||||||
|
*/
|
||||||
|
handleCheckIn() {
|
||||||
|
if (this.data.todayCheckedIn) {
|
||||||
|
wx.showToast({ title: '今日已签到', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 模拟后端签到逻辑
|
||||||
|
wx.showLoading({ title: '签到中...' });
|
||||||
|
setTimeout(() => {
|
||||||
|
// 假设后端返回签到成功
|
||||||
|
const today = new Date().getDate();
|
||||||
|
const newCheckedInDates = [...this.data.checkedInDates, today];
|
||||||
|
|
||||||
|
this.setData({
|
||||||
|
todayCheckedIn: true,
|
||||||
|
consecutiveCheckInDays: this.data.consecutiveCheckInDays + 1, // 假设连续+1
|
||||||
|
monthCheckInDays: this.data.monthCheckInDays + 1, // 假设当月+1
|
||||||
|
checkedInDates: newCheckedInDates,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 重新渲染日历,标记今天为已签到
|
||||||
|
this.renderCalendar(this.data.displayMonthDate);
|
||||||
|
|
||||||
|
wx.hideLoading();
|
||||||
|
wx.showToast({ title: '签到成功!', icon: 'success' });
|
||||||
|
}, 1000); // 模拟网络请求
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理日历中的日期点击(可选,如果需要点击日期查看历史签到等)
|
||||||
|
*/
|
||||||
|
handleDayClick(event: WechatMiniprogram.TouchEvent) {
|
||||||
|
const fullDate = event.currentTarget.dataset.date;
|
||||||
|
if (fullDate) {
|
||||||
|
console.log('点击了日期:', fullDate);
|
||||||
|
// 可在此处实现点击日期查看历史签到详情等逻辑
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 辅助函数:判断两个日期是否是同一天 (忽略时间)
|
||||||
|
*/
|
||||||
|
isSameDay(date1: Date, date2: Date): boolean {
|
||||||
|
return date1.getFullYear() === date2.getFullYear() &&
|
||||||
|
date1.getMonth() === date2.getMonth() &&
|
||||||
|
date1.getDate() === date2.getDate();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 辅助函数:格式化日期为 YYYY-MM-DD
|
||||||
|
*/
|
||||||
|
formatDate(date: Date): string {
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||||
|
const day = date.getDate().toString().padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,107 +1,53 @@
|
|||||||
<view class="checkin-container">
|
<view class="container">
|
||||||
<!-- 顶部信息区 -->
|
<view class="summary-card">
|
||||||
<view class="header">
|
<view class="month-display">{{ currentYear }}年{{ currentMonth }}月</view>
|
||||||
<view class="month-info">{{currentYear}}年{{currentMonth + 1}}月</view>
|
<view class="stats-row">
|
||||||
<view class="checkin-stats">
|
|
||||||
<view class="stat-item">
|
<view class="stat-item">
|
||||||
<view class="stat-value">{{continuousCheckinDays}}</view>
|
<text class="stat-number">{{ consecutiveCheckInDays }}</text>
|
||||||
<view class="stat-label">连续签到</view>
|
<text class="stat-label">连续签到</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="divider-v"></view>
|
||||||
<view class="stat-item">
|
<view class="stat-item">
|
||||||
<view class="stat-value">{{totalCheckinDays}}</view>
|
<text class="stat-number">{{ monthCheckInDays }}</text>
|
||||||
<view class="stat-label">本月签到</view>
|
<text class="stat-label">本月签到</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="today-checkin-box">
|
||||||
|
<view class="checkin-button" wx:if="{{ !todayCheckedIn }}" bindtap="handleCheckIn">
|
||||||
|
<text>签到</text>
|
||||||
|
</view>
|
||||||
|
<view class="checked-in-status" wx:else>
|
||||||
|
<text>已签到</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="checkin-tip" wx:if="{{ todayCheckedIn }}">今日已完成签到,明天继续哦~</text>
|
||||||
|
<text class="checkin-tip" wx:else>点击签到,记录美好生活~</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 签到按钮区 -->
|
<view class="calendar-card">
|
||||||
<view class="checkin-button-area">
|
<view class="calendar-header">
|
||||||
<button
|
<text class="calendar-title">签到日历</text>
|
||||||
class="checkin-btn {{isCheckedToday ? 'checked' : ''}} {{isAnimating ? 'animating' : ''}}"
|
</view>
|
||||||
bindtap="handleCheckin"
|
|
||||||
disabled="{{isCheckedToday || isAnimating}}"
|
<view class="calendar-weekdays">
|
||||||
>
|
<block wx:for="{{ weekdays }}" wx:key="*this">
|
||||||
<view class="btn-content">
|
<text class="weekday-item">{{ item }}</text>
|
||||||
{{isCheckedToday ? '已签到' : '今日签到'}}
|
</block>
|
||||||
<image
|
|
||||||
class="check-icon"
|
|
||||||
src="/images/check.png"
|
|
||||||
mode="widthFix"
|
|
||||||
style="width: 40rpx; height: auto; display: {{isCheckedToday ? 'block' : 'none'}};"
|
|
||||||
></image>
|
|
||||||
</view>
|
|
||||||
</button>
|
|
||||||
<view class="checkin-tip">
|
|
||||||
{{isCheckedToday ? '今日已完成签到,明天继续哦~' : '点击按钮完成今日签到,领取奖励'}}
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 日历签到区 -->
|
<view class="calendar-days">
|
||||||
<view class="calendar-section">
|
<block wx:for="{{ calendarDays }}" wx:key="index">
|
||||||
<view class="section-title">签到日历</view>
|
|
||||||
<!-- 星期头部 -->
|
|
||||||
<view class="weekdays">
|
|
||||||
<view class="weekday">日</view>
|
|
||||||
<view class="weekday">一</view>
|
|
||||||
<view class="weekday">二</view>
|
|
||||||
<view class="weekday">三</view>
|
|
||||||
<view class="weekday">四</view>
|
|
||||||
<view class="weekday">五</view>
|
|
||||||
<view class="weekday">六</view>
|
|
||||||
</view>
|
|
||||||
<!-- 日历格子 -->
|
|
||||||
<view class="calendar-grid">
|
|
||||||
<block wx:for="{{calendarDays}}" wx:key="index">
|
|
||||||
<view
|
<view
|
||||||
class="calendar-day {{item.type === 'empty' ? 'empty' : ''}} {{item.isChecked ? 'checked' : ''}} {{item.isToday ? 'today' : ''}}"
|
class="day-item {{ item.isPrevMonth || item.isNextMonth ? 'other-month' : '' }} {{ item.isToday ? 'today' : '' }}"
|
||||||
|
data-date="{{ item.fullDate }}"
|
||||||
|
bindtap="handleDayClick"
|
||||||
>
|
>
|
||||||
<view class="day-number">
|
<view class="day-content {{ item.isCheckedIn ? 'checked-in' : '' }}">
|
||||||
{{item.type !== 'empty' ? item.day : ''}}
|
<text class="day-number">{{ item.day }}</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 签到对勾(仅已签到显示) -->
|
|
||||||
<image
|
|
||||||
class="check-mark"
|
|
||||||
src="/images/check.png"
|
|
||||||
mode="widthFix"
|
|
||||||
style="width: 24rpx; height: auto; display: {{item.isChecked ? 'block' : 'none'}};"
|
|
||||||
></image>
|
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
<!-- 奖励区 -->
|
|
||||||
<view class="rewards-section">
|
|
||||||
<view class="section-title">签到奖励</view>
|
|
||||||
<view class="rewards-list">
|
|
||||||
<view class="reward-item {{continuousCheckinDays >= 3 ? 'achieved' : ''}}">
|
|
||||||
<view class="reward-days">连续签到3天</view>
|
|
||||||
<view class="reward-separator">→</view>
|
|
||||||
<view class="reward-content">获得10积分</view>
|
|
||||||
<view class="reward-status" wx:if="{{continuousCheckinDays >= 3}}">
|
|
||||||
<image src="/images/check.png" mode="widthFix" style="width: 24rpx; height: auto;"></image>
|
|
||||||
已达成
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="reward-item {{continuousCheckinDays >= 7 ? 'achieved' : ''}}">
|
|
||||||
<view class="reward-days">连续签到7天</view>
|
|
||||||
<view class="reward-separator">→</view>
|
|
||||||
<view class="reward-content">获得30积分 + 优惠券</view>
|
|
||||||
<view class="reward-status" wx:if="{{continuousCheckinDays >= 7}}">
|
|
||||||
<image src="/images/check.png" mode="widthFix" style="width: 24rpx; height: auto;"></image>
|
|
||||||
已达成
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="reward-item {{continuousCheckinDays >= 15 ? 'achieved' : ''}}">
|
|
||||||
<view class="reward-days">连续签到15天</view>
|
|
||||||
<view class="reward-separator">→</view>
|
|
||||||
<view class="reward-content">获得50积分 + 专属权益</view>
|
|
||||||
<view class="reward-status" wx:if="{{continuousCheckinDays >= 15}}">
|
|
||||||
<image src="/images/check.png" mode="widthFix" style="width: 24rpx; height: auto;"></image>
|
|
||||||
已达成
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
@@ -1,271 +1,198 @@
|
|||||||
/* 全局样式 */
|
/* pages/checkin/checkin.wxss */
|
||||||
page {
|
page {
|
||||||
background-color: #f7f8fa;
|
background-color: #f4f6f8;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
min-height: 100vh;
|
/* ⭐️ 移除这里的 padding */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 容器样式 */
|
/* ⭐️ 将 padding 添加到这里 */
|
||||||
.checkin-container {
|
.container {
|
||||||
padding: 20rpx;
|
padding: 32rpx;
|
||||||
box-sizing: border-box;
|
display: flex;
|
||||||
}
|
flex-direction: column;
|
||||||
|
gap: 32rpx; /* 间距 */
|
||||||
/* 顶部信息区 */
|
}
|
||||||
.header {
|
|
||||||
background-color: #51bdb6;
|
/* 顶部统计卡片 */
|
||||||
border-radius: 20rpx;
|
.summary-card {
|
||||||
padding: 30rpx;
|
background: linear-gradient(135deg, #74cdb9, #52b19e); /* 渐变绿 */
|
||||||
color: #fff;
|
border-radius: 20rpx;
|
||||||
margin-bottom: 30rpx;
|
padding: 40rpx 32rpx;
|
||||||
box-shadow: 0 8rpx 16rpx rgba(81, 189, 182, 0.2);
|
box-shadow: 0 8rpx 24rpx rgba(82, 177, 158, 0.3);
|
||||||
}
|
color: #fff;
|
||||||
|
display: flex;
|
||||||
.month-info {
|
flex-direction: column;
|
||||||
font-size: 32rpx;
|
align-items: center;
|
||||||
font-weight: 500;
|
}
|
||||||
margin-bottom: 20rpx;
|
|
||||||
text-align: center;
|
.month-display {
|
||||||
}
|
font-size: 30rpx;
|
||||||
|
margin-bottom: 30rpx;
|
||||||
.checkin-stats {
|
font-weight: 500;
|
||||||
display: flex;
|
}
|
||||||
justify-content: space-around;
|
|
||||||
align-items: center;
|
.stats-row {
|
||||||
}
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
.stat-item {
|
width: 100%;
|
||||||
display: flex;
|
margin-bottom: 40rpx;
|
||||||
flex-direction: column;
|
align-items: center;
|
||||||
align-items: center;
|
}
|
||||||
}
|
|
||||||
|
.stat-item {
|
||||||
.stat-value {
|
display: flex;
|
||||||
font-size: 48rpx;
|
flex-direction: column;
|
||||||
font-weight: bold;
|
align-items: center;
|
||||||
line-height: 1;
|
width: 45%; /* 均分空间 */
|
||||||
margin-bottom: 10rpx;
|
}
|
||||||
}
|
|
||||||
|
.stat-number {
|
||||||
.stat-label {
|
font-size: 68rpx;
|
||||||
font-size: 24rpx;
|
font-weight: bold;
|
||||||
opacity: 0.9;
|
line-height: 1;
|
||||||
}
|
margin-bottom: 10rpx;
|
||||||
|
}
|
||||||
/* 签到按钮区 */
|
|
||||||
.checkin-button-area {
|
.stat-label {
|
||||||
display: flex;
|
font-size: 26rpx;
|
||||||
flex-direction: column;
|
opacity: 0.8;
|
||||||
align-items: center;
|
}
|
||||||
margin-bottom: 40rpx;
|
|
||||||
}
|
.divider-v {
|
||||||
|
width: 2rpx;
|
||||||
.checkin-btn {
|
height: 80rpx;
|
||||||
width: 240rpx;
|
background-color: rgba(255, 255, 255, 0.4);
|
||||||
height: 240rpx;
|
align-self: center;
|
||||||
border-radius: 50%;
|
}
|
||||||
background-color: #51bdb6;
|
|
||||||
color: #fff;
|
.today-checkin-box {
|
||||||
font-size: 34rpx;
|
margin-top: 30rpx;
|
||||||
font-weight: 500;
|
margin-bottom: 20rpx;
|
||||||
display: flex;
|
}
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
.checkin-button, .checked-in-status {
|
||||||
margin-bottom: 20rpx;
|
width: 180rpx;
|
||||||
box-shadow: 0 10rpx 20rpx rgba(81, 189, 182, 0.3);
|
height: 180rpx;
|
||||||
transition: all 0.3s ease;
|
border-radius: 50%;
|
||||||
border: none;
|
display: flex;
|
||||||
padding: 0;
|
align-items: center;
|
||||||
}
|
justify-content: center;
|
||||||
|
font-size: 36rpx;
|
||||||
.checkin-btn.checked {
|
font-weight: 600;
|
||||||
background-color: #e6f7f6;
|
transition: all 0.2s ease-in-out;
|
||||||
color: #51bdb6;
|
}
|
||||||
box-shadow: 0 5rpx 15rpx rgba(81, 189, 182, 0.2);
|
|
||||||
}
|
.checkin-button {
|
||||||
|
background-color: rgba(255, 255, 255, 0.2);
|
||||||
.checkin-btn.animating {
|
border: 4rpx solid rgba(255, 255, 255, 0.6);
|
||||||
animation: pulse 1s ease-in-out;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pulse {
|
.checkin-button:active {
|
||||||
0% { transform: scale(1); }
|
background-color: rgba(255, 255, 255, 0.3);
|
||||||
50% { transform: scale(1.1); }
|
transform: scale(0.98);
|
||||||
100% { transform: scale(1); }
|
}
|
||||||
}
|
|
||||||
|
.checked-in-status {
|
||||||
.btn-content {
|
background-color: rgba(255, 255, 255, 0.3); /* 已签到的淡背景 */
|
||||||
display: flex;
|
border: 4rpx solid rgba(255, 255, 255, 0.4);
|
||||||
flex-direction: column;
|
color: #fff;
|
||||||
align-items: center;
|
}
|
||||||
}
|
|
||||||
|
.checkin-tip {
|
||||||
/* 签到按钮内部的对勾图标样式控制 */
|
font-size: 26rpx;
|
||||||
.checkin-btn .check-icon {
|
opacity: 0.9;
|
||||||
width: 40rpx;
|
text-align: center;
|
||||||
height: auto;
|
margin-top: 10rpx;
|
||||||
margin-top: 10rpx;
|
}
|
||||||
display: none; /* 默认隐藏 */
|
|
||||||
}
|
/* 签到日历卡片 */
|
||||||
|
.calendar-card {
|
||||||
.checkin-btn.checked .check-icon {
|
background-color: #ffffff;
|
||||||
display: block; /* 仅在已签到状态下显示 */
|
border-radius: 20rpx;
|
||||||
}
|
padding: 32rpx;
|
||||||
|
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
|
||||||
.checkin-tip {
|
}
|
||||||
font-size: 26rpx;
|
|
||||||
color: #666;
|
.calendar-header {
|
||||||
text-align: center;
|
padding-bottom: 24rpx;
|
||||||
line-height: 1.5;
|
border-bottom: 1rpx solid #eee;
|
||||||
}
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
/* 日历签到区 - 核心修复区域 */
|
|
||||||
.calendar-section {
|
.calendar-title {
|
||||||
background-color: #fff;
|
font-size: 32rpx;
|
||||||
border-radius: 20rpx;
|
font-weight: 600;
|
||||||
padding: 30rpx;
|
color: #333333;
|
||||||
margin-bottom: 30rpx;
|
}
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
.calendar-weekdays {
|
||||||
|
display: grid;
|
||||||
.section-title {
|
grid-template-columns: repeat(7, 1fr);
|
||||||
font-size: 30rpx;
|
text-align: center;
|
||||||
font-weight: 500;
|
margin-bottom: 20rpx;
|
||||||
color: #333;
|
}
|
||||||
margin-bottom: 25rpx;
|
|
||||||
padding-left: 10rpx;
|
.weekday-item {
|
||||||
border-left: 6rpx solid #51bdb6;
|
font-size: 26rpx;
|
||||||
}
|
color: #999999;
|
||||||
|
padding: 10rpx 0;
|
||||||
.weekdays {
|
}
|
||||||
display: flex;
|
|
||||||
margin-bottom: 15rpx;
|
.calendar-days {
|
||||||
}
|
display: grid;
|
||||||
|
grid-template-columns: repeat(7, 1fr);
|
||||||
.weekday {
|
text-align: center;
|
||||||
flex: 1;
|
}
|
||||||
text-align: center;
|
|
||||||
font-size: 26rpx;
|
.day-item {
|
||||||
color: #999;
|
height: 80rpx;
|
||||||
padding: 10rpx 0;
|
display: flex;
|
||||||
}
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
.calendar-grid {
|
position: relative;
|
||||||
display: flex;
|
font-size: 30rpx;
|
||||||
flex-wrap: wrap;
|
color: #333333;
|
||||||
width: 100%;
|
line-height: 1; /* 确保文字不撑开 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 日期格子容器 */
|
/* 其他月份日期 */
|
||||||
.calendar-day {
|
.day-item.other-month {
|
||||||
width: 14.2857%; /* 7天平均分配宽度 */
|
color: #cccccc;
|
||||||
aspect-ratio: 1; /* 宽高比1:1 */
|
}
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
/* 今日高亮 */
|
||||||
align-items: center;
|
.day-item.today .day-content {
|
||||||
position: relative;
|
background-color: #ffeecc; /* 浅黄色背景 */
|
||||||
padding: 8rpx;
|
border-radius: 50%;
|
||||||
box-sizing: border-box;
|
width: 60rpx;
|
||||||
}
|
height: 60rpx;
|
||||||
|
display: flex;
|
||||||
/* 日期数字和圆圈 - 重点修复 */
|
align-items: center;
|
||||||
.day-number {
|
justify-content: center;
|
||||||
width: 60rpx;
|
}
|
||||||
height: 60rpx;
|
|
||||||
border-radius: 50%;
|
/* 已签到日期样式 */
|
||||||
display: flex;
|
.day-content.checked-in {
|
||||||
justify-content: center;
|
background-color: #52b19e; /* 绿色背景 */
|
||||||
align-items: center;
|
border-radius: 50%;
|
||||||
font-size: 28rpx;
|
width: 60rpx;
|
||||||
font-weight: 500;
|
height: 60rpx;
|
||||||
position: relative;
|
display: flex;
|
||||||
line-height: 1;
|
align-items: center;
|
||||||
color: #333; /* 默认颜色 */
|
justify-content: center;
|
||||||
}
|
color: #fff; /* 确保数字颜色为白色,在绿色背景上清晰可见 */
|
||||||
|
font-weight: 600;
|
||||||
/* 已签到状态 - 关键修复,确保数字可见 */
|
}
|
||||||
.calendar-day.checked .day-number {
|
|
||||||
background-color: #51bdb6; /* 绿色背景 */
|
/* 确保数字的样式 */
|
||||||
color: #ffffff; /* **纯白色文字,解决覆盖问题** */
|
.day-number {
|
||||||
font-weight: 600;
|
z-index: 2; /* 确保数字在背景之上 */
|
||||||
box-shadow: 0 2rpx 8rpx rgba(81, 189, 182, 0.4);
|
position: relative; /* 配合 z-index */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 今日未签到状态 */
|
/* 卡片整体点击态 */
|
||||||
.calendar-day.today .day-number {
|
.card-hover {
|
||||||
border: 2rpx solid #51bdb6;
|
transform: scale(0.99);
|
||||||
color: #51bdb6;
|
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
|
||||||
font-weight: 600;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* 空日期(上月/下月) */
|
|
||||||
.calendar-day.empty .day-number {
|
|
||||||
color: #eee;
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 签到对勾 - 调整位置 */
|
|
||||||
.check-mark {
|
|
||||||
position: absolute;
|
|
||||||
/* 将对勾放在圆圈的右下角作为修饰 */
|
|
||||||
right: 15rpx;
|
|
||||||
bottom: 10rpx;
|
|
||||||
width: 24rpx !important;
|
|
||||||
height: 24rpx !important;
|
|
||||||
opacity: 0.9;
|
|
||||||
z-index: 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 奖励区 */
|
|
||||||
.rewards-section {
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
padding: 30rpx;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.rewards-list {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reward-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 25rpx;
|
|
||||||
border-radius: 12rpx;
|
|
||||||
background-color: #f7f8fa;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reward-item.achieved {
|
|
||||||
background-color: #e6f7f6;
|
|
||||||
border-left: 6rpx solid #51bdb6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reward-days {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #333;
|
|
||||||
width: 160rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reward-separator {
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #ccc;
|
|
||||||
margin: 0 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reward-content {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #666;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reward-status {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #51bdb6;
|
|
||||||
gap: 8rpx;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user