Skip to content

LimeDailyPunch 打卡签到日历

一款签到打卡的日历插件,数据驱动,支持补签和统计连续打卡天数。兼容uniapp/uniappx。

插件依赖:lime-style,lime-shared

基础功能

  • 支持自定义打卡日期
  • 支持补签功能
  • 统计连续打卡天数
  • 支持切换月份
  • 支持自定义样式

文档链接

📚 组件详细文档请访问以下站点:

安装方法

  1. 在uni-app插件市场入口 中搜索并导入lime-daily-punch
  2. 首次导入可能需要重新编译

代码演示

基础使用

通过设置signedDates传入已经打卡的日期

html
<l-daily-punch :signedDates="checkIns"></l-daily-punch>
js
// 已打卡
const checkIns = ref(['2024-09-12','2024-09-02','2024-09-10','2024-09-03'])

事件

当点击日期时,触发select事件,当传入已打卡日期会触发streak事件,这事件是统计连续打卡天数,当切换月份时触发panelChange

html
<l-daily-punch :signedDates="checkIns" @select="select" @panelChange="change"></l-daily-punch>
js
import { LimeDailyPunchDay,  LimeDailyPunchYearMonth} from '@/uni_modules/lime-daily-punch'

// 已打卡
const checkIns = ref(['2024-09-12','2024-09-02','2024-09-10','2024-09-03'])

const select = (day : LimeDailyPunchDay) => {
	if (day.canSupplement) {
		uni.showModal({
			title: '补签',
			content: '是否补签?',
			success: (res : ShowModalSuccess) => {
				if (!res.confirm) return
				checkIns.value.push(day.fullDate)
			}
		})
	}
	if(!day.isCheckedIn) {
		console.log('已签')
		uni.showModal({
			title: '签到',
			content: '是否签到?',
			success: (res : ShowModalSuccess) => {
				if (!res.confirm) return
				checkIns.value.push(day.fullDate)
			}
		})
	}
	if(day.isToday) {
		console.log('今天')
	}
}

const change = (res: LimeDailyPunchYearMonth) => {
	console.log('res', res)
}

快速预览

导入插件后,可以直接使用以下标签查看演示效果:

html
<!-- 代码位于 uni_modules/lime-daily-punch/components/lime-daily-punch -->
<lime-daily-punch />

插件标签说明

  • l-daily-punch:打卡日历组件
  • lime-daily-punch:演示标签

API文档

Props

参数说明类型默认值
canSupplement是否支持补签booleantrue
yearMonth显示年月,格式:YYYY-MMstring当前月份
signedDates打卡数据,格式:YYYY-MM-DD[]string[][]
dayHeight天格子的高度number76
week星期string[]['周日', '周一', '周二', '周三', '周四', '周五', '周六']
weekStartsOn星期几为一周的开始,默认是6,即周一number6
weekColor星期文本颜色string#BDC0C3
weekFontSize星期文本字体number14
weekHeight星期文本高度number30
selectedDayBgColor选择中背景色stringrgba(0,0,0,0.06)
dayFontSize天的字体大小number16
textColor文本颜色string#1A1F24
disabledColor禁用颜色(日历中非本月的日期,week文本)string#BDC0C3
monthTitleHeight日历年月标题高度number50
monthTitleFontSize日历年月标题字体大小number20
color主色,签到和today选中颜色string#3B87F6
unsignedColor可补签小点颜色string#F1A33A'

主题定制

组件提供了以下CSS变量,可用于自定义样式:
组件在uniappx是基于canvas故不支持变量,仅uniapp支持

变量名称默认值说明
--l-daily-punch-month-title-height50px月份标题高度
--l-daily-punch-month-title-font-size18px月份标题字体大小
--l-daily-punch-month-title-color#1A1F24月份标题颜色
--l-daily-punch-arrow-size28px月份切换箭头大小
--l-daily-punch-arrow-color#A0A5AA月份切换箭头颜色
--l-daily-punch-week-height30px星期栏高度
--l-daily-punch-week-font-size$font-size星期文字大小
--l-daily-punch-week-color#BDC0C3星期文字颜色
--l-daily-punch-day-height76px日期单元格高度
--l-daily-punch-day-font-size$spacer日期文字大小
--l-daily-punch-text-color#1A1F24日期文字颜色
--l-daily-punch-disabled-color#BDC0C3禁用日期颜色
--l-daily-punch-dot-size6px状态点大小
--l-daily-punch-color#3B87F6已打卡状态颜色
--l-daily-punch-unsigned-color#F1A33A未打卡状态颜色
--l-daily-punch-selected-bg-color$fill-2选中状态背景色

支持与赞赏

如果你觉得本插件解决了你的问题,可以考虑支持作者:

支付宝赞助微信赞助

源代码

组件源码