feat(打卡): 重构打卡页面并提取公共逻辑到composable
- 将打卡按钮改为底部悬浮样式 - 统一编辑跳转逻辑到CheckinDetailPage - 提取打卡相关逻辑到useCheckin composable - 优化打卡详情页的UI和交互
Showing
3 changed files
with
50 additions
and
43 deletions
src/composables/useCheckin.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
| 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-09-30 17:02:29 | 4 | + * @LastEditTime: 2025-09-30 17:58:09 |
| 5 | * @FilePath: /mlaj/src/views/checkin/IndexCheckInPage.vue | 5 | * @FilePath: /mlaj/src/views/checkin/IndexCheckInPage.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -57,19 +57,6 @@ | ... | @@ -57,19 +57,6 @@ |
| 57 | </div> | 57 | </div> |
| 58 | </div> | 58 | </div> |
| 59 | 59 | ||
| 60 | - <!-- 我要打卡按钮 --> | ||
| 61 | - <div v-if="!taskDetail.is_finish" class="text-wrapper" style="padding-bottom: 0;"> | ||
| 62 | - <van-button | ||
| 63 | - type="primary" | ||
| 64 | - block | ||
| 65 | - round | ||
| 66 | - @click="goToCheckinDetailPage" | ||
| 67 | - class="checkin-action-button" | ||
| 68 | - > | ||
| 69 | - <van-icon name="edit" size="1.2rem" /> | ||
| 70 | - <span style="margin-left: 0.5rem;">我要打卡</span> | ||
| 71 | - </van-button> | ||
| 72 | - </div> | ||
| 73 | 60 | ||
| 74 | <div class="text-wrapper"> | 61 | <div class="text-wrapper"> |
| 75 | <div class="text-header">打卡动态</div> | 62 | <div class="text-header">打卡动态</div> |
| ... | @@ -162,13 +149,26 @@ | ... | @@ -162,13 +149,26 @@ |
| 162 | <van-back-top right="5vw" bottom="10vh" /> | 149 | <van-back-top right="5vw" bottom="10vh" /> |
| 163 | </div> | 150 | </div> |
| 164 | 151 | ||
| 165 | - <div style="height: 5rem;"></div> | 152 | + <div style="height: 10rem;"></div> |
| 166 | </div> <!-- 闭合 scrollable-content --> | 153 | </div> <!-- 闭合 scrollable-content --> |
| 167 | </van-config-provider> | 154 | </van-config-provider> |
| 168 | 155 | ||
| 169 | <van-dialog v-model:show="dialog_show" title="标题" show-cancel-button></van-dialog> | 156 | <van-dialog v-model:show="dialog_show" title="标题" show-cancel-button></van-dialog> |
| 170 | 157 | ||
| 171 | <van-back-top right="5vw" bottom="15vh" /> | 158 | <van-back-top right="5vw" bottom="15vh" /> |
| 159 | + | ||
| 160 | + <!-- 底部悬浮打卡按钮 --> | ||
| 161 | + <div v-if="!taskDetail.is_finish" class="floating-checkin-button"> | ||
| 162 | + <van-button | ||
| 163 | + type="primary" | ||
| 164 | + round | ||
| 165 | + @click="goToCheckinDetailPage" | ||
| 166 | + class="checkin-action-button" | ||
| 167 | + > | ||
| 168 | + <van-icon name="edit" size="1.2rem" /> | ||
| 169 | + <span style="margin-left: 0.5rem;">我要打卡</span> | ||
| 170 | + </van-button> | ||
| 171 | + </div> | ||
| 172 | </AppLayout> | 172 | </AppLayout> |
| 173 | </template> | 173 | </template> |
| 174 | 174 | ||
| ... | @@ -606,34 +606,15 @@ const handLike = async (post) => { | ... | @@ -606,34 +606,15 @@ const handLike = async (post) => { |
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | const editCheckin = (post) => { | 608 | const editCheckin = (post) => { |
| 609 | - if (post.file_type === 'image') { | 609 | + // 统一跳转到CheckinDetailPage页面处理所有类型的编辑 |
| 610 | - router.push({ | 610 | + router.push({ |
| 611 | - path: '/checkin/image', | 611 | + path: '/checkin/detail', |
| 612 | - query: { | 612 | + query: { |
| 613 | - post_id: post.id, | 613 | + post_id: post.id, |
| 614 | - type: 'image', | 614 | + type: post.file_type, |
| 615 | - status: 'edit', | 615 | + status: 'edit', |
| 616 | - } | 616 | + } |
| 617 | - }) | 617 | + }) |
| 618 | - } else if (post.file_type === 'video') { | ||
| 619 | - router.push({ | ||
| 620 | - path: '/checkin/video', | ||
| 621 | - query: { | ||
| 622 | - post_id: post.id, | ||
| 623 | - type: 'video', | ||
| 624 | - status: 'edit', | ||
| 625 | - } | ||
| 626 | - }) | ||
| 627 | - } else if (post.file_type === 'audio') { | ||
| 628 | - router.push({ | ||
| 629 | - path: '/checkin/audio', | ||
| 630 | - query: { | ||
| 631 | - post_id: post.id, | ||
| 632 | - type: 'audio', | ||
| 633 | - status: 'edit', | ||
| 634 | - } | ||
| 635 | - }) | ||
| 636 | - } | ||
| 637 | } | 618 | } |
| 638 | 619 | ||
| 639 | const delCheckin = (post) => { | 620 | const delCheckin = (post) => { |
| ... | @@ -651,6 +632,13 @@ const delCheckin = (post) => { | ... | @@ -651,6 +632,13 @@ const delCheckin = (post) => { |
| 651 | // router.go(0); | 632 | // router.go(0); |
| 652 | // 删除post_id相应的数据 | 633 | // 删除post_id相应的数据 |
| 653 | checkinDataList.value = checkinDataList.value.filter(item => item.id !== post.id); | 634 | checkinDataList.value = checkinDataList.value.filter(item => item.id !== post.id); |
| 635 | + // 检查是否还可以打卡 | ||
| 636 | + const current_date = route.query.date; | ||
| 637 | + if (current_date) { | ||
| 638 | + getTaskDetail(dayjs(current_date).format('YYYY-MM')); | ||
| 639 | + } else { | ||
| 640 | + getTaskDetail(dayjs().format('YYYY-MM')); | ||
| 641 | + } | ||
| 654 | } else { | 642 | } else { |
| 655 | showErrorToast('删除失败'); | 643 | showErrorToast('删除失败'); |
| 656 | } | 644 | } |
| ... | @@ -957,6 +945,25 @@ const formatData = (data) => { | ... | @@ -957,6 +945,25 @@ const formatData = (data) => { |
| 957 | </style> | 945 | </style> |
| 958 | 946 | ||
| 959 | <style scoped> | 947 | <style scoped> |
| 948 | +/* 底部悬浮打卡按钮样式 */ | ||
| 949 | +.floating-checkin-button { | ||
| 950 | + position: fixed; | ||
| 951 | + bottom: 6rem; | ||
| 952 | + left: 1rem; | ||
| 953 | + right: 1rem; | ||
| 954 | + z-index: 1000; | ||
| 955 | + padding: 0 1rem; | ||
| 956 | +} | ||
| 957 | + | ||
| 958 | +.floating-checkin-button .checkin-action-button { | ||
| 959 | + width: 100%; | ||
| 960 | + height: 3rem; | ||
| 961 | + font-size: 1rem; | ||
| 962 | + font-weight: 600; | ||
| 963 | + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); | ||
| 964 | + border: none; | ||
| 965 | +} | ||
| 966 | + | ||
| 960 | :deep(.van-calendar__footer) { | 967 | :deep(.van-calendar__footer) { |
| 961 | display: none; | 968 | display: none; |
| 962 | } | 969 | } | ... | ... |
-
Please register or login to post a comment