|
@@ -65,7 +65,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<!-- 打卡功能区域 -->
|
|
<!-- 打卡功能区域 -->
|
|
|
- <view class="checkin-card" v-if="checkinTasks.length > 0">
|
|
|
|
|
|
|
+ <!-- <view class="checkin-card" v-if="checkinTasks.length > 0">
|
|
|
<view class="card-header">
|
|
<view class="card-header">
|
|
|
<text class="card-title">今日打卡</text>
|
|
<text class="card-title">今日打卡</text>
|
|
|
<text class="card-subtitle">{{ currentDate }}</text>
|
|
<text class="card-subtitle">{{ currentDate }}</text>
|
|
@@ -82,7 +82,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
- </view>
|
|
|
|
|
|
|
+ </view> -->
|
|
|
|
|
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -118,17 +118,17 @@ const avatarSrc = computed(() => {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// 打卡任务相关数据
|
|
// 打卡任务相关数据
|
|
|
-const checkinTasks = ref<Array<{
|
|
|
|
|
- time: string
|
|
|
|
|
- type: string
|
|
|
|
|
- checked: boolean
|
|
|
|
|
-}>>([])
|
|
|
|
|
|
|
+// const checkinTasks = ref<Array<{
|
|
|
|
|
+// time: string
|
|
|
|
|
+// type: string
|
|
|
|
|
+// checked: boolean
|
|
|
|
|
+// }>>([])
|
|
|
|
|
|
|
|
// 当前日期
|
|
// 当前日期
|
|
|
-const currentDate = computed(() => {
|
|
|
|
|
- const now = new Date()
|
|
|
|
|
- return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`
|
|
|
|
|
-})
|
|
|
|
|
|
|
+// const currentDate = computed(() => {
|
|
|
|
|
+// const now = new Date()
|
|
|
|
|
+// return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`
|
|
|
|
|
+// })
|
|
|
|
|
|
|
|
const loadUser = () => {
|
|
const loadUser = () => {
|
|
|
try {
|
|
try {
|
|
@@ -193,135 +193,135 @@ const fetchUserInfo = async () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 生成打卡任务
|
|
// 生成打卡任务
|
|
|
-const generateCheckinTasks = () => {
|
|
|
|
|
- try {
|
|
|
|
|
- // 获取本地存储的提醒设置
|
|
|
|
|
- const patientReminders = uni.getStorageSync('patientReminders')
|
|
|
|
|
- if (!patientReminders) {
|
|
|
|
|
- console.log('未找到本地提醒设置')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 获取今天的打卡记录
|
|
|
|
|
- const today = currentDate.value
|
|
|
|
|
- const checkinRecords = uni.getStorageSync('checkinRecords') || {}
|
|
|
|
|
- const todayRecords = checkinRecords[today] || {}
|
|
|
|
|
-
|
|
|
|
|
- const tasks: Array<{ time: string; type: string; checked: boolean }> = []
|
|
|
|
|
-
|
|
|
|
|
- // 处理血压测量任务
|
|
|
|
|
- if (patientReminders.bloodPressureReminder?.enabled) {
|
|
|
|
|
- patientReminders.bloodPressureReminder.times.forEach((time: string) => {
|
|
|
|
|
- tasks.push({
|
|
|
|
|
- time,
|
|
|
|
|
- type: '测量血压',
|
|
|
|
|
- checked: !!todayRecords[`bloodPressure_${time}`]
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 处理血糖测量任务
|
|
|
|
|
- if (patientReminders.bloodSugarReminder?.enabled) {
|
|
|
|
|
- patientReminders.bloodSugarReminder.times.forEach((time: string) => {
|
|
|
|
|
- tasks.push({
|
|
|
|
|
- time,
|
|
|
|
|
- type: '测量血糖',
|
|
|
|
|
- checked: !!todayRecords[`bloodSugar_${time}`]
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 处理心率测量任务
|
|
|
|
|
- if (patientReminders.heartRateReminder?.enabled) {
|
|
|
|
|
- patientReminders.heartRateReminder.times.forEach((time: string) => {
|
|
|
|
|
- tasks.push({
|
|
|
|
|
- time,
|
|
|
|
|
- type: '测量心率',
|
|
|
|
|
- checked: !!todayRecords[`heartRate_${time}`]
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 处理用药提醒任务
|
|
|
|
|
- if (patientReminders.medicationReminder?.enabled) {
|
|
|
|
|
- patientReminders.medicationReminder.times.forEach((time: string) => {
|
|
|
|
|
- tasks.push({
|
|
|
|
|
- time,
|
|
|
|
|
- type: '用药提醒',
|
|
|
|
|
- checked: !!todayRecords[`medication_${time}`]
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 按时间排序
|
|
|
|
|
- tasks.sort((a, b) => a.time.localeCompare(b.time))
|
|
|
|
|
-
|
|
|
|
|
- checkinTasks.value = tasks
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.error('生成打卡任务失败:', e)
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// const generateCheckinTasks = () => {
|
|
|
|
|
+// try {
|
|
|
|
|
+// // 获取本地存储的提醒设置
|
|
|
|
|
+// const patientReminders = uni.getStorageSync('patientReminders')
|
|
|
|
|
+// if (!patientReminders) {
|
|
|
|
|
+// console.log('未找到本地提醒设置')
|
|
|
|
|
+// return
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 获取今天的打卡记录
|
|
|
|
|
+// const today = currentDate.value
|
|
|
|
|
+// const checkinRecords = uni.getStorageSync('checkinRecords') || {}
|
|
|
|
|
+// const todayRecords = checkinRecords[today] || {}
|
|
|
|
|
+
|
|
|
|
|
+// const tasks: Array<{ time: string; type: string; checked: boolean }> = []
|
|
|
|
|
+
|
|
|
|
|
+// // 处理血压测量任务
|
|
|
|
|
+// if (patientReminders.bloodPressureReminder?.enabled) {
|
|
|
|
|
+// patientReminders.bloodPressureReminder.times.forEach((time: string) => {
|
|
|
|
|
+// tasks.push({
|
|
|
|
|
+// time,
|
|
|
|
|
+// type: '测量血压',
|
|
|
|
|
+// checked: !!todayRecords[`bloodPressure_${time}`]
|
|
|
|
|
+// })
|
|
|
|
|
+// })
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 处理血糖测量任务
|
|
|
|
|
+// if (patientReminders.bloodSugarReminder?.enabled) {
|
|
|
|
|
+// patientReminders.bloodSugarReminder.times.forEach((time: string) => {
|
|
|
|
|
+// tasks.push({
|
|
|
|
|
+// time,
|
|
|
|
|
+// type: '测量血糖',
|
|
|
|
|
+// checked: !!todayRecords[`bloodSugar_${time}`]
|
|
|
|
|
+// })
|
|
|
|
|
+// })
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 处理心率测量任务
|
|
|
|
|
+// if (patientReminders.heartRateReminder?.enabled) {
|
|
|
|
|
+// patientReminders.heartRateReminder.times.forEach((time: string) => {
|
|
|
|
|
+// tasks.push({
|
|
|
|
|
+// time,
|
|
|
|
|
+// type: '测量心率',
|
|
|
|
|
+// checked: !!todayRecords[`heartRate_${time}`]
|
|
|
|
|
+// })
|
|
|
|
|
+// })
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 处理用药提醒任务
|
|
|
|
|
+// if (patientReminders.medicationReminder?.enabled) {
|
|
|
|
|
+// patientReminders.medicationReminder.times.forEach((time: string) => {
|
|
|
|
|
+// tasks.push({
|
|
|
|
|
+// time,
|
|
|
|
|
+// type: '用药提醒',
|
|
|
|
|
+// checked: !!todayRecords[`medication_${time}`]
|
|
|
|
|
+// })
|
|
|
|
|
+// })
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 按时间排序
|
|
|
|
|
+// tasks.sort((a, b) => a.time.localeCompare(b.time))
|
|
|
|
|
+
|
|
|
|
|
+// checkinTasks.value = tasks
|
|
|
|
|
+// } catch (e) {
|
|
|
|
|
+// console.error('生成打卡任务失败:', e)
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// 切换打卡状态
|
|
// 切换打卡状态
|
|
|
-const toggleCheckin = (task: { time: string; type: string }) => {
|
|
|
|
|
- try {
|
|
|
|
|
- const today = currentDate.value
|
|
|
|
|
- const checkinRecords = uni.getStorageSync('checkinRecords') || {}
|
|
|
|
|
-
|
|
|
|
|
- // 初始化今天的记录
|
|
|
|
|
- if (!checkinRecords[today]) {
|
|
|
|
|
- checkinRecords[today] = {}
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 生成任务键名
|
|
|
|
|
- let taskKey = ''
|
|
|
|
|
- if (task.type === '测量血压') {
|
|
|
|
|
- taskKey = `bloodPressure_${task.time}`
|
|
|
|
|
- } else if (task.type === '测量血糖') {
|
|
|
|
|
- taskKey = `bloodSugar_${task.time}`
|
|
|
|
|
- } else if (task.type === '测量心率') {
|
|
|
|
|
- taskKey = `heartRate_${task.time}`
|
|
|
|
|
- } else if (task.type === '用药提醒') {
|
|
|
|
|
- taskKey = `medication_${task.time}`
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 切换打卡状态
|
|
|
|
|
- checkinRecords[today][taskKey] = !checkinRecords[today][taskKey]
|
|
|
|
|
-
|
|
|
|
|
- // 保存到本地存储
|
|
|
|
|
- uni.setStorageSync('checkinRecords', checkinRecords)
|
|
|
|
|
-
|
|
|
|
|
- // 更新界面显示
|
|
|
|
|
- generateCheckinTasks()
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.error('切换打卡状态失败:', e)
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// const toggleCheckin = (task: { time: string; type: string }) => {
|
|
|
|
|
+// try {
|
|
|
|
|
+// const today = currentDate.value
|
|
|
|
|
+// const checkinRecords = uni.getStorageSync('checkinRecords') || {}
|
|
|
|
|
+
|
|
|
|
|
+// // 初始化今天的记录
|
|
|
|
|
+// if (!checkinRecords[today]) {
|
|
|
|
|
+// checkinRecords[today] = {}
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 生成任务键名
|
|
|
|
|
+// let taskKey = ''
|
|
|
|
|
+// if (task.type === '测量血压') {
|
|
|
|
|
+// taskKey = `bloodPressure_${task.time}`
|
|
|
|
|
+// } else if (task.type === '测量血糖') {
|
|
|
|
|
+// taskKey = `bloodSugar_${task.time}`
|
|
|
|
|
+// } else if (task.type === '测量心率') {
|
|
|
|
|
+// taskKey = `heartRate_${task.time}`
|
|
|
|
|
+// } else if (task.type === '用药提醒') {
|
|
|
|
|
+// taskKey = `medication_${task.time}`
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// // 切换打卡状态
|
|
|
|
|
+// checkinRecords[today][taskKey] = !checkinRecords[today][taskKey]
|
|
|
|
|
+
|
|
|
|
|
+// // 保存到本地存储
|
|
|
|
|
+// uni.setStorageSync('checkinRecords', checkinRecords)
|
|
|
|
|
+
|
|
|
|
|
+// // 更新界面显示
|
|
|
|
|
+// generateCheckinTasks()
|
|
|
|
|
+// } catch (e) {
|
|
|
|
|
+// console.error('切换打卡状态失败:', e)
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// 清理过期的打卡记录
|
|
// 清理过期的打卡记录
|
|
|
-const cleanExpiredCheckinRecords = () => {
|
|
|
|
|
- try {
|
|
|
|
|
- const checkinRecords = uni.getStorageSync('checkinRecords') || {}
|
|
|
|
|
- const today = currentDate.value
|
|
|
|
|
- const keys = Object.keys(checkinRecords)
|
|
|
|
|
-
|
|
|
|
|
- // 只保留最近7天的记录
|
|
|
|
|
- const sevenDaysAgo = new Date()
|
|
|
|
|
- sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7)
|
|
|
|
|
-
|
|
|
|
|
- const cleanedRecords: Record<string, any> = {}
|
|
|
|
|
- keys.forEach(key => {
|
|
|
|
|
- // 简单的日期比较(格式:YYYY-MM-DD)
|
|
|
|
|
- if (key >= sevenDaysAgo.toISOString().split('T')[0] || key === today) {
|
|
|
|
|
- cleanedRecords[key] = checkinRecords[key]
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- uni.setStorageSync('checkinRecords', cleanedRecords)
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.error('清理过期打卡记录失败:', e)
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// const cleanExpiredCheckinRecords = () => {
|
|
|
|
|
+// try {
|
|
|
|
|
+// const checkinRecords = uni.getStorageSync('checkinRecords') || {}
|
|
|
|
|
+// const today = currentDate.value
|
|
|
|
|
+// const keys = Object.keys(checkinRecords)
|
|
|
|
|
+
|
|
|
|
|
+// // 只保留最近7天的记录
|
|
|
|
|
+// const sevenDaysAgo = new Date()
|
|
|
|
|
+// sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7)
|
|
|
|
|
+
|
|
|
|
|
+// const cleanedRecords: Record<string, any> = {}
|
|
|
|
|
+// keys.forEach(key => {
|
|
|
|
|
+// // 简单的日期比较(格式:YYYY-MM-DD)
|
|
|
|
|
+// if (key >= sevenDaysAgo.toISOString().split('T')[0] || key === today) {
|
|
|
|
|
+// cleanedRecords[key] = checkinRecords[key]
|
|
|
|
|
+// }
|
|
|
|
|
+// })
|
|
|
|
|
+
|
|
|
|
|
+// uni.setStorageSync('checkinRecords', cleanedRecords)
|
|
|
|
|
+// } catch (e) {
|
|
|
|
|
+// console.error('清理过期打卡记录失败:', e)
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// 如果在微信小程序端且未登录,自动跳转到登录页
|
|
// 如果在微信小程序端且未登录,自动跳转到登录页
|
|
|
onShow(() => {
|
|
onShow(() => {
|
|
@@ -332,9 +332,9 @@ onShow(() => {
|
|
|
} else {
|
|
} else {
|
|
|
fetchUserInfo()
|
|
fetchUserInfo()
|
|
|
// 生成打卡任务
|
|
// 生成打卡任务
|
|
|
- generateCheckinTasks()
|
|
|
|
|
|
|
+ // generateCheckinTasks()
|
|
|
// 清理过期记录
|
|
// 清理过期记录
|
|
|
- cleanExpiredCheckinRecords()
|
|
|
|
|
|
|
+ // cleanExpiredCheckinRecords()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -343,7 +343,7 @@ onMounted(() => {
|
|
|
uni.$on('reminderSettingsUpdated', () => {
|
|
uni.$on('reminderSettingsUpdated', () => {
|
|
|
// 延迟一点时间确保本地存储已更新
|
|
// 延迟一点时间确保本地存储已更新
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
- generateCheckinTasks()
|
|
|
|
|
|
|
+ // generateCheckinTasks()
|
|
|
}, 100)
|
|
}, 100)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|