From 0af51bc47449d391d9fe899f79c9cf58c1a3d212 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Thu, 22 Feb 2024 18:45:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8D=95=E5=AE=8C=E6=88=90=E5=85=89?= =?UTF-8?q?=E7=85=A7=E5=88=B0=E6=8A=A4=E7=90=86=E8=AE=B0=E5=BD=95=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.tsx | 17 +- .../components/ElectricityView/index.tsx | 119 +++++ .../iotCarePlan/components/ModeList/index.tsx | 72 +-- src/pages/iotCarePlan/iotCarePlan.less | 41 +- src/pages/iotCarePlan/iotCarePlan.tsx | 479 +++++++++--------- 5 files changed, 442 insertions(+), 286 deletions(-) create mode 100644 src/pages/iotCarePlan/components/ElectricityView/index.tsx diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 121f6bb..e8276d4 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -597,7 +597,6 @@ class Index extends Component { Taro.getSystemInfo({ success: (res) => { console.log("getSystemInfo", res); - this.setState({ isConnectShow: true }); let { locationEnabled, locationAuthorized, bluetoothEnabled } = res; if (!locationEnabled || !locationAuthorized) { showModal({ @@ -615,7 +614,7 @@ class Index extends Component { }); } else { // 打开连接弹窗 - this.setState({ isConnectShow: true }); + this.connectionOpen(); } }, }); @@ -628,7 +627,8 @@ class Index extends Component { async pairingChange(e) { console.log("===epairingChange===》", e); go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转 - // return; + + this.connectionClose(); } async goIot() { @@ -743,14 +743,15 @@ class Index extends Component { console.log(offlinelist); }; - connectionClose = async (data) => { - console.log("connectionClose", data); - this.setState({ isConnectShow: false }); + connectionOpen = async () => { + this.setState({ isConnectShow: true }); }; - connectionConfirm = async (data) => { - console.log("connectionConfirm", data); + connectionClose = async () => { this.setState({ isConnectShow: false }); }; + connectionConfirm = async () => { + this.connectionClose(); + }; /*蓝牙 END*/ render() { diff --git a/src/pages/iotCarePlan/components/ElectricityView/index.tsx b/src/pages/iotCarePlan/components/ElectricityView/index.tsx new file mode 100644 index 0000000..0afc8fa --- /dev/null +++ b/src/pages/iotCarePlan/components/ElectricityView/index.tsx @@ -0,0 +1,119 @@ +import Taro from "@tarojs/taro"; +import classnames from "classnames"; +import { Block, View, Image, Text } from "@tarojs/components"; +import { useState, useEffect } from "react"; +// import "./index.less"; + +interface Props { + Electricity: any; + matrixElectricity: any; + facialMaskConnectStatus: any; +} +function Index({ + Electricity, + matrixElectricity, + facialMaskConnectStatus, +}: Props) { + return ( + + + + WE200电量 : + + {matrixElectricity >= 4 && ( + + + + + + + )} + {matrixElectricity === 3 && ( + + + + + + + )} + {matrixElectricity === 2 && ( + + + + + + + )} + {matrixElectricity === 1 && ( + + + + + + + )} + {matrixElectricity === 0 && ( + + + + + + + )} + + + {facialMaskConnectStatus === 1 && ( + + + 面罩电量 : + + {Electricity >= 4 && ( + + + + + + + )} + {Electricity === 3 && ( + + + + + + + )} + {Electricity === 2 && ( + + + + + + + )} + {Electricity === 1 && ( + + + + + + + )} + {Electricity === 0 && ( + + + + + + + )} + + + + )} + + + ); +} + +export default Index; diff --git a/src/pages/iotCarePlan/components/ModeList/index.tsx b/src/pages/iotCarePlan/components/ModeList/index.tsx index 5fc4718..332d204 100644 --- a/src/pages/iotCarePlan/components/ModeList/index.tsx +++ b/src/pages/iotCarePlan/components/ModeList/index.tsx @@ -5,51 +5,55 @@ import { useState, useEffect } from "react"; import "./index.less"; interface Props { + ModeID: any; + activeModeID: any; ModeList: any; ModeType: string; // all visor cabin yimeish ActiveModeItem: any; isShowNurse: boolean; // 是否已进入护理详情页 + isPop: boolean; // 是否弹窗 onEmit: Function; // 每次点击item,回调事件和数据给父组件 + onEmitShowAll: Function; // 打开弹窗按钮 } function Index({ + isShowNurse, + isPop, ModeList, ModeType, - isShowNurse, ActiveModeItem, + ModeID, + activeModeID, onEmit, + onEmitShowAll, }: Props) { let VisorList = ModeList.filter((item) => item.modeClass === 1); // 面罩模式 let CabinList = ModeList.filter((item) => item.modeClass === 2); // 舱体模式 let YimeishList = ModeList.filter((item) => item.modeClass === 3); // 医美术后 - const [ModeID, setModeID] = useState("mode_" + ActiveModeItem.id); - const [activeID, setActiveID] = useState(ActiveModeItem.id); - - console.log("ModeID", ModeID, activeID); + // const [ModeID, setModeID] = useState("mode_" + ActiveModeItem.id); + // const [activeModeID, setactiveModeID] = useState(ActiveModeItem.id); const yimeishClick = (item) => { onEmit(item); - setActiveID(item.id); - setModeID("mode_" + item.id); }; const cabinClick = (item) => { onEmit(item); - setActiveID(item.id); - setModeID("mode_" + item.id); }; const visorClick = (item) => { onEmit(item); - setActiveID(item.id); - setModeID("mode_" + item.id); + }; + + const showAll = () => { + onEmitShowAll(); }; return ( - {ModeList.length > 0 && isShowNurse && ( - + {!isPop && ModeList.length > 0 && isShowNurse && ( + 全部模式 )} {VisorList.length > 0 && - (ModeType === "all" || ModeType === "visor") && ( + (ModeType === "all" || ModeType === "visor" || isPop) && ( @@ -85,19 +89,21 @@ function Index({ {item.modeName} - {item.modeTime} + + {item.modeTimeStr} + - {activeID === item.id && ( + {activeModeID === item.id && ( )} - {activeID === item.id && ( + {activeModeID === item.id && ( @@ -110,7 +116,7 @@ function Index({ )} {CabinList.length > 0 && - (ModeType === "all" || ModeType === "cabin") && ( + (ModeType === "all" || ModeType === "cabin" || isPop) && ( {item.modeName} - {item.modeTime} + + {item.modeTimeStr} + - {activeID === item.id && ( + {activeModeID === item.id && ( )} - {activeID === item.id && ( + {activeModeID === item.id && ( @@ -162,7 +170,7 @@ function Index({ )} {YimeishList.length > 0 && - (ModeType === "all" || ModeType === "yimeish") && ( + (ModeType === "all" || ModeType === "yimeish" || isPop) && ( {item.modeName} - {item.modeTime} + + {item.modeTimeStr} + - {activeID === item.id && ( + {activeModeID === item.id && ( )} - {activeID === item.id && ( + {activeModeID === item.id && ( diff --git a/src/pages/iotCarePlan/iotCarePlan.less b/src/pages/iotCarePlan/iotCarePlan.less index 2272662..10d3207 100644 --- a/src/pages/iotCarePlan/iotCarePlan.less +++ b/src/pages/iotCarePlan/iotCarePlan.less @@ -30,23 +30,46 @@ .video-or-image { display: block; width: 690rpx; - height: 690rpx; + height: 640rpx; border-radius: 30rpx; } .iot-device { width: 690rpx; - height: 100rpx; + height: 150rpx; display: flex; align-items: center; - .item { - flex: 1; - display: flex; - align-items: center; - justify-content: center; + justify-content: center; + .device-time { + font-size: 26rpx; + color: #000; + font-weight: 400; + .time { + font-size: 30rpx; + font-weight: 800; + } + } + .line { + width: 1rpx; height: 50rpx; + background: #dddddd; + margin-left: 69rpx; + margin-right: 60rpx; } - .border-right { - border-right: 1px solid #ddd; + .electricity-box { + display: flex; + flex-direction: column; + .item { + display: flex; + align-items: center; + justify-content: left; + height: 50rpx; + .label { + width: 154rpx; + font-size: 26rpx; + color: #000; + margin-right: 14rpx; + } + } } } .msg-tips { diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index b3ab138..88b3972 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -25,6 +25,7 @@ import PopupConfirm from "@/components/popup/popup-confirm"; /* 公共组件 END */ /* 本页组件 */ +import ElectricityView from "./components/ElectricityView/index"; import ModeListView from "./components/ModeList/index"; import ModeContent from "./components/ModeContent/index"; import Footer from "./components/Footer"; @@ -46,12 +47,10 @@ import { bleCommandSamples, } from "@/components/bluetoot/connection/test"; import { - hourMinSecToS, - minSecToS, s_to_s, s_to_m, + minSecToS, s_to_ms, - s_to_hms, isNeedToUpdate, } from "@/utils/util"; import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; @@ -59,6 +58,7 @@ import commandMap from "@/utils/commandMap"; const deviceToolKitInstanceWE100 = new DeviceToolKitWE100("WE100", "M01"); const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200"); +let currentTimeTimer: any = null; // 当前项目时间定时器 let CountdownTimer: any = null; let timer: any = null; let checkVersionTimeout: any = null; @@ -84,22 +84,6 @@ const WORK_MODE_NAME_ENUM = { ScalpCare: "ScalpCare", }; -// 模式类型:英文名 -const WORK_MODE_ENGLISH_NAME = { - 6: "powerfulSoothing", - 7: "Stability", - 8: "Brighten", - 9: "FirmSkin", - MaskCustom: "MaskCustom", - 21: "BrightenStand", - 22: "FirmSkinStand", - 23: "SmallpoxSoothingPro", - 24: "SmallpoxSoothing", - 25: "MixNursePro", - 26: "MixNurse", - 27: "ScalpCare", -}; - // 组合模式:分别对应的是哪几个模式类型 // 黄光590nm // 红光630nm @@ -121,21 +105,6 @@ const WORK_MODE_Chinese_NAME = { 头皮护理: "ScalpCare", }; -const WORK_MODE_TYPE = { - powerfulSoothing: 6, - Stability: 7, - Brighten: 8, - FirmSkin: 9, - MaskCustom: "MaskCustom", - BrightenStand: 21, - FirmSkinStand: 22, - SmallpoxSoothingPro: 23, - SmallpoxSoothing: 24, - MixNursePro: 25, - MixNurse: 26, - ScalpCare: 27, -}; - const MODE_WORKING_ENUM = { STANDBY: "standby", // 待命 WORKING: "working", // 工作 @@ -159,7 +128,6 @@ let CountDownTime = { ScalpCare: 6, }; -let KeepCheckingLink = true; let DeviceSyncData = { totalWorkingMinutes: 0, totalWorkingSeconds: 0, @@ -173,6 +141,10 @@ class IotCarePlan extends Component { name: "iotCarePlan", title: "美容仪名字", // 页面标题 instrument: "WE200", + currentDevice: { + name: "", + model: "", + }, // 当前设备 /** 连接设备 */ hasVersion: false, // 是否已查询到版本号 @@ -183,18 +155,10 @@ class IotCarePlan extends Component { isStandStatus: false, // 支架开启状态(支架就是舱体) facialMaskConnectStatus: 0, // 面罩连接状态 0未连接 1已连接 workStatus: "", // 工作状态 - Electricity: 0, // WL200电量 - matrixElectricity: 0, // matrix电量 + Electricity: 4, // WL200电量 + matrixElectricity: 4, // WE200发箍电量 workMode: "", //当前模式 - showCombinationModeDialog: false, // 组合模式弹窗 - combinationModeList: [], // 可选的组合模式列表 - combinationList: [], // 选择的组合模式列表 - combinationModeInfo: {}, // 组合模式缓存的信息 - originCombinationList: [], // 原始组合模式列表 - originCombinationModeInfo: {}, // 原始组合模式缓存的信息 - isCurrentModeCombination: false, // 当前模式是否是组合模式 - isSendModeCombination: false, // 当前是否在发送组合模式 gear: { gear: 1 }, currentShowDialog: "", @@ -222,10 +186,14 @@ class IotCarePlan extends Component { errorTips: "", // 错误提示 // 模式列表 + isSwitchActiveMode: false, // 是否显示弹窗切换模式 ModeList: [], ModeType: "all", // all visor面罩 cabin舱体 yimeish医美 modeClass: "", // 1面罩 2舱体 3医美 ActiveModeItem: {}, // 当前选中模式 + SwitchActiveModeItem: {}, // 切换选中模式 + ModeID: "mode_", + activeModeID: "", ModeStepIndex: 0, // 当前护理功效步骤:每个步骤时间不定,所以时间另外计算,根据步骤显示 // 倒计时 @@ -237,7 +205,7 @@ class IotCarePlan extends Component { // 最后执行步骤位置 endPlace: "", - currentTime: "00:01:00", + currentTime: "01:00", }; } @@ -266,6 +234,11 @@ class IotCarePlan extends Component { let objStr = getStorageSync("instrument_detail"); if (objStr) { let info = JSON.parse(objStr); + + this.setState({ + currentDevice: info, + }); + this.GetModeList(info.id); console.log("info"); @@ -367,7 +340,8 @@ class IotCarePlan extends Component { if (isStopNurse) { // 开始光照逻辑 this.showCountdownFun(3, () => {}); - this.handleWorkStatus(false, MODE_WORKING_ENUM.WORKING); + // this.handleWorkStatus(false, MODE_WORKING_ENUM.WORKING); + this.onNursingTap(); } else { // 暂停光照逻辑 this.handleWorkStatus(false, MODE_WORKING_ENUM.PAUSE); @@ -406,9 +380,48 @@ class IotCarePlan extends Component { }, 0); } + /** 选中护理模式 */ modeCurrentFun = async (data) => { - console.log("modeCurrentFun", data); - this.setState({ ActiveModeItem: data }); + this.setState({ + ActiveModeItem: data, + activeModeID: data.id, + ModeID: "mode_" + data.id, + }); + }; + /** 切换护理模式 */ + switchModeCurrentFun = async (data) => { + this.setState({ + SwitchActiveModeItem: data, + activeModeID: data.id, + ModeID: "mode_" + data.id, + }); + }; + // 打开模式切换弹窗 + openModeSwitch = () => { + console.log("openModeSwitch"); + this.setState({ + isSwitchActiveMode: true, + }); + }; + // 取消并关闭切换护理模式弹窗 + cancelModeSwitchBtn = () => { + this.setState({ + isSwitchActiveMode: false, + }); + }; + // 弹窗确定切换护理模式 + confirmModeSwitchBtn = () => { + let { SwitchActiveModeItem } = this.state; + let modeArray = ["all", "visor", "cabin", "yimeish"]; + this.setState({ + ModeType: modeArray[SwitchActiveModeItem.modeClass], + }); + setTimeout(() => { + this.setState({ + ActiveModeItem: SwitchActiveModeItem, + }); + this.cancelModeSwitchBtn(); + }, 100); }; stepNext = () => { @@ -421,6 +434,7 @@ class IotCarePlan extends Component { isStopNurse: true, isStandStatus: this.state.ActiveModeItem.isCabinMode === 1, workStatus: "pause", + step: 2, }); this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY); @@ -509,21 +523,9 @@ class IotCarePlan extends Component { } console.log("支架是否链接", isStandDevice); console.log("面罩是否链接", isConnectedMask); - //这里bug 先注释掉 bug是拔掉支架之后启动面罩工作就会一直弹 - // let { basicModeList, modelActiveIndex } = that.data; - // if ( - // that.data.step == 2 && - // !isStandDevice && - // basicModeList[modelActiveIndex].isStandMode && - // !that.data.hadShowBreakTips - // ) { - // that.data.hadShowBreakTips = true; - // that.onPauseTap(); - // that.standVideoContext.seek(0); - // // that.showTips('检测到支架未连接成功,请确认面罩开机后与支架连接,并接通支架电源'); - // that.showTips( - // `检测到舱体未连接成功,请确认面罩开机后与舱体连接,并接通舱体电源` - // ); + if (isConnectedMask) { + this.setState({ isConnectionBlutoot: true }); + } // 连上面罩后, 设置自定义模式 -- 不在这里设置自定义模式 if ( @@ -615,7 +617,7 @@ class IotCarePlan extends Component { ); this.setState({ Electricity: jsonStatus.battery, - fr200Electricity: jsonStatus.battery, + // fr200Electricity: jsonStatus.battery, matrixElectricity: jsonStatus.matrixBattery, workStatus: jsonStatus.workStatus, workMode: jsonStatus?.workMode, @@ -640,12 +642,13 @@ class IotCarePlan extends Component { ); } - if (jsonStatus.workMode && this.state.step == 2) { + if ( + jsonStatus.workMode === MODE_WORKING_ENUM.WORKING && + this.state.step == 2 + ) { const { ActiveModeItem } = this.state; const item = ActiveModeItem; - if ( - jsonStatus.workMode !== WORK_MODE_ENGLISH_NAME[item.model_type] - ) { + if (jsonStatus.workMode !== item.modeType) { clearTimeout(loadingTipsTimer); this.setState({ isShowCountdown: false, @@ -832,31 +835,54 @@ class IotCarePlan extends Component { renderDeviceStatus = { renderWorkTime: (jsonStatus) => { const { totalWorkingMinutes, totalWorkingSeconds } = DeviceSyncData; - const { ActiveModeItem, currentTime } = this.state; + let { ActiveModeItem, currentTime } = this.state; const totalTime = totalWorkingMinutes * 60 + totalWorkingSeconds; console.log("仪器上报的已经运行的总秒数", totalTime); console.log("时间校准频率,默认5秒一次", TIME_CALIBRATION_FREQUENCY); //对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准 const currentScene = ActiveModeItem; // 获取当前的场景 - let sceneTime = hourMinSecToS(currentScene.modeTime); // 场景时间 + let sceneTime = minSecToS(currentScene.modeTimeStr); // 场景时间 + + console.log("场景时间 sceneTime", sceneTime); + console.log("当前显示时间 currentTime", currentTime); + console.log("设备运行时间 totalTime", totalTime); + console.log(" this.state.step", this.state.step); + console.log("sceneTime > totalTime", sceneTime > totalTime); + + // 更新界面倒计时 + // clearInterval(currentTimeTimer); + // currentTimeTimer = setInterval(() => { + // let currentSeconds = minSecToS(this.state.currentTime); + // if (currentSeconds > 1) { + // this.setState({ + // currentTime: s_to_ms(--currentSeconds), + // }); + // } + // }, 1000); + this.resetTimer(); + + console.log( + "sceneTime > totalTime &&this.state.step == 2 &&this.state.facialMaskConnectStatus == 1", + sceneTime > totalTime && + this.state.step == 2 && + this.state.facialMaskConnectStatus == 1 + ); - const timeRemaining = sceneTime - hourMinSecToS(currentTime); // 小程序上已运行的总秒数 if ( - Math.abs(timeRemaining - totalTime) >= 0 && + sceneTime > totalTime && this.state.step == 2 && this.state.facialMaskConnectStatus == 1 ) { - this.resetTimer(); + // 界面倒计时同步设备时间 const t = sceneTime - totalTime; // 场景时间 - 已运行时间 = 剩余时间 - let { ActiveModeItem } = this.state; - ActiveModeItem.seconds = t; //修复时间跳变的问题 this.setState({ - currentTime: s_to_hms(t), - ActiveModeItem, + currentTime: s_to_ms(t), + }); + } else { + this.setState({ + currentTime: "00:00", + endPlace: "report", }); - } - - if (Math.abs(timeRemaining - totalTime) < 0) { this.judgementWorkStatus( MODE_WORKING_ENUM.END, jsonStatus.workMode, @@ -922,9 +948,9 @@ class IotCarePlan extends Component { // fix: 启动非支架模式倒计时时,连上支架,仪器的状态变为standby opts.step = 1; } - if (loadingTipsTimer) { - clearTimeout(loadingTipsTimer); - } + // if (loadingTipsTimer) { + // clearTimeout(loadingTipsTimer); + // } // 本来用于更新时间的,但是产生了 ID1000367 bug,先移除 // if (nowModeItem) { // opts.currentTime = nowModeItem.time; @@ -980,6 +1006,7 @@ class IotCarePlan extends Component { }); }, pause: () => { + clearInterval(currentTimeTimer); this.setState({ isShowCountdown: false, }); @@ -997,18 +1024,22 @@ class IotCarePlan extends Component { // that.onPauseTap(); // } // 已进入了报告阶段, 防止重复进入, 主要防止在手动点击结束护理接收到仪器消息 - if (this.state.endPlace) return; - // 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下 - const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus; - if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) { - const sceneTime = hourMinSecToS(ActiveModeItem.modeTime); // 模式的总时长 - const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长 - const timeRemaining = sceneTime - runTime; // 剩余未运行时间 - this.setState({ - currentTime: s_to_hms(timeRemaining), - }); - } + console.log("END 护理结束"); + clearInterval(currentTimeTimer); + this.endnursing(true); + // if (this.state.endPlace) return; + + // 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下 + // const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus; + // if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) { + // const sceneTime = minSecToS(ActiveModeItem.modeTimeStr); // 模式的总时长 + // const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长 + // const timeRemaining = sceneTime - runTime; // 剩余未运行时间 + // this.setState({ + // currentTime: s_to_ms(timeRemaining), + // }); + // } // this.rmWL200NursingHistory(this.state.WL200NursingHistory); }, }; @@ -1023,34 +1054,7 @@ class IotCarePlan extends Component { * 1.是否跳转 2.数据 * */ saveNurseReport = async (isJump = true, from) => { - // const { isStandStatus, standInfo, ActiveModeItem, options } = this.state; - // const currentScene = ActiveModeItem; - // let sceneTime = minSecToS(currentScene.time); - // const timeRemaining = sceneTime - minSecToS(this.state.currentTime); - // const form = { - // second: timeRemaining, - // screne_id: currentScene.screne_id, - // screne_name: currentScene.screne_name, - // instrument_id: options?.devId, - // report: JSON.stringify({ - // positionRatio: Math.floor((timeRemaining / sceneTime) * 100), - // }), - // }; - // // log.info(commandMap.WL200Command, '保存护理报告saveNurseReport', '来自方法from:' + from, '护理时间timeRemaining:'+timeRemaining); - // console.log("timeRemaining=>", timeRemaining); - // console.log("currentScene=>", currentScene); - // console.log("form=>", form); - // // const { data } = await UserNursingLogAdd(form) - // // // 清除缓存 - // // that.rmWL200NursingHistory(that.data.WL200NursingHistory, true); - // // if (data.code == 200 && isJump) { - // // that.setData({ - // // showNurseSuccess: true - // // }); - // // setTimeout(()=>{ - // // wx.redirectTo({ url: `/pages/MatrixWL200/pages/nursingRecord/nursingRecord?instrument_id=${options?.devId}&id=${data.data}` }) - // // }, 2000); - // // } + this.endNurseFun(); }; /** @@ -1060,7 +1064,7 @@ class IotCarePlan extends Component { endnursing = (isAuto) => { if (isAuto == true) { // 仪器自动上报完成, 直接上报并跳转报告页 - clearInterval(timer); + clearInterval(currentTimeTimer); const isEnough = this.checkTime(); if (isEnough && !this.state.endPlace) { this.setState({ @@ -1068,7 +1072,6 @@ class IotCarePlan extends Component { }); this.saveNurseReport(true, "endnursing"); } - // this.handleTimeCheck(that.endNurseFun) } else { // 手动点击结束, 弹出弹窗, 看看是否需要结束 this.onEndPlan(); @@ -1123,54 +1126,33 @@ class IotCarePlan extends Component { } // 重置计时器 - resetTimer() { + resetTimer = () => { // 切换模式后, 需要重新设置计时器, 以防进行中的计时器 - timer && clearInterval(timer); - timer = setInterval(() => { + currentTimeTimer && clearInterval(currentTimeTimer); + currentTimeTimer = setInterval(() => { if ( this.state.workStatus == MODE_WORKING_ENUM.WORKING && this.state.step == 2 && this.state.facialMaskConnectStatus == 1 ) { - /*if(that.data.workMode !== WORK_MODE_NAME_ENUM.POWERFULSOOTHING){*/ - let currentSeconds; - if (this.state.isCurrentModeCombination) { - // 组合模式逻辑 - // that.data.combinationModeInfo.seconds -= 1; - // that.setData({ - // currentTime: s_to_ms(that.data.combinationModeInfo.seconds) - // }) - // currentSeconds = that.data.combinationModeInfo.seconds + let currentSeconds = minSecToS(this.state.currentTime); + if (currentSeconds > 1) { + this.setState({ + currentTime: s_to_ms(--currentSeconds), + }); } else { - const { ActiveModeItem, currentTime } = this.state; - currentSeconds = hourMinSecToS(currentTime); + clearInterval(currentTimeTimer); this.setState({ - currentTime: s_to_hms(--currentSeconds), + currentTime: "00:00", + endPlace: "report", }); - console.log(ActiveModeItem.isCustomMode); - if (ActiveModeItem.isCustomMode) { - this.setCustomModeData(); - } - } - if (currentSeconds <= 0) { - clearInterval(timer); - // 统一接收仪器结束指令 - // that.data.endPlace = 'report'; - // that.saveNurseReport(true, 'setTimer'); + this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束 } - /*} else { - that.data.standInfo.seconds -= 1; - that.setData({ currentTime: s_to_ms(that.data.standInfo.seconds) }) - if(that.data.standInfo.seconds <= 0){ - clearInterval(timer); - this.showNurseSuccessDialog() - } - }*/ } }, 1000); - } + }; - // 工作状态 + // 检测并控制工作状态 handleWorkStatus = (isBtnClick: boolean, workStatus) => { const { facialMaskConnectStatus, isStandStatus, ActiveModeItem } = this.state; @@ -1291,42 +1273,47 @@ class IotCarePlan extends Component { // 结束护理? endNurseFun() { - // this.handleWorkStatus(false, "end"); - setTimeout(() => { - //TODO IOS关闭蓝牙太快导致关机指令没发出去,暂时这么解决 - const isEnough = this.checkTime(); - if (!isEnough) { - Taro.showModal({ - title: "提示", - content: "护理时间不足,请重新连接护理", - showCancel: false, - success: (res) => { - if (!this.state.endPlace || this.state.endPlace !== "report") { - // back(); - console.log("back"); - } - // this.state.innerAudioContext.destroy(); - Taro.closeBluetoothAdapter(); - }, - }); - } else { - if (!this.state.endPlace || this.state.endPlace !== "report") { - // back(); - console.log("back"); - } - // this.state.innerAudioContext.destroy(); - Taro.closeBluetoothAdapter(); - } - }, 500); + this.handleWorkStatus(false, "end"); + this.PostNursingLogClock(); + // setTimeout(() => { + // //TODO IOS关闭蓝牙太快导致关机指令没发出去,暂时这么解决 + // const isEnough = this.checkTime(); + // if (!isEnough) { + // Taro.showModal({ + // title: "提示", + // content: "护理时间不足,请重新连接护理", + // showCancel: false, + // success: (res) => { + // if (!this.state.endPlace || this.state.endPlace !== "report") { + // // back(); + // console.log("back"); + // } + // // this.state.innerAudioContext.destroy(); + // Taro.closeBluetoothAdapter(); + // }, + // }); + // } else { + // if (!this.state.endPlace || this.state.endPlace !== "report") { + // // back(); + // console.log("back"); + // } + // // this.state.innerAudioContext.destroy(); + // Taro.closeBluetoothAdapter(); + // } + // }, 500); } // 检查时间是否达标 checkTime() { - const { curDeviceInfo, ActiveModeItem } = this.state; + const { currentDevice, ActiveModeItem } = this.state; const currentScene = ActiveModeItem; - let sceneTime = hourMinSecToS(currentScene.modeTime); - const timeRemaining = sceneTime - hourMinSecToS(this.state.currentTime); - if (timeRemaining >= Number(curDeviceInfo?.nursingTime) * 60) { + let sceneTime = minSecToS(currentScene.modeTimeStr); + const timeRemaining = sceneTime - minSecToS(this.state.currentTime); // 当前模式已运行时间 + + let nursingTimeStr = currentDevice?.nursingTimeStr; + let nursingTime = nursingTimeStr ? minSecToS(nursingTimeStr) : 60; // 设备生成护理记录至少需要运行时间 + + if (timeRemaining >= nursingTime) { return true; } else { return false; @@ -1412,6 +1399,7 @@ class IotCarePlan extends Component { }); }; confirmEndBtn = () => { + this.endNurseFun(); this.cancelEndBtn(); }; cancelEndBtn = () => { @@ -1421,6 +1409,22 @@ class IotCarePlan extends Component { }; /** 弹窗 END*/ + /** 护理记录 */ + // apiClock + PostNursingLogClock = async () => { + let { currentDevice, ActiveModeItem } = this.state; + let params = { + instrumentId: currentDevice.id, + instrumentName: currentDevice.name, + modeId: ActiveModeItem.id, + modeName: ActiveModeItem.modeName, + nursingTime: ActiveModeItem.modeTime, + }; + let res: any = await InstrumentInfo.apiNursingLog.addLog(params); + console.log("PostNursingLogClock", res); + }; + /** 护理记录 End */ + render() { let { name, @@ -1432,13 +1436,19 @@ class IotCarePlan extends Component { isShowNurse, isStopNurse, ActiveModeItem, + SwitchActiveModeItem, + isSwitchActiveMode, + ModeID, + activeModeID, isShowCountdown, countdown, ModeStepIndex, Electricity, + matrixElectricity, errorTips, isEndCarePlan, currentTime, + facialMaskConnectStatus, } = this.state; return ( @@ -1458,6 +1468,31 @@ class IotCarePlan extends Component { close={this.cancelEndBtn} confirm={this.confirmEndBtn} /> + + } + textAlgin="center" + cancelButtonText="取消" + confirmButtonText="确定" + close={this.cancelModeSwitchBtn} + confirm={this.confirmModeSwitchBtn} + /> + {ActiveModeItem.openSourceData && ( { - - 护理时间:{currentTime} - - WE200电量: - - {Electricity >= 4 && ( - - - - - - - )} - {Electricity === 3 && ( - - - - - - - )} - {Electricity === 2 && ( - - - - - - - )} - {Electricity === 1 && ( - - - - - - - )} - {Electricity === 0 && ( - - - - - - - )} - + + 护理时间: + {currentTime} + + + {ModeList.length > 0 && ( )}