feat(签到): 添加感恩次数统计功能
在签到页面增加今日感恩次数和累计感恩次数的显示 修改postCountModel组件条件渲染逻辑和可选链操作 更新API文档添加感恩次数相关字段
Showing
3 changed files
with
47 additions
and
7 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-06-06 09:26:16 | 2 | * @Date: 2025-06-06 09:26:16 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-16 17:54:43 | 4 | + * @LastEditTime: 2025-12-17 09:47:48 |
| 5 | * @FilePath: /mlaj/src/api/checkin.js | 5 | * @FilePath: /mlaj/src/api/checkin.js |
| 6 | * @Description: 签到模块相关接口 | 6 | * @Description: 签到模块相关接口 |
| 7 | */ | 7 | */ |
| ... | @@ -38,7 +38,14 @@ export const getTaskListAPI = (params) => fn(fetch.get(Api.GET_TASK_LIST, param | ... | @@ -38,7 +38,14 @@ export const getTaskListAPI = (params) => fn(fetch.get(Api.GET_TASK_LIST, param |
| 38 | * @param: i 作业ID | 38 | * @param: i 作业ID |
| 39 | * @param: month 月份 | 39 | * @param: month 月份 |
| 40 | * @param: subtask_id 小作业ID | 40 | * @param: subtask_id 小作业ID |
| 41 | - * @returns data: { id 大作业id, cover 封面图, title 大作业名称, note 大作业描述, frequency 交作业的频次, cycle 交作业的周期 {0=本周期 | 30=每月 | 7=每周 | 1=每日}, attachment_type 上传附件的类型 [text=文本 image=图片 video=视频 audio=音频], begin_date 开始时间, end_date 结束时间, task_type 任务类型 [checkin=签到 | upload=上传附件 | count=计数], is_gray 作业是否应该置灰, is_finish 作业在当前周期是否已经达标, my_checkin_dates[] 我在日历中打过卡的日期, makeup_checkin_dates[] 我在日历中,可以补卡的日期, target_number 打卡的目标数量, checkin_number 已经打卡的数量, checkin_avatars 最后打卡的10个人的头像, subtask_list 小作业列表 [{id,title,cycle,frequency,attachment_type,begin_date,end_date,is_finish}] } | 41 | + * @returns data: { |
| 42 | + * id 大作业id, cover 封面图, title 大作业名称, note 大作业描述, frequency 交作业的频次, cycle 交作业的周期 {0=本周期 | 30=每月 | 7=每周 | 1=每日}, | ||
| 43 | + * attachment_type 上传附件的类型 [text=文本 image=图片 video=视频 audio=音频], begin_date 开始时间, end_date 结束时间, | ||
| 44 | + * task_type 任务类型 [checkin=签到 | upload=上传附件 | count=计数], is_gray 作业是否应该置灰, is_finish 作业在当前周期是否已经达标, | ||
| 45 | + * my_checkin_dates[] 我在日历中打过卡的日期, makeup_checkin_dates[] 我在日历中,可以补卡的日期, target_number 打卡的目标数量, | ||
| 46 | + * checkin_number 已经打卡的数量, checkin_avatars 最后打卡的10个人的头像, my_today_gratitude_count 我在今天的感恩次数, my_total_gratitude_count 我累计感恩次数, | ||
| 47 | + * subtask_list 小作业列表 [{id,title,cycle,frequency,attachment_type,begin_date,end_date,is_finish}] , | ||
| 48 | + * } | ||
| 42 | */ | 49 | */ |
| 43 | export const getTaskDetailAPI = (params) => fn(fetch.get(Api.GET_TASK_DETAIL, params)) | 50 | export const getTaskDetailAPI = (params) => fn(fetch.get(Api.GET_TASK_DETAIL, params)) |
| 44 | 51 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-12-11 17:26:25 | 2 | * @Date: 2025-12-11 17:26:25 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-17 09:38:07 | 4 | + * @LastEditTime: 2025-12-17 09:45:05 |
| 5 | * @FilePath: /mlaj/src/components/count/postCountModel.vue | 5 | * @FilePath: /mlaj/src/components/count/postCountModel.vue |
| 6 | * @Description: 发布作业统计模型(包括感恩次数和感恩对象) | 6 | * @Description: 发布作业统计模型(包括感恩次数和感恩对象) |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | - <div v-if="postData.gratitude_count || postData.gratitude_form_list.length" class="post-count-model"> | 9 | + <div v-if="postData.gratitude_count" class="post-count-model"> |
| 10 | <div class="flex justify-between items-center mb-2"> | 10 | <div class="flex justify-between items-center mb-2"> |
| 11 | <div class="text-gray-500">感恩次数: </div> | 11 | <div class="text-gray-500">感恩次数: </div> |
| 12 | <div class="font-bold">{{ postData.gratitude_count }} 次</div> | 12 | <div class="font-bold">{{ postData.gratitude_count }} 次</div> |
| 13 | </div> | 13 | </div> |
| 14 | <div class="flex justify-between items-center"> | 14 | <div class="flex justify-between items-center"> |
| 15 | <div class="text-gray-500">感恩对象: </div> | 15 | <div class="text-gray-500">感恩对象: </div> |
| 16 | - <div class="font-bold">{{ postData.gratitude_form_list.map(item => item.name).join('、') }}</div> | 16 | + <div class="font-bold">{{ postData.gratitude_form_list?.map(item => item.name).join('、') }}</div> |
| 17 | </div> | 17 | </div> |
| 18 | </div> | 18 | </div> |
| 19 | </template> | 19 | </template> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-05-29 15:34:17 | 2 | * @Date: 2025-05-29 15:34:17 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-17 09:39:20 | 4 | + * @LastEditTime: 2025-12-17 10:05:41 |
| 5 | * @FilePath: /mlaj/src/views/checkin/IndexCheckInPage.vue | 5 | * @FilePath: /mlaj/src/views/checkin/IndexCheckInPage.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -25,6 +25,30 @@ | ... | @@ -25,6 +25,30 @@ |
| 25 | 25 | ||
| 26 | <!-- 可滚动的内容区域 --> | 26 | <!-- 可滚动的内容区域 --> |
| 27 | <div class="scrollable-content"> | 27 | <div class="scrollable-content"> |
| 28 | + <div v-if="taskDetail.task_type === 'count'" class="text-wrapper" style="padding-bottom: 0;"> | ||
| 29 | + <div class="text-header">我的{{ dynamicFieldText }}</div> | ||
| 30 | + <div style="margin: 0.5rem 0;"> | ||
| 31 | + <div class="flex items-center"> | ||
| 32 | + <!-- 今日次数 --> | ||
| 33 | + <div class="flex-1 flex flex-col items-center border-r border-gray-100"> | ||
| 34 | + <div class="flex items-baseline"> | ||
| 35 | + <span class="text-3xl font-bold text-[#4caf50] leading-none">{{ myTodayGratitudeCount }}</span> | ||
| 36 | + <span class="text-xs text-gray-400 ml-1 transform translate-y-0.5">次</span> | ||
| 37 | + </div> | ||
| 38 | + <div class="text-xs text-gray-500 mt-2">今日次数</div> | ||
| 39 | + </div> | ||
| 40 | + <!-- 累计次数 --> | ||
| 41 | + <div class="flex-1 flex flex-col items-center"> | ||
| 42 | + <div class="flex items-baseline"> | ||
| 43 | + <span class="text-3xl font-bold text-[#ff9800] leading-none" style="color: #ff9800;">{{ myTotalGratitudeCount }}</span> | ||
| 44 | + <span class="text-xs text-gray-400 ml-1 transform translate-y-0.5">次</span> | ||
| 45 | + </div> | ||
| 46 | + <div class="text-xs text-gray-500 mt-2">累计次数</div> | ||
| 47 | + </div> | ||
| 48 | + </div> | ||
| 49 | + </div> | ||
| 50 | + </div> | ||
| 51 | + | ||
| 28 | <div v-if="showProgress" class="text-wrapper"> | 52 | <div v-if="showProgress" class="text-wrapper"> |
| 29 | <div class="text-header">目标进度</div> | 53 | <div class="text-header">目标进度</div> |
| 30 | <div style="background-color: #FFF; margin-top: 1rem;"> | 54 | <div style="background-color: #FFF; margin-top: 1rem;"> |
| ... | @@ -60,7 +84,6 @@ | ... | @@ -60,7 +84,6 @@ |
| 60 | </div> | 84 | </div> |
| 61 | </div> | 85 | </div> |
| 62 | 86 | ||
| 63 | - | ||
| 64 | <div class="text-wrapper"> | 87 | <div class="text-wrapper"> |
| 65 | <div class="text-header">打卡动态</div> | 88 | <div class="text-header">打卡动态</div> |
| 66 | <van-list | 89 | <van-list |
| ... | @@ -133,6 +156,9 @@ const route = useRoute() | ... | @@ -133,6 +156,9 @@ const route = useRoute() |
| 133 | const router = useRouter() | 156 | const router = useRouter() |
| 134 | useTitle(route.meta.title); | 157 | useTitle(route.meta.title); |
| 135 | 158 | ||
| 159 | +// 动态字段文字 | ||
| 160 | +const dynamicFieldText = ref('感恩') | ||
| 161 | + | ||
| 136 | const myRefCalendar = ref(null); | 162 | const myRefCalendar = ref(null); |
| 137 | 163 | ||
| 138 | // 窗口尺寸相关的响应式数据 | 164 | // 窗口尺寸相关的响应式数据 |
| ... | @@ -521,6 +547,11 @@ const isPatchCheckin = ref(false); | ... | @@ -521,6 +547,11 @@ const isPatchCheckin = ref(false); |
| 521 | // 作品类型选项 | 547 | // 作品类型选项 |
| 522 | const attachmentTypeOptions = ref([]); | 548 | const attachmentTypeOptions = ref([]); |
| 523 | 549 | ||
| 550 | +// 今日计数次数 | ||
| 551 | +const myTodayGratitudeCount = ref(0); | ||
| 552 | +// 累计计数次数 | ||
| 553 | +const myTotalGratitudeCount = ref(0); | ||
| 554 | + | ||
| 524 | const getTaskDetail = async (month) => { | 555 | const getTaskDetail = async (month) => { |
| 525 | const { code, data } = await getTaskDetailAPI({ i: route.query.id, month, subtask_id: selectedSubtaskId.value }); | 556 | const { code, data } = await getTaskDetailAPI({ i: route.query.id, month, subtask_id: selectedSubtaskId.value }); |
| 526 | if (code) { | 557 | if (code) { |
| ... | @@ -536,6 +567,8 @@ const getTaskDetail = async (month) => { | ... | @@ -536,6 +567,8 @@ const getTaskDetail = async (month) => { |
| 536 | // myCheckinDates.value = myCheckinDates.value.map(date => { | 567 | // myCheckinDates.value = myCheckinDates.value.map(date => { |
| 537 | // return dayjs(date).date(); | 568 | // return dayjs(date).date(); |
| 538 | // }) | 569 | // }) |
| 570 | + myTodayGratitudeCount.value = data.my_today_gratitude_count; | ||
| 571 | + myTotalGratitudeCount.value = data.my_total_gratitude_count; | ||
| 539 | } | 572 | } |
| 540 | } | 573 | } |
| 541 | 574 | ... | ... |
-
Please register or login to post a comment