diff --git a/src/app.config.ts b/src/app.config.ts index 30bc10c..880b905 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -83,7 +83,6 @@ export default defineAppConfig({ root: "recoding", pages: [ "pages/recording/recording", - "pages/face_report/face_report", "pages/face_report_one/face_report_one", "pages/moisture_test_report/moisture_test_report", diff --git a/src/moduleIOT/pages/iotCarePlan/FR200.less b/src/moduleIOT/pages/iotCarePlan/FR200.less index f5baef9..bf8caf2 100644 --- a/src/moduleIOT/pages/iotCarePlan/FR200.less +++ b/src/moduleIOT/pages/iotCarePlan/FR200.less @@ -1,13 +1,49 @@ @import url(./WL200.less); -.text { - // writing-mode: vertical-lr; - // text-orientation: upright; - // white-space: nowrap; - // font-size: 18px; - // font-weight: bold; - // background-color: #c2e5f3; - // color: #fff; - // width: 100%; + +.fr200-iot-device { + width: 690rpx; + height: 150rpx; + display: flex; + align-items: 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: 34rpx; + margin-right: 34rpx; + } + .gear { + margin-left: 10rpx; + font-size: 30rpx; + font-weight: 800; + color: #000; + } + .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; + } + } + } } .show { display: none; diff --git a/src/moduleIOT/pages/iotCarePlan/FR200.tsx b/src/moduleIOT/pages/iotCarePlan/FR200.tsx index 2ac4833..2513890 100644 --- a/src/moduleIOT/pages/iotCarePlan/FR200.tsx +++ b/src/moduleIOT/pages/iotCarePlan/FR200.tsx @@ -56,7 +56,7 @@ import ConnectionBluetoot from "@/components/bluetoot/connection"; /* 公共组件 END */ /* 本页组件 */ -import ElectricityView from "./components/ElectricityView/index"; +import ElectricityView from "./components/ElectricityView/Electricity"; import ModeListView from "./components/ModeList/FR200"; import Footer from "./components/Footer/FR200"; import WaterTest from "./components/WaterTest/index"; @@ -65,11 +65,8 @@ import WaterTest from "./components/WaterTest/index"; import Echarts from "./components/Echart"; import Gears from "./components/Gears"; - import "./FR200.less"; - - const deviceToolKitInstanceFR200 = new DeviceToolKitWM("FR200"); let deviceToolKitInstance = deviceToolKitInstanceFR200; @@ -124,7 +121,7 @@ class IotCarePlanFR200 extends Component { { name: "左脸颊", forehead: 6, Total: 10 }, { name: "右脸颊", forehead: 2, Total: 10 }, ], - stepList: [ + waterStepList: [ { value: "Step1", name: "额头", @@ -150,12 +147,11 @@ class IotCarePlanFR200 extends Component { forehead: 0, }, ], - stepIndex: 0, + waterStepIndex: 0, // 进度条定时器 timerIdSchedule: null, timerIdSuccess: null, - gear: { gear: 1 }, currentShowDialog: "", showVideoPlayBtn: true, // 视频播放按钮 duration: 0, // 视频总时长 @@ -165,6 +161,7 @@ class IotCarePlanFR200 extends Component { /** 连接设备 End */ /** 护理过程 */ + currentGear: 5, // 默认档位 isRuningTest: 1, // 是否正在测试 isShowStepTips: false, // 是否显示介绍步骤弹窗 isConnectionBlutoot: true, // 是否已连接蓝牙 @@ -175,8 +172,8 @@ class IotCarePlanFR200 extends Component { /** 护理过程 END*/ // 模式列表 - TestModeStepIndex: 0, - currentWorkModeType: 1, + currentWorkModeType: 1, // 现在的模式类型 + currentVideoSrc: "", // 现在模式的视频地址 isModeLock: false, // 模式是否锁定 isSwitchActiveMode: false, // 是否显示弹窗切换模式 ModeList: [], @@ -189,6 +186,16 @@ class IotCarePlanFR200 extends Component { activeModeID: "", // 当前选中模式ID:用于高亮 ModeStepIndex: 0, // 当前护理功效步骤:每个步骤时间不定,所以时间另外计算,根据步骤显示 ModeStepTimeArray: [], // 护理功效时间步骤,用于切换显示GIF + + TestModeStepIndex: 0, // 水分测试步骤 + EssenceStepIndex: 0, // 精华促渗步骤 + MaskModeStepIndex: 0, // 面膜促渗步骤 + + EssenceBuzzingIndex: 0, // 精华蜂鸣 + EssenceVibrateIndex: 0, // 精华震动 + MaskModeBuzzingIndex: 0, // 面膜蜂鸣 + MaskModeVibrateIndex: 0, // 面膜震动 + currentServiceData: { // 当前展示的开启暂停GIF: 因为时间判断不方便,所以单独领出来 startSource: "", @@ -223,8 +230,7 @@ class IotCarePlanFR200 extends Component { isShowHistoryMsg: false, // 是否显示正在同步历史 showEcharts: false, - echartsData: '' //传给echarts图表的数据 - + echartsData: "", //传给echarts图表的数据 }; } @@ -262,8 +268,14 @@ class IotCarePlanFR200 extends Component { "intelligence", ]; - /** 基础版:脸部/眼部 */ - BaseModeType: string[] = ["face", "eyes"]; + /** 基础版:脸部/眼部/PRO 设备使用时,会自动开启暂停 */ + BaseModeType: string[] = [ + "face", + "eyes", + "nasolabialFold", + "mandibularLine", + "headLiftingPro", + ]; async onLoad(option) { console.log(option, "跳转过来的数据"); @@ -277,11 +289,10 @@ class IotCarePlanFR200 extends Component { this.initData(); this.getInstrumentClockSummary(); this.getInstrumentClockDetail(); - } - componentDidMount() { } + componentDidMount() {} - componentWillUnmount() { } + componentWillUnmount() {} componentDidShow() { console.log("页面显示了"); @@ -429,7 +440,7 @@ class IotCarePlanFR200 extends Component { this.modeCurrentFun(res.data.data[0]); }, 100); } - let res1 = res.data.data.find(e => e.id == this.state.activeModeID) + let res1 = res.data.data.find((e) => e.id == this.state.activeModeID); setTimeout(() => { this.modeCurrentFun(res1); }, 100); @@ -507,18 +518,15 @@ class IotCarePlanFR200 extends Component { activeModeID: data.id, ModeID: "mode_" + data.id, ModeStepIndex: 0, + TestModeStepIndex: 0, // 水分测试步骤 + EssenceStepIndex: 0, // 精华促渗步骤 + MaskModeStepIndex: 0, // 面膜促渗步骤 ModeType: this.ModeTypeArray[data.modeClass], currentWorkModeType, }); - setTimeout(() => { - // 设置时间组合 - if (data.serviceData.length > 0) { - this.setServiceTimeData(); - } - - - }); + // 切换模式时:重新设置视频地址 + this.VideoSrcLoad(data.modeVideo); // 开发中,暂时允许直接切换 // 每次切换模式时清空一下历史数据 @@ -536,6 +544,8 @@ class IotCarePlanFR200 extends Component { /** 设备运行中切换模式 */ modeRuningChange() { // 运行中切换模式逻辑 + // 当且仅当,护理模式时长大于设备最低时常时,提示是否保存护理记录。 + // 若不满足,直接切换 if ( this.workStatus === MODE_WORKING_ENUM.PAUSE || this.workStatus === MODE_WORKING_ENUM.WORKING @@ -558,8 +568,8 @@ class IotCarePlanFR200 extends Component { this.setState({ isShowTipsSave: true, }); + return true; } - return true; } } return false; @@ -644,17 +654,14 @@ class IotCarePlanFR200 extends Component { }; /** 完成护理,跳转到水分 */ onsuccess = async () => { - let stepList = this.state.stepList; + let waterStepList = this.state.waterStepList; this.setState({ isShowNursingSuccess: true, }); // return; let { currentDevice, ActiveModeItem } = this.state; let params:any = {}; - - // let nursingData = JSON.stringify({ - // GearData: [...stepList], - // }); + params = { instrumentId: currentDevice.id, instrumentName: currentDevice.name, @@ -662,7 +669,7 @@ class IotCarePlanFR200 extends Component { modeName: ActiveModeItem.modeName, nursingTime: s_to_hms(this.elapsedTime), nursingData: JSON.stringify({ - GearData: [...stepList], + GearData: [...waterStepList], }) }; @@ -701,26 +708,22 @@ class IotCarePlanFR200 extends Component { }); }; look() { - let that = this + let that = this; // this.setState({ showEcharts: !this.state.showEcharts }); - let stop = 0 + let stop = 0; let time = setInterval(function () { - stop++ + stop++; let random = Math.random(); - that.setState({ echartsData: random }) + that.setState({ echartsData: random }); if (stop >= 20) { - clearInterval(time) + clearInterval(time); } - }, 1000) - - - } - updata() { - + }, 1000); } + updata() {} // 绘制能量图 - drawProwerPicture() { } + drawProwerPicture() {} /** 切换光照 */ onSwitchChange = async () => { @@ -812,55 +815,54 @@ class IotCarePlanFR200 extends Component { break; //设备状态同步 case "DeviceStatusSync": - this.setState({ - Electricity: jsonStatus.battery, - }); + if (jsonStatus.battery) { + // 防止抖动 + this.setState({ + Electricity: jsonStatus.battery, + }); + } + switch (jsonStatus.workStatus) { case "standby": //设备的待机状态 可能workMode字段为空 console.log("设备状态同步 待机状态", jsonStatus); - // this.judgementWorkStatus( - // MODE_WORKING_ENUM.STANDBY, - // jsonStatus.workMode - // ); + if (this.BaseModeType.includes(jsonStatus.workMode)) { + this.openTips("检测到您的设备没有紧贴肌肤,请紧贴肌肤"); + } break; case "pause": //设备的暂停状态 console.log("设备状态同步 暂停状态", jsonStatus); - // this.judgementWorkStatus( - // MODE_WORKING_ENUM.PAUSE, - // jsonStatus.workMode - // ); + if (this.BaseModeType.includes(jsonStatus.workMode)) { + this.openTips( + "检测到您的设备没有紧贴肌肤,请紧贴肌肤后重新尝试" + ); + } break; case "working": //设备的运行中状态 - console.log("设备状态同步 运行中状态", jsonStatus.workMode); + console.log("设备状态同步 工作中状态", jsonStatus.workMode); // 脸部模式 - if (jsonStatus.workMode === "face") { - // impedance - // totalWorkingMinutes: 0 - // totalWorkingSeconds: 24 + if (this.BaseModeType.includes(jsonStatus.workMode)) { + this.closeTips(); } - // this.judgementWorkStatus( - // MODE_WORKING_ENUM.WORKING, - // jsonStatus.workMode - // ); break; default: break; } if (jsonStatus.workMode === "moistureTest") { if ("success" === jsonStatus.testStatus) { - let stepList = this.state.stepList; - let stepIndex = this.state.stepIndex; + let waterStepList = this.state.waterStepList; + let waterStepIndex = this.state.waterStepIndex; let timerIdSuccess = this.state.timerIdSuccess; let timerIdSchedule = this.state.timerIdSchedule; - if (stepList[stepIndex].finish) { - stepList[stepIndex].forehead = jsonStatus.waterLevel; - if (stepIndex === 2) { + if (waterStepList[waterStepIndex].finish) { + waterStepList[waterStepIndex].forehead = + jsonStatus.waterLevel; + if (waterStepIndex === 2) { this.setState({ isRuningTest: 4, }); @@ -872,30 +874,30 @@ class IotCarePlanFR200 extends Component { clearTimeout(timerIdSuccess); clearTimeout(timerIdSchedule); - console.log("成功拿到", jsonStatus, stepIndex); - let num = stepIndex; - if (stepIndex < 2) { - num = stepIndex + 1; + console.log("成功拿到", jsonStatus, waterStepIndex); + let num = waterStepIndex; + if (waterStepIndex < 2) { + num = waterStepIndex + 1; } this.setState({ timerIdSuccess: null, timerIdSchedule: null, - stepIndex: num, - stepList, + waterStepIndex: num, + waterStepList, }); } } else { - let stepList = this.state.stepList; - let stepIndex = this.state.stepIndex; + let waterStepList = this.state.waterStepList; + let waterStepIndex = this.state.waterStepIndex; let timerIdSuccess = this.state.timerIdSuccess; let timerIdSchedule = this.state.timerIdSchedule; - if (stepList[stepIndex].finish) { + if (waterStepList[waterStepIndex].finish) { clearTimeout(timerIdSuccess); clearTimeout(timerIdSchedule); - stepList[stepIndex].schedule = 0; - stepList[stepIndex].finish = false; + waterStepList[waterStepIndex].schedule = 0; + waterStepList[waterStepIndex].finish = false; this.setState({ - stepList, + waterStepList, isRuningTest: 3, }); } @@ -904,15 +906,7 @@ class IotCarePlanFR200 extends Component { // testStatus:success } - console.log( - "jsonStatus?.workMode === this.state.ActiveModeItem.modeType", - jsonStatus?.workMode === this.state.ActiveModeItem.modeType - ); - console.log( - "this.state.DeviceConnectStatus", - this.state.DeviceConnectStatus - ); - console.log("this.isRuning", this.isRuning); + console.log("设备运行中?", this.isRuning); if (jsonStatus?.workMode === this.state.ActiveModeItem.modeType) { if (this.state.workMode !== jsonStatus?.workMode) { this.setState({ @@ -950,10 +944,11 @@ class IotCarePlanFR200 extends Component { this.workStatus = jsonStatus.workStatus; setTimeout(() => console.log("this.workStatus", this.workStatus)); - this.setState({ - Electricity: jsonStatus.battery, - matrixElectricity: jsonStatus.matrixBattery, - }); + if (jsonStatus.battery) { + this.setState({ + Electricity: jsonStatus.battery, + }); + } // 判断设备主动上报的关机事件 if (jsonStatus.workStatus === MODE_WORKING_ENUM.END) { @@ -1147,7 +1142,7 @@ class IotCarePlanFR200 extends Component { * params 工作状态 工作模式 响应状态 */ judgementWorkStatus(nWorkStatus, nWorkMode) { - const { ActiveModeItem, ModeList } = this.state; + const { ActiveModeItem, ModeList, currentVideoTime } = this.state; const opts: any = {}; // ActiveModeItem let nowModeItem; @@ -1158,7 +1153,7 @@ class IotCarePlanFR200 extends Component { } opts.workStatus = nWorkStatus; - let nowCurrentTime = ActiveModeItem.modeTimeStr; + let nowCurrentTime = currentVideoTime; // 完成重连同步则删除重连时间字段 if (ActiveModeItem?.breakTimeStr) { nowCurrentTime = ActiveModeItem?.breakTimeStr; @@ -1176,25 +1171,11 @@ class IotCarePlanFR200 extends Component { }); }, setting: () => { + this.isRuning = true; this.setState({ - hadShowBreakTips: false, + title: "正在护理", + isStopNurse: false, }); - if (!this.isRuning && !ActiveModeItem.isCabinMode) { - this.isRuning = true; - this.setState({ - title: "正在护理", - isStopNurse: false, - }); - } else if (!this.isRuning && ActiveModeItem.isCabinMode) { - this.isRuning = true; - // this.setState({ - // title: "正在护理", - // }); - this.setState({ - title: "正在护理", - isStopNurse: false, - }); - } if (nowModeItem) { opts.currentTime = nowCurrentTime; } @@ -1211,20 +1192,18 @@ class IotCarePlanFR200 extends Component { title: "正在护理", isStopNurse: false, isShowCountdown: false, - hadShowBreakTips: false, }); + this.closeTips(); }, pause: () => { clearInterval(currentTimeTimer); this.setState({ isShowCountdown: false, }); - if (ActiveModeItem.isCabinMode) { - this.setState({ - title: "暂停护理", - isStopNurse: true, - }); - } + this.setState({ + title: "暂停护理", + isStopNurse: true, + }); }, end: () => { // 已进入了报告阶段, 防止重复进入, 主要防止在手动点击结束护理接收到仪器消息 @@ -1274,9 +1253,8 @@ class IotCarePlanFR200 extends Component { let { DeviceConnectStatus, currentTime, - ModeStepTimeArray, - ModeStepIndex, ActiveModeItem, + currentVideoTime, } = this.state; if ( this.workStatus == MODE_WORKING_ENUM.WORKING && @@ -1285,20 +1263,22 @@ class IotCarePlanFR200 extends Component { ) { let totalSeconds = ActiveModeItem?.breakTimeStr ? minSecToS(ActiveModeItem.breakTimeStr) - : minSecToS(ActiveModeItem.modeTimeStr); + : minSecToS(currentVideoTime); // 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算 let currentSeconds = minSecToS(currentTime); let checkTime = totalSeconds - currentSeconds; // 缓存经过的时间:用于接口提交 this.elapsedTime = checkTime; + // fr200不需要加上中断的时间 // 如果存在中断时间,则要加上间隔的时间 - if (ActiveModeItem?.breakTimeStr) { - let intervalTime = - minSecToS(ActiveModeItem.modeTimeStr) - - minSecToS(ActiveModeItem.breakTimeStr); - this.elapsedTime += intervalTime; - } + // if (ActiveModeItem?.breakTimeStr) { + // let intervalTime = + // minSecToS(ActiveModeItem.modeTimeStr) - + // minSecToS(ActiveModeItem.breakTimeStr); + // this.elapsedTime += intervalTime; + // } + console.log("this.elapsedTime", this.elapsedTime); // 判断剩余时间是否大于1 if (currentSeconds >= 1) { @@ -1307,40 +1287,19 @@ class IotCarePlanFR200 extends Component { currentTime: s_to_ms(--currentSeconds), }); - let length = ModeStepTimeArray.length; - if (length) { - // 模式多个步骤节点切换 - // 已运行时间达到下一节点时,切换 - if (checkTime > ModeStepTimeArray[ModeStepIndex]) { - // 已运行时间达到下一节点,且存在下一节点,步骤切换时更新 - if (ModeStepIndex < length - 1) { - let index = ModeStepIndex + 1; // 提前步骤+1 - let currentServiceData = { - startSource: "", - stopSource: "", - }; - let serviceLength = ActiveModeItem.serviceData.length; - if (serviceLength > index) { - currentServiceData = ActiveModeItem.serviceData[index]; - } - - console.log("********************"); - console.log("********************"); - console.log( - "仅在时间达到下一步,步骤切换时更新currentServiceData", - currentServiceData - ); - this.setState({ - ModeStepIndex: index, - }); - } - } + // 根据不同的模式,切换步骤到下一步 + if (ActiveModeItem.modeType === "essence") { + this.essencePenetrationNext(); + } else if (ActiveModeItem.modeType === "maskPenetration") { + this.maskPenetrationNext(); } } else { clearInterval(currentTimeTimer); this.setState({ currentTime: "00:00", - ModeStepIndex: 0, + TestModeStepIndex: 0, // 水分测试步骤 + EssenceStepIndex: 0, // 精华促渗步骤 + MaskModeStepIndex: 0, // 面膜促渗步骤 }); this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束 } @@ -1348,6 +1307,243 @@ class IotCarePlanFR200 extends Component { }, 1000); }; + /** + * @name 水分测试下一步,手动调用 + * @description 步骤+1并设置视频 + */ + waterTestNext() { + let { TestModeStepIndex, ActiveModeItem } = this.state; + if (TestModeStepIndex < 3) { + let index = TestModeStepIndex + 1; // 提前步骤+1 + this.setState({ + TestModeStepIndex: index, + }); + + if (index === 1 && ActiveModeItem.stepOneVideo) { + this.VideoSrcLoad(ActiveModeItem.stepOneVideo); + } else if (index === 2 && ActiveModeItem.stepTwoVideo) { + this.VideoSrcLoad(ActiveModeItem.stepTwoVideo); + } else if (index === 3 && ActiveModeItem.stepThreeVideo) { + this.VideoSrcLoad(ActiveModeItem.stepThreeVideo); + } + } + } + + /** + * @name 面膜促渗下一步,根据时间自动调用 + * @description 1.切换步骤 2.检测记录蜂鸣/震动的时间节点与步骤 + * */ + maskPenetrationNext() { + let { + MaskModeStepIndex, + MaskModeBuzzingIndex, + MaskModeVibrateIndex, + ActiveModeItem, + } = this.state; + + // 模式多个步骤节点切换 + // 已运行时间达到下一节点时,切换 + let GearLength = ActiveModeItem.modeGear.length; + if (GearLength && MaskModeStepIndex < GearLength) { + let GearTime = minSecToS(ActiveModeItem.modeGear[MaskModeStepIndex].time); + if (this.elapsedTime > GearTime) { + // 已运行时间达到下一节点,且存在下一节点,步骤切换时更新 + if (MaskModeStepIndex < GearLength) { + let index = MaskModeStepIndex + 1; // 提前步骤+1 + this.setState({ + MaskModeStepIndex: index, + }); + this.FR200AutoChangeGear(index); + } + } + } + + let BuzzingLength = ActiveModeItem.modeBuzzing.length; + if (BuzzingLength && MaskModeStepIndex < GearLength) { + let BuzzingTime = minSecToS( + ActiveModeItem.modeBuzzing[MaskModeStepIndex].time + ); + if (this.elapsedTime > BuzzingTime) { + if (MaskModeBuzzingIndex < BuzzingLength) { + let index = MaskModeBuzzingIndex + 1; // 提前步骤+1 + this.setState({ + MaskModeBuzzingIndex: index, + }); + this.FR200Buzzing(); + } + } + } + + let VibrateLength = ActiveModeItem.modeVibrate.length; + if (VibrateLength && MaskModeStepIndex < VibrateLength) { + let VibrateTime = minSecToS( + ActiveModeItem.modeVibrate[MaskModeStepIndex].time + ); + if (this.elapsedTime > VibrateTime) { + if (MaskModeVibrateIndex < VibrateLength) { + let index = MaskModeVibrateIndex + 1; // 提前步骤+1 + this.setState({ + MaskModeVibrateIndex: index, + }); + this.FR200Vibrate(); + } + } + } + } + + /** @name 精华促渗下一步,根据时间自动调用 */ + essencePenetrationNext() { + let { + EssenceStepIndex, + EssenceBuzzingIndex, + EssenceVibrateIndex, + ActiveModeItem, + } = this.state; + + // 模式多个步骤节点切换 + // 已运行时间达到下一节点时,切换 + let GearLength = ActiveModeItem.modeGear.length; + if (GearLength && EssenceBuzzingIndex < GearLength) { + let GearTime = minSecToS( + ActiveModeItem.modeGear[EssenceBuzzingIndex].time + ); + if (this.elapsedTime > GearTime) { + // 已运行时间达到下一节点,且存在下一节点,步骤切换时更新 + if (EssenceStepIndex < GearLength) { + let index = EssenceStepIndex + 1; // 提前步骤+1 + this.setState({ + EssenceStepIndex: index, + }); + this.FR200AutoChangeGear(index); + } + } + } + + let BuzzingLength = ActiveModeItem.modeBuzzing.length; + if (BuzzingLength && EssenceBuzzingIndex < BuzzingLength) { + let BuzzingTime = minSecToS( + ActiveModeItem.modeBuzzing[EssenceBuzzingIndex].time + ); + if (this.elapsedTime > BuzzingTime) { + if (EssenceBuzzingIndex < BuzzingLength) { + let index = EssenceBuzzingIndex + 1; // 提前步骤+1 + this.setState({ + EssenceBuzzingIndex: index, + }); + this.FR200Buzzing(); + } + } + } + + let VibrateLength = ActiveModeItem.modeVibrate.length; + if (VibrateLength && EssenceBuzzingIndex < VibrateLength) { + let VibrateTime = minSecToS( + ActiveModeItem.modeBuzzing[EssenceBuzzingIndex].time + ); + if (this.elapsedTime > VibrateTime) { + if (EssenceVibrateIndex < VibrateLength) { + let index = EssenceVibrateIndex + 1; // 提前步骤+1 + this.setState({ + EssenceVibrateIndex: index, + }); + this.FR200Vibrate(); + } + } + } + } + + /**切换挡位发起蜂鸣:可以切换到现在的挡位?*/ + FR200Buzzing = () => { + console.log("FR200Buzzing 蜂鸣", this.elapsedTime); + const { ActiveModeItem, currentGear } = this.state; + let sendParams: any = { + ...deviceCommandSamples.pause, + workMode: ActiveModeItem.modeType, // 使用模式 + workStatus: "working", + gear: currentGear, + }; + + if (currentGear > 1) { + sendParams.gear = currentGear - 1; + let pauseArrayBuffer = deviceToolKitInstance.toBleCommand( + sendParams as any + ); + sendCommand({ + value: pauseArrayBuffer, + }); + } else { + sendParams.gear = currentGear + 1; + let pauseArrayBuffer = deviceToolKitInstance.toBleCommand( + sendParams as any + ); + sendCommand({ + value: pauseArrayBuffer, + }); + } + setTimeout(() => { + sendParams.gear = currentGear; + let pauseArrayBuffer = deviceToolKitInstance.toBleCommand( + sendParams as any + ); + sendCommand({ + value: pauseArrayBuffer, + }); + }, 300); + }; + + /** + * @name FR200自动切换挡位 + * @description 需要传参索引 + */ + FR200AutoChangeGear = (index: number = 0) => { + console.log("FR200AutoChangeGear 切换挡位", this.elapsedTime); + const { ActiveModeItem, GearData } = this.state; + let gear = GearData[index].forehead; + + // 同步挡位 + this.setState({ + currentGear: gear, + }); + + let sendParams: any = { + ...deviceCommandSamples.pause, + workMode: ActiveModeItem.modeType, // 使用模式 + workStatus: "working", + gear: gear, + }; + const pauseArrayBuffer = deviceToolKitInstance.toBleCommand( + sendParams as any + ); + sendCommand({ + value: pauseArrayBuffer, + }).then(() => { + this.workStatus = "working"; + this.resetTimer(); + }); + }; + + /** + * @name FR200震动 + * @description 同步设备工作却不改变档位,仅震动 + */ + FR200Vibrate = () => { + console.log("FR200Vibrate FR200震动", this.elapsedTime); + const { ActiveModeItem, currentGear } = this.state; + + let sendParams: any = { + ...deviceCommandSamples.pause, + workMode: ActiveModeItem.modeType, // 使用模式 + workStatus: "working", + gear: currentGear, + }; + const pauseArrayBuffer = deviceToolKitInstance.toBleCommand( + sendParams as any + ); + sendCommand({ + value: pauseArrayBuffer, + }); + }; + // 检测并控制工作状态 handleWorkStatus = (isBtnClick: boolean, workStatus) => { const { DeviceConnectStatus, ActiveModeItem } = this.state; @@ -1374,22 +1570,22 @@ class IotCarePlanFR200 extends Component { // 水分测试准备 水分测试工作 水分测试启动 if (ActiveModeItem.modeType === "moistureTest") { sendParams.testStatus = "standby"; // 切换为准备 - let stepList = this.state.stepList; - let stepIndex = this.state.stepIndex; + let waterStepList = this.state.waterStepList; + let waterStepIndex = this.state.waterStepIndex; let timerIdSchedule = this.state.timerIdSchedule; let timerIdSuccess = this.state.timerIdSuccess; if (isBtnClick) { timerIdSchedule = setTimeout(function () { - stepList[stepIndex].schedule = 100; + waterStepList[waterStepIndex].schedule = 100; timerIdSuccess = setTimeout(function () { - stepList[stepIndex].finish = true; + waterStepList[waterStepIndex].finish = true; this.setState({ - stepList, + waterStepList, }); }, 2000); this.setState({ - stepList, + waterStepList, timerIdSuccess, }); }, 3000); @@ -1404,7 +1600,7 @@ class IotCarePlanFR200 extends Component { } if (ActiveModeItem.modeType === "maskPenetration") { - sendParams.gear = 10; // 点击开始再开始 + sendParams.gear = this.state.currentGear; // 点击开始再开始 } console.log("准备发送自定义或工作指令", ActiveModeItem, sendParams); @@ -1480,9 +1676,8 @@ class IotCarePlanFR200 extends Component { /** 检查时间是否达标仪器最低护理时间 */ isCheckNurseTime() { - const { currentDevice, ActiveModeItem } = this.state; - const currentScene = ActiveModeItem; - let sceneTime = minSecToS(currentScene.modeTimeStr); + const { currentDevice, currentVideoTime } = this.state; + let sceneTime = minSecToS(currentVideoTime); const timeRemaining = sceneTime - minSecToS(this.state.currentTime); // 当前模式已运行时间 let nursingTimeStr = currentDevice?.nursingTimeStr; @@ -1542,7 +1737,8 @@ class IotCarePlanFR200 extends Component { * */ checkInstrumentRecord = async (jsonStatus: any) => { console.log("检查护理记录"); - let { currentDevice, ActiveModeItem, ModeList } = this.state; + let { currentDevice, ActiveModeItem, ModeList, currentVideoTime } = + this.state; await sleep(2); @@ -1598,8 +1794,7 @@ class IotCarePlanFR200 extends Component { console.log("currentTime", FR200NursingHistory.currentTime); let historyElapsedTime = - minSecToS(recordModeItem.modeTimeStr) - - minSecToS(FR200NursingHistory.currentTime); + minSecToS(currentVideoTime) - minSecToS(FR200NursingHistory.currentTime); this.elapsedTime = this.elapsedTime > historyElapsedTime @@ -1693,12 +1888,6 @@ class IotCarePlanFR200 extends Component { ModeID: "mode_" + ActiveModeItem.id, currentTime: this.FR200NursingHistory.currentTime, }); - setTimeout(() => { - // 设置时间组合 - if (ActiveModeItem.serviceData.length > 0) { - this.setServiceTimeData(); - } - }); } } /** 设置WL200护理历史 */ @@ -1721,8 +1910,7 @@ class IotCarePlanFR200 extends Component { console.log("保存setFR200NursingHistory"); }; /** 更新WL200护理历史运行时间 */ - - updateFR200NursingHistory = (data: any = null, jsonStatus = null) => { + updateFR200NursingHistory = (data: any = null, jsonStatus: any = null) => { this.FR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); if (this.FR200NursingHistory) { @@ -1739,17 +1927,24 @@ class IotCarePlanFR200 extends Component { if (!params.dataArray) params.dataArray = []; params.dataArray.push(jsonStatus); params.jsonStatus = jsonStatus; - - + params.workMode = jsonStatus?.workMode; + params.modeId = this.state.ActiveModeItem.id; + params.modeName = this.state.ActiveModeItem.modeName; } + } else { + params.jsonStatus = jsonStatus; + params.workMode = jsonStatus?.workMode; + params.modeId = data.id; + params.modeName = data.modeName; } + Taro.setStorageSync("FR200NursingHistory", params); console.log("更新updateFR200NursingHistory"); // 基础模式可在这里调用函数更新图标Echarts // 最新一条数据jsonStatus // 注意事项:只拿working状态 - // todo + // todo } else { this.setFR200NursingHistory(jsonStatus); } @@ -1924,59 +2119,7 @@ class IotCarePlanFR200 extends Component { } } - /** 获取护理时间组合 */ - getServiceTimeData() { - const { ActiveModeItem } = this.state; - let serviceData = ActiveModeItem.serviceData.map((item) => { - let totalWorkingMinutes = parseInt( - item.serviceStartTimeStr.split(":")[0] - ); // 仅分钟数 - let totalWorkingSeconds = parseInt(item.serviceEndTimeStr.split(":")[1]); // 仅秒数 - // let totalWorkingMinutes = 1; // 仅分钟数 - // let totalWorkingSeconds = 0; // 仅秒数 - return { - totalWorkingMinutes, - totalWorkingSeconds, - }; - }); - return serviceData; - } - /** 设置护理时间组合 */ - setServiceTimeData() { - let ServiceTimeData = this.getServiceTimeData(); - - // 组合时间 - let ModeStepTimeArray: any = []; - ServiceTimeData.reduce((old, cur) => { - let curTime = cur.totalWorkingMinutes * 60 + cur.totalWorkingSeconds; - let newTotalWorkingMinutes = cur.totalWorkingMinutes; - let newTotalWorkingSeconds = cur.totalWorkingSeconds; - if (old) { - newTotalWorkingMinutes += old.totalWorkingMinutes; - newTotalWorkingSeconds += old.totalWorkingSeconds; - - let oldTime = old.totalWorkingMinutes * 60 + old.totalWorkingSeconds; - let value = oldTime + curTime; - ModeStepTimeArray.push(value); - return { - totalWorkingMinutes: newTotalWorkingMinutes, - totalWorkingSeconds: newTotalWorkingSeconds, - }; - } - ModeStepTimeArray.push(curTime); - return { - totalWorkingMinutes: newTotalWorkingMinutes, - totalWorkingSeconds: newTotalWorkingSeconds, - }; - }, null); - this.setState({ - ModeStepTimeArray: ModeStepTimeArray, - ModeStepIndex: 0, // 每次切换组合模式,重置组合步骤 - }); - console.log("组合时间ModeStepTimeArray", ModeStepTimeArray); - } - - // 护理的错误提示 + /** 会自动关闭的护理错误提示 */ showTips(ctx) { if (!ctx) return; if (showTipsTimer) clearTimeout(showTipsTimer); @@ -1989,6 +2132,19 @@ class IotCarePlanFR200 extends Component { }); }, 2000); } + /** 不自动关闭的护理错误提示 */ + openTips(ctx) { + if (!ctx) return; + this.setState({ + errorTips: ctx, + }); + } + /** 关闭护理错误提示 */ + closeTips() { + this.setState({ + errorTips: "", + }); + } /** 结束护理弹窗 */ onEndPlan = async () => { @@ -2060,11 +2216,11 @@ class IotCarePlanFR200 extends Component { let report = true; go( "/recoding/pages/face_report_one/face_report_one?id=" + - id + - "&report=" + - report + - "&obj=" + - JSON.stringify(obj) + id + + "&report=" + + report + + "&obj=" + + JSON.stringify(obj) ); } else if ("moistureTest" === nursingData.workMode) { console.log("水分测试"); @@ -2171,13 +2327,24 @@ class IotCarePlanFR200 extends Component { // 获取并设置视频时间 GetVideosTime = (event) => { + console.log("获取并设置视频时间GetVideosTime", event?.detail?.duration); if (event?.detail?.duration) { let duration = Math.floor(event?.detail?.duration); let currentTime = s_to_ms(duration); - this.setState({ currentTime }); + this.setState({ currentTime, currentVideoTime: currentTime }); } }; + VideoSrcLoad = (video: string = "") => { + this.setState({ + currentVideoSrc: "", + }); + setTimeout(() => { + this.setState({ + currentVideoSrc: video, + }); + }, 10); + }; switchVideoPlay = () => { setTimeout(() => { let videoRef = Taro.createVideoContext("myVideo", this); @@ -2196,8 +2363,8 @@ class IotCarePlanFR200 extends Component { title, isConnectShow, GearData, - stepList, - stepIndex, + waterStepList, + waterStepIndex, isShowStepTips, isShowNurse, isStopNurse, @@ -2212,7 +2379,6 @@ class IotCarePlanFR200 extends Component { isShowCountdown, countdown, Electricity, - matrixElectricity, errorTips, isEndCarePlan, currentTime, @@ -2230,10 +2396,12 @@ class IotCarePlanFR200 extends Component { isShowHistoryMsg, isModeLock, TestModeStepIndex, + currentVideoSrc, + currentGear, showEcharts, echartsData, isShowReReadRecordConnect, - currentServiceData + currentServiceData, } = this.state; return ( @@ -2249,19 +2417,19 @@ class IotCarePlanFR200 extends Component { { isLarge isClose isShow={isEndCarePlan} - title='提示' - content='是否结束护理' - textAlgin='center' - cancelButtonText='取消' - confirmButtonText='确定' + title="提示" + content="是否结束护理" + textAlgin="center" + cancelButtonText="取消" + confirmButtonText="确定" close={this.cancelEndBtn} confirm={this.confirmEndBtn} /> @@ -2285,7 +2453,7 @@ class IotCarePlanFR200 extends Component { isLarge isClose isShow={isSwitchActiveMode} - title='护理模式切换' + title="护理模式切换" content={ { onModeLockOpen={this.onModeLockOpen} /> } - textAlgin='center' - cancelButtonText='取消' - confirmButtonText='确定' + textAlgin="center" + cancelButtonText="取消" + confirmButtonText="确定" close={this.cancelModeSwitchBtn} confirm={this.confirmModeSwitchBtn} /> @@ -2311,7 +2479,7 @@ class IotCarePlanFR200 extends Component { isShow={isShowStepTips} isLarge isFirstEntry={false} - confirmButtonText='知道了' + confirmButtonText="知道了" data={ActiveModeItem.openSourceData} close={this.closeStepTips} /> @@ -2320,10 +2488,10 @@ class IotCarePlanFR200 extends Component { @@ -2332,11 +2500,11 @@ class IotCarePlanFR200 extends Component { isShow={isShowErrorTipsText} isClose zIndex={10020} - myClassName='level-up' - title='提示' + myClassName="level-up" + title="提示" content={errorTipsText} - confirmButtonText='知道了' - textAlgin='center' + confirmButtonText="知道了" + textAlgin="center" close={this.closeErrorTipsText} confirm={this.closeErrorTipsText} /> @@ -2345,17 +2513,17 @@ class IotCarePlanFR200 extends Component { isShow={isShowTipsSave} isClose zIndex={10020} - myClassName='level-up' - title='提示' + myClassName="level-up" + title="提示" content={ 当前模式已护理部分时间 是否保存护理记录 } - cancelButtonText='取消' - confirmButtonText='确认' - textAlgin='center' + cancelButtonText="取消" + confirmButtonText="确认" + textAlgin="center" close={this.closeTipsSave} cancel={this.cancelTipsSave} confirm={this.confirmTipsSave} @@ -2364,11 +2532,11 @@ class IotCarePlanFR200 extends Component { { /*不需要做处理*/ }} @@ -2379,72 +2547,62 @@ class IotCarePlanFR200 extends Component { deviceInfo={currentDevice} close={this.connectionClose} isDisconnect={!isConnectionBlutoot} - offlineChange={() => { }} + offlineChange={() => {}} pairingChange={this.pairingChange} - upgradeFun={() => { }} + upgradeFun={() => {}} /> )} - 正在同步护理记录... + 正在同步护理记录... - - + + - {!isShowNurse && ( - - - - - 护理时间: - {currentTime} + + + + 倒计时:{currentTime} - + + + 档位:{currentGear}档 + + @@ -2463,32 +2621,30 @@ class IotCarePlanFR200 extends Component { onModeLockOpen={this.onModeLockOpen} /> )} - - - + + - {/* */} - - - + + + {/* {(ActiveModeItem.modeType === "face" || ActiveModeItem.modeType === "eyes") && } */} {(ActiveModeItem.modeType === "maskPenetration" || ActiveModeItem.modeType === "essence") && ( - - )} + + )} {ActiveModeItem.modeType === "moistureTest" && ( )} diff --git a/src/moduleIOT/pages/iotCarePlan/components/ElectricityView/Electricity.tsx b/src/moduleIOT/pages/iotCarePlan/components/ElectricityView/Electricity.tsx new file mode 100644 index 0000000..4c15cc7 --- /dev/null +++ b/src/moduleIOT/pages/iotCarePlan/components/ElectricityView/Electricity.tsx @@ -0,0 +1,61 @@ +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; + DeviceConnectStatus: any; +} +function Index({ Electricity, DeviceConnectStatus }: Props) { + return ( + + + {DeviceConnectStatus === 1 && ( + + + 电量: + + {Electricity >= 4 && ( + + + + + + + )} + {Electricity === 3 && ( + + + + + + + )} + {Electricity === 2 && ( + + + + + + + )} + {Electricity <= 1 && ( + + + + + + + )} + + + + )} + + + ); +} + +export default Index;