From 29b59c23f27f718f4c500b3238c0e08f3577138f Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Wed, 21 Feb 2024 16:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=9Eiot=E8=AE=BE=E5=A4=87=E7=9A=84lock?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.tsx | 4 + src/pages/instrumentClickinUpload/index.less | 7 +- src/pages/instrumentClickinUpload/index.tsx | 129 +++++++++--------- src/pages/iotCarePlan/iotCarePlan.tsx | 130 +++++++------------ src/utils/util.js | 60 ++++++--- 5 files changed, 163 insertions(+), 167 deletions(-) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 1aecc9e..6f003b0 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -586,6 +586,10 @@ class Index extends Component { this.alertRegister(); return false; } + setTimeout(() => { + go("/pages/instrumentClickinUpload/index"); + }, 10); + return; if (this.state.connectInstrument.type === 1) { //非IOT setTimeout(() => { diff --git a/src/pages/instrumentClickinUpload/index.less b/src/pages/instrumentClickinUpload/index.less index b99d5e6..dbe8f11 100644 --- a/src/pages/instrumentClickinUpload/index.less +++ b/src/pages/instrumentClickinUpload/index.less @@ -217,6 +217,11 @@ page { height: 100%; flex-direction: column; width: 134rpx; + .icon { + width: 30rpx; + height: 30rpx; + margin-top: 15rpx; + } } } .info1_img { @@ -253,7 +258,7 @@ page { background-color: #fff; border-color: #fff; align-items: center; - justify-content: center; + justify-content: center; } .quan2 { border-radius: 50%; diff --git a/src/pages/instrumentClickinUpload/index.tsx b/src/pages/instrumentClickinUpload/index.tsx index e9dd58f..1db6632 100644 --- a/src/pages/instrumentClickinUpload/index.tsx +++ b/src/pages/instrumentClickinUpload/index.tsx @@ -26,7 +26,6 @@ import { setStorageSync, getStorageSync, msg } from "@/utils/traoAPI"; import "./index.less"; - export default class InstrumentClickInUpload extends Component { constructor(props) { super(props); @@ -90,7 +89,7 @@ export default class InstrumentClickInUpload extends Component { } const searchParams = new URLSearchParams(window.location.search); - const id = searchParams.get('id'); + const id = searchParams.get("id"); setTimeout(() => { this.firstNurseInfo(); @@ -303,113 +302,119 @@ export default class InstrumentClickInUpload extends Component { } = this.state; return ( - + - - + + - + {modeInfo.map((item, index) => { return ( - + - {item.modeName} - {item.modeDesc} + {item.modeName} + {item.modeDesc} {!item.lock && zkmoshiindex !== index && ( - + )} {!item.lock && zkmoshiindex == index && ( - - + + )} {item.lock && ( - + )} - {item.modeBanner && index == zkmoshiindex &&( - - + {item.modeBanner && index == zkmoshiindex && ( + + )} @@ -419,32 +424,32 @@ export default class InstrumentClickInUpload extends Component { - - - - - 打卡上传 - + + + + + 打卡上传 + - + {punchInInfo.clockImageList.length > 0 && punchInInfo.clockImageList.map((item, index) => { return ( - + @@ -453,23 +458,23 @@ export default class InstrumentClickInUpload extends Component { {punchInInfo.clockImageList.length < 3 && ( )} - + {/* {tipshow && ( @@ -478,7 +483,7 @@ export default class InstrumentClickInUpload extends Component { : "请记录一下今天打卡的心得吧~"} )} */} - + {punchInInfo.clockContent.length}/100 @@ -486,16 +491,16 @@ export default class InstrumentClickInUpload extends Component { - + {!isSubmit && ( - - 提交打卡 + + 提交打卡 )} {isSubmit && ( - - 提交打卡 + + 提交打卡 )} diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index fea9964..a9039b1 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -46,10 +46,12 @@ import { bleCommandSamples, } from "@/components/bluetoot/connection/test"; import { + hourMinSecToS, minSecToS, - s_to_h, - s_to_hs, s_to_s, + s_to_m, + s_to_ms, + s_to_hms, isNeedToUpdate, } from "@/utils/util"; import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; @@ -97,12 +99,18 @@ const WORK_MODE_ENGLISH_NAME = { 26: "MixNurse", 27: "ScalpCare", }; + +// 组合模式:分别对应的是哪几个模式类型 +// 黄光590nm +// 红光630nm +// 近红外光830nm + // 模式类型中文名 const WORK_MODE_Chinese_NAME = { 强效舒缓: "powerfulSoothing", - 维稳修复: "Stability", - 均色提亮: "Brighten", - 紧致淡纹: "FirmSkin", + 维稳修复: "Stability", // 黄光?近红外光? + 均色提亮: "Brighten", // 黄光?近红外光? + 紧致淡纹: "FirmSkin", // 黄光?近红外光? 自定义: "MaskCustom", 均色提亮Pro: "BrightenStand", 紧致淡纹Pro: "FirmSkinStand", @@ -173,7 +181,7 @@ class IotCarePlan extends Component { modelActiveIndex: 0, //模式下标 sliderProgress: 22, isStandStatus: false, // 支架开启状态(支架就是舱体) - facialMaskConnectStatus: 0, // 面膜?暂时认为是面罩连接状态 0未连接 1已连接 + facialMaskConnectStatus: 0, // 面罩连接状态 0未连接 1已连接 workStatus: "", // 工作状态 Electricity: 0, // WL200电量 matrixElectricity: 0, // matrix电量 @@ -229,6 +237,7 @@ class IotCarePlan extends Component { // 最后执行步骤位置 endPlace: "", + currentTime: "00:01:00", }; } @@ -586,36 +595,17 @@ class IotCarePlan extends Component { case "DeviceControl": console.log("小程序控制设备,给设备发送指令", jsonStatus); - if ( - jsonStatus.responseStatus == "OK" && - this.state.isSendModeCombination - ) { - // 发送启动指令 - this.startCombinationMode(); - - // const totalTime = this.state.combinationList.reduce( - // (total, item) => { - // return total + minSecToS(item.time); - // }, - // 0 - // ); - - // 设备启动后小程序操作 - // this.setState({ - // showCombinationModeDialog: false, - // combinationModeInfo: { - // time: s_to_hs(totalTime), - // seconds: totalTime, - // }, - // modelActiveIndex: -1, - // currentTime: s_to_hs(totalTime), - // isCurrentModeCombination: true, - // isSendModeCombination: false, - // }); - setTimeout(() => { - console.log("currentTime", this.state.currentTime); - }); - } + // if ( + // jsonStatus.responseStatus == "OK" && + // this.state.isSendModeCombination + // ) { + // // 发送启动指令 + // this.startCombinationMode(); + + // setTimeout(() => { + // console.log("currentTime", this.state.currentTime); + // }); + // } break; //设备主动上报给小程序的指令 一般是工作状态改变 case "DeviceStatusSync": @@ -846,20 +836,20 @@ class IotCarePlan extends Component { console.log("时间校准频率,默认5秒一次", TIME_CALIBRATION_FREQUENCY); //对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准 const currentScene = ActiveModeItem; // 获取当前的场景 - let sceneTime = minSecToS(currentScene.modeTime); // 场景时间 + let sceneTime = hourMinSecToS(currentScene.modeTime); // 场景时间 - const timeRemaining = sceneTime - minSecToS(currentTime); // 小程序上已运行的总秒数 + const timeRemaining = sceneTime - hourMinSecToS(currentTime); // 小程序上已运行的总秒数 if ( Math.abs(timeRemaining - totalTime) >= 2 && this.state.step == 2 && this.state.facialMaskConnectStatus == 1 ) { - this.setTimer(); + this.resetTimer(); const t = sceneTime - totalTime; // 场景时间 - 已运行时间 = 剩余时间 let { ActiveModeItem } = this.state; ActiveModeItem.seconds = t; //修复时间跳变的问题 this.setState({ - currentTime: s_to_hs(t), + currentTime: s_to_hms(t), ActiveModeItem, }); } @@ -1002,11 +992,11 @@ class IotCarePlan extends Component { // 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下 const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus; if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) { - const sceneTime = minSecToS(ActiveModeItem.modeTime); // 模式的总时长 + const sceneTime = hourMinSecToS(ActiveModeItem.modeTime); // 模式的总时长 const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长 const timeRemaining = sceneTime - runTime; // 剩余未运行时间 this.setState({ - currentTime: s_to_hs(timeRemaining), + currentTime: s_to_hms(timeRemaining), }); } this.endnursing(null, true); @@ -1130,7 +1120,8 @@ class IotCarePlan extends Component { return inTime; } - setTimer() { + // 重置计时器 + resetTimer() { // 切换模式后, 需要重新设置计时器, 以防进行中的计时器 timer && clearInterval(timer); timer = setInterval(() => { @@ -1145,14 +1136,14 @@ class IotCarePlan extends Component { // 组合模式逻辑 // that.data.combinationModeInfo.seconds -= 1; // that.setData({ - // currentTime: s_to_hs(that.data.combinationModeInfo.seconds) + // currentTime: s_to_ms(that.data.combinationModeInfo.seconds) // }) // currentSeconds = that.data.combinationModeInfo.seconds } else { const { ActiveModeItem, currentTime } = this.state; - currentSeconds = minSecToS(currentTime); + currentSeconds = hourMinSecToS(currentTime); this.setState({ - currentTime: s_to_hs(--currentSeconds), + currentTime: s_to_hms(--currentSeconds), }); console.log(ActiveModeItem.isCustomMode); if (ActiveModeItem.isCustomMode) { @@ -1167,7 +1158,7 @@ class IotCarePlan extends Component { } /*} else { that.data.standInfo.seconds -= 1; - that.setData({ currentTime: s_to_hs(that.data.standInfo.seconds) }) + that.setData({ currentTime: s_to_ms(that.data.standInfo.seconds) }) if(that.data.standInfo.seconds <= 0){ clearInterval(timer); this.showNurseSuccessDialog() @@ -1214,7 +1205,7 @@ class IotCarePlan extends Component { this.setState({ workStatus: newWorkStatus, }); - this.setTimer(); + this.resetTimer(); console.info( `handleWorkStatus 发送${newWorkStatus}指令成功 参数为 =>`, sendParams @@ -1329,50 +1320,17 @@ class IotCarePlan extends Component { // 检查时间是否达标 checkTime() { - const { curDeviceInfo, workStatus, ActiveModeItem } = this.state; + const { curDeviceInfo, ActiveModeItem } = this.state; const currentScene = ActiveModeItem; - let sceneTime = minSecToS(currentScene.time); - const timeRemaining = sceneTime - minSecToS(this.state.currentTime); - if (timeRemaining >= Number(curDeviceInfo?.times) * 60) { + let sceneTime = hourMinSecToS(currentScene.modeTime); + const timeRemaining = sceneTime - hourMinSecToS(this.state.currentTime); + if (timeRemaining >= Number(curDeviceInfo?.nursingTime) * 60) { return true; } else { return false; } } - // 开始护理? - onPlayTap() { - const { ActiveModeItem, step } = this.state; - const modeItem = ActiveModeItem; - if (step == 1) { - this.state.videoContext.play(); - this.setState({ - showVideoPlayBtn: false, - }); - } else if (modeItem.isStandMode && step == 2) { - this.setState({ - standVideoContext: Taro.createVideoContext("standVideo"), - }); - setTimeout(() => { - this.state.standVideoContext.play(); - }, 100); - } - } - // 暂停护理? - onPauseTap() { - const { ActiveModeItem, step } = this.state; - const modeItem = ActiveModeItem; - if (step == 1) { - } else if (modeItem.isStandMode && step == 2) { - this.setState({ - standVideoContext: Taro.createVideoContext("standVideo"), - }); - setTimeout(() => { - this.state.standVideoContext.play(); - }, 100); - } - } - // 删除WL200护理历史 rmWL200NursingHistory(WL200NursingHistory, hard = false) { // const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); @@ -1387,7 +1345,6 @@ class IotCarePlan extends Component { bluetoothDisconnectProcessing() { clearInterval(timer); Taro.offBLEConnectionStateChange(this.listener); // 需传入与监听时同一个的函数对象 - // this.state.innerAudioContext.destroy(); Taro.offBLECharacteristicValueChange((res) => { console.log("offBLECharacteristicValueChange", res); }); @@ -1432,6 +1389,7 @@ class IotCarePlan extends Component { } } + // 护理的错误提示 showTips(ctx) { if (!ctx) return; if (showTipsTimer) clearTimeout(showTipsTimer); diff --git a/src/utils/util.js b/src/utils/util.js index c56a10d..f383c47 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -292,56 +292,69 @@ const ccrc8 = (str) => { return (crc & 0xff).toString(16).padStart("2", 0); }; -/** 秒数转分秒,返回分秒 */ -const s_to_hs = (s) => { +/** 秒数转分秒,返回时分秒 */ +const s_to_hms = (s) => { //计算分钟 + //算法:将秒数除以60,然后下舍入,既得到分钟数 + var m; + m = Math.floor(s / 60); + //算法:将分钟除以60,然后下舍入,既得到小时数 var h; - h = Math.floor(s / 60); + h = Math.floor(m / 60); //计算秒 //算法:取得秒%60的余数,既得到秒数 s = s % 60; - //将变量转换为字符串 + // 将变量强制类型转换为字符串 h += ""; + m += ""; s += ""; //如果只有一位数,前面增加一个0 h = h.length == 1 ? "0" + h : h; + m = m.length == 1 ? "0" + m : m; s = s.length == 1 ? "0" + s : s; - return h + ":" + s; + return h + ":" + m + ":" + s; }; -/** 秒数转分钟,只返回分钟 */ -const s_to_h = (s) => { +/** 秒数转分秒,返回分秒 */ +const s_to_ms = (s) => { //计算分钟 //算法:将秒数除以60,然后下舍入,既得到分钟数 - var h; - h = Math.floor(s / 60); + var m; + m = Math.floor(s / 60); //计算秒 //算法:取得秒%60的余数,既得到秒数 s = s % 60; //将变量转换为字符串 - h += ""; + m += ""; s += ""; //如果只有一位数,前面增加一个0 - h = h.length == 1 ? "0" + h : h; + m = m.length == 1 ? "0" + m : m; s = s.length == 1 ? "0" + s : s; - return h; + return m + ":" + s; }; -/** 秒数转分钟,只返回秒数 */ -const s_to_s = (s) => { +/** 秒数转分钟,只返回分钟 */ +const s_to_m = (s) => { //计算分钟 //算法:将秒数除以60,然后下舍入,既得到分钟数 var h; h = Math.floor(s / 60); + //将变量转换为字符串 + h += ""; + //如果只有一位数,前面增加一个0 + h = h.length == 1 ? "0" + h : h; + return h; +}; + +/** 秒数转分钟,只返回秒数 */ +const s_to_s = (s) => { //计算秒 //算法:取得秒%60的余数,既得到秒数 s = s % 60; //将变量转换为字符串 - h += ""; s += ""; //如果只有一位数,前面增加一个0 - h = h.length == 1 ? "0" + h : h; s = s.length == 1 ? "0" + s : s; return s; }; @@ -354,6 +367,15 @@ const minSecToS = (minSecStr) => { return strArr.length ? parseInt(strArr[0]) * 60 + parseInt(strArr[1]) : 0; }; +/** 时分秒转秒数,返回秒数 */ +const hourMinSecToS = (hourMinSecStr) => { + if (!hourMinSecStr) return 0; + let strArr = hourMinSecStr.split(":"); + return strArr.length + ? parseInt(strArr[0]) * 360 + parseInt(strArr[1]) * 60 + parseInt(strArr[2]) + : 0; +}; + // 将字符串转换成ArrayBufer const string2buffer = (str) => { let val = ""; @@ -696,7 +718,6 @@ module.exports = { filterData, ccrc8, //crc8校验位 string2buffer, //将字符串转换成ArrayBufer - s_to_hs, //秒转换成分秒 checkEnd, //相加和 filterBleData, getofflineData, @@ -709,9 +730,12 @@ module.exports = { getimpedanceList, DYNAMIC_BONES_OFFSETS, //阻抗获取值 getreportData, //解析上报数据 - s_to_h, + s_to_m, s_to_s, + s_to_ms, //秒转换成分秒 + s_to_hms, //秒转换成时分秒 minSecToS, + hourMinSecToS, getTimeCode, //同步时间指令 isNeedToUpdate, compareVersion,