From 21e61acb7dbc40c5b5992c9aed2cd00fced5b890 Mon Sep 17 00:00:00 2001 From: qsj <731458905@qq.com> Date: Wed, 27 Mar 2024 18:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/moduleIOT/pages/iotCarePlan/FR200.tsx | 336 ++++++++++-------- .../iotCarePlan/components/Bluetoot/FR200.ts | 6 +- .../components/EchartFullScean/index.tsx | 2 + src/pages/index/index.tsx | 7 +- 4 files changed, 203 insertions(+), 148 deletions(-) diff --git a/src/moduleIOT/pages/iotCarePlan/FR200.tsx b/src/moduleIOT/pages/iotCarePlan/FR200.tsx index f177a02..c5dfdd4 100644 --- a/src/moduleIOT/pages/iotCarePlan/FR200.tsx +++ b/src/moduleIOT/pages/iotCarePlan/FR200.tsx @@ -20,6 +20,7 @@ import { Video, Input, Button, + PageMeta } from "@tarojs/components"; import { sendCommand } from "@/utils/bluetoothWXAPI"; @@ -98,6 +99,8 @@ class IotCarePlanFR200 extends Component { constructor(props) { super(props); this.state = { + textshow: false, + textscreen: 'portrait', name: "FR200", title: "FR200", // 页面标题 // 当前设备 @@ -181,6 +184,7 @@ class IotCarePlanFR200 extends Component { ModeType: "all", // all 1基础护理 2专区护理 3专研促渗 4敏期护理 5智能测肤 ActiveModeItem: { openSourceData: [], + modeType:"" }, // 当前选中模式 SwitchActiveModeItem: {}, // 切换选中模式 ModeID: "mode_", // 模式KEY @@ -404,9 +408,9 @@ class IotCarePlanFR200 extends Component { this.getInstrumentClockSummary(); this.getInstrumentClockDetail(); } - componentDidMount() {} + componentDidMount() { } - componentWillUnmount() {} + componentWillUnmount() { } componentDidShow() { console.log("页面显示了"); @@ -429,6 +433,11 @@ class IotCarePlanFR200 extends Component { } async initData() { + Taro.closeBluetoothAdapter({ + complete: () => { + // this.openBluetoothAdapter(); + }, + }); let obj = getStorageSync("instrument_detail"); if (obj) { this.setState({ @@ -436,10 +445,10 @@ class IotCarePlanFR200 extends Component { title: obj.name, }); - await this.GetModeList(obj.id); + await this.GetModeList(obj?.id); // 如果不存在设备模式值,则判断为首次进入,弹窗提示 - let isFirstTipShow = getStorageSync("first_instrument_" + obj.id); + let isFirstTipShow = getStorageSync("first_instrument_" + obj?.id); if (!isFirstTipShow) { this.firstNurseInfo(); } @@ -515,7 +524,7 @@ class IotCarePlanFR200 extends Component { }); if (this.state.activeModeID != "") { - 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); @@ -524,7 +533,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); @@ -588,20 +597,20 @@ class IotCarePlanFR200 extends Component { // 根据模式,动态设置底部按钮样式 let currentWorkModeType = 1; - if (data.modeType === "moistureTest") { + if (data?.modeType === "moistureTest") { currentWorkModeType = 3; } else if ( - data.modeType === "maskPenetration" || - data.modeType === "essence" || - data.modeType === "led" + data?.modeType === "maskPenetration" || + data?.modeType === "essence" || + data?.modeType === "led" ) { currentWorkModeType = 2; } this.setState({ ActiveModeItem: data, - activeModeID: data.id, - ModeID: "mode_" + data.id, + activeModeID: data?.id, + ModeID: "mode_" + data?.id, ModeStepIndex: 0, waterStepIndex: 0, // 水分测试步骤 EssenceStepIndex: 0, // 精华促渗步骤 @@ -620,7 +629,7 @@ class IotCarePlanFR200 extends Component { // FR200水分测试不可自动运行,需手动点击开始测试,手动启动检测 // 其他模式可以自动运行 - if (data.modeType !== "moistureTest") { + if (data?.modeType !== "moistureTest") { setTimeout(() => { this.onNursingTap("switch"); }, 800); @@ -680,8 +689,8 @@ class IotCarePlanFR200 extends Component { switchModeCurrentFun = async (data) => { this.setState({ SwitchActiveModeItem: data, - activeModeID: data.id, - ModeID: "mode_" + data.id, + activeModeID: data?.id, + ModeID: "mode_" + data?.id, }); }; // 打开模式切换弹窗 @@ -748,9 +757,9 @@ class IotCarePlanFR200 extends Component { let params: any = {}; params = { - instrumentId: currentDevice.id, + instrumentId: currentDevice?.id, instrumentName: currentDevice.name, - modeId: ActiveModeItem.id, + modeId: ActiveModeItem?.id, modeName: ActiveModeItem.modeName, nursingTime: s_to_hms(this.elapsedTime), nursingData: JSON.stringify({ @@ -777,8 +786,8 @@ class IotCarePlanFR200 extends Component { this.moistureTest( params.nursingData, formattedDate, - ActiveModeItem.id, - currentDevice.id + ActiveModeItem?.id, + currentDevice?.id ); }, 2000); }; @@ -851,6 +860,10 @@ class IotCarePlanFR200 extends Component { this.showTips("检测到您的设备没有紧贴肌肤,请紧贴肌肤后重新尝试"); }); }; + ontextshow() { + let textshow = this.state.textshow + this.setState({ textshow: !textshow }) + } updata() { let that = this; let stop = 0; @@ -884,7 +897,16 @@ class IotCarePlanFR200 extends Component { } full() { + let landscape = this.state.textscreen + if (landscape === 'landscape') { + this.setState({ textscreen: 'portrait' }) + } else { + this.setState({ textscreen: 'landscape' }) + } + // return 'landscape' this.setState({ isFullScreen: !this.state.isFullScreen }); + console.log(this.state.textscreen,1111); + } /** 切换光照 */ @@ -892,7 +914,7 @@ class IotCarePlanFR200 extends Component { let { isStopNurse, ActiveModeItem } = this.state; console.log("切换光照,", ActiveModeItem); - if (ActiveModeItem.modeType === "led") { + if (ActiveModeItem?.modeType === "led") { this.onSwitchChangeLED(); return; } @@ -947,7 +969,7 @@ class IotCarePlanFR200 extends Component { */ openStepTips = () => { let isFirstEntryModeNot = getStorageSync( - "isFirstEntryMode_" + this.state.currentDevice.id + "isFirstEntryMode_" + this.state.currentDevice?.id ); // 1.如果没有持久化不再提示,每次进入都会弹窗提示 if (!isFirstEntryModeNot) { @@ -959,7 +981,7 @@ class IotCarePlanFR200 extends Component { }; closeStepTips = (data) => { if (data.isLocal) { - setStorageSync("isFirstEntryMode_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗 + setStorageSync("isFirstEntryMode_" + this.state.currentDevice?.id, true); // 关闭首次进入弹窗 } this.setState({ isShowStepTips: false }); }; @@ -1075,7 +1097,7 @@ class IotCarePlanFR200 extends Component { let nowModeItem; if (nWorkMode) { nowModeItem = ModeList.find((item) => { - return item.modeType === nWorkMode; + return item?.modeType === nWorkMode; }); } opts.workStatus = nWorkStatus; @@ -1215,9 +1237,9 @@ class IotCarePlanFR200 extends Component { }); // 根据不同的模式,切换步骤到下一步 - if (ActiveModeItem.modeType === "essence") { + if (ActiveModeItem?.modeType === "essence") { this.essencePenetrationNext(); - } else if (ActiveModeItem.modeType === "maskPenetration") { + } else if (ActiveModeItem?.modeType === "maskPenetration") { this.maskPenetrationNext(); } } else { @@ -1378,7 +1400,7 @@ class IotCarePlanFR200 extends Component { const { ActiveModeItem, currentGear } = this.state; let sendParams: any = { ...deviceCommandSamples.pause, - workMode: ActiveModeItem.modeType, // 使用模式 + workMode: ActiveModeItem?.modeType, // 使用模式 workStatus: "working", gear: currentGear, }; @@ -1427,7 +1449,7 @@ class IotCarePlanFR200 extends Component { let sendParams: any = { ...deviceCommandSamples.pause, - workMode: ActiveModeItem.modeType, // 使用模式 + workMode: ActiveModeItem?.modeType, // 使用模式 workStatus: "working", gear: gear, }; @@ -1452,7 +1474,7 @@ class IotCarePlanFR200 extends Component { let sendParams: any = { ...deviceCommandSamples.pause, - workMode: ActiveModeItem.modeType, // 使用模式 + workMode: ActiveModeItem?.modeType, // 使用模式 workStatus: "working", gear: currentGear, }; @@ -1499,13 +1521,13 @@ class IotCarePlanFR200 extends Component { let sendParams: any = { ...deviceCommandSamples.pause, - workMode: ActiveModeItem.modeType, // 使用模式 + workMode: ActiveModeItem?.modeType, // 使用模式 workStatus: newWorkStatus, }; // 水分测试需要特殊处理 // 水分测试准备 水分测试工作 水分测试启动 - if (ActiveModeItem.modeType === "moistureTest") { + if (ActiveModeItem?.modeType === "moistureTest") { let that = this; sendParams.testStatus = "standby"; // 切换为准备 @@ -1523,8 +1545,8 @@ class IotCarePlanFR200 extends Component { // 面膜促渗和精华促渗 if ( - ActiveModeItem.modeType === "maskPenetration" || - ActiveModeItem.modeType === "essence" + ActiveModeItem?.modeType === "maskPenetration" || + ActiveModeItem?.modeType === "essence" ) { sendParams.gear = this.state.currentGear; // 点击开始再开始 } @@ -1702,7 +1724,7 @@ class IotCarePlanFR200 extends Component { // 仪器缓存模式,判断是否存在于现有模式中 let recordModeItem = ModeList.find((item) => { - return item.id == FR200NursingHistory.modeId; + return item?.id == FR200NursingHistory.modeId; }); if (!FR200NursingHistory || !recordModeItem) { console.log("仪器有数据, 但是缓存没有数据, 忽略"); @@ -1723,7 +1745,7 @@ class IotCarePlanFR200 extends Component { !workStatus ) { // 判断id是否一致, 一致的话则生成护理报表 - if (jsonStatus.id == FR200NursingHistory.id) { + if (jsonStatus?.id == FR200NursingHistory?.id) { console.log("id一致, 设备没有运行/已完成/待机"); let totalSeconds = jsonStatus.totalSeconds; // 从仪器上获取的使用时间 @@ -1744,9 +1766,9 @@ class IotCarePlanFR200 extends Component { : s_to_hms(this.elapsedTime); let params = { - instrumentId: currentDevice.id, + instrumentId: currentDevice?.id, instrumentName: currentDevice.name, - modeId: ActiveModeItem.id, + modeId: ActiveModeItem?.id, modeName: ActiveModeItem.modeName, nursingTime: timeValue, }; @@ -1757,9 +1779,9 @@ class IotCarePlanFR200 extends Component { } else { // ID不一致,同步异常,统一提交一分钟 let params = { - instrumentId: currentDevice.id, + instrumentId: currentDevice?.id, instrumentName: currentDevice.name, - modeId: ActiveModeItem.id, + modeId: ActiveModeItem?.id, modeName: ActiveModeItem.modeName, nursingTime: "00:01:00", }; @@ -1772,7 +1794,7 @@ class IotCarePlanFR200 extends Component { console.log("id一致, 设备运行中或暂停"); // 5.判断设备状态-运行中 // 同步时间 - if (jsonStatus.id == FR200NursingHistory.id) { + if (jsonStatus?.id == FR200NursingHistory?.id) { if (FR200NursingHistory.currentTime) { this.isRuning = true; this.resetTimer(); @@ -1800,8 +1822,8 @@ class IotCarePlanFR200 extends Component { videoTime: this.FR200NursingHistory.videoTime, tempModeCurrent: ActiveModeItem, ActiveModeItem: ActiveModeItem, - activeModeID: ActiveModeItem.id, - ModeID: "mode_" + ActiveModeItem.id, + activeModeID: ActiveModeItem?.id, + ModeID: "mode_" + ActiveModeItem?.id, currentTime: this.FR200NursingHistory.currentTime, }); } @@ -1812,9 +1834,9 @@ class IotCarePlanFR200 extends Component { const params = { createDate: dayjs().format("YYYY-MM-DD"), workMode: jsonStatus.workMode, - instrumentId: currentDevice.id, + instrumentId: currentDevice?.id, instrumentName: currentDevice.name, - modeId: ActiveModeItem.id, + modeId: ActiveModeItem?.id, modeName: ActiveModeItem.modeName, id: dayjs().format("YYYY-MM-DD HH:mm:ss"), neededTotalSeconds: jsonStatus.neededTotalSeconds, @@ -1844,7 +1866,7 @@ class IotCarePlanFR200 extends Component { params.dataArray.push(jsonStatus); params.jsonStatus = jsonStatus; params.workMode = jsonStatus?.workMode; - params.modeId = this.state.ActiveModeItem.id; + params.modeId = this.state.ActiveModeItem?.id; params.modeName = this.state.ActiveModeItem.modeName; console.log(jsonStatus, 555555555555); @@ -1852,7 +1874,7 @@ class IotCarePlanFR200 extends Component { } else { params.jsonStatus = jsonStatus; params.workMode = jsonStatus?.workMode; - params.modeId = data.id; + params.modeId = data?.id; params.modeName = data.modeName; } @@ -2002,9 +2024,9 @@ class IotCarePlanFR200 extends Component { params = data; } else { params = { - instrumentId: currentDevice.id, + instrumentId: currentDevice?.id, instrumentName: currentDevice.name, - modeId: ActiveModeItem.id, + modeId: ActiveModeItem?.id, modeName: ActiveModeItem.modeName, nursingTime: s_to_hms(this.elapsedTime), }; @@ -2019,7 +2041,7 @@ class IotCarePlanFR200 extends Component { console.log("PostNursingLogClock", res2); if (res2.data.code === 200) { let params = { - instrumentId: currentDevice.id, + instrumentId: currentDevice?.id, }; // 上传护理完成的仪器ID let res = await InstrumentInfo.apiClock.addClockInstrument(params); @@ -2037,9 +2059,9 @@ class IotCarePlanFR200 extends Component { this.goFaceReport( res1, - ActiveModeItem.id, + ActiveModeItem?.id, res2.data.data, - currentDevice.id + currentDevice?.id ); // 跳转 }, 2000); } @@ -2162,11 +2184,11 @@ class IotCarePlanFR200 extends Component { let report = true; go( "/recoding/pages/face_report_one/face_report_one?id=" + - ids + - "&report=" + - report + - "&obj=" + - JSON.stringify(obj) + ids + + "&report=" + + report + + "&obj=" + + JSON.stringify(obj) ); } else if ("moistureTest" === nursingData.workMode) { console.log("水分测试"); @@ -2177,11 +2199,11 @@ class IotCarePlanFR200 extends Component { go( "/recoding/pages/face_report/face_report?id=" + - deviceid + - "&recordId=" + - currentDevice + - "&report=" + - report + deviceid + + "&recordId=" + + currentDevice + + "&report=" + + report ); } }; @@ -2230,13 +2252,13 @@ class IotCarePlanFR200 extends Component { firstNurseInfo = async () => { let { currentDevice } = this.state; let res = await InstrumentInfo.firstNurseInfo({ - instrumentId: currentDevice.id, + instrumentId: currentDevice?.id, }); console.log(res, "接口"); if (res.data.code === 200) { let isFirstTipShow = getStorageSync( - "first_instrument_" + currentDevice.id + "first_instrument_" + currentDevice?.id ); console.log(isFirstTipShow, "查看返回值"); @@ -2246,7 +2268,7 @@ class IotCarePlanFR200 extends Component { this.setState({ nurseInfo: res.data.data, isFirstTipShow: true }); } - setStorageSync("first_instrument_" + currentDevice.id, true); + setStorageSync("first_instrument_" + currentDevice?.id, true); } else { this.setState({ nurseInfo: res.data.data }); } @@ -2256,7 +2278,7 @@ class IotCarePlanFR200 extends Component { this.setState({ isFirstTipShow: true }); }; onTipShowClose = async () => { - setStorageSync("first_instrument_" + this.state.currentDevice.id, true); + setStorageSync("first_instrument_" + this.state.currentDevice?.id, true); this.setState({ isFirstTipShow: false }); }; /** 初次护理信息弹窗 END */ @@ -2308,6 +2330,7 @@ class IotCarePlanFR200 extends Component { render() { let { title, + textshow, isConnectShow, GearData, waterStepList, @@ -2335,6 +2358,7 @@ class IotCarePlanFR200 extends Component { isNotEnoughTime, isShowNursingSuccess, currentDevice, + textscreen, isConnectionBlutoot, isShowTipsSave, isFirstTipShow, @@ -2354,13 +2378,16 @@ class IotCarePlanFR200 extends Component { return ( - - {!isFullScreen && ( + + + + + { - - - - - - - 倒计时:{currentTime} - + {isFullScreen && + + + - - - 档位:{currentGear}档 + + + + + 倒计时:{currentTime} + + + + + 档位:{currentGear}档 + + + - - - + } - {ModeList.length > 0 && ( + {ModeList.length > 0 && isFullScreen&&( { {/* */} + + + + + + {(ActiveModeItem?.modeType === "maskPenetration" || + ActiveModeItem?.modeType === "essence") &&isFullScreen&&( + + )} + + {ActiveModeItem?.modeType === "moistureTest" && isFullScreen&&( + + )} + + - + > */} + - {(ActiveModeItem.modeType === "maskPenetration" || - ActiveModeItem.modeType === "essence") && ( - - )} + {isFullScreen && +