From 4db65b4d05747456b7e2eaae811c48ac12805cd3 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Wed, 21 Feb 2024 18:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=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 --- src/pages/index/index.tsx | 4 +- src/pages/iotCarePlan/iotCarePlan.tsx | 101 ++++++++++++-------------- 2 files changed, 48 insertions(+), 57 deletions(-) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 1aecc9e..121f6bb 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -421,7 +421,9 @@ class Index extends Component { Taro.setStorageSync("mobile", data.data.mobile); this.props.tokenRefresh(data.data); - this.initPageData(); + setTimeout(() => { + this.initPageData(); + }, 300); } else { msg("请求失败,尝试重新请求"); this.WCUserLogin(); diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index a9039b1..b3ab138 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -615,26 +615,31 @@ class IotCarePlan extends Component { ); this.setState({ Electricity: jsonStatus.battery, - matrixElectricity: jsonStatus.matrixBattery, - workStatus: jsonStatus.workStatus, - workMode: jsonStatus?.workMode, - }); - this.setState({ fr200Electricity: jsonStatus.battery, matrixElectricity: jsonStatus.matrixBattery, workStatus: jsonStatus.workStatus, workMode: jsonStatus?.workMode, }); + // this.setState({ + // fr200Electricity: jsonStatus.battery, + // matrixElectricity: jsonStatus.matrixBattery, + // workStatus: jsonStatus.workStatus, + // workMode: jsonStatus?.workMode, + // }); // 判断是否在step == 2(护理中) if ( this.state.step == 2 && jsonStatus.workStatus !== MODE_WORKING_ENUM.END ) { - this.updateDeviceSyncData({ - totalWorkingMinutes: jsonStatus.totalWorkingMinutes, - totalWorkingSeconds: jsonStatus.totalWorkingSeconds, - }); + this.updateDeviceSyncData( + { + totalWorkingMinutes: jsonStatus.totalWorkingMinutes, + totalWorkingSeconds: jsonStatus.totalWorkingSeconds, + }, + jsonStatus + ); } + if (jsonStatus.workMode && this.state.step == 2) { const { ActiveModeItem } = this.state; const item = ActiveModeItem; @@ -647,16 +652,13 @@ class IotCarePlan extends Component { }); } } - // // 我忘记了为啥要这样传参... 埋坑了... - this.judgementWorkStatus( - jsonStatus.workStatus, - jsonStatus.workMode, - jsonStatus - ); - if (jsonStatus.workMode && this.state.step == 2) { - // this.judgementModel(jsonStatus.workMode); - // that.data.startSettingCountDown = false; - } + + // 根据工作状态:执行逻辑 + + // if (jsonStatus.workMode && this.state.step == 2) { + // // this.judgementModel(jsonStatus.workMode); + // // that.data.startSettingCountDown = false; + // } break; //设备信息查询返回 case "InfoQuery": @@ -816,19 +818,19 @@ class IotCarePlan extends Component { } //待完善,以后同步设备数据到小程序的事件,在这个事件里判断是否需要更新页面(是否需要触发setData) - updateDeviceSyncData = (newData) => { + updateDeviceSyncData = (newData, jsonStatus) => { DeviceSyncData = { ...DeviceSyncData, ...newData, }; if (newData.hasOwnProperty("totalWorkingSeconds")) { - this.renderDeviceStatus.renderWorkTime(); + this.renderDeviceStatus.renderWorkTime(jsonStatus); } }; - // 渲染页面时间状态 + // 页面同步护理剩余时间 renderDeviceStatus = { - renderWorkTime: () => { + renderWorkTime: (jsonStatus) => { const { totalWorkingMinutes, totalWorkingSeconds } = DeviceSyncData; const { ActiveModeItem, currentTime } = this.state; const totalTime = totalWorkingMinutes * 60 + totalWorkingSeconds; @@ -840,7 +842,7 @@ class IotCarePlan extends Component { const timeRemaining = sceneTime - hourMinSecToS(currentTime); // 小程序上已运行的总秒数 if ( - Math.abs(timeRemaining - totalTime) >= 2 && + Math.abs(timeRemaining - totalTime) >= 0 && this.state.step == 2 && this.state.facialMaskConnectStatus == 1 ) { @@ -853,6 +855,14 @@ class IotCarePlan extends Component { ActiveModeItem, }); } + + if (Math.abs(timeRemaining - totalTime) < 0) { + this.judgementWorkStatus( + MODE_WORKING_ENUM.END, + jsonStatus.workMode, + jsonStatus + ); + } }, }; @@ -891,9 +901,8 @@ class IotCarePlan extends Component { // ActiveModeItem let nowModeItem; if (nWorkMode) { - const nowModeType = WORK_MODE_TYPE[nWorkMode]; nowModeItem = ModeList.find((item) => { - return item.model_type == nowModeType; + return item.modeType === nWorkMode; }); } opts.workStatus = nWorkStatus; @@ -908,7 +917,7 @@ class IotCarePlan extends Component { isShowCountdown: false, }); if (nowModeItem?.isStandMode && step == 2) { - opts.currentTime = nowModeItem.time; + opts.currentTime = nowModeItem.modeTime; } else if (!nowModeItem?.isStandMode && step == 2) { // fix: 启动非支架模式倒计时时,连上支架,仪器的状态变为standby opts.step = 1; @@ -943,7 +952,7 @@ class IotCarePlan extends Component { }); } if (nowModeItem) { - opts.currentTime = nowModeItem.time; + opts.currentTime = nowModeItem.modeTime; } // startSettingCountDown 用于标记打开了倒计时loading if (!this.state.isShowCountdown) { @@ -999,7 +1008,7 @@ class IotCarePlan extends Component { currentTime: s_to_hms(timeRemaining), }); } - this.endnursing(null, true); + this.endnursing(true); // this.rmWL200NursingHistory(this.state.WL200NursingHistory); }, }; @@ -1048,7 +1057,7 @@ class IotCarePlan extends Component { * 结束护理 * param isAuto 是否仪器自动结束 */ - endnursing(e, isAuto) { + endnursing = (isAuto) => { if (isAuto == true) { // 仪器自动上报完成, 直接上报并跳转报告页 clearInterval(timer); @@ -1062,16 +1071,9 @@ class IotCarePlan extends Component { // this.handleTimeCheck(that.endNurseFun) } else { // 手动点击结束, 弹出弹窗, 看看是否需要结束 - this.setState({ - popupType: "endPopup", - }); - /*showModal({ - t2: "是否结束护理?", - }).then(async () => { - this.handleTimeCheck(that.endNurseFun) - });*/ + this.onEndPlan(); } - } + }; // 设置自定义模式数据 setCustomModeData() { @@ -1436,6 +1438,7 @@ class IotCarePlan extends Component { Electricity, errorTips, isEndCarePlan, + currentTime, } = this.state; return ( @@ -1505,7 +1508,7 @@ class IotCarePlan extends Component { className="msg-tips-img" src={require("../../img/tips.png")} /> - {{ errorTips }} + {errorTips} )} @@ -1513,27 +1516,17 @@ class IotCarePlan extends Component { - 护理时间:10:00 + 护理时间:{currentTime} WE200电量: - {Electricity === 5 && ( - - - - - - - - )} - {Electricity === 4 && ( + {Electricity >= 4 && ( - )} {Electricity === 3 && ( @@ -1542,7 +1535,6 @@ class IotCarePlan extends Component { - )} {Electricity === 2 && ( @@ -1551,7 +1543,6 @@ class IotCarePlan extends Component { - )} {Electricity === 1 && ( @@ -1560,7 +1551,6 @@ class IotCarePlan extends Component { - )} {Electricity === 0 && ( @@ -1569,7 +1559,6 @@ class IotCarePlan extends Component { - )}