From cce60dd135f800e81bbbca81c4699f9f3fc237b4 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Wed, 18 Mar 2026 22:12:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B6=88=E6=81=AF=E9=A1=B5=E9=9D=A2bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E3=80=82=E4=B8=BB=E9=A1=B5=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=BC=80=E5=85=B3=E5=AE=9A=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=BA=B6=E8=A7=A3=E6=B0=A7=E5=92=8C=E6=B8=A9=E5=BA=A6=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=BA=A2=E8=89=B2=E6=A0=87=E8=AF=86=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/other/index.vue | 38 ++++++++++++++++++++++++++++++++++ src/pages/msg/index.vue | 16 ++++++++++---- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/components/other/index.vue b/src/components/other/index.vue index 72f9339..d48a612 100644 --- a/src/components/other/index.vue +++ b/src/components/other/index.vue @@ -99,6 +99,8 @@ :class=" !item.up ? '' + : (item.oxyWarnLower && Number(item.valueDissolvedOxygen) < Number(item.oxyWarnLower)) + ? 'c_E22323' : alarmJudgeCode(item.warnCodeInfo?.warnCode, 7) ? 'c_E22323' : '' @@ -126,6 +128,9 @@ :class=" !item.up ? '' + : (item.tempWarnUpper && Number(item.valueTemperature) > Number(item.tempWarnUpper)) || + (item.tempWarnLower && Number(item.valueTemperature) < Number(item.tempWarnLower)) + ? 'c_E22323' : alarmJudgeCode(item.warnCodeInfo?.warnCode, 9) || alarmJudgeCode(item.warnCodeInfo?.warnCode, 8) ? 'c_E22323' @@ -820,6 +825,8 @@ const keepNightOpen = ref(false); const openSetNameSwitch = ref(false); const switchName = ref(''); const switchId = ref(); +// 定时刷新定时器 +const refreshTimer = ref(null); /** -----------------method start----------------- */ Taro.useDidShow(() => { const sysInfo = Taro.getSystemInfoSync(); @@ -836,6 +843,9 @@ Taro.useDidShow(() => { visControl.value = false; getDeviceList(); getNowDate(); + + // 启动定时刷新,每10秒刷新一次开关状态 + startRefreshTimer(); }); onMounted(() => { const sysInfo = Taro.getSystemInfoSync(); @@ -853,7 +863,35 @@ onMounted(() => { getDeviceList(); getNowDate(); + + // 启动定时刷新,每10秒刷新一次开关状态 + startRefreshTimer(); }); + +// 页面隐藏时停止定时刷新 +Taro.useDidHide(() => { + stopRefreshTimer(); +}); + +// 启动定时刷新 +function startRefreshTimer() { + // 先清除已有的定时器 + stopRefreshTimer(); + // 每10秒刷新一次 + refreshTimer.value = setInterval(() => { + if (controlList.value.length > 0) { + getDeviceList(); + } + }, 10000); +} + +// 停止定时刷新 +function stopRefreshTimer() { + if (refreshTimer.value) { + clearInterval(refreshTimer.value); + refreshTimer.value = null; + } +} watchEffect(() => { emit("getPondInfo", pondDeviceRes.value); }); diff --git a/src/pages/msg/index.vue b/src/pages/msg/index.vue index afdab25..ce6cbf2 100644 --- a/src/pages/msg/index.vue +++ b/src/pages/msg/index.vue @@ -284,11 +284,19 @@ let currentLoadingPage = 0; let isInitialized = false; Taro.useDidShow(() => { - // 只在首次显示时加载数据 - if (!isInitialized) { - selectVal.value = 0; + // 每次显示页面时都刷新数据,确保数据一致性 + // 重置分页参数 + warnParams.value.pageNum = 1; + switchParams.value.pageNum = 1; + payParams.value.pageNum = 1; + + // 根据当前选中的标签刷新对应数据 + if (selectVal.value === 0) { getWarnMsg(); - isInitialized = true; + } else if (selectVal.value === 1) { + getSwitchMsg(); + } else if (selectVal.value === 2) { + getPayMsg(); } }); // 头部组件刷新