diff --git a/project.config.json b/project.config.json index 5b91d3e..8c8e96f 100644 --- a/project.config.json +++ b/project.config.json @@ -8,7 +8,7 @@ "compileHotReLoad": false, "postcss": false, "preloadBackgroundData": false, - "minified": false, + "minified": true, "newFeature": true, "autoAudits": false, "coverView": true, diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..8793a36 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,33 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "condition": { + "miniprogram": { + "list": [ + { + "name": "moduleIOT/pages/iotCarePlan/WL200", + "pathName": "moduleIOT/pages/iotCarePlan/WL200", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "pages/index/index", + "pathName": "pages/index/index", + "query": "", + "launchMode": "default", + "scene": null + }, + { + "name": "pages/face_report_one/face_report_one", + "pathName": "pages/face_report_one/face_report_one", + "query": "id=60&recordId=undefined&report=false", + "launchMode": "default", + "scene": null + } + ] + } + }, + "setting": { + "bigPackageSizeSupport": true + } +} \ No newline at end of file diff --git a/src/app.config.ts b/src/app.config.ts index e1f9347..21b808b 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -25,8 +25,10 @@ export default defineAppConfig({ "pages/integral_list/integral_list", "pages/recording/recording", "pages/webViewPage/webViewPage", - "pages/template/template", - "pages/face_report/face_report", + 'pages/template/template', + 'pages/face_report/face_report', + 'pages/face_report_one/face_report_one', + 'pages/face_report_AllDevice/face_report_AllDevice', "pages/connection_help/connection_help", "pages/errorpage/errorpage", "pages/moisture_test_report/moisture_test_report", diff --git a/src/components/bluetoot/connection/fr200.js b/src/components/bluetoot/connection/fr200.js index 80a01fd..52fa2a5 100644 --- a/src/components/bluetoot/connection/fr200.js +++ b/src/components/bluetoot/connection/fr200.js @@ -57,21 +57,27 @@ export const fr200DeviceControlCommand = { }, /** - * '脸部' = 'workFace', - * '眼部' = 'workEye', - * '颈纹' = 'workNeck', * '进入水分测试模式' = 'switchTestMode', * '启动水分测试模式' = 'startTestMode', - * face - * eyes - * neck - * moistureTest + * face: "01", 面部 + * eyes: "02", 脸部 + * nasolabialFold: "03", 法令纹 + * mandibularLine: "04", 下颌线 + * led: "05", led + * moistureTest: "06", 水分测试 + * maskPenetration: "07",面膜促渗 + * essence: "08", 精华模式 + * headLiftingPro: "09", 抬头纹Pro + * neck: "0A", 颈纹 + * partition: "11", 分区模式 废弃VM1001 + * ignore: "255", 不改变/无模式 */ + // 普通工作模式 work: { commandType: "DeviceControl", workStatus: "working", - workMode: "face", + workMode: "ignore", // face }, // 切换/进入水分测试 switchTestMode: { diff --git a/src/components/bluetoot/connection/index.tsx b/src/components/bluetoot/connection/index.tsx index 707ba39..16753da 100644 --- a/src/components/bluetoot/connection/index.tsx +++ b/src/components/bluetoot/connection/index.tsx @@ -459,7 +459,7 @@ class ConnectionBluetoot extends Component { return jsonStatus; } - /** 7.通知BLE特征值更改 */ + /** 7.通知BLE特征值更改 连接成功需拿到响应判断是否需要升级,然后跳转详情页 */ notifyBLECharacteristicValueChange() { console.log("7.通知BLE特征值更改"); const { deviceInfo } = this.props; diff --git a/src/img/face-report/Head_lift_Pro.png b/src/img/face-report/Head_lift_Pro.png new file mode 100644 index 0000000..d0dfdaa Binary files /dev/null and b/src/img/face-report/Head_lift_Pro.png differ diff --git a/src/img/face-report/Mandibular_Pro.png b/src/img/face-report/Mandibular_Pro.png new file mode 100644 index 0000000..5c16d10 Binary files /dev/null and b/src/img/face-report/Mandibular_Pro.png differ diff --git a/src/img/face-report/eye.png b/src/img/face-report/eye.png new file mode 100644 index 0000000..93049a2 Binary files /dev/null and b/src/img/face-report/eye.png differ diff --git a/src/img/face-report/face.png b/src/img/face-report/face.png new file mode 100644 index 0000000..d58fab8 Binary files /dev/null and b/src/img/face-report/face.png differ diff --git a/src/img/face-report/nasolabial_Pro.png b/src/img/face-report/nasolabial_Pro.png new file mode 100644 index 0000000..be98a0d Binary files /dev/null and b/src/img/face-report/nasolabial_Pro.png differ diff --git a/src/moduleIOT/pages/iotCarePlan/FR200.tsx b/src/moduleIOT/pages/iotCarePlan/FR200.tsx index 25eed0d..f517d81 100644 --- a/src/moduleIOT/pages/iotCarePlan/FR200.tsx +++ b/src/moduleIOT/pages/iotCarePlan/FR200.tsx @@ -10,7 +10,8 @@ import React, { useState, } from "react"; -import Echarts from "./components/Echart/index"; +// import Echarts from "./components/Echart/index"; +import Gears from "./components/Gears/index"; import { Block, View, @@ -40,7 +41,7 @@ import ConnectionBluetoot from "@/components/bluetoot/connection"; import ElectricityView from "./components/ElectricityView/index"; import ModeListView from "./components/ModeList/FR200"; import ModeContent from "./components/ModeContent/FR200"; -import Footer from "./components/Footer"; +import Footer from "./components/Footer/FR200"; /* 本页组件 END */ import { go, getStorageSync, setStorageSync, msg } from "@/utils/traoAPI"; @@ -64,8 +65,10 @@ import { } from "@flossom-npm/iot-translater"; import commandMap from "@/utils/commandMap"; import { Popup } from "@antmjs/vantui"; +import { fr200BleCommand } from "@/components/bluetoot/connection/fr200"; const deviceToolKitInstanceFR200 = new DeviceToolKitWM("FR200"); +let deviceToolKitInstance = deviceToolKitInstanceFR200; let currentTimeTimer: any = null; // 当前项目时间定时器 let CountdownTimer: any = null; @@ -102,7 +105,6 @@ let DeviceSyncData = { totalWorkingMinutes: 0, totalWorkingSeconds: 0, }; -let deviceToolKitInstance = deviceToolKitInstanceFR200; class IotCarePlanFR200 extends Component { constructor(props) { @@ -121,15 +123,20 @@ class IotCarePlanFR200 extends Component { basicModeList: [], //模式列表 modelActiveIndex: 0, //模式下标 sliderProgress: 22, - facialMaskConnectStatus: 1, // 面罩连接状态 0未连接 1已连接 + DeviceConnectStatus: 1, // 设备连接状态 0未连接 1已连接 Electricity: 4, // WL200电量 matrixElectricity: 4, // WE200发箍电量 workMode: "", //当前模式 + // 挡位调节组件参数 + GearData: [ + { name: "额头", forehead: 5, Total: 10 }, + { name: "左脸颊", forehead: 6, Total: 10 }, + { name: "右脸颊", forehead: 2, Total: 10 }, + ], gear: { gear: 1 }, currentShowDialog: "", - step: 1, // 1:选择模式并播放视频, 2:护理中 showVideoPlayBtn: true, // 视频播放按钮 duration: 0, // 视频总时长 hadShowBreakTips: false, // 是否展示过支架断开提示 @@ -141,18 +148,21 @@ class IotCarePlanFR200 extends Component { isStandStatus: false, // 当前模式是否舱体/支架模式 isShowStepTips: false, // 是否显示介绍步骤弹窗 isConnectionBlutoot: true, // 是否已连接蓝牙 - isShowNurse: false, // 是否开始并显示护理 + isShowNurse: true, // 是否开始并显示护理 FR200默认已经开始准备护理 isStopNurse: false, // 是否暂停护理 isEndNurse: false, // 是否结束护理 errorTips: "", // 错误提示 /** 护理过程 END*/ // 模式列表 + isModeLock: false, // 模式是否锁定 isSwitchActiveMode: false, // 是否显示弹窗切换模式 ModeList: [], ModeType: "all", // all modeClass: "", // 1基础护理 2专区护理 3专研促渗 4敏期护理 5智能测肤 - ActiveModeItem: {}, // 当前选中模式 + ActiveModeItem: { + openSourceData: [], + }, // 当前选中模式 SwitchActiveModeItem: {}, // 切换选中模式 ModeID: "mode_", // 模式KEY activeModeID: "", // 当前选中模式ID:用于高亮 @@ -164,8 +174,6 @@ class IotCarePlanFR200 extends Component { stopSource: "", }, - // 模式组合 - isCombineSuccess: false, // 组合模式是否设置成功 // 倒计时 isShowCountdown: false, // 倒计时弹窗 countdown: 3, @@ -189,8 +197,8 @@ class IotCarePlanFR200 extends Component { // 上一次护理记录未生成,是否继续连接设备 isShowReReadRecordConnect: false, - // 按钮是否不可运行 - isFooterBtnDisabled: true, + // 按钮是否不可运行:FR200不可禁用 + isFooterBtnDisabled: false, // isFirstEntryMode: false, // 模式首次打开 isShowHistoryMsg: false, // 是否显示正在同步历史 @@ -198,17 +206,28 @@ class IotCarePlanFR200 extends Component { } // 不涉及渲染的页面变量 - isRuning: any = false; // 设备是否运行中 + isRuning: any = true; // 设备默认运行中:fr200贴脸就会自动开始工作 jsonStatus: any = {}; // 同步设备返回数据,用于结束 workJsonStatus: any = {}; // 同步工作中的仪器 tempModeCurrent: any = {}; // 临时保存的当前模式 elapsedTime: any = 0; // 设备已运行时间 workStatus: any = ""; // 工作状态 - WL200NursingHistory: any = null; // 护理缓存历史 + FR200NursingHistory: any = null; // 护理缓存历史 hadCheckReport = false; // 是否已检查仪器护理记录 hadGotInstrumentHistoryData = false; // 是否已缓存仪器历史数据 hadLoadedPage = false; // 判断是否首次进入页面 + // FR200同步状态 + FR200Status: any = { + gear: 1, // 1-5 挡位 + isCharging: false, // 是否充电 + joulePerSecond: 0, // 每秒焦耳 0-10 + nasolabialOrMandibularOutput: false, // 鼻唇或下颌输出 + partition: 0, // 分割? + pointOutChangeSide: false, // 交叉输出点 + impedance: 107, // 阻抗? + }; + /** FR200模式类型:名称 */ ModeTypeArray: string[] = [ "all", @@ -224,8 +243,9 @@ class IotCarePlanFR200 extends Component { Taro.setKeepScreenOn({ keepScreenOn: true, }); - // this.getWL200NursingHistory(); this.initData(); + this.getInstrumentClockSummary(); + this.getInstrumentClockDetail(); } componentDidMount() {} @@ -239,7 +259,7 @@ class IotCarePlanFR200 extends Component { return; } - // this.getWL200NursingHistory(); + this.getFR200NursingHistory(); // 重置初始值,每次进入页面重新检查面罩护理记录 this.hadCheckReport = false; this.hadGotInstrumentHistoryData = false; @@ -314,19 +334,17 @@ class IotCarePlanFR200 extends Component { } async init() { - // 查询自定义设备指令 + // 查询离线记录汇总 const queryInstructionParams = { commandType: "InfoQuery", - infoQueryType: "customModeInfo", + infoQueryType: "offlineClockInInfo", + dataType: "summary", }; let commandBuffer = deviceToolKitInstance.toBleCommand( queryInstructionParams as any ); sendCommand({ value: commandBuffer }).then((res) => { - console.log( - "查询自定义组合模式指令发送成功 参数为=>", - queryInstructionParams - ); + console.log("查询查询离线记录汇总 参数为=>", queryInstructionParams); }); // 监听蓝牙连接状态改变 @@ -350,7 +368,7 @@ class IotCarePlanFR200 extends Component { this.setState({ isConnectShow: true, // 打开蓝牙链接弹窗 isConnectionBlutoot: false, // 断开蓝牙 - isShowCountdown: false, // 关闭倒计时,防止倒计时还在运行 + // isShowCountdown: false, // 关闭倒计时,防止倒计时还在运行 }); this.footerIsDisabled(); }; @@ -367,9 +385,9 @@ class IotCarePlanFR200 extends Component { ModeList: res.data.data, }); - // setTimeout(() => { - // this.modeCurrentFun(res.data.data[0]); - // }, 100); + setTimeout(() => { + this.modeCurrentFun(res.data.data[0]); + }, 100); } else { this.setState({ ModeList: [] }); } @@ -413,6 +431,7 @@ class IotCarePlanFR200 extends Component { this.tempModeCurrent = data; // 仅在未开始护理前,切换模式的时候提示模式弹窗 + // FR200默认开始护理 if (!this.state.isShowNurse) { this.openStepTips(); } @@ -450,10 +469,6 @@ class IotCarePlanFR200 extends Component { if (data.serviceData.length > 0) { this.setServiceTimeData(); } - // 存在组合模式时,设置组合模式 - if (data.combineData.length > 0) { - this.setCustomMaskData(); - } }); // 如果是正在运行中切换,则直接准备运行 @@ -480,7 +495,7 @@ class IotCarePlanFR200 extends Component { return false; } - if (this.state.step == 2 && this.state.facialMaskConnectStatus == 1) { + if (this.isRuning === true && this.state.DeviceConnectStatus == 1) { // 提示切换护理模式 if (this.isCheckNurseTime()) { // 满足时间条件,提示是否保存部分护理记录 @@ -497,6 +512,22 @@ class IotCarePlanFR200 extends Component { } return false; } + // 加减组件- 减号操作 + handleMinus = async (data, inde) => { + let GearData = this.state.GearData; + if (GearData[inde].forehead !== 1) { + GearData[inde].forehead = GearData[inde].forehead - 1; + this.setState({ GearData }); + } + }; + // 加减组件- 加号操作 + handleAdd = async (data, inde) => { + let GearData = this.state.GearData; + if (GearData[inde].forehead !== GearData[inde].Total) { + GearData[inde].forehead = GearData[inde].forehead + 1; + this.setState({ GearData }); + } + }; /** 切换护理模式 */ switchModeCurrentFun = async (data) => { @@ -533,11 +564,11 @@ class IotCarePlanFR200 extends Component { stepNext = () => { let modeClass = this.state.ActiveModeItem.modeClass; this.workStatus = "pause"; + this.isRuning = true; // 暂停也是运行中 this.setState({ ModeType: this.ModeTypeArray[modeClass], isShowNurse: true, isStopNurse: true, - step: 2, }); setTimeout(() => { @@ -565,7 +596,7 @@ class IotCarePlanFR200 extends Component { /** * @name 不可切换光照提示 - * @description isCabinMode是否舱体模式。 0.检测面罩与舱体是否仍在连接中,需要分离 1.检测是否连接失败,需要重新连接 + * @description 检测紧贴肌肤 */ onEmitErrorTips = async () => { setTimeout(() => { @@ -574,13 +605,7 @@ class IotCarePlanFR200 extends Component { // 按钮不可点击时,提示报错 let isDisabled = this.footerIsDisabled(); if (isDisabled) { - if (ActiveModeItem.isCabinMode === 0) { - this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); - } else { - this.showTips( - "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" - ); - } + this.showTips("检测到您的设备没有紧贴肌肤,请紧贴肌肤后重新尝试"); } }); }; @@ -626,119 +651,19 @@ class IotCarePlanFR200 extends Component { this.setState({ isShowStepTips: false }); }; - /** 蓝牙相关 */ + /** 蓝牙连接相关 */ switchBLEMatch = (jsonStatus: any) => { - console.log("蓝牙相关", jsonStatus); - let { ActiveModeItem } = this.state; - + console.log("蓝牙连接相关", jsonStatus); switch (jsonStatus.bleCommandType) { // 如果设备配对链接发送配对码的时候,设备应答小程序配对码是否正确。 case "SendMatchCode": if (jsonStatus.matchedSuccess) { console.log("设备配对成功"); this.setState({ - facialMaskConnectStatus: 1, + DeviceConnectStatus: 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, - }); - if (!this.state.isStandStatus && this.isRuning) { - // 断开连接直接暂停 - this.judgementWorkStatus( - MODE_WORKING_ENUM.PAUSE, - ActiveModeItem?.modeType - ); - } - } else { - console.log("舱体支架断开连接"); - - if (this.state.isStandStatus && this.isRuning) { - // 断开连接直接暂停 - this.judgementWorkStatus( - MODE_WORKING_ENUM.PAUSE, - ActiveModeItem?.modeType - ); - } - - // 设备断开时,给定一个断开时间 - ActiveModeItem.breakTimeStr = this.state.currentTime; - - this.setState({ - isStandStatus: false, - isStopNurse: true, - ActiveModeItem, - }); - - setTimeout(() => { - this.onEmitErrorTips(); - }, 500); - } - setTimeout(() => { - this.footerIsDisabled(); - }, 100); - break; - default: - console.log("监听到到设备连接状态改变 this.footerIsDisabled()"); - this.footerIsDisabled(); // 判断底部运行按钮是否可点击 - break; - } - break; - - //小程序主动问主机,现在链接了哪些附属设备,这时候主机给小程序的回复消息 - case "QueryMatchStatus": - console.log("QueryMatchStatus 设备回复小程序", jsonStatus); - - const isStandDevice = jsonStatus?.subDeviceList?.includes("Stand"); - deviceToolKitInstance = deviceToolKitInstanceFR200; - console.log("支架是否链接", isStandDevice); - this.setState({ - isStandStatus: isStandDevice, - }); - setTimeout(() => { - this.footerIsDisabled(); - }); - - // 连上面罩后, 获取仪器记录, 与缓存信息对比 - if (!this.hadGotInstrumentHistoryData) { - // 查询护理记录 - this.getInstrumentHistoryData(); - - // 查询仪器状态 - const queryDeviceArrayBuffer = deviceToolKitInstance.toBleCommand( - bleCommandSamples.queryDeviceStatus as any - ); - console.log("发送查询设备指令 获取仪器状态"); - sendCommand({ - value: queryDeviceArrayBuffer, - }); - } } }; @@ -776,88 +701,138 @@ class IotCarePlanFR200 extends Component { break; //设备状态同步 case "DeviceStatusSync": - console.log("设备状态同步", jsonStatus); + this.setState({ + Electricity: jsonStatus.battery, + }); switch (jsonStatus.workStatus) { case "standby": //设备的待机状态 可能workMode字段为空 + console.log("设备状态同步 待机状态", jsonStatus); + // this.judgementWorkStatus( + // MODE_WORKING_ENUM.STANDBY, + // jsonStatus.workMode + // ); break; case "pause": //设备的暂停状态 + console.log("设备状态同步 暂停状态", jsonStatus); + // this.judgementWorkStatus( + // MODE_WORKING_ENUM.PAUSE, + // jsonStatus.workMode + // ); break; case "working": //设备的运行中状态 + console.log("设备状态同步 运行中状态", jsonStatus); + // this.judgementWorkStatus( + // MODE_WORKING_ENUM.WORKING, + // jsonStatus.workMode + // ); break; default: break; } + 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); + if (jsonStatus?.workMode === this.state.ActiveModeItem.modeType) { + if (this.state.workMode !== jsonStatus?.workMode) { + this.setState({ + workMode: jsonStatus?.workMode, // 仅当设备上报模式与小程序一致时,才允许改变小程序变量缓存 + }); + } + + // 判断设备是否在运行中(护理中) + // 仅当设备模式与小程序是否一致,才允许更改设备运行时间 + if (this.isRuning) { + if ( + this.state.DeviceConnectStatus === 1 && + jsonStatus.workStatus !== MODE_WORKING_ENUM.END + ) { + this.updateDeviceSyncData( + { + totalWorkingMinutes: jsonStatus.totalWorkingMinutes, + totalWorkingSeconds: jsonStatus.totalWorkingSeconds, + }, + jsonStatus + ); + } + } + } break; //设备对控制指令的响应 case "DeviceControl": console.log("设备控制响应", jsonStatus); - // if (jsonStatus.responseStatus == "OK") { - // console.log("发送控制指令成功"); - // this.workJsonStatus = jsonStatus; - // this.workStatus = jsonStatus.workStatus; - - // setTimeout(() => console.log("this.workStatus", this.workStatus)); - // this.setState({ - // Electricity: jsonStatus.battery, - // // fr200Electricity: jsonStatus.battery, - // matrixElectricity: jsonStatus.matrixBattery, - // }); - - // // 判断设备主动上报的关机事件 - // if (jsonStatus.workStatus === MODE_WORKING_ENUM.END) { - // // 判断id是否一致, 一致的话则生成护理报表, 并提示 - // if (jsonStatus.id == this.WL200NursingHistory.id) { - // debounce( - // this.checkInstrumentRecord.bind(this, jsonStatus), - // 500 - // ); - // } - // return; - // } - - // 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 ( - // jsonStatus.workMode === MODE_WORKING_ENUM.WORKING && - // this.state.step == 2 - // ) { - // const { ActiveModeItem } = this.state; - // const item = ActiveModeItem; - // if (jsonStatus.workMode !== item.modeType) { - // clearTimeout(loadingTipsTimer); - // this.setState({ - // isShowCountdown: false, - // }); - // } - // } - // } + if (jsonStatus.responseStatus == "OK") { + console.log("发送控制指令成功"); + this.workJsonStatus = jsonStatus; + this.workStatus = jsonStatus.workStatus; + + setTimeout(() => console.log("this.workStatus", this.workStatus)); + this.setState({ + Electricity: jsonStatus.battery, + matrixElectricity: jsonStatus.matrixBattery, + }); + + // 判断设备主动上报的关机事件 + if (jsonStatus.workStatus === MODE_WORKING_ENUM.END) { + // 判断id是否一致, 一致的话则生成护理报表, 并提示 + if (jsonStatus.id == this.FR200NursingHistory.id) { + debounce( + this.checkInstrumentRecord.bind(this, jsonStatus), + 500 + ); + } + return; + } + + if (jsonStatus?.workMode === this.state.ActiveModeItem.modeType) { + this.setState({ + workMode: jsonStatus?.workMode, // 仅当设备上报模式与小程序一致时,才允许改变小程序变量缓存 + }); + + // 判断是否在isRuning(护理中) + // 仅当设备模式与小程序是否一致,才允许更改设备运行时间 + if ( + this.state.DeviceConnectStatus === 1 && + this.isRuning == 2 && + jsonStatus.workStatus !== MODE_WORKING_ENUM.END + ) { + this.updateDeviceSyncData( + { + totalWorkingMinutes: jsonStatus.totalWorkingMinutes, + totalWorkingSeconds: jsonStatus.totalWorkingSeconds, + }, + jsonStatus + ); + } + } + + if ( + jsonStatus.workMode === MODE_WORKING_ENUM.WORKING && + this.isRuning + ) { + const { ActiveModeItem } = this.state; + const item = ActiveModeItem; + if (jsonStatus.workMode !== item.modeType) { + clearTimeout(loadingTipsTimer); + this.setState({ + isShowCountdown: false, + }); + } + } + } break; - //设备对信息查询指令的响应 + // 设备对信息查询指令的响应 case "InfoQuery": + console.log("设备对信息查询指令的响应 InfoQuery", jsonStatus); switch (jsonStatus.infoQueryType) { // 离线记录 case "offlineClockInInfo": @@ -911,7 +886,7 @@ class IotCarePlanFR200 extends Component { /**监听关机事件*/ onEndDevice = () => { - this.rmWL200NursingHistory(this.WL200NursingHistory, true); + this.rmFR200NursingHistory(this.FR200NursingHistory, true); // 判断护理时间,如果不足,则提示不足 if (!this.isCheckNurseTime()) { this.setState({ isNotEnoughTime: true }); @@ -954,8 +929,8 @@ class IotCarePlanFR200 extends Component { if ( sceneTime > totalTime && - this.state.step == 2 && - this.state.facialMaskConnectStatus == 1 + this.isRuning === true && + this.state.DeviceConnectStatus == 1 ) { // 界面倒计时同步设备时间 const t = sceneTime - totalTime; // 场景时间 - 已运行时间 = 剩余时间 @@ -971,7 +946,7 @@ class IotCarePlanFR200 extends Component { // 每次同步后,更新历史缓存 setTimeout(() => { - this.updateWL200NursingHistory(); + this.updateFR200NursingHistory(null, jsonStatus); }, 100); }, }; @@ -999,7 +974,7 @@ class IotCarePlanFR200 extends Component { * params 工作状态 工作模式 响应状态 */ judgementWorkStatus(nWorkStatus, nWorkMode) { - const { step, workMode, ActiveModeItem, ModeList } = this.state; + const { workMode, ActiveModeItem, ModeList } = this.state; const opts: any = {}; // ActiveModeItem let nowModeItem; @@ -1026,11 +1001,11 @@ class IotCarePlanFR200 extends Component { this.setState({ isShowCountdown: false, }); - if (nowModeItem?.isCabinMode && step == 2) { + if (nowModeItem?.isCabinMode && this.isRuning === true) { opts.currentTime = nowCurrentTime; - } else if (!nowModeItem?.isCabinMode && step == 2) { + } else if (!nowModeItem?.isCabinMode && this.isRuning === true) { // fix: 启动非支架模式倒计时时,连上支架,仪器的状态变为standby - opts.step = 1; + this.isRuning === false; } }, setting: () => { @@ -1038,14 +1013,14 @@ class IotCarePlanFR200 extends Component { this.setState({ hadShowBreakTips: false, }); - if (step != 2 && !ActiveModeItem.isCabinMode) { - opts.step = 2; + if (this.isRuning === false && !ActiveModeItem.isCabinMode) { + this.isRuning = true; this.setState({ title: "正在护理", isStopNurse: false, }); - } else if (step != 2 && ActiveModeItem.isCabinMode) { - opts.step = 2; + } else if (this.isRuning === false && ActiveModeItem.isCabinMode) { + this.isRuning = true; // this.setState({ // title: "正在护理", // }); @@ -1057,27 +1032,18 @@ class IotCarePlanFR200 extends Component { if (nowModeItem) { opts.currentTime = nowCurrentTime; } - // startSettingCountDown 用于标记打开了倒计时loading - if (!this.state.isShowCountdown) { - this.setState({ - isShowCountdown: true, - }); - this.setLoadingTips(CountDownTime[workMode] || 6); - } + // 倒计时loading + // if (!this.state.isShowCountdown) { + // this.setState({ + // isShowCountdown: true, + // }); + // this.setLoadingTips(CountDownTime[workMode] || 6); + // } }, working: () => { - if (this.state.facialMaskConnectStatus != 1) { - opts.workStatus = MODE_WORKING_ENUM.STANDBY; - opts.step = 1; - } else if (step != 2) { - opts.step = 2; - this.setState({ - title: "正在护理", - isStopNurse: false, - }); - } - this.setState({ + title: "正在护理", + isStopNurse: false, isShowCountdown: false, hadShowBreakTips: false, }); @@ -1140,8 +1106,7 @@ class IotCarePlanFR200 extends Component { currentTimeTimer && clearInterval(currentTimeTimer); currentTimeTimer = setInterval(() => { let { - step, - facialMaskConnectStatus, + DeviceConnectStatus, currentTime, ModeStepTimeArray, ModeStepIndex, @@ -1149,8 +1114,8 @@ class IotCarePlanFR200 extends Component { } = this.state; if ( this.workStatus == MODE_WORKING_ENUM.WORKING && - step == 2 && - facialMaskConnectStatus == 1 + this.isRuning && + DeviceConnectStatus == 1 ) { let totalSeconds = ActiveModeItem?.breakTimeStr ? minSecToS(ActiveModeItem.breakTimeStr) @@ -1220,23 +1185,15 @@ class IotCarePlanFR200 extends Component { // 检测并控制工作状态 handleWorkStatus = (isBtnClick: boolean, workStatus) => { - const { facialMaskConnectStatus, isStandStatus, ActiveModeItem } = - this.state; + const { DeviceConnectStatus, ActiveModeItem } = this.state; let newWorkStatus = workStatus || (this.workStatus == MODE_WORKING_ENUM.WORKING ? "pause" : "working"); if (isBtnClick && newWorkStatus == "working") { - // 舱体模式 - if (ActiveModeItem.isCabinMode === 1 && !isStandStatus) { - this.showTips( - `检测到舱体未连接成功,请确认面罩开机后与舱体连接,并接通舱体电源` - ); - return; - } - // 非舱体模式 - if (!ActiveModeItem.isCabinMode && facialMaskConnectStatus != 1) { - console.log("facialMaskConnectStatus", facialMaskConnectStatus); - this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴"); + // todo FR200 不判断舱体,判断肌肤 + if (!ActiveModeItem.isCabinMode && DeviceConnectStatus != 1) { + console.log("DeviceConnectStatus", DeviceConnectStatus); + this.showTips("检测到您的设备没有紧贴肌肤,请紧贴肌肤后点击重新检测"); return; } } @@ -1280,56 +1237,19 @@ class IotCarePlanFR200 extends Component { }); }, 500); - const { ActiveModeItem, isStandStatus, facialMaskConnectStatus } = - this.state; + const { ActiveModeItem, DeviceConnectStatus } = this.state; - if (isStandStatus === true && ActiveModeItem.isCabinMode === 0) { - console.log("已连接舱体,只可选择舱体模式"); - return; - } - if (isStandStatus === false && ActiveModeItem.isCabinMode === 1) { - console.log("未连接舱体!"); - return; - } - - console.info( - commandMap.WL200Command, - "点击开始护理按钮", - `当前模式: ${ActiveModeItem.modeType}`, - `当前面罩状态:${facialMaskConnectStatus}`, - `当前仪器模式:${this.workStatus}` - ); - console.log(ActiveModeItem); - console.log("isStandStatus:" + isStandStatus); - - if (facialMaskConnectStatus != 1) { - console.log("facialMaskConnectStatus 开始处", facialMaskConnectStatus); - this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴"); - return; - } - // 如果是强效舒缓,需要判断是否连接支架 - if (ActiveModeItem.isCabinMode && !isStandStatus) { - this.showTips( - `检测到舱体未连接成功,请确认面罩开机后与舱体连接,并接通舱体电源` - ); - return; - } else if (!ActiveModeItem.isCabinMode && isStandStatus) { - this.showTips(`检测到面罩仍和舱体连接中,请分离后切换`); - return; - } - if ( - ActiveModeItem.modeType === "MaskCustom" && - !this.state.isCombineSuccess - ) { - this.showTips(`${ActiveModeItem.modeName}模式设置失败,请联系小助手`); + if (DeviceConnectStatus != 1) { + console.log("DeviceConnectStatus 开始处", DeviceConnectStatus); + this.showTips("检测到FR200未连接成功,请确认FR200开机并佩戴"); return; } // 仅在切换模式的时候,弹窗倒计时. - if (type === "switch") { - let downNum = CountDownTime[ActiveModeItem.modeType] || 3; - this.showCountdownFun(downNum, () => {}); // 倒计时弹窗 - } + // if (type === "switch") { + // let downNum = CountDownTime[ActiveModeItem.modeType] || 3; + // this.showCountdownFun(downNum, () => {}); // 倒计时弹窗 + // } // 开始执行护理 this.workStatus = MODE_WORKING_ENUM.WORKING; // 不管当前什么状态,直接设为工作状态 @@ -1372,20 +1292,33 @@ class IotCarePlanFR200 extends Component { } } /*** 护理记录 START ***/ - /** 小程序查询护理记录 */ - getInstrumentHistoryData() { + /** 小程序查询护理记录概要 */ + getInstrumentClockSummary() { this.hadGotInstrumentHistoryData = true; - console.log("发送指令currentMaskReportInfo 获取设备护理记录"); + console.log("发送指令clockSummary 获取设备护理概要"); setTimeout(() => { - const queryCurrentMaskReportInfoBuffer = - deviceToolKitInstance.toBleCommand({ - ...(bleCommandSamples.queryCurrentMaskReportInfo as any), - }); + const queryClockSummary = deviceToolKitInstance.toBleCommand({ + ...(fr200BleCommand.InfoQuery.clockSummary as any), + }); sendCommand({ - value: queryCurrentMaskReportInfoBuffer, + value: queryClockSummary, }); - }, 3000); + }, 1000); } + /** 小程序查询最近一条护理详情 */ + getInstrumentClockDetail() { + this.hadGotInstrumentHistoryData = true; + console.log("发送指令clockDetail 查询最近一条护理详情"); + setTimeout(() => { + const queryClockSummary = deviceToolKitInstance.toBleCommand({ + ...(fr200BleCommand.InfoQuery.clockDetail as any), + }); + sendCommand({ + value: queryClockSummary, + }); + }, 2000); + } + /** * @title 检查护理记录 * @description @@ -1424,6 +1357,7 @@ class IotCarePlanFR200 extends Component { isFooterBtnDisabled: false, }); if (this.workJsonStatus.workMode) { + // FR200可能要判断是否水分测试 Test console.log("this.workJsonStatus.workMode", this.workJsonStatus.workMode); if (this.workJsonStatus.workMode.indexOf("Stand") > -1) { console.log( @@ -1439,43 +1373,42 @@ class IotCarePlanFR200 extends Component { // 2.判断是否已存在缓存的护理记录:如果没有历史,则缓存 let workStatus = this.workJsonStatus.workStatus; - let WL200NursingHistory = this.WL200NursingHistory; - if (!this.WL200NursingHistory) { + let FR200NursingHistory = this.FR200NursingHistory; + if (!this.FR200NursingHistory) { console.log("小程序缓存没有数据, 忽略"); if ( workStatus == MODE_WORKING_ENUM.WORKING || workStatus == MODE_WORKING_ENUM.PAUSE ) { // 缓存没有数据, 要存缓存 - this.setWL200NursingHistory(jsonStatus); + this.setFR200NursingHistory(jsonStatus); } return; } // 3.判断是否当天(如果不是当天,则删除记录) - if (!dayjs().isSame(WL200NursingHistory?.createDate, "day")) { + if (!dayjs().isSame(FR200NursingHistory?.createDate, "day")) { console.log("小程序缓存有数据,但是不是当天数据,忽略"); - this.rmWL200NursingHistory(WL200NursingHistory); + this.rmFR200NursingHistory(FR200NursingHistory); return; } // 仪器缓存模式,判断是否存在于现有模式中 let recordModeItem = ModeList.find((item) => { - return item.id == WL200NursingHistory.currentServiceData.modeId; + return item.id == FR200NursingHistory.currentServiceData.modeId; }); - if (!WL200NursingHistory || !recordModeItem) { + if (!FR200NursingHistory || !recordModeItem) { console.log("仪器有数据, 但是缓存没有数据, 忽略"); return; } console.log("workStatus", workStatus); console.log("jsonStatus", jsonStatus, this.workJsonStatus); - console.log("currentTime", WL200NursingHistory.currentTime); - console.log("isStandStatus", this.state.isStandStatus); + console.log("currentTime", FR200NursingHistory.currentTime); let historyElapsedTime = minSecToS(recordModeItem.modeTimeStr) - - minSecToS(WL200NursingHistory.currentTime); + minSecToS(FR200NursingHistory.currentTime); this.elapsedTime = this.elapsedTime > historyElapsedTime @@ -1488,7 +1421,7 @@ class IotCarePlanFR200 extends Component { !workStatus ) { // 判断id是否一致, 一致的话则生成护理报表 - if (jsonStatus.id == WL200NursingHistory.id) { + if (jsonStatus.id == FR200NursingHistory.id) { console.log("id一致, 设备没有运行/已完成/待机"); let totalSeconds = jsonStatus.totalSeconds; // 从仪器上获取的使用时间 @@ -1498,7 +1431,7 @@ class IotCarePlanFR200 extends Component { if (totalSeconds < nursingTime) { // 护理时间不足 this.setState({ isNotEnoughTime: true }); - this.rmWL200NursingHistory(WL200NursingHistory); + this.rmFR200NursingHistory(FR200NursingHistory); return; } @@ -1518,7 +1451,7 @@ class IotCarePlanFR200 extends Component { this.handleWorkStatus(false, "end"); let res: any = await this.PostNursingLogClock(params); console.log("res", res); - this.rmWL200NursingHistory(WL200NursingHistory); + this.rmFR200NursingHistory(FR200NursingHistory); } else { // ID不一致,同步异常,统一提交一分钟 let params = { @@ -1531,17 +1464,15 @@ class IotCarePlanFR200 extends Component { this.handleWorkStatus(false, "end"); let res: any = await this.PostNursingLogClock(params); console.log("res", res); - this.rmWL200NursingHistory(WL200NursingHistory); + this.rmFR200NursingHistory(FR200NursingHistory); } } else { console.log("id一致, 设备运行中或暂停"); // 5.判断设备状态-运行中 // 同步时间 - if (jsonStatus.id == WL200NursingHistory.id) { - if (WL200NursingHistory.currentTime) { - this.setState({ - step: 2, - }); + if (jsonStatus.id == FR200NursingHistory.id) { + if (FR200NursingHistory.currentTime) { + this.isRuning = true; this.resetTimer(); } } @@ -1549,39 +1480,35 @@ class IotCarePlanFR200 extends Component { }; /** 获取小程序本地缓存的历史记录 */ - getWL200NursingHistory() { - this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); + getFR200NursingHistory() { + this.FR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); // 是否同步历史记录 let isSyncHistory = Taro.getStorageSync("isSyncHistory"); if (isSyncHistory) { - let ActiveModeItem = this.WL200NursingHistory.ActiveModeItem; + let ActiveModeItem = this.FR200NursingHistory.ActiveModeItem; // 直接进入开始护理状态 this.setState({ isShowNurse: true, isShowHistoryMsg: true, - currentServiceData: this.WL200NursingHistory.currentServiceData, + currentServiceData: this.FR200NursingHistory.currentServiceData, tempModeCurrent: ActiveModeItem, ActiveModeItem: ActiveModeItem, activeModeID: ActiveModeItem.id, ModeID: "mode_" + ActiveModeItem.id, - currentTime: this.WL200NursingHistory.currentTime, + currentTime: this.FR200NursingHistory.currentTime, }); setTimeout(() => { // 设置时间组合 if (ActiveModeItem.serviceData.length > 0) { this.setServiceTimeData(); } - // 存在组合模式时,设置组合模式 - if (ActiveModeItem.combineData.length > 0) { - this.setCustomMaskData(); - } }); } } /** 设置WL200护理历史 */ - setWL200NursingHistory = (jsonStatus: any) => { - let { currentDevice, ActiveModeItem, ModeList } = this.state; + setFR200NursingHistory = (jsonStatus: any) => { + let { currentDevice, ActiveModeItem } = this.state; const params = { createDate: dayjs().format("YYYY-MM-DD"), workMode: jsonStatus.workMode, @@ -1594,16 +1521,16 @@ class IotCarePlanFR200 extends Component { jsonStatus, ActiveModeItem: this.state.ActiveModeItem, }; - this.WL200NursingHistory = JSON.parse(JSON.stringify(params)); - Taro.setStorageSync("WL200NursingHistory", params); - console.log("保存setWL200NursingHistory"); + this.FR200NursingHistory = JSON.parse(JSON.stringify(params)); + Taro.setStorageSync("FR200NursingHistory", params); + console.log("保存setFR200NursingHistory"); }; /** 更新WL200护理历史运行时间 */ - updateWL200NursingHistory = (data: any = null) => { - this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); + updateFR200NursingHistory = (data: any = null, jsonStatus = null) => { + this.FR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); - if (this.WL200NursingHistory) { - let params: any = this.WL200NursingHistory; + if (this.FR200NursingHistory) { + let params: any = this.FR200NursingHistory; // 设置当前时间 params.currentTime = this.state.currentTime; @@ -1621,9 +1548,17 @@ class IotCarePlanFR200 extends Component { currentServiceData = this.state.ActiveModeItem.serviceData[0]; } params.currentServiceData = currentServiceData; + + if (jsonStatus) { + // 缓存每秒数据 + if (!params.dataArray) params.dataArray = []; + params.dataArray.push(jsonStatus); + } } - Taro.setStorageSync("WL200NursingHistory", params); - console.log("更新updateWL200NursingHistory"); + Taro.setStorageSync("FR200NursingHistory", params); + console.log("更新updateFR200NursingHistory"); + } else { + this.setFR200NursingHistory(jsonStatus); } }; /** @@ -1632,14 +1567,16 @@ class IotCarePlanFR200 extends Component { * 如果传入护理历史ID与现有ID相等,则删除。 * 如果参数二为真,则强制删除 */ - rmWL200NursingHistory = (WL200NursingHistory, hard = false) => { - const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); - if (nowWL200NursingHistory.id == WL200NursingHistory.id) { - Taro.removeStorageSync("WL200NursingHistory"); - this.WL200NursingHistory.id = ""; + rmFR200NursingHistory = (FR200NursingHistory, hard = false) => { + const nowFR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); + + Taro.setStorageSync("FR200Echart", nowFR200NursingHistory); // 临时保存用于观看和调试 + if (nowFR200NursingHistory.id == FR200NursingHistory.id) { + Taro.removeStorageSync("FR200NursingHistory"); + this.FR200NursingHistory.id = ""; } else if (hard) { - Taro.removeStorageSync("WL200NursingHistory"); - this.WL200NursingHistory.id = ""; + Taro.removeStorageSync("FR200NursingHistory"); + this.FR200NursingHistory.id = ""; } }; @@ -1671,7 +1608,7 @@ class IotCarePlanFR200 extends Component { let res = await InstrumentInfo.apiClock.addClockInstrument(params); console.log(res, "护理完成"); - this.rmWL200NursingHistory(this.WL200NursingHistory); // 护理完成,删除记录 + this.rmFR200NursingHistory(this.FR200NursingHistory); // 护理完成,删除记录 if (isJump) { this.setState({ isShowNursingSuccess: true, @@ -1771,43 +1708,6 @@ class IotCarePlanFR200 extends Component { }); return modesArray; }; - setCustomMaskData() { - console.log("================"); - console.log("setCustomMaskData"); - console.log("================"); - - // modesArray 发送组合模式数组指令到设备存储 - let modesArray = this.getCustomModesArray(); - console.log("组合模式modesArray", modesArray); - - let customModeSetCommand = { - commandType: "InfoQuery", - infoQueryType: "customModeSet", - modesArray, - }; - let commandBuffer = deviceToolKitInstance.toBleCommand( - customModeSetCommand as any - ); - sendCommand({ - value: commandBuffer, - }).then((res) => { - console.info("发送切换组合模式指令成功", res); - }); - } - // 发送启动组合模式指令 - startCombinationMode() { - const jsonCommand = { - commandType: "DeviceControl", - workStatus: "working", - workMode: "MaskCustom", - }; - let commandBuffer = deviceToolKitInstance.toBleCommand(jsonCommand as any); - sendCommand({ - value: commandBuffer, - }).then(() => { - console.info("发送启动组合模式指令成功 参数为 =>", jsonCommand); - }); - } // 护理的错误提示 showTips(ctx) { @@ -1960,24 +1860,12 @@ class IotCarePlanFR200 extends Component { * @returns 返回true则禁用 */ footerIsDisabled = () => { - let { isStandStatus } = this.state; - let isCanClick = isStandStatus - ? this.tempModeCurrent?.isCabinMode === 1 - : this.tempModeCurrent?.isCabinMode === 0; - // 如果舱体状态和模式类型不相等,则禁用 + // 默认不禁用,FR200无法禁用 let isFooterBtnDisabled = false; - if (!isCanClick) { - isFooterBtnDisabled = true; - } - console.log("isCanClick", isCanClick); - console.log("isFooterBtnDisabled", isFooterBtnDisabled); - // 仅在值变化时更新state - // if (isFooterBtnDisabled !== this.state.isFooterBtnDisabled) { - this.setState({ - isFooterBtnDisabled: isFooterBtnDisabled, - }); - // } + // this.setState({ + // isFooterBtnDisabled: isFooterBtnDisabled, + // }); return isFooterBtnDisabled; // 数据更新有延迟,返回用于判断 }; @@ -1986,10 +1874,18 @@ class IotCarePlanFR200 extends Component { Taro.reLaunch({ url: "/pages/index/index" }); }; + onModeLockOpen = async () => { + this.setState({ isModeLock: true }); + }; + onModeLockClose = async () => { + this.setState({ isModeLock: false }); + }; + render() { let { title, isConnectShow, + GearData, isShowStepTips, isShowNurse, isStopNurse, @@ -1998,7 +1894,6 @@ class IotCarePlanFR200 extends Component { ModeStepIndex, currentServiceData, ActiveModeItem, - SwitchActiveModeItem, isSwitchActiveMode, ModeID, activeModeID, @@ -2009,7 +1904,7 @@ class IotCarePlanFR200 extends Component { errorTips, isEndCarePlan, currentTime, - facialMaskConnectStatus, + DeviceConnectStatus, isShowErrorTipsText, errorTipsText, isNotEnoughTime, @@ -2022,7 +1917,7 @@ class IotCarePlanFR200 extends Component { isShowReReadRecordSave, isFooterBtnDisabled, isShowHistoryMsg, - stepIndex, + isModeLock, } = this.state; return ( @@ -2035,6 +1930,17 @@ class IotCarePlanFR200 extends Component { /> + { ModeType={ModeType} onEmit={this.switchModeCurrentFun} onEmitShowAll={this.openModeSwitch} + onModeLockOpen={this.onModeLockOpen} /> } textAlgin="center" @@ -2083,7 +1990,7 @@ class IotCarePlanFR200 extends Component { confirm={this.confirmModeSwitchBtn} /> - {ActiveModeItem.openSourceData && ( + {ActiveModeItem.openSourceData.length > 0 && ( { @@ -2237,6 +2144,7 @@ class IotCarePlanFR200 extends Component { activeModeID={activeModeID} onEmit={this.modeCurrentFun} onEmitShowAll={this.openModeSwitch} + onModeLockOpen={this.onModeLockOpen} /> )} @@ -2248,7 +2156,12 @@ class IotCarePlanFR200 extends Component { /> )} - + {/* */} +