From 9c83b1d9bf8bee67db5ea132d796724496924cd2 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Tue, 5 Mar 2024 10:09:16 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=87=86=E5=A4=87=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/instrumentClickinUpload/index.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pages/instrumentClickinUpload/index.tsx b/src/pages/instrumentClickinUpload/index.tsx index c090427..5e27efb 100644 --- a/src/pages/instrumentClickinUpload/index.tsx +++ b/src/pages/instrumentClickinUpload/index.tsx @@ -87,14 +87,10 @@ export default class InstrumentClickInUpload extends Component { let instrumentDetail = JSON.parse(objStr); this.setState({ instrumentDetail }); } - - const searchParams = new URLSearchParams(window.location.search); - const id = searchParams.get("id"); - setTimeout(() => { this.firstNurseInfo(); this.getLatestClockRecord(); - this.modeInfoList(id); + this.modeInfoList(this.state.instrumentDetail.id); }, 10); } From 0f0bca2771789459e1ed26505a906e810701eae4 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Tue, 5 Mar 2024 10:22:48 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=E5=AF=BC=E8=88=AA=E6=A0=8F=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +-- src/components/navbar/navbar.tsx | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b1bb931..dc37833 100644 --- a/package.json +++ b/package.json @@ -53,9 +53,8 @@ "@tarojs/plugin-platform-weapp": "3.6.19", "@tarojs/react": "3.6.19", "@tarojs/runtime": "3.6.19", - "@tarojs/shared": "3.6.19", + "@tarojs/shared": "3.6.19", "@tarojs/taro": "3.6.19", - "@visactor/taro-vchart": "^1.9.0", "dayjs": "^1.11.10", "echarts": "^5.5.0", "lodash": "^4.17.15", diff --git a/src/components/navbar/navbar.tsx b/src/components/navbar/navbar.tsx index 780fe29..ab2223c 100644 --- a/src/components/navbar/navbar.tsx +++ b/src/components/navbar/navbar.tsx @@ -49,8 +49,7 @@ export default class Navbar extends Component { success: (res) => { const statusBarHeight = res.statusBarHeight || 0; // 获取微信胶囊的位置信息 width,height,top,right,left,bottom - // const custom = Taro.getMenuButtonBoundingClientRect(); - const custom = { height: 60, top: 20 }; + const custom = Taro.getMenuButtonBoundingClientRect(); // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2 const navigationBarHeight = custom.height + (custom.top - statusBarHeight) * 2; From b426251c836735ced0dc529e7bf2e1b9db0fc964 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Tue, 5 Mar 2024 20:41:53 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +- .../device-connection-popup.tsx | 4 +- src/components/navbar/navbar.tsx | 2 +- .../popup/popup-instrument-upload-tips.less | 6 + .../popup/popup-instrument-upload-tips.tsx | 67 ++-- src/components/popup/popup-step-tips.tsx | 63 ++-- src/pages/consultant/consultant.tsx | 18 +- src/pages/index/index.tsx | 48 ++- src/pages/instrument/instrument.tsx | 74 ++++- src/pages/instrument/intro.tsx | 23 +- src/pages/instrumentClickinUpload/index.tsx | 6 +- .../iotCarePlan/components/ModeList/index.tsx | 18 +- src/pages/iotCarePlan/iotCarePlan.less | 2 + src/pages/iotCarePlan/iotCarePlan.tsx | 301 ++++++++++-------- src/pages/recording/recording.tsx | 2 +- src/pages/register/register.tsx | 6 +- 16 files changed, 413 insertions(+), 231 deletions(-) diff --git a/package.json b/package.json index dc37833..a6e080b 100644 --- a/package.json +++ b/package.json @@ -61,8 +61,8 @@ "react": "^18.0.0", "react-dom": "^18.0.0", "react-redux": "^9.0.3", - "taro-ui": "^3.2.0", - "taro-react-echarts": "^1.2.2" + "taro-react-echarts": "^1.2.2", + "taro-ui": "^3.2.0" }, "devDependencies": { "@babel/core": "^7.8.0", diff --git a/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx b/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx index 3dbae7b..0057e32 100644 --- a/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx +++ b/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx @@ -149,7 +149,7 @@ export default class DeviceConnectPopup extends Component { )} - + {/* {connectionSuccess ? ( @@ -175,7 +175,7 @@ export default class DeviceConnectPopup extends Component { )} - + */} )} - {data.length > 1 && ( + {data.length > 1 && current > 0 && ( - - ) : ( - - )} + )} {data.length > 1 && current === 0 && ( - )} - {data.length > 1 && ( + {data.length > 1 && current > 0 && ( - - + 跳过 > From a1d3824adfe1d50d3c8f73dfed71121116ab8dd4 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Wed, 6 Mar 2024 15:02:04 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iotCarePlan/components/Footer/index.tsx | 23 ++- src/pages/iotCarePlan/iotCarePlan.tsx | 179 +++++++++++++----- 2 files changed, 147 insertions(+), 55 deletions(-) diff --git a/src/pages/iotCarePlan/components/Footer/index.tsx b/src/pages/iotCarePlan/components/Footer/index.tsx index fed6aba..20c91cf 100644 --- a/src/pages/iotCarePlan/components/Footer/index.tsx +++ b/src/pages/iotCarePlan/components/Footer/index.tsx @@ -5,18 +5,18 @@ import { useState, useEffect } from "react"; import "./index.less"; interface Props { - isCanClick: boolean; isShowNurse: boolean; isStopNurse: boolean; + isDisabled: boolean; // 是否禁用开始暂停按钮:模式与连接设备是否一致 onEmitStartNurse: Function; // 每次点击item,回调事件和数据给父组件 onEmitSwitchChange: Function; onEmitEndPlan: Function; onEmitErrorTips: Function; // 不可点击,提示错误 } function Index({ - isCanClick, isShowNurse, isStopNurse, + isDisabled, onEmitStartNurse, onEmitSwitchChange, onEmitEndPlan, @@ -27,7 +27,9 @@ function Index({ }; const onSwitchChange = () => { - onEmitSwitchChange(); + if (!isDisabled) { + onEmitSwitchChange(); + } }; const onEndPlan = () => { @@ -43,12 +45,12 @@ function Index({ {!isShowNurse && ( - {isCanClick ? ( - + {isDisabled ? ( + 开始护理 ) : ( - + 开始护理 )} @@ -56,7 +58,7 @@ function Index({ )} {isShowNurse && ( - {isCanClick && ( + {!isDisabled && ( {isStopNurse ? ( @@ -79,8 +81,11 @@ function Index({ )} )} - {!isCanClick && ( - + {isDisabled && ( + {isStopNurse ? ( { /** 连接设备 End */ /** 护理过程 */ - isCanClick: false, // 是否可以点击开始按钮/启动暂停 isStandStatus: false, // 当前模式是否舱体/支架模式 isShowStepTips: false, // 是否显示介绍步骤弹窗 isConnectionBlutoot: true, // 是否已连接蓝牙 @@ -220,6 +219,9 @@ class IotCarePlan extends Component { // 上一次护理记录未生成,是否继续连接设备 isShowReReadRecordConnect: false, + + // 按钮是否可运行 + isFooterBtnDisabled: false, }; } @@ -371,6 +373,7 @@ class IotCarePlan extends Component { isConnectionBlutoot: false, // 断开蓝牙 isShowCountdown: false, // 关闭倒计时,防止倒计时还在运行 }); + this.footerIsDisabled(); }; GetModeList = async (id) => { @@ -429,21 +432,21 @@ class IotCarePlan extends Component { // 护理检查改变模式,是否提示切换护理模式 // isNotCheck为真时,不进行校验,直接切换 this.tempModeCurrent = data; + this.footerIsDisabled(); + if (!isNotCheck) { let isReturn = this.modeRuningChange(); if (isReturn) return; } let { isStandStatus, isShowNurse } = this.state; - // 舱体模式无法对应的时候,置灰开始按钮 - let isCabinMode = data.isCabinMode === 1; - if (isStandStatus === isCabinMode) { - this.setState({ isCanClick: true }); // 是否舱体一致时,可以点击 - } else { - this.setState({ isCanClick: false }); - } - console.log("isStandStatus", isStandStatus, isCabinMode); - console.log("isStandStatus === isCabinMode", isStandStatus === isCabinMode); + + // let isCabinMode = data.isCabinMode === 1; + // if (isStandStatus === isCabinMode) { + // this.setState({ isCanClick: true }); // 是否舱体一致时,可以点击 + // } else { + // this.setState({ isCanClick: false }); + // } let currentServiceData = { startSource: "", @@ -595,22 +598,19 @@ class IotCarePlan extends Component { }; /** 开始护理按钮:点击开始,页面进行到下一步 */ onStartNurse = async () => { - // 开发者工具 - // const platform = Taro.getSystemInfoSync().platform; - // if (platform === "devtools") { - // // 仅开发者工具,直接运行 - // this.stepNext(); - // } - - let { isStandStatus, ActiveModeItem } = this.state; - let isCabinMode = ActiveModeItem.isCabinMode === 1; - if (isStandStatus === isCabinMode) { + // 如果检查通过,可运行,则执行下一步 + if (!this.footerIsDisabled()) { this.stepNext(); return; } + // 如果检查失败,则报错 this.onEmitErrorTips(); }; - /** 不可切换光照提示 */ + + /** + * @name 不可切换光照提示 + * @description isCabinMode是否舱体模式。 0.检测面罩与舱体是否仍在连接中,需要分离 1.检测是否连接失败,需要重新连接 + */ onEmitErrorTips = async () => { let { isStandStatus, ActiveModeItem } = this.state; if (isStandStatus) { @@ -653,54 +653,76 @@ class IotCarePlan extends Component { /** 蓝牙相关 */ switchBLEMatch = (jsonStatus: any) => { console.log("蓝牙相关", jsonStatus); + let { ActiveModeItem } = this.state; switch (jsonStatus.bleCommandType) { // 如果设备配对链接发送配对码的时候,设备应答小程序配对码是否正确。 case "SendMatchCode": if (jsonStatus.matchedSuccess) { console.log("设备配对成功"); this.setState({ - facialMaskConnectStatus: true, + facialMaskConnectStatus: 1, }); } break; - // 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了 + // 设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了 case "BleStatusSync": console.log("BleStatusSync 附属设备状态主动上报", jsonStatus); switch (jsonStatus.connectMessage?.deviceName) { + case "WL200": + if (jsonStatus.connectMessage?.connectType == "CONNECTED") { + } else { + // 清除时间倒计时定时器 + this.setState({ + facialMaskConnectStatus: 0, // 蓝牙断开 + isFooterBtnDisabled: false, // 蓝牙断开所以不可点击 + }); + // 断开连接直接暂停 + this.judgementWorkStatus( + MODE_WORKING_ENUM.PAUSE, + ActiveModeItem?.modeType + ); + // 设备断开时,给定一个断开时间 + ActiveModeItem.breakTimeStr = this.state.currentTime; + } + break; // 附属设备是否连接支架 case "Stand": if (jsonStatus.connectMessage?.connectType == "CONNECTED") { console.log("舱体支架连接"); this.setState({ isStandStatus: true, - isCanClick: this.state.ActiveModeItem?.isCabinMode === 1, }); if (!this.state.isStandStatus && this.isRuning) { // 断开连接直接暂停 this.judgementWorkStatus( MODE_WORKING_ENUM.PAUSE, - this.state.ActiveModeItem?.modeType + ActiveModeItem?.modeType ); } } else { console.log("舱体支架断开连接"); + if (this.state.isStandStatus && this.isRuning) { // 断开连接直接暂停 this.judgementWorkStatus( MODE_WORKING_ENUM.PAUSE, - this.state.ActiveModeItem?.modeType + ActiveModeItem?.modeType ); } + // 设备断开时,给定一个断开时间 + ActiveModeItem.breakTimeStr = this.state.currentTime; this.setState({ isStandStatus: false, - isCanClick: this.state.ActiveModeItem?.isCabinMode !== 1, isStopNurse: true, + ActiveModeItem, }); } break; default: + console.log("监听到到设备连接状态改变 this.footerIsDisabled()"); + this.footerIsDisabled(); // 判断底部运行按钮是否可点击 break; } break; @@ -714,9 +736,6 @@ class IotCarePlan extends Component { console.log("支架是否链接", isStandDevice); this.setState({ isStandStatus: isStandDevice, - isCanClick: isStandDevice - ? this.state.ActiveModeItem?.isCabinMode === 1 - : this.state.ActiveModeItem?.isCabinMode !== 1, }); // 连上面罩后, 获取仪器记录, 与缓存信息对比 @@ -781,25 +800,34 @@ class IotCarePlan extends Component { "设备主动上报给小程序的指令 一般是工作状态改变", jsonStatus ); + this.workStatus = jsonStatus.workStatus; this.setState({ Electricity: jsonStatus.battery, // fr200Electricity: jsonStatus.battery, matrixElectricity: jsonStatus.matrixBattery, - workMode: jsonStatus?.workMode, }); - // 判断是否在step == 2(护理中) - if ( - this.state.step == 2 && - jsonStatus.workStatus !== MODE_WORKING_ENUM.END - ) { - this.updateDeviceSyncData( - { - totalWorkingMinutes: jsonStatus.totalWorkingMinutes, - totalWorkingSeconds: jsonStatus.totalWorkingSeconds, - }, - jsonStatus - ); + + if (jsonStatus?.workMode === this.state.ActiveModeItem.modeType) { + this.setState({ + workMode: jsonStatus?.workMode, // 仅当设备上报模式与小程序一致时,才允许改变小程序变量缓存 + }); + + // 判断是否在step == 2(护理中) + // 仅当设备模式与小程序是否一致,才允许更改设备运行时间 + if ( + this.state.facialMaskConnectStatus === 1 && + this.state.step == 2 && + jsonStatus.workStatus !== MODE_WORKING_ENUM.END + ) { + this.updateDeviceSyncData( + { + totalWorkingMinutes: jsonStatus.totalWorkingMinutes, + totalWorkingSeconds: jsonStatus.totalWorkingSeconds, + }, + jsonStatus + ); + } } if ( @@ -1122,9 +1150,19 @@ class IotCarePlan extends Component { facialMaskConnectStatus == 1 ) { let totalSeconds = minSecToS(ActiveModeItem.modeTimeStr); - let currentSeconds = minSecToS(currentTime); + // 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算 + let currentSeconds = ActiveModeItem?.breakTimeStr + ? minSecToS(ActiveModeItem.breakTimeStr) + : minSecToS(currentTime); let checkTime = totalSeconds - currentSeconds; this.elapsedTime = checkTime; + // 完成重连同步则删除重连时间字段 + if (ActiveModeItem?.breakTimeStr) { + delete ActiveModeItem?.breakTimeStr; + this.setState({ ActiveModeItem }); + } + + // 判断剩余时间是否大于1 if (currentSeconds >= 1) { // 小程序显示倒计时 this.setState({ @@ -1155,6 +1193,8 @@ class IotCarePlan extends Component { currentServiceData ); + this.updateWL200NursingHistory(currentServiceData); + this.setState({ ModeStepIndex: index, currentServiceData, @@ -1222,6 +1262,8 @@ class IotCarePlan extends Component { * 点击开始护理 */ onNursingTap() { + // 如果已禁止运行,则停止执行后续逻辑 + if (this.state.isFooterBtnDisabled) return; // 防止多次点击 if (this.state.hadClickStart) return; this.setState({ @@ -1407,7 +1449,8 @@ class IotCarePlan extends Component { let totalSeconds = jsonStatus.totalSeconds; // 从仪器上获取的使用时间 let neededTotalSeconds = jsonStatus.neededTotalSeconds; // 从仪器上获取的使用时间 console.log( - "从仪器上获取的使用时间 neededTotalSeconds", + "从仪器上获取的使用时间 totalSeconds: %d neededTotalSeconds: %d", + totalSeconds, neededTotalSeconds ); let nursingTimeStr = currentDevice?.nursingTimeStr; @@ -1478,6 +1521,32 @@ class IotCarePlan extends Component { Taro.setStorageSync("WL200NursingHistory", params); console.log("保存setWL200NursingHistory"); }; + /** 更新WL200护理历史运行时间 */ + updateWL200NursingHistory = (data: any = null) => { + this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); + + if (this.WL200NursingHistory) { + let params: any = this.WL200NursingHistory; + params.currentTime = this.state.currentTime; + + // 设置正确封面 + if (data) { + params.currentServiceData = data; + } else { + let currentServiceData = { + startSource: "", + stopSource: "", + }; + let serviceLength = this.state.ActiveModeItem.serviceData.length; + if (serviceLength > 0) { + currentServiceData = this.state.ActiveModeItem.serviceData[0]; + } + params.currentServiceData = currentServiceData; + } + Taro.setStorageSync("WL200NursingHistory", params); + console.log("更新updateWL200NursingHistory"); + } + }; /** 删除WL200护理历史 */ rmWL200NursingHistory = (WL200NursingHistory, hard = false) => { const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); @@ -1772,6 +1841,23 @@ class IotCarePlan extends Component { }; /** 初次护理信息弹窗 END */ + /** + * @name 设备运行开关按钮是否禁用 + * @description 判断所选模式与设备连接状态是否一致 + * @returns 返回true则禁用 + */ + footerIsDisabled = () => { + let { isStandStatus } = this.state; + let isCanClick = isStandStatus + ? this.tempModeCurrent?.isCabinMode === 1 + : this.tempModeCurrent?.isCabinMode === 0; + let isFooterBtnDisabled = !(isStandStatus === isCanClick); + this.setState({ + isFooterBtnDisabled: isFooterBtnDisabled, + }); + return isFooterBtnDisabled; // 数据更新有延迟,返回用于判断 + }; + render() { let { name, @@ -1807,6 +1893,7 @@ class IotCarePlan extends Component { isFirstTipShow, nurseInfo, isShowReReadRecordSave, + isFooterBtnDisabled, } = this.state; return ( @@ -2037,7 +2124,7 @@ class IotCarePlan extends Component {