From 63a28dba2174c18f217e38ccfdc9a9793f9d844b Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Thu, 28 Mar 2024 20:49:05 +0800 Subject: [PATCH] =?UTF-8?q?we100=20=E5=89=8D=E6=9C=9F=E5=87=86=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.config.ts | 2 +- src/components/bluetoot/connection/fr200.js | 3 + src/components/bluetoot/connection/we100.js | 183 ++++ src/components/bluetoot/connection/we200.js | 100 -- src/moduleIOT/pages/iotCarePlan/FR200.tsx | 2 +- .../iotCarePlan/{WE200.less => WE100.less} | 0 .../iotCarePlan/{WE200.tsx => WE100.tsx} | 872 +++++++----------- .../pages/iotCarePlan/WE200.config.ts | 5 - .../iotCarePlan/components/Bluetoot/FR200.ts | 14 - .../iotCarePlan/components/Bluetoot/WE100.ts | 418 +++++++++ 10 files changed, 925 insertions(+), 674 deletions(-) create mode 100644 src/components/bluetoot/connection/we100.js delete mode 100644 src/components/bluetoot/connection/we200.js rename src/moduleIOT/pages/iotCarePlan/{WE200.less => WE100.less} (100%) rename src/moduleIOT/pages/iotCarePlan/{WE200.tsx => WE100.tsx} (71%) delete mode 100644 src/moduleIOT/pages/iotCarePlan/WE200.config.ts create mode 100644 src/moduleIOT/pages/iotCarePlan/components/Bluetoot/WE100.ts diff --git a/src/app.config.ts b/src/app.config.ts index ac0e79f..a539342 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -79,7 +79,7 @@ export default defineAppConfig({ subPackages: [ { root: "moduleIOT", - pages: ["pages/iotCarePlan/WL200", "pages/iotCarePlan/FR200", "pages/iotCarePlan/WE200",], + pages: ["pages/iotCarePlan/WL200", "pages/iotCarePlan/FR200", "pages/iotCarePlan/WE100",], }, { root: "recoding", diff --git a/src/components/bluetoot/connection/fr200.js b/src/components/bluetoot/connection/fr200.js index 4b997e4..df0b5a6 100644 --- a/src/components/bluetoot/connection/fr200.js +++ b/src/components/bluetoot/connection/fr200.js @@ -41,6 +41,9 @@ export const fr200DeviceControlCommand = { queryDeviceStatus: { commandType: "DeviceStatusSync", deviceSyncCommandType: "onlySyncStatusToDevice", + // totalWorkingSeconds: 55, + // workStatus: "working", + // workMode: 'eyes', }, /**控制设备暂停 pause暂停 working启动 end关闭*/ pause: { diff --git a/src/components/bluetoot/connection/we100.js b/src/components/bluetoot/connection/we100.js new file mode 100644 index 0000000..067aec0 --- /dev/null +++ b/src/components/bluetoot/connection/we100.js @@ -0,0 +1,183 @@ +/**蓝牙命令合集*/ +export const WE100BleCommand = { + /**发送配对码*/ + match: { + commandType: "BleMatch", + bleCommandType: "SendMatchCode", + }, + /**查询附属设备的配对状态*/ + querySubDevice: { + commandType: "BleMatch", + bleCommandType: "QueryMatchStatus", + }, + + // 查询信息 + InfoQuery: { + /**查询版本指令*/ + versionInfo: { + commandType: "InfoQuery", + infoQueryType: "versionInfo", + otaDeviceType: "WE100", + }, + /**时间同步*/ + timeSync: { + commandType: "InfoQuery", + infoQueryType: "timeSync", + date: new Date(), + }, + /** 查询 面膜自定义模式信息 */ + facialMaskCustomModeInfo: { + commandType: "InfoQuery", + infoQueryType: "facialMaskCustomModeInfo", + }, + /** + * @name 查询并设置:自定义电流配方模式面膜模式 + * @description 部位只是执行顺序,所有部位共用三种模式 Pulling(提拉) Moisturize(滋润) Mix(混合) + * */ + facialMaskCustomModeSet: { + commandType: "InfoQuery", + infoQueryType: "facialMaskCustomModeSet", + feelingTakeEffectOffline: true, + partitionConfigArray: [ + { + feelingType: "Pulling", + pullingSeconds: 1.05, + moisturizeSeconds: 2.25, + }, + { + feelingType: "Mix", + pullingSeconds: 1.05, + moisturizeSeconds: 2.25, + }, + { + feelingType: "Mix", + pullingSeconds: 1.05, + moisturizeSeconds: 2.25, + }, + { + feelingType: "Moisturize", + pullingSeconds: 1.15, + moisturizeSeconds: 0.25, + }, + ], + neededTotalSeconds: 900, // 设置工作时间 + }, + + /** 离线汇总 */ + offlineSummary: { + commandType: "InfoQuery", + infoQueryType: "offlineClockSummary", + }, + /** 离线详情 */ + offlineDetail: { + commandType: "InfoQuery", + infoQueryType: "offlineClockDetail", + dataIndex: 0, + }, + + /** 现在的面膜报告信息 */ + currentFacialReportInfo: { + commandType: "InfoQuery", + infoQueryType: "currentFacialReportInfo", + }, + /** 查询M02自定义面膜信息 */ + m02MaskCustomModeInfo: { + commandType: "InfoQuery", + infoQueryType: "m02MaskCustomModeInfo", + workMode: "PreMakeup_Custom", + }, + /** 查询并设置:眼雕大师自定义、妆前急救自定义面膜模式 */ + m02MaskCustomModeSet: { + commandType: "InfoQuery", + infoQueryType: "m02MaskCustomModeSet", + workMode: "EyeCarving_Custom", + feelingTakeEffectOffline: "OnlyAffectOnce", + partitionConfigArray: [ + { + feelingType: ["Moisturize", "EyeSculpt"], + pullingSeconds: 0.05, + moisturizeSeconds: 1.15, + eyeSculptSeconds: 6, + }, + { + feelingType: ["Moisturize", "EyeSculpt"], + pullingSeconds: 0, + moisturizeSeconds: 1.15, + eyeSculptSeconds: 6, + }, + { + feelingType: ["Pulling", "Moisturize"], + pullingSeconds: 1, + moisturizeSeconds: 2, + eyeSculptSeconds: 0, + }, + ], + neededTotalSeconds: 900, // 设置工作时间 + }, + }, +}; + +/**控制设备命令合集*/ +export const WE100DeviceControlCommand = { + /**控制设备暂停 pause暂停 working启动 end关闭*/ + // '水光精华模式分区档位0-3-2-5离线生效' = 'workByPatitionSet', + // '自定义电流配方模式运行档位1-3-2-2离线不生效' = 'workCustom', + + // '控制设备暂停' = 'pause', + // '控制设备继续工作' = 'working', + // '发送APP状态使设备同步-工作时间55秒' = 'onlySyncStatusToDevice', + + // '主动查询设备的状态' = 'queryDeviceStatus', + // // m02 + // '状前模式运行档位1-3-2档位离线不生效' = 'm02work1', + // '眼雕电流配方模式运行档位1-3-2档位离线生效' = 'm02workCustom2', + // standby: { + // commandType: "DeviceControl", + // workStatus: "standby", + // }, + work: { + commandType: "DeviceControl", + workStatus: "working", + }, + pause: { + commandType: "DeviceControl", + workStatus: "pause", + }, + end: { + commandType: "DeviceControl", + workStatus: "end", + }, + + working2: { ...working, neededTotalSeconds: 600 }, // 设置工作十分钟 + + /** + * M01膜布 + * WaterLightEssence: 水光精华模式 + * ShapeBeautyEssence: 塑颜精华模式 + * DiyFacial: DIY面膜模式 + * ShapeBeautyEssence_Custom: 自定义电流配方模式 + * + * M02膜布 + * EyeCarving_Custom: 眼雕大师配方模式 + * PreMakeup_Custom: 妆前急救模式 + */ + + // 设置工作模式 + workByPatitionSet: { + commandType: "DeviceControl", + workStatus: "working", + workMode: "WaterLightEssence", // 工作模式 + gearTakeEffectOffline: true, // 是否离线生效 + partitionStatus: [{ gear: 0 }, { gear: 3 }, { gear: 2 }, { gear: 5 }], // 0-3-2-5挡位是官配电流模式,自定义时可修改? + }, + + // 发送APP状态使设备同步 + onlySyncStatusToDevice: { + commandType: "DeviceStatusSync", + deviceSyncCommandType: "onlySyncStatusToDevice", + totalWorkingSeconds: 55, // 同步工作时间? + workStatus: "working", // 工作状态,与程序同步 + workMode: "ShapeBeautyEssence", // 模式,与程序同步 + partitionStatus: [{ gear: 0 }, { gear: 3 }, { gear: 2 }, { gear: 5 }], // 挡位,与程序同步,非自定义模式或许可以不传 + }, +}; diff --git a/src/components/bluetoot/connection/we200.js b/src/components/bluetoot/connection/we200.js deleted file mode 100644 index 8975fa1..0000000 --- a/src/components/bluetoot/connection/we200.js +++ /dev/null @@ -1,100 +0,0 @@ -/**蓝牙命令合集*/ -export const we200BleCommand = { - /**发送配对码*/ - match: { - commandType: "BleMatch", - bleCommandType: "SendMatchCode", - }, - - InfoQuery: { - /**查询版本指令*/ - versionInfo: { - commandType: "InfoQuery", - infoQueryType: "versionInfo", - otaDeviceType: "FR200", - }, - /**时间同步*/ - timeSync: { - commandType: "InfoQuery", - infoQueryType: "timeSync", - date: new Date(), - }, - /**查询离线记录概要*/ - clockSummary: { - commandType: "InfoQuery", - infoQueryType: "offlineClockInInfo", - dataType: "summary", - }, - /**查询离线明细第一条*/ - clockDetail: { - commandType: "InfoQuery", - infoQueryType: "offlineClockInInfo", - dataType: "detail", - dataIndex: 0, - }, - }, -}; - -/**控制设备命令合集*/ -export const we200DeviceControlCommand = { - /**查询设备状态指令*/ - queryDeviceStatus: { - commandType: "DeviceStatusSync", - deviceSyncCommandType: "onlySyncStatusToDevice", - }, - /**控制设备暂停 pause暂停 working启动 end关闭*/ - pause: { - commandType: "DeviceControl", - workStatus: "pause", - }, - standby: { - commandType: "DeviceControl", - workStatus: "standby", - }, - end: { - commandType: "DeviceControl", - workStatus: "end", - }, - - /** - * '进入水分测试模式' = 'switchTestMode', - * '启动水分测试模式' = 'startTestMode', - * - * face: "01", 面部 - * eyes: "02", 眼部 - * - * nasolabialFold: "03", 法令纹Pro - * mandibularLine: "04", 下颌线Pro - * led: "05", led - * headLiftingPro: "09", 抬头纹Pro - * - * moistureTest: "06", 水分测试 - * maskPenetration: "07",面膜促渗 - * essence: "08", 精华模式 - * - * neck: "0A", 颈纹 - * partition: "11", 分区模式 废弃VM1001 - * ignore: "255", 不改变/无模式 - */ - - // 普通工作模式 - work: { - commandType: "DeviceControl", - workStatus: "working", - workMode: "ignore", // face - }, - // 切换/进入水分测试 - switchTestMode: { - commandType: "DeviceControl", - workStatus: "working", - workMode: "moistureTest", - testStatus: "standby", - }, - // 启动水分测试 - startTestMode: { - commandType: "DeviceControl", - workStatus: "working", - workMode: "moistureTest", - testStatus: "start", - }, -}; diff --git a/src/moduleIOT/pages/iotCarePlan/FR200.tsx b/src/moduleIOT/pages/iotCarePlan/FR200.tsx index 2612a0f..01301d2 100644 --- a/src/moduleIOT/pages/iotCarePlan/FR200.tsx +++ b/src/moduleIOT/pages/iotCarePlan/FR200.tsx @@ -448,7 +448,7 @@ class IotCarePlanFR200 extends Component { const platform = Taro.getSystemInfoSync().platform; if (platform !== "devtools") { // 仅手机端初始化蓝牙 - // this.init(); + this.init(); } } diff --git a/src/moduleIOT/pages/iotCarePlan/WE200.less b/src/moduleIOT/pages/iotCarePlan/WE100.less similarity index 100% rename from src/moduleIOT/pages/iotCarePlan/WE200.less rename to src/moduleIOT/pages/iotCarePlan/WE100.less diff --git a/src/moduleIOT/pages/iotCarePlan/WE200.tsx b/src/moduleIOT/pages/iotCarePlan/WE100.tsx similarity index 71% rename from src/moduleIOT/pages/iotCarePlan/WE200.tsx rename to src/moduleIOT/pages/iotCarePlan/WE100.tsx index 06e8123..5efc050 100644 --- a/src/moduleIOT/pages/iotCarePlan/WE200.tsx +++ b/src/moduleIOT/pages/iotCarePlan/WE100.tsx @@ -20,14 +20,15 @@ import { Video, Input, Button, - PageMeta, } from "@tarojs/components"; import { sendCommand } from "@/utils/bluetoothWXAPI"; import { - deviceCommandSamples, - bleCommandSamples, -} from "@/components/bluetoot/connection/wl200"; + // deviceCommandSamples, + // bleCommandSamples, + WE100BleCommand, + WE100DeviceControlCommand, +} from "@/components/bluetoot/connection/we100"; import { minSecToS, s_to_ms, s_to_hms, sleep, s_to_s } from "@/utils/util"; // import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; @@ -57,14 +58,8 @@ import ConnectionBluetoot from "@/components/bluetoot/connection"; import ElectricityView from "./components/ElectricityView/Electricity"; import ModeListView from "./components/ModeList/FR200"; import Footer from "./components/Footer/FR200"; -import WaterTest from "./components/WaterTest/index"; /* 本页组件 END */ -import Echarts from "./components/Echart"; -import EchartsFullScean from "./components/EchartFullScean"; - -import Gears from "./components/Gears"; - import "./FR200.less"; import BluetoothContainer from "./components/Bluetoot/FR200"; @@ -95,12 +90,12 @@ let DeviceSyncData = { totalWorkingSeconds: 0, }; -class IotCarePlanWE200 extends Component { +class IotCarePlanWE100 extends Component { constructor(props) { super(props); this.state = { - name: "WE200", - title: "WE200", // 页面标题 + name: "WE100", + title: "WE100", // 页面标题 // 当前设备 currentDevice: { name: "", @@ -175,7 +170,6 @@ class IotCarePlanWE200 extends Component { // 模式列表 currentWorkModeType: 1, // 现在的模式类型 - currentVideoSrc: "", // 现在模式的视频地址 isModeLock: false, // 模式是否锁定 isSwitchActiveMode: false, // 是否显示弹窗切换模式 ModeList: [], @@ -189,7 +183,6 @@ class IotCarePlanWE200 extends Component { ModeStepIndex: 0, // 当前护理功效步骤:每个步骤时间不定,所以时间另外计算,根据步骤显示 ModeStepTimeArray: [], // 护理功效时间步骤,用于切换显示GIF - // TestModeStepIndex: 0, // 水分测试步骤 EssenceStepIndex: 0, // 精华促渗步骤 MaskModeStepIndex: 0, // 面膜促渗步骤 @@ -232,123 +225,9 @@ class IotCarePlanWE200 extends Component { isShowHistoryMsg: false, // 是否显示正在同步历史 showEcharts: false, - echartsData: "", //传给echarts图表的数据 - series: [ - { - data: [2, 3, 5, 3, 5, 6, 8, 5, 6, 4], - type: "line", - smooth: true, - z: 1, - areaStyle: {}, - color: "red", - }, - { - data: [2, 3, 5, 3, 5, 6, 8, 5, 6, 4], - type: "line", - smooth: true, - symbolSize: 10, - lineStyle: { - color: "#ff8410", - width: 1, - }, - itemStyle: { - color: "#ff8410", - }, - }, - { - name: "a", - data: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - type: "bar", - barWidth: 22, - z: 2, - stack: "x", - visualMap: false, - itemStyle: { - color: "#ffcf56", - }, - }, - { - name: "b", - data: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - type: "bar", - z: 2, - stack: "x", - visualMap: false, - itemStyle: { - color: "#febb22", - }, - }, - { - name: "c", - data: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1], - type: "bar", - z: 2, - stack: "x", - visualMap: false, - itemStyle: { - color: "#ffac28", - }, - }, - { - name: "d", - data: [0, 0, 1, 0, 1, 1, 1, 1, 1, 1], - type: "bar", - z: 2, - stack: "x", - visualMap: false, - itemStyle: { - color: "#ff8410", - }, - }, - { - name: "e", - data: [0, 0, 1, 0, 1, 1, 1, 1, 1, 0], - type: "bar", - z: 2, - stack: "x", - visualMap: false, - itemStyle: { - color: "#f85804", - }, - }, - { - name: "f", - data: [0, 0, 0, 0, 0, 1, 1, 0, 1, 0], - type: "bar", - z: 2, - stack: "x", - visualMap: false, - itemStyle: { - color: "#e02e14", - }, - }, - { - name: "h", - data: [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], - type: "bar", - z: 2, - stack: "x", - visualMap: false, - itemStyle: { - color: "#b30016", - }, - }, - { - name: "i", - data: [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], - type: "bar", - z: 2, - stack: "x", - visualMap: false, - itemStyle: { - color: "#750010", - }, - }, - ], }; } bluetoothContainer: any = null; - isFullScreen: boolean = false; // 不涉及渲染的页面变量 isRuning: any = true; // 设备默认运行中:fr200贴脸就会自动开始工作 jsonStatus: any = {}; // 同步设备返回数据,用于结束 @@ -356,7 +235,7 @@ class IotCarePlanWE200 extends Component { tempModeCurrent: any = {}; // 临时保存的当前模式 elapsedTime: any = 0; // 设备已运行时间 workStatus: any = ""; // 工作状态 - FR200NursingHistory: any = null; // 护理缓存历史 + WE100NursingHistory: any = null; // 护理缓存历史 hadCheckReport = false; // 是否已检查仪器护理记录 hadGotInstrumentHistoryData = false; // 是否已缓存仪器历史数据 hadLoadedPage = false; // 判断是否首次进入页面 @@ -383,15 +262,6 @@ class IotCarePlanWE200 extends Component { "intelligence", ]; - /** 基础版:脸部/眼部/PRO 设备使用时,会自动开启暂停 */ - BaseModeType: string[] = [ - "face", - "eyes", - "nasolabialFold", - "mandibularLine", - "headLiftingPro", - ]; - async onLoad(option) { console.log(option, "跳转过来的数据"); if (option.modeId) { @@ -402,8 +272,8 @@ class IotCarePlanWE200 extends Component { keepScreenOn: true, }); this.initData(); - this.getInstrumentClockSummary(); - this.getInstrumentClockDetail(); + this.getInstrumentOfflineSummary(); + this.getInstrumentOfflineDetail(); } componentDidMount() {} @@ -417,7 +287,7 @@ class IotCarePlanWE200 extends Component { return; } - this.getFR200NursingHistory(); + this.getWE100NursingHistory(); // 重置初始值,每次进入页面重新检查面罩护理记录 this.hadCheckReport = false; this.hadGotInstrumentHistoryData = false; @@ -475,11 +345,7 @@ class IotCarePlanWE200 extends Component { deviceToolKitInstance, this ); - this.bluetoothContainer.notifyBLECharacteristicValueChange(); - - setTimeout(() => { - this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY); - }, 1000); + this.bluetoothContainer.notifyBLECharacteristicValueChange(); // 开始监听蓝牙变化 } listener = (res) => { console.log("listener res", res); @@ -517,18 +383,16 @@ class IotCarePlanWE200 extends Component { if (this.state.activeModeID != "") { let res1 = res.data.data.find((e) => e.id == this.state.activeModeID); - setTimeout(() => { - this.modeCurrentFun(res1); - }, 100); + if (res1) { + setTimeout(() => { + this.modeCurrentFun(res1); + }, 100); + } } else { setTimeout(() => { this.modeCurrentFun(res.data.data[0]); }, 100); } - let res1 = res.data.data.find((e) => e.id == this.state.activeModeID); - setTimeout(() => { - this.modeCurrentFun(res1); - }, 100); } else { this.setState({ ModeList: [] }); } @@ -569,13 +433,13 @@ class IotCarePlanWE200 extends Component { * @name 选中/切换护理模式 * */ modeCurrentFun = async (data, isNotCheck = false) => { - let { isShowNurse, activeModeID } = this.state; + let { isShowNurse } = this.state; // 护理检查改变模式,是否提示切换护理模式 // isNotCheck为真时,不进行校验,直接切换 this.tempModeCurrent = data; // 仅在未开始护理前,切换模式的时候提示模式弹窗 - // FR200默认开始护理 + // WE100默认开始护理 if (!isShowNurse) { this.openStepTips(); } @@ -589,43 +453,32 @@ class IotCarePlanWE200 extends Component { // 根据模式,动态设置底部按钮样式 let currentWorkModeType = 1; - if (data.modeType === "moistureTest") { - currentWorkModeType = 3; - } else if ( - data.modeType === "maskPenetration" || - data.modeType === "essence" || - data.modeType === "led" - ) { - currentWorkModeType = 2; - } + // if (data.modeType === "moistureTest") { + // currentWorkModeType = 3; + // } this.setState({ + // 设置选中 ActiveModeItem: data, activeModeID: data.id, ModeID: "mode_" + data.id, + // 设置重置步骤与模式类型 ModeStepIndex: 0, - waterStepIndex: 0, // 水分测试步骤 - EssenceStepIndex: 0, // 精华促渗步骤 - MaskModeStepIndex: 0, // 面膜促渗步骤 ModeType: this.ModeTypeArray[data.modeClass], currentWorkModeType, }); - // 切换模式时:重新设置视频地址 - this.VideoSrcLoad(data.modeVideo); - // 开发中,暂时允许直接切换 // 每次切换模式时清空一下历史数据 - this.changeItemUpdateFR200NursingHistory(); + this.changeItemUpdateWE100NursingHistory(); this.stepNext(); // 仅切换模式,不执行开始逻辑 - // FR200水分测试不可自动运行,需手动点击开始测试,手动启动检测 - // 其他模式可以自动运行 - if (data.modeType !== "moistureTest") { - setTimeout(() => { - this.onNursingTap("switch"); - }, 800); - } + // 用于限制模式是否在切换后自动开始运行 + // if () { + // setTimeout(() => { + // this.onNursingTap("switch"); + // }, 800); + // } }; /** 设备运行中切换模式 */ modeRuningChange() { @@ -720,7 +573,9 @@ class IotCarePlanWE200 extends Component { }); setTimeout(() => { - this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY); + this.bluetoothContainer.DeviceControl.standby( + this.state.ActiveModeItem.modeType + ); }); }; @@ -731,8 +586,8 @@ class IotCarePlanWE200 extends Component { setTimeout(() => { this.onNursingTap(); // // 倒计时弹窗: 倒计时完成后,自动开始,并判断弹窗 - // let downNum = CountDownTime[this.state.ActiveModeItem.modeType] || 3; - // this.showCountdownFun(downNum, () => {}); + let downNum = CountDownTime[this.state.ActiveModeItem.modeType] || 3; + this.showCountdownFun(downNum, () => {}); }, 500); // 如果检查失败,则报错 @@ -757,19 +612,13 @@ class IotCarePlanWE200 extends Component { let { isStopNurse, ActiveModeItem } = this.state; console.log("切换光照,", ActiveModeItem); - if (ActiveModeItem.modeType === "led") { - this.onSwitchChangeLED(); - return; - } if (isStopNurse) { // 开始光照逻辑 this.onNursingTap(); - this.switchVideoPlay(); // 开始 } else { // 暂停光照逻辑 - this.handleWorkStatus(false, MODE_WORKING_ENUM.PAUSE); - this.switchVideoPause(); // 暂停 + this.bluetoothContainer.DeviceControl.pause(ActiveModeItem.modeType); } this.setState({ isStopNurse: !isStopNurse, @@ -816,7 +665,7 @@ class IotCarePlanWE200 extends Component { /**监听关机事件*/ onEndDevice = () => { - this.rmFR200NursingHistory(this.FR200NursingHistory, true); + this.rmWE100NursingHistory(this.WE100NursingHistory, true); // 判断护理时间,如果不足,则提示不足 if (!this.isCheckNurseTime()) { this.setState({ isNotEnoughTime: true }); @@ -875,7 +724,7 @@ class IotCarePlanWE200 extends Component { // 每次同步后,更新历史缓存 setTimeout(() => { - this.updateFR200NursingHistory(null, jsonStatus); + this.updateWE100NursingHistory(null, jsonStatus); }, 100); }, }; @@ -899,13 +748,12 @@ class IotCarePlanWE200 extends Component { } /** - * 设备上报不同状态 - * params 工作状态 工作模式 响应状态 + * @name 设备上报不同状态 + * @params 工作状态 工作模式 */ judgementWorkStatus(nWorkStatus, nWorkMode) { const { ActiveModeItem, ModeList, currentVideoTime } = this.state; const opts: any = {}; - // ActiveModeItem let nowModeItem; if (nWorkMode) { nowModeItem = ModeList.find((item) => { @@ -921,33 +769,11 @@ class IotCarePlanWE200 extends Component { } const statusF = { - sleep: () => { - this.setState({ - isShowCountdown: false, - }); - }, standby: () => { this.setState({ isShowCountdown: false, }); }, - setting: () => { - this.isRuning = true; - this.setState({ - title: "正在护理", - isStopNurse: false, - }); - if (nowModeItem) { - opts.currentTime = nowCurrentTime; - } - // 倒计时loading - // if (!this.state.isShowCountdown) { - // this.setState({ - // isShowCountdown: true, - // }); - // this.setLoadingTips(CountDownTime[workMode] || 6); - // } - }, working: () => { this.setState({ title: "正在护理", @@ -970,7 +796,6 @@ class IotCarePlanWE200 extends Component { // 已进入了报告阶段, 防止重复进入, 主要防止在手动点击结束护理接收到仪器消息 console.log("END 护理结束"); clearInterval(currentTimeTimer); - this.endnursing(true); }, }; @@ -1049,18 +874,10 @@ class IotCarePlanWE200 extends Component { }); // 根据不同的模式,切换步骤到下一步 - if (ActiveModeItem.modeType === "essence") { - this.essencePenetrationNext(); - } else if (ActiveModeItem.modeType === "maskPenetration") { - this.maskPenetrationNext(); - } } else { clearInterval(currentTimeTimer); this.setState({ currentTime: "00:00", - waterStepIndex: 0, // 水分测试步骤 - EssenceStepIndex: 0, // 精华促渗步骤 - MaskModeStepIndex: 0, // 面膜促渗步骤 }); this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束 } @@ -1069,36 +886,32 @@ class IotCarePlanWE200 extends Component { }; // 检测并控制工作状态 - handleWorkStatus = async (isBtnClick: boolean, workStatus) => { - const { DeviceConnectStatus, ActiveModeItem } = this.state; - - // 如果没有指定工作状态,则切换工作状态 - let newWorkStatus = - workStatus || - (this.workStatus == MODE_WORKING_ENUM.WORKING ? "pause" : "working"); - - let sendParams: any = { - ...deviceCommandSamples.pause, - workMode: ActiveModeItem.modeType, // 使用模式 - workStatus: newWorkStatus, - }; - - console.log("准备发送自定义或工作指令", ActiveModeItem, sendParams); - - const pauseArrayBuffer = deviceToolKitInstance.toBleCommand( - sendParams as any - ); - sendCommand({ - value: pauseArrayBuffer, - }).then(() => { - this.workStatus = newWorkStatus; - this.resetTimer(); - console.info( - `handleWorkStatus 发送${newWorkStatus}指令成功 参数为 =>`, - sendParams - ); - }); - }; + // handleWorkStatus = async (isBtnClick: boolean, workStatus) => { + // const { DeviceConnectStatus, ActiveModeItem } = this.state; + + // // 如果没有指定工作状态,则切换工作状态 + // let newWorkStatus = + // workStatus || + // (this.workStatus == MODE_WORKING_ENUM.WORKING ? "pause" : "working"); + + // let sendParams: any = { + // ...WE100DeviceControlCommand.pause, + // workMode: ActiveModeItem.modeType, // 使用模式 + // workStatus: newWorkStatus, + // }; + + // console.log("准备发送自定义或工作指令", ActiveModeItem, sendParams); + + // const pauseArrayBuffer = deviceToolKitInstance.toBleCommand( + // sendParams as any + // ); + // sendCommand({ + // value: pauseArrayBuffer, + // }).then(() => { + // this.workStatus = newWorkStatus; + // this.resetTimer(); + // }); + // }; /** * @name 点击开始护理 @@ -1118,17 +931,20 @@ class IotCarePlanWE200 extends Component { }); }, 500); - const { DeviceConnectStatus } = this.state; + const { DeviceConnectStatus, ActiveModeItem } = this.state; if (DeviceConnectStatus != 1) { console.log("DeviceConnectStatus 开始处", DeviceConnectStatus); - this.showTips("检测到FR200未连接成功,请确认FR200开机并佩戴"); + this.showTips("检测到WE100未连接成功,请确认WE100开机并佩戴"); return; } // 开始执行护理 this.workStatus = MODE_WORKING_ENUM.WORKING; // 不管当前什么状态,直接设为工作状态 - this.handleWorkStatus(true, MODE_WORKING_ENUM.WORKING); + // todo 仅点击按钮开始才出发,开始前,可能需要执行一下逻辑 + // if () {} + this.bluetoothContainer.DeviceControl.working(ActiveModeItem.modeType); + this.setState({ isStopNurse: false, }); @@ -1136,12 +952,13 @@ class IotCarePlanWE200 extends Component { // 结束护理 async endNurseFun() { + let { ActiveModeItem } = this.state; if (this.isCheckNurseTime()) { await this.PostNursingLogClock(); - this.handleWorkStatus(false, "end"); + this.bluetoothContainer.DeviceControl.end(ActiveModeItem.modeType); } else { // 时间不满足,直接提交回到主页 - this.handleWorkStatus(false, "end"); + this.bluetoothContainer.DeviceControl.end(ActiveModeItem.modeType); this.setState({ isEndCarePlan: false, isNotEnoughTime: true, @@ -1167,29 +984,19 @@ class IotCarePlanWE200 extends Component { } /*** 护理记录 START ***/ /** 小程序查询护理记录概要 */ - getInstrumentClockSummary() { + getInstrumentOfflineSummary() { this.hadGotInstrumentHistoryData = true; console.log("发送指令clockSummary 获取设备护理概要"); setTimeout(() => { - const queryClockSummary = deviceToolKitInstance.toBleCommand({ - ...(fr200BleCommand.InfoQuery.clockSummary as any), - }); - sendCommand({ - value: queryClockSummary, - }); + this.bluetoothContainer.DeviceControl.syncOfflineSummary(); }, 1000); } /** 小程序查询最近一条护理详情 */ - getInstrumentClockDetail() { + getInstrumentOfflineDetail() { this.hadGotInstrumentHistoryData = true; console.log("发送指令clockDetail 查询最近一条护理详情"); setTimeout(() => { - const queryClockSummary = deviceToolKitInstance.toBleCommand({ - ...(fr200BleCommand.InfoQuery.clockDetail as any), - }); - sendCommand({ - value: queryClockSummary, - }); + this.bluetoothContainer.DeviceControl.syncOfflineDetail(); }, 2000); } @@ -1235,37 +1042,37 @@ class IotCarePlanWE200 extends Component { // 2.判断是否已存在缓存的护理记录:如果没有历史,则缓存 let workStatus = this.workJsonStatus.workStatus; - let FR200NursingHistory = this.FR200NursingHistory; - if (!this.FR200NursingHistory) { + let WE100NursingHistory = this.WE100NursingHistory; + if (!this.WE100NursingHistory) { console.log("小程序缓存没有数据, 忽略"); if ( workStatus == MODE_WORKING_ENUM.WORKING || workStatus == MODE_WORKING_ENUM.PAUSE ) { // 缓存没有数据, 要存缓存 - this.setFR200NursingHistory(jsonStatus); + this.setWE100NursingHistory(jsonStatus); } return; } // 3.判断是否当天(如果不是当天,则删除记录) - if (!dayjs().isSame(FR200NursingHistory?.createDate, "day")) { + if (!dayjs().isSame(WE100NursingHistory?.createDate, "day")) { console.log("小程序缓存有数据,但是不是当天数据,忽略"); - this.rmFR200NursingHistory(FR200NursingHistory); + this.rmWE100NursingHistory(WE100NursingHistory); return; } // 仪器缓存模式,判断是否存在于现有模式中 let recordModeItem = ModeList.find((item) => { - return item.id == FR200NursingHistory.modeId; + return item.id == WE100NursingHistory.modeId; }); - if (!FR200NursingHistory || !recordModeItem) { + if (!WE100NursingHistory || !recordModeItem) { console.log("仪器有数据, 但是缓存没有数据, 忽略"); return; } let historyElapsedTime = - minSecToS(currentVideoTime) - minSecToS(FR200NursingHistory.currentTime); + minSecToS(currentVideoTime) - minSecToS(WE100NursingHistory.currentTime); this.elapsedTime = this.elapsedTime > historyElapsedTime @@ -1278,7 +1085,7 @@ class IotCarePlanWE200 extends Component { !workStatus ) { // 判断id是否一致, 一致的话则生成护理报表 - if (jsonStatus.id == FR200NursingHistory.id) { + if (jsonStatus.id == WE100NursingHistory.id) { console.log("id一致, 设备没有运行/已完成/待机"); let totalSeconds = jsonStatus.totalSeconds; // 从仪器上获取的使用时间 @@ -1288,7 +1095,7 @@ class IotCarePlanWE200 extends Component { if (totalSeconds < nursingTime) { // 护理时间不足 this.setState({ isNotEnoughTime: true }); - this.rmFR200NursingHistory(FR200NursingHistory); + this.rmWE100NursingHistory(WE100NursingHistory); return; } @@ -1305,10 +1112,10 @@ class IotCarePlanWE200 extends Component { modeName: ActiveModeItem.modeName, nursingTime: timeValue, }; - this.handleWorkStatus(false, "end"); + this.bluetoothContainer.DeviceControl.end(ActiveModeItem.modeType); let res: any = await this.PostNursingLogClock(params); console.log("res", res); - this.rmFR200NursingHistory(FR200NursingHistory); + this.rmWE100NursingHistory(WE100NursingHistory); } else { // ID不一致,同步异常,统一提交一分钟 let params = { @@ -1318,17 +1125,17 @@ class IotCarePlanWE200 extends Component { modeName: ActiveModeItem.modeName, nursingTime: "00:01:00", }; - this.handleWorkStatus(false, "end"); + this.bluetoothContainer.DeviceControl.end(ActiveModeItem.modeType); let res: any = await this.PostNursingLogClock(params); console.log("res", res); - this.rmFR200NursingHistory(FR200NursingHistory); + this.rmWE100NursingHistory(WE100NursingHistory); } } else { console.log("id一致, 设备运行中或暂停"); // 5.判断设备状态-运行中 // 同步时间 - if (jsonStatus.id == FR200NursingHistory.id) { - if (FR200NursingHistory.currentTime) { + if (jsonStatus.id == WE100NursingHistory.id) { + if (WE100NursingHistory.currentTime) { this.isRuning = true; this.resetTimer(); } @@ -1337,32 +1144,32 @@ class IotCarePlanWE200 extends Component { }; /** 获取小程序本地缓存的历史记录 */ - getFR200NursingHistory() { - this.FR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); + getWE100NursingHistory() { + this.WE100NursingHistory = Taro.getStorageSync("WE100NursingHistory"); console.log( - this.FR200NursingHistory, + this.WE100NursingHistory, "获取本地数据++++++++++++++++++++++++++++++++++++++++++" ); // 是否同步历史记录 let isSyncHistory = Taro.getStorageSync("isSyncHistory"); if (isSyncHistory) { - let ActiveModeItem = this.FR200NursingHistory.ActiveModeItem; + let ActiveModeItem = this.WE100NursingHistory.ActiveModeItem; // 直接进入开始护理状态 this.setState({ isShowNurse: true, isShowHistoryMsg: true, - videoTime: this.FR200NursingHistory.videoTime, + videoTime: this.WE100NursingHistory.videoTime, tempModeCurrent: ActiveModeItem, ActiveModeItem: ActiveModeItem, activeModeID: ActiveModeItem.id, ModeID: "mode_" + ActiveModeItem.id, - currentTime: this.FR200NursingHistory.currentTime, + currentTime: this.WE100NursingHistory.currentTime, }); } } /** 设置WL200护理历史 */ - setFR200NursingHistory = (jsonStatus: any) => { + setWE100NursingHistory = (jsonStatus: any) => { let { currentDevice, ActiveModeItem } = this.state; const params = { createDate: dayjs().format("YYYY-MM-DD"), @@ -1376,16 +1183,16 @@ class IotCarePlanWE200 extends Component { jsonStatus, ActiveModeItem: this.state.ActiveModeItem, }; - this.FR200NursingHistory = JSON.parse(JSON.stringify(params)); - Taro.setStorageSync("FR200NursingHistory", params); - console.log("保存setFR200NursingHistory"); + this.WE100NursingHistory = JSON.parse(JSON.stringify(params)); + Taro.setStorageSync("WE100NursingHistory", params); + console.log("保存setWE100NursingHistory"); }; /** 更新WL200护理历史运行时间 */ - updateFR200NursingHistory = (data: any = null, jsonStatus: any = null) => { - this.FR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); + updateWE100NursingHistory = (data: any = null, jsonStatus: any = null) => { + this.WE100NursingHistory = Taro.getStorageSync("WE100NursingHistory"); - if (this.FR200NursingHistory) { - let params: any = this.FR200NursingHistory; + if (this.WE100NursingHistory) { + let params: any = this.WE100NursingHistory; // 设置当前时间 params.currentTime = this.state.currentTime; @@ -1411,23 +1218,23 @@ class IotCarePlanWE200 extends Component { params.modeName = data.modeName; } - Taro.setStorageSync("FR200NursingHistory", params); - // console.log("更新updateFR200NursingHistory"); + Taro.setStorageSync("WE100NursingHistory", params); + // console.log("更新updateWE100NursingHistory"); // 基础模式可在这里调用函数更新图标Echarts // 最新一条数据jsonStatus // 注意事项:只拿working状态 // todo } else { - this.setFR200NursingHistory(jsonStatus); + this.setWE100NursingHistory(jsonStatus); } }; // 改变模式时,清空dataArray,防止数据无限叠加 - changeItemUpdateFR200NursingHistory() { - this.FR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); - if (this.FR200NursingHistory) { - this.FR200NursingHistory.dataArray = []; - Taro.setStorageSync("FR200NursingHistory", this.FR200NursingHistory); + changeItemUpdateWE100NursingHistory() { + this.WE100NursingHistory = Taro.getStorageSync("WE100NursingHistory"); + if (this.WE100NursingHistory) { + this.WE100NursingHistory.dataArray = []; + Taro.setStorageSync("WE100NursingHistory", this.WE100NursingHistory); } } /** @@ -1436,19 +1243,19 @@ class IotCarePlanWE200 extends Component { * 如果传入护理历史ID与现有ID相等,则删除。 * 如果参数二为真,则强制删除 */ - rmFR200NursingHistory = (FR200NursingHistory, hard = false) => { - const nowFR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); - if (nowFR200NursingHistory) { - Taro.setStorageSync("FR200Echart", nowFR200NursingHistory); // 临时保存用于观看和调试 + rmWE100NursingHistory = (WE100NursingHistory, hard = false) => { + const nowWE100NursingHistory = Taro.getStorageSync("WE100NursingHistory"); + if (nowWE100NursingHistory) { + Taro.setStorageSync("FR200Echart", nowWE100NursingHistory); // 临时保存用于观看和调试 } - Taro.removeStorageSync("FR200NursingHistory"); + Taro.removeStorageSync("WE100NursingHistory"); }; // 脸部one todoPromise = async () => { - const nowFR200NursingHistory = Taro.getStorageSync("FR200NursingHistory"); - console.log(nowFR200NursingHistory, "nowFR200NursingHistory"); + const nowWE100NursingHistory = Taro.getStorageSync("WE100NursingHistory"); + console.log(nowWE100NursingHistory, "nowWE100NursingHistory"); // 护理脸部 if ( @@ -1458,10 +1265,10 @@ class IotCarePlanWE200 extends Component { "nasolabialFold", "mandibularLine", "headLiftingPro", - ].includes(nowFR200NursingHistory.jsonStatus.workMode) + ].includes(nowWE100NursingHistory.jsonStatus.workMode) ) { // 把working=工作中的状态数据筛选出来 - let filtered = nowFR200NursingHistory.dataArray.filter( + let filtered = nowWE100NursingHistory.dataArray.filter( (item) => item.workStatus === "working" ); // 能量发数 @@ -1517,7 +1324,7 @@ class IotCarePlanWE200 extends Component { average, groupedAa, filtered: filtered.length, - workMode: nowFR200NursingHistory.workMode, + workMode: nowWE100NursingHistory.workMode, }), }; @@ -1525,7 +1332,7 @@ class IotCarePlanWE200 extends Component { } return { nursingData: JSON.stringify({ - workMode: nowFR200NursingHistory.workMode, + workMode: nowWE100NursingHistory.workMode, }), showFace: true, }; @@ -1580,7 +1387,7 @@ class IotCarePlanWE200 extends Component { let res = await InstrumentInfo.apiClock.addClockInstrument(params); console.log(res, "护理完成"); - this.rmFR200NursingHistory(this.FR200NursingHistory); // 护理完成,删除记录 + this.rmWE100NursingHistory(this.WE100NursingHistory); // 护理完成,删除记录 if (isJump) { this.setState({ isShowNursingSuccess: true, @@ -1648,12 +1455,13 @@ class IotCarePlanWE200 extends Component { }); }; confirmEndBtn = () => { + let { ActiveModeItem } = this.state; console.log("confirmEndBtn", this.isCheckNurseTime()); if (this.isCheckNurseTime()) { this.endNurseFun(); this.cancelEndBtn(); } else { - this.handleWorkStatus(false, "end"); + this.bluetoothContainer.DeviceControl.end(ActiveModeItem.modeType); this.setState({ isEndCarePlan: false, isNotEnoughTime: true, @@ -1837,36 +1645,10 @@ class IotCarePlanWE200 extends Component { } }; - VideoSrcLoad = (video: string = "") => { - this.setState({ - currentVideoSrc: "", - }); - setTimeout(() => { - this.setState({ - currentVideoSrc: video, - }); - }, 10); - }; - switchVideoPlay = () => { - setTimeout(() => { - let videoRef = Taro.createVideoContext("myVideo", this); - videoRef.play(); - }, 100); - }; - switchVideoPause = () => { - setTimeout(() => { - let videoRef = Taro.createVideoContext("myVideo", this); - videoRef.pause(); - }, 100); - }; - render() { let { title, isConnectShow, - GearData, - waterStepList, - waterStepIndex, isShowStepTips, isShowNurse, isStopNurse, @@ -1897,220 +1679,204 @@ class IotCarePlanWE200 extends Component { isRuningTest, isShowHistoryMsg, isModeLock, - currentVideoSrc, currentGear, - showEcharts, - echartsData, isShowReReadRecordConnect, currentServiceData, - series, - isFullScreen, } = this.state; return ( - - - {!isFullScreen && ( - - - - - - + + + + + + + + + - - - - } - textAlgin="center" - cancelButtonText="取消" - confirmButtonText="确定" - close={this.cancelModeSwitchBtn} - confirm={this.confirmModeSwitchBtn} - /> - - - 正在同步护理记录... - - - - - - - - - - - - - 倒计时:{currentTime} - - - - - 档位:{currentGear}档 - - - - + } + textAlgin="center" + cancelButtonText="取消" + confirmButtonText="确定" + close={this.cancelModeSwitchBtn} + confirm={this.confirmModeSwitchBtn} + /> + + {ActiveModeItem.openSourceData.length > 0 && ( + + )} + + + + + + + 当前模式已护理部分时间 + 是否保存护理记录 + + } + cancelButtonText="取消" + confirmButtonText="确认" + textAlgin="center" + close={this.closeTipsSave} + cancel={this.cancelTipsSave} + confirm={this.confirmTipsSave} + /> + + { + /*不需要做处理*/ + }} + /> + + {isConnectShow && ( + {}} + pairingChange={this.pairingChange} + upgradeFun={() => {}} + /> + )} + + + 正在同步护理记录... + + + + + + + {/* todo 切换gif图片 */} + + + + + 倒计时:{currentTime} + - - {ModeList.length > 0 && ( - - )} - - {/* */} - - - - - + + + 档位:{currentGear} - - {(ActiveModeItem.modeType === "maskPenetration" || - ActiveModeItem.modeType === "essence") && ( - - )} - - {ActiveModeItem.modeType === "moistureTest" && ( - - )} + + - -