|
|
|
|
@ -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<any, any> {
|
|
|
|
|
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<any, any> {
|
|
|
|
|
|
|
|
|
|
// 最后执行步骤位置
|
|
|
|
|
endPlace: "",
|
|
|
|
|
currentTime: "00:01:00",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -586,36 +595,17 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
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<any, any> {
|
|
|
|
|
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<any, any> {
|
|
|
|
|
// 获取仪器运行时间,更新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<any, any> {
|
|
|
|
|
return inTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setTimer() {
|
|
|
|
|
// 重置计时器
|
|
|
|
|
resetTimer() {
|
|
|
|
|
// 切换模式后, 需要重新设置计时器, 以防进行中的计时器
|
|
|
|
|
timer && clearInterval(timer);
|
|
|
|
|
timer = setInterval(() => {
|
|
|
|
|
@ -1145,14 +1136,14 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
// 组合模式逻辑
|
|
|
|
|
// 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<any, any> {
|
|
|
|
|
}
|
|
|
|
|
/*} 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<any, any> {
|
|
|
|
|
this.setState({
|
|
|
|
|
workStatus: newWorkStatus,
|
|
|
|
|
});
|
|
|
|
|
this.setTimer();
|
|
|
|
|
this.resetTimer();
|
|
|
|
|
console.info(
|
|
|
|
|
`handleWorkStatus 发送${newWorkStatus}指令成功 参数为 =>`,
|
|
|
|
|
sendParams
|
|
|
|
|
@ -1329,50 +1320,17 @@ class IotCarePlan extends Component<any, any> {
|
|
|
|
|
|
|
|
|
|
// 检查时间是否达标
|
|
|
|
|
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<any, any> {
|
|
|
|
|
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<any, any> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 护理的错误提示
|
|
|
|
|
showTips(ctx) {
|
|
|
|
|
if (!ctx) return;
|
|
|
|
|
if (showTipsTimer) clearTimeout(showTipsTimer);
|
|
|
|
|
|