Commit d0f59c06 authored by weishengfei's avatar weishengfei

feat(postnatalCheckUp): 产检首页添加滚动定位功能

- 新增 scrollToCurrentWeek 方法,用于滚动到当前孕周对应的产检项
- 在获取首页信息后调用 scrollToCurrentWeek 方法
- 优化了产检记录列表的展示,使用 scroll-view 组件支持滚动
parent 0e5b1d90
......@@ -45,8 +45,9 @@
</view>
</view>
<!-- 产检记录 -->
<view class="postnatal-con-record">
<view class="record-item"
<scroll-view class="postnatal-con-record" scroll-y :scroll-top="scrollTop">
<!-- <view class="postnatal-con-record"> -->
<view :class="['record-item', `item-${index}`]"
v-for="({ id, checkupDate, index, pregnancyWeek, status, examinationItems, type }, i) in homeInfo.checkupList"
@click="onDetails(id, type)" :key="i">
<image class="add-image" v-if="type === '1'" :src="`${$baseUrl}chanjianTool/1001/bs.png`">
......@@ -78,7 +79,8 @@
重点:{{ getProject(examinationItems) }}
</view>
</view>
</view>
<!-- </view> -->
</scroll-view>
</view>
<!-- 新增产检 -->
<view class="postnatal-add" @click="onAdd">
......@@ -124,7 +126,8 @@
import {
ref,
getCurrentInstance,
onMounted
onMounted,
nextTick
} from 'vue'
import {
onLoad,
......@@ -156,9 +159,12 @@ const babyId = ref(userStore.babyInfo?.content?.id)
const back_btn = ref('')
const scrollTop = ref(0)
// 是否授权
const isWxNotification = ref(true)
// 提示弹窗
const isTip = ref(false)
// 弹窗控制
......@@ -347,7 +353,38 @@ const handleDateConfirm = (date) => {
console.log(editId.value, time.value)
onEditTime()
}
// 添加计算滚动位置的方法
const scrollToCurrentWeek = async () => {
// 确保数据已加载
if (!homeInfo.value || !homeInfo.value.gestationalWeeks || !homeInfo.value.checkupList) return;
// 找到当前孕周对应的产检项
const currentItem = homeInfo.value.checkupList.find(
item => item.pregnancyWeek == homeInfo.value.gestationalWeeks
);
if (!currentItem) return;
// 等待DOM更新
await nextTick();
// 创建选择器查询
const query = uni.createSelectorQuery().in(proxy);
query.select(`.item-${currentItem.index}`).boundingClientRect();
query.select('.postnatal-con-record').boundingClientRect();
query.exec((rects) => {
if (!rects[0] || !rects[1]) return;
const [itemRect, containerRect] = rects;
// 计算元素在容器内的相对位置
const position = itemRect.top - containerRect.top;
// 设置滚动位置(增加20px的缓冲距离)
scrollTop.value = position + 20;
});
};
// 保存订阅消息
const getWxNotificationFn = async (notificationDate, wxTemplateId, babyId) => {
const params = {
......@@ -397,14 +434,19 @@ const getInfoFn = async () => {
console.log('产检提醒首页获取信息', code, success, message, data)
if (success) {
homeInfo.value = data
uni.setStorageSync('dueDate', data.dueDate);
uni.setStorageSync('dueDate', data.dueDate)
// 新增:调用滚动方法
scrollToCurrentWeek()
} else {
uni.showToast({
title: message,
icon: "none",
});
// isTip.value = true
}
}
// 获取banner图
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment