FR200 促渗模式自动震动蜂鸣切换档位

master
blak-kong 2 years ago
parent 586edb21de
commit d6729d0de3

@ -1 +1,47 @@
@import url(./WL200.less);
.fr200-iot-device {
width: 690rpx;
height: 150rpx;
display: flex;
align-items: center;
justify-content: center;
.device-time {
font-size: 26rpx;
color: #000;
font-weight: 400;
.time {
font-size: 30rpx;
font-weight: 800;
}
}
.line {
width: 1rpx;
height: 50rpx;
background: #dddddd;
margin-left: 34rpx;
margin-right: 34rpx;
}
.gear {
margin-left: 10rpx;
font-size: 30rpx;
font-weight: 800;
color: #000;
}
.electricity-box {
display: flex;
flex-direction: column;
.item {
display: flex;
align-items: center;
justify-content: left;
height: 50rpx;
.label {
// width: 154rpx;
font-size: 26rpx;
color: #000;
margin-right: 14rpx;
}
}
}
}

@ -39,7 +39,7 @@ import ConnectionBluetoot from "@/components/bluetoot/connection";
/* 公共组件 END */
/* 本页组件 */
import ElectricityView from "./components/ElectricityView/index";
import ElectricityView from "./components/ElectricityView/Electricity";
import ModeListView from "./components/ModeList/FR200";
import Footer from "./components/Footer/FR200";
import WaterTest from "./components/WaterTest/index";
@ -122,7 +122,7 @@ class IotCarePlanFR200 extends Component<any, any> {
{ name: "左脸颊", forehead: 6, Total: 10 },
{ name: "右脸颊", forehead: 2, Total: 10 },
],
stepList: [
waterStepList: [
{
value: "Step1",
name: "额头",
@ -148,12 +148,11 @@ class IotCarePlanFR200 extends Component<any, any> {
forehead: 0,
},
],
stepIndex: 0,
waterStepIndex: 0,
// 进度条定时器
timerIdSchedule: null,
timerIdSuccess: null,
gear: { gear: 1 },
currentShowDialog: "",
showVideoPlayBtn: true, // 视频播放按钮
duration: 0, // 视频总时长
@ -163,6 +162,7 @@ class IotCarePlanFR200 extends Component<any, any> {
/** 连接设备 End */
/** 护理过程 */
currentGear: 5, // 默认档位
isRuningTest: 1, // 是否正在测试
isShowStepTips: false, // 是否显示介绍步骤弹窗
isConnectionBlutoot: true, // 是否已连接蓝牙
@ -173,8 +173,8 @@ class IotCarePlanFR200 extends Component<any, any> {
/** 护理过程 END*/
// 模式列表
TestModeStepIndex: 0,
currentWorkModeType: 1,
currentWorkModeType: 1, // 现在的模式类型
currentVideoSrc: "", // 现在模式的视频地址
isModeLock: false, // 模式是否锁定
isSwitchActiveMode: false, // 是否显示弹窗切换模式
ModeList: [],
@ -187,6 +187,16 @@ class IotCarePlanFR200 extends Component<any, any> {
activeModeID: "", // 当前选中模式ID:用于高亮
ModeStepIndex: 0, // 当前护理功效步骤:每个步骤时间不定,所以时间另外计算,根据步骤显示
ModeStepTimeArray: [], // 护理功效时间步骤用于切换显示GIF
TestModeStepIndex: 0, // 水分测试步骤
EssenceStepIndex: 0, // 精华促渗步骤
MaskModeStepIndex: 0, // 面膜促渗步骤
EssenceBuzzingIndex: 0, // 精华蜂鸣
EssenceVibrateIndex: 0, // 精华震动
MaskModeBuzzingIndex: 0, // 面膜蜂鸣
MaskModeVibrateIndex: 0, // 面膜震动
currentServiceData: {
// 当前展示的开启暂停GIF: 因为时间判断不方便,所以单独领出来
startSource: "",
@ -257,8 +267,14 @@ class IotCarePlanFR200 extends Component<any, any> {
"intelligence",
];
/** 基础版:脸部/眼部 */
BaseModeType: string[] = ["face", "eyes"];
/** 基础版:脸部/眼部/PRO 设备使用时,会自动开启暂停 */
BaseModeType: string[] = [
"face",
"eyes",
"nasolabialFold",
"mandibularLine",
"headLiftingPro",
];
async onLoad(option) {
console.log(option, "跳转过来的数据");
@ -497,10 +513,16 @@ class IotCarePlanFR200 extends Component<any, any> {
activeModeID: data.id,
ModeID: "mode_" + data.id,
ModeStepIndex: 0,
TestModeStepIndex: 0, // 水分测试步骤
EssenceStepIndex: 0, // 精华促渗步骤
MaskModeStepIndex: 0, // 面膜促渗步骤
ModeType: this.ModeTypeArray[data.modeClass],
currentWorkModeType,
});
// 切换模式时:重新设置视频地址
this.VideoSrcLoad(data.modeVideo);
// 开发中,暂时允许直接切换
// 每次切换模式时清空一下历史数据
this.changeItemUpdateFR200NursingHistory();
@ -517,6 +539,8 @@ class IotCarePlanFR200 extends Component<any, any> {
/** 设备运行中切换模式 */
modeRuningChange() {
// 运行中切换模式逻辑
// 当且仅当,护理模式时长大于设备最低时常时,提示是否保存护理记录。
// 若不满足,直接切换
if (
this.workStatus === MODE_WORKING_ENUM.PAUSE ||
this.workStatus === MODE_WORKING_ENUM.WORKING
@ -539,8 +563,8 @@ class IotCarePlanFR200 extends Component<any, any> {
this.setState({
isShowTipsSave: true,
});
return true;
}
return true;
}
}
return false;
@ -625,7 +649,7 @@ class IotCarePlanFR200 extends Component<any, any> {
};
/** 完成护理,跳转到水分 */
onsuccess = async () => {
let stepList = this.state.stepList;
let waterStepList = this.state.waterStepList;
this.setState({
isShowNursingSuccess: true,
});
@ -634,7 +658,7 @@ class IotCarePlanFR200 extends Component<any, any> {
let params = {};
let nursingData = {
nursingData: JSON.stringify({
GearData: [...stepList],
GearData: [...waterStepList],
}),
};
params = {
@ -766,55 +790,54 @@ class IotCarePlanFR200 extends Component<any, any> {
break;
//设备状态同步
case "DeviceStatusSync":
this.setState({
Electricity: jsonStatus.battery,
});
if (jsonStatus.battery) {
// 防止抖动
this.setState({
Electricity: jsonStatus.battery,
});
}
switch (jsonStatus.workStatus) {
case "standby":
//设备的待机状态 可能workMode字段为空
console.log("设备状态同步 待机状态", jsonStatus);
// this.judgementWorkStatus(
// MODE_WORKING_ENUM.STANDBY,
// jsonStatus.workMode
// );
if (this.BaseModeType.includes(jsonStatus.workMode)) {
this.openTips("检测到您的设备没有紧贴肌肤,请紧贴肌肤");
}
break;
case "pause":
//设备的暂停状态
console.log("设备状态同步 暂停状态", jsonStatus);
// this.judgementWorkStatus(
// MODE_WORKING_ENUM.PAUSE,
// jsonStatus.workMode
// );
if (this.BaseModeType.includes(jsonStatus.workMode)) {
this.openTips(
"检测到您的设备没有紧贴肌肤,请紧贴肌肤后重新尝试"
);
}
break;
case "working":
//设备的运行中状态
console.log("设备状态同步 运行中状态", jsonStatus.workMode);
console.log("设备状态同步 工作中状态", jsonStatus.workMode);
// 脸部模式
if (jsonStatus.workMode === "face") {
// impedance
// totalWorkingMinutes: 0
// totalWorkingSeconds: 24
if (this.BaseModeType.includes(jsonStatus.workMode)) {
this.closeTips();
}
// this.judgementWorkStatus(
// MODE_WORKING_ENUM.WORKING,
// jsonStatus.workMode
// );
break;
default:
break;
}
if (jsonStatus.workMode === "moistureTest") {
if ("success" === jsonStatus.testStatus) {
let stepList = this.state.stepList;
let stepIndex = this.state.stepIndex;
let waterStepList = this.state.waterStepList;
let waterStepIndex = this.state.waterStepIndex;
let timerIdSuccess = this.state.timerIdSuccess;
let timerIdSchedule = this.state.timerIdSchedule;
if (stepList[stepIndex].finish) {
stepList[stepIndex].forehead = jsonStatus.waterLevel;
if (stepIndex === 2) {
if (waterStepList[waterStepIndex].finish) {
waterStepList[waterStepIndex].forehead =
jsonStatus.waterLevel;
if (waterStepIndex === 2) {
this.setState({
isRuningTest: 4,
});
@ -826,30 +849,30 @@ class IotCarePlanFR200 extends Component<any, any> {
clearTimeout(timerIdSuccess);
clearTimeout(timerIdSchedule);
console.log("成功拿到", jsonStatus, stepIndex);
let num = stepIndex;
if (stepIndex < 2) {
num = stepIndex + 1;
console.log("成功拿到", jsonStatus, waterStepIndex);
let num = waterStepIndex;
if (waterStepIndex < 2) {
num = waterStepIndex + 1;
}
this.setState({
timerIdSuccess: null,
timerIdSchedule: null,
stepIndex: num,
stepList,
waterStepIndex: num,
waterStepList,
});
}
} else {
let stepList = this.state.stepList;
let stepIndex = this.state.stepIndex;
let waterStepList = this.state.waterStepList;
let waterStepIndex = this.state.waterStepIndex;
let timerIdSuccess = this.state.timerIdSuccess;
let timerIdSchedule = this.state.timerIdSchedule;
if (stepList[stepIndex].finish) {
if (waterStepList[waterStepIndex].finish) {
clearTimeout(timerIdSuccess);
clearTimeout(timerIdSchedule);
stepList[stepIndex].schedule = 0;
stepList[stepIndex].finish = false;
waterStepList[waterStepIndex].schedule = 0;
waterStepList[waterStepIndex].finish = false;
this.setState({
stepList,
waterStepList,
isRuningTest: 3,
});
}
@ -858,15 +881,7 @@ class IotCarePlanFR200 extends Component<any, any> {
// testStatus:success
}
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);
console.log("设备运行中?", this.isRuning);
if (jsonStatus?.workMode === this.state.ActiveModeItem.modeType) {
if (this.state.workMode !== jsonStatus?.workMode) {
this.setState({
@ -904,10 +919,11 @@ class IotCarePlanFR200 extends Component<any, any> {
this.workStatus = jsonStatus.workStatus;
setTimeout(() => console.log("this.workStatus", this.workStatus));
this.setState({
Electricity: jsonStatus.battery,
matrixElectricity: jsonStatus.matrixBattery,
});
if (jsonStatus.battery) {
this.setState({
Electricity: jsonStatus.battery,
});
}
// 判断设备主动上报的关机事件
if (jsonStatus.workStatus === MODE_WORKING_ENUM.END) {
@ -1101,7 +1117,7 @@ class IotCarePlanFR200 extends Component<any, any> {
* params
*/
judgementWorkStatus(nWorkStatus, nWorkMode) {
const { ActiveModeItem, ModeList } = this.state;
const { ActiveModeItem, ModeList, currentVideoTime } = this.state;
const opts: any = {};
// ActiveModeItem
let nowModeItem;
@ -1112,7 +1128,7 @@ class IotCarePlanFR200 extends Component<any, any> {
}
opts.workStatus = nWorkStatus;
let nowCurrentTime = ActiveModeItem.modeTimeStr;
let nowCurrentTime = currentVideoTime;
// 完成重连同步则删除重连时间字段
if (ActiveModeItem?.breakTimeStr) {
nowCurrentTime = ActiveModeItem?.breakTimeStr;
@ -1130,25 +1146,11 @@ class IotCarePlanFR200 extends Component<any, any> {
});
},
setting: () => {
this.isRuning = true;
this.setState({
hadShowBreakTips: false,
title: "正在护理",
isStopNurse: false,
});
if (!this.isRuning && !ActiveModeItem.isCabinMode) {
this.isRuning = true;
this.setState({
title: "正在护理",
isStopNurse: false,
});
} else if (!this.isRuning && ActiveModeItem.isCabinMode) {
this.isRuning = true;
// this.setState({
// title: "正在护理",
// });
this.setState({
title: "正在护理",
isStopNurse: false,
});
}
if (nowModeItem) {
opts.currentTime = nowCurrentTime;
}
@ -1165,20 +1167,18 @@ class IotCarePlanFR200 extends Component<any, any> {
title: "正在护理",
isStopNurse: false,
isShowCountdown: false,
hadShowBreakTips: false,
});
this.closeTips();
},
pause: () => {
clearInterval(currentTimeTimer);
this.setState({
isShowCountdown: false,
});
if (ActiveModeItem.isCabinMode) {
this.setState({
title: "暂停护理",
isStopNurse: true,
});
}
this.setState({
title: "暂停护理",
isStopNurse: true,
});
},
end: () => {
// 已进入了报告阶段, 防止重复进入, 主要防止在手动点击结束护理接收到仪器消息
@ -1228,9 +1228,8 @@ class IotCarePlanFR200 extends Component<any, any> {
let {
DeviceConnectStatus,
currentTime,
ModeStepTimeArray,
ModeStepIndex,
ActiveModeItem,
currentVideoTime,
} = this.state;
if (
this.workStatus == MODE_WORKING_ENUM.WORKING &&
@ -1239,20 +1238,22 @@ class IotCarePlanFR200 extends Component<any, any> {
) {
let totalSeconds = ActiveModeItem?.breakTimeStr
? minSecToS(ActiveModeItem.breakTimeStr)
: minSecToS(ActiveModeItem.modeTimeStr);
: minSecToS(currentVideoTime);
// 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算
let currentSeconds = minSecToS(currentTime);
let checkTime = totalSeconds - currentSeconds;
// 缓存经过的时间:用于接口提交
this.elapsedTime = checkTime;
// fr200不需要加上中断的时间
// 如果存在中断时间,则要加上间隔的时间
if (ActiveModeItem?.breakTimeStr) {
let intervalTime =
minSecToS(ActiveModeItem.modeTimeStr) -
minSecToS(ActiveModeItem.breakTimeStr);
this.elapsedTime += intervalTime;
}
// if (ActiveModeItem?.breakTimeStr) {
// let intervalTime =
// minSecToS(ActiveModeItem.modeTimeStr) -
// minSecToS(ActiveModeItem.breakTimeStr);
// this.elapsedTime += intervalTime;
// }
console.log("this.elapsedTime", this.elapsedTime);
// 判断剩余时间是否大于1
if (currentSeconds >= 1) {
@ -1261,40 +1262,19 @@ class IotCarePlanFR200 extends Component<any, any> {
currentTime: s_to_ms(--currentSeconds),
});
let length = ModeStepTimeArray.length;
if (length) {
// 模式多个步骤节点切换
// 已运行时间达到下一节点时,切换
if (checkTime > ModeStepTimeArray[ModeStepIndex]) {
// 已运行时间达到下一节点,且存在下一节点,步骤切换时更新
if (ModeStepIndex < length - 1) {
let index = ModeStepIndex + 1; // 提前步骤+1
let currentServiceData = {
startSource: "",
stopSource: "",
};
let serviceLength = ActiveModeItem.serviceData.length;
if (serviceLength > index) {
currentServiceData = ActiveModeItem.serviceData[index];
}
console.log("********************");
console.log("********************");
console.log(
"仅在时间达到下一步步骤切换时更新currentServiceData",
currentServiceData
);
this.setState({
ModeStepIndex: index,
});
}
}
// 根据不同的模式,切换步骤到下一步
if (ActiveModeItem.modeType === "essence") {
this.essencePenetrationNext();
} else if (ActiveModeItem.modeType === "maskPenetration") {
this.maskPenetrationNext();
}
} else {
clearInterval(currentTimeTimer);
this.setState({
currentTime: "00:00",
ModeStepIndex: 0,
TestModeStepIndex: 0, // 水分测试步骤
EssenceStepIndex: 0, // 精华促渗步骤
MaskModeStepIndex: 0, // 面膜促渗步骤
});
this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束
}
@ -1302,6 +1282,243 @@ class IotCarePlanFR200 extends Component<any, any> {
}, 1000);
};
/**
* @name
* @description +1
*/
waterTestNext() {
let { TestModeStepIndex, ActiveModeItem } = this.state;
if (TestModeStepIndex < 3) {
let index = TestModeStepIndex + 1; // 提前步骤+1
this.setState({
TestModeStepIndex: index,
});
if (index === 1 && ActiveModeItem.stepOneVideo) {
this.VideoSrcLoad(ActiveModeItem.stepOneVideo);
} else if (index === 2 && ActiveModeItem.stepTwoVideo) {
this.VideoSrcLoad(ActiveModeItem.stepTwoVideo);
} else if (index === 3 && ActiveModeItem.stepThreeVideo) {
this.VideoSrcLoad(ActiveModeItem.stepThreeVideo);
}
}
}
/**
* @name ,
* @description 1. 2./
* */
maskPenetrationNext() {
let {
MaskModeStepIndex,
MaskModeBuzzingIndex,
MaskModeVibrateIndex,
ActiveModeItem,
} = this.state;
// 模式多个步骤节点切换
// 已运行时间达到下一节点时,切换
let GearLength = ActiveModeItem.modeGear.length;
if (GearLength && MaskModeStepIndex < GearLength) {
let GearTime = minSecToS(ActiveModeItem.modeGear[MaskModeStepIndex].time);
if (this.elapsedTime > GearTime) {
// 已运行时间达到下一节点,且存在下一节点,步骤切换时更新
if (MaskModeStepIndex < GearLength) {
let index = MaskModeStepIndex + 1; // 提前步骤+1
this.setState({
MaskModeStepIndex: index,
});
this.FR200AutoChangeGear(index);
}
}
}
let BuzzingLength = ActiveModeItem.modeBuzzing.length;
if (BuzzingLength && MaskModeStepIndex < GearLength) {
let BuzzingTime = minSecToS(
ActiveModeItem.modeBuzzing[MaskModeStepIndex].time
);
if (this.elapsedTime > BuzzingTime) {
if (MaskModeBuzzingIndex < BuzzingLength) {
let index = MaskModeBuzzingIndex + 1; // 提前步骤+1
this.setState({
MaskModeBuzzingIndex: index,
});
this.FR200Buzzing();
}
}
}
let VibrateLength = ActiveModeItem.modeVibrate.length;
if (VibrateLength && MaskModeStepIndex < VibrateLength) {
let VibrateTime = minSecToS(
ActiveModeItem.modeVibrate[MaskModeStepIndex].time
);
if (this.elapsedTime > VibrateTime) {
if (MaskModeVibrateIndex < VibrateLength) {
let index = MaskModeVibrateIndex + 1; // 提前步骤+1
this.setState({
MaskModeVibrateIndex: index,
});
this.FR200Vibrate();
}
}
}
}
/** @name 精华促渗下一步,根据时间自动调用 */
essencePenetrationNext() {
let {
EssenceStepIndex,
EssenceBuzzingIndex,
EssenceVibrateIndex,
ActiveModeItem,
} = this.state;
// 模式多个步骤节点切换
// 已运行时间达到下一节点时,切换
let GearLength = ActiveModeItem.modeGear.length;
if (GearLength && EssenceBuzzingIndex < GearLength) {
let GearTime = minSecToS(
ActiveModeItem.modeGear[EssenceBuzzingIndex].time
);
if (this.elapsedTime > GearTime) {
// 已运行时间达到下一节点,且存在下一节点,步骤切换时更新
if (EssenceStepIndex < GearLength) {
let index = EssenceStepIndex + 1; // 提前步骤+1
this.setState({
EssenceStepIndex: index,
});
this.FR200AutoChangeGear(index);
}
}
}
let BuzzingLength = ActiveModeItem.modeBuzzing.length;
if (BuzzingLength && EssenceBuzzingIndex < BuzzingLength) {
let BuzzingTime = minSecToS(
ActiveModeItem.modeBuzzing[EssenceBuzzingIndex].time
);
if (this.elapsedTime > BuzzingTime) {
if (EssenceBuzzingIndex < BuzzingLength) {
let index = EssenceBuzzingIndex + 1; // 提前步骤+1
this.setState({
EssenceBuzzingIndex: index,
});
this.FR200Buzzing();
}
}
}
let VibrateLength = ActiveModeItem.modeVibrate.length;
if (VibrateLength && EssenceBuzzingIndex < VibrateLength) {
let VibrateTime = minSecToS(
ActiveModeItem.modeBuzzing[EssenceBuzzingIndex].time
);
if (this.elapsedTime > VibrateTime) {
if (EssenceVibrateIndex < VibrateLength) {
let index = EssenceVibrateIndex + 1; // 提前步骤+1
this.setState({
EssenceVibrateIndex: index,
});
this.FR200Vibrate();
}
}
}
}
/**切换挡位发起蜂鸣:可以切换到现在的挡位?*/
FR200Buzzing = () => {
console.log("FR200Buzzing 蜂鸣", this.elapsedTime);
const { ActiveModeItem, currentGear } = this.state;
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workStatus: "working",
gear: currentGear,
};
if (currentGear > 1) {
sendParams.gear = currentGear - 1;
let pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
});
} else {
sendParams.gear = currentGear + 1;
let pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
});
}
setTimeout(() => {
sendParams.gear = currentGear;
let pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
});
}, 300);
};
/**
* @name FR200
* @description
*/
FR200AutoChangeGear = (index: number = 0) => {
console.log("FR200AutoChangeGear 切换挡位", this.elapsedTime);
const { ActiveModeItem, GearData } = this.state;
let gear = GearData[index].forehead;
// 同步挡位
this.setState({
currentGear: gear,
});
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workStatus: "working",
gear: gear,
};
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
}).then(() => {
this.workStatus = "working";
this.resetTimer();
});
};
/**
* @name FR200
* @description
*/
FR200Vibrate = () => {
console.log("FR200Vibrate FR200震动", this.elapsedTime);
const { ActiveModeItem, currentGear } = this.state;
let sendParams: any = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
workStatus: "working",
gear: currentGear,
};
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
});
};
// 检测并控制工作状态
handleWorkStatus = (isBtnClick: boolean, workStatus) => {
const { DeviceConnectStatus, ActiveModeItem } = this.state;
@ -1328,22 +1545,22 @@ class IotCarePlanFR200 extends Component<any, any> {
// 水分测试准备 水分测试工作 水分测试启动
if (ActiveModeItem.modeType === "moistureTest") {
sendParams.testStatus = "standby"; // 切换为准备
let stepList = this.state.stepList;
let stepIndex = this.state.stepIndex;
let waterStepList = this.state.waterStepList;
let waterStepIndex = this.state.waterStepIndex;
let timerIdSchedule = this.state.timerIdSchedule;
let timerIdSuccess = this.state.timerIdSuccess;
if (isBtnClick) {
timerIdSchedule = setTimeout(function () {
stepList[stepIndex].schedule = 100;
waterStepList[waterStepIndex].schedule = 100;
timerIdSuccess = setTimeout(function () {
stepList[stepIndex].finish = true;
waterStepList[waterStepIndex].finish = true;
this.setState({
stepList,
waterStepList,
});
}, 2000);
this.setState({
stepList,
waterStepList,
timerIdSuccess,
});
}, 3000);
@ -1358,7 +1575,7 @@ class IotCarePlanFR200 extends Component<any, any> {
}
if (ActiveModeItem.modeType === "maskPenetration") {
sendParams.gear = 10; // 点击开始再开始
sendParams.gear = this.state.currentGear; // 点击开始再开始
}
console.log("准备发送自定义或工作指令", ActiveModeItem, sendParams);
@ -1434,9 +1651,8 @@ class IotCarePlanFR200 extends Component<any, any> {
/** 检查时间是否达标仪器最低护理时间 */
isCheckNurseTime() {
const { currentDevice, ActiveModeItem } = this.state;
const currentScene = ActiveModeItem;
let sceneTime = minSecToS(currentScene.modeTimeStr);
const { currentDevice, currentVideoTime } = this.state;
let sceneTime = minSecToS(currentVideoTime);
const timeRemaining = sceneTime - minSecToS(this.state.currentTime); // 当前模式已运行时间
let nursingTimeStr = currentDevice?.nursingTimeStr;
@ -1496,7 +1712,8 @@ class IotCarePlanFR200 extends Component<any, any> {
* */
checkInstrumentRecord = async (jsonStatus: any) => {
console.log("检查护理记录");
let { currentDevice, ActiveModeItem, ModeList } = this.state;
let { currentDevice, ActiveModeItem, ModeList, currentVideoTime } =
this.state;
await sleep(2);
@ -1552,8 +1769,7 @@ class IotCarePlanFR200 extends Component<any, any> {
console.log("currentTime", FR200NursingHistory.currentTime);
let historyElapsedTime =
minSecToS(recordModeItem.modeTimeStr) -
minSecToS(FR200NursingHistory.currentTime);
minSecToS(currentVideoTime) - minSecToS(FR200NursingHistory.currentTime);
this.elapsedTime =
this.elapsedTime > historyElapsedTime
@ -1647,12 +1863,6 @@ class IotCarePlanFR200 extends Component<any, any> {
ModeID: "mode_" + ActiveModeItem.id,
currentTime: this.FR200NursingHistory.currentTime,
});
setTimeout(() => {
// 设置时间组合
if (ActiveModeItem.serviceData.length > 0) {
this.setServiceTimeData();
}
});
}
}
/** 设置WL200护理历史 */
@ -1675,7 +1885,7 @@ class IotCarePlanFR200 extends Component<any, any> {
console.log("保存setFR200NursingHistory");
};
/** 更新WL200护理历史运行时间 */
updateFR200NursingHistory = (data: any = null, jsonStatus = null) => {
updateFR200NursingHistory = (data: any = null, jsonStatus: any = null) => {
this.FR200NursingHistory = Taro.getStorageSync("FR200NursingHistory");
if (this.FR200NursingHistory) {
@ -1692,8 +1902,17 @@ class IotCarePlanFR200 extends Component<any, any> {
if (!params.dataArray) params.dataArray = [];
params.dataArray.push(jsonStatus);
params.jsonStatus = jsonStatus;
params.workMode = jsonStatus?.workMode;
params.modeId = this.state.ActiveModeItem.id;
params.modeName = this.state.ActiveModeItem.modeName;
}
} else {
params.jsonStatus = jsonStatus;
params.workMode = jsonStatus?.workMode;
params.modeId = data.id;
params.modeName = data.modeName;
}
Taro.setStorageSync("FR200NursingHistory", params);
console.log("更新updateFR200NursingHistory");
@ -1889,59 +2108,7 @@ class IotCarePlanFR200 extends Component<any, any> {
}
}
/** 获取护理时间组合 */
getServiceTimeData() {
const { ActiveModeItem } = this.state;
let serviceData = ActiveModeItem.serviceData.map((item) => {
let totalWorkingMinutes = parseInt(
item.serviceStartTimeStr.split(":")[0]
); // 仅分钟数
let totalWorkingSeconds = parseInt(item.serviceEndTimeStr.split(":")[1]); // 仅秒数
// let totalWorkingMinutes = 1; // 仅分钟数
// let totalWorkingSeconds = 0; // 仅秒数
return {
totalWorkingMinutes,
totalWorkingSeconds,
};
});
return serviceData;
}
/** 设置护理时间组合 */
setServiceTimeData() {
let ServiceTimeData = this.getServiceTimeData();
// 组合时间
let ModeStepTimeArray: any = [];
ServiceTimeData.reduce((old, cur) => {
let curTime = cur.totalWorkingMinutes * 60 + cur.totalWorkingSeconds;
let newTotalWorkingMinutes = cur.totalWorkingMinutes;
let newTotalWorkingSeconds = cur.totalWorkingSeconds;
if (old) {
newTotalWorkingMinutes += old.totalWorkingMinutes;
newTotalWorkingSeconds += old.totalWorkingSeconds;
let oldTime = old.totalWorkingMinutes * 60 + old.totalWorkingSeconds;
let value = oldTime + curTime;
ModeStepTimeArray.push(value);
return {
totalWorkingMinutes: newTotalWorkingMinutes,
totalWorkingSeconds: newTotalWorkingSeconds,
};
}
ModeStepTimeArray.push(curTime);
return {
totalWorkingMinutes: newTotalWorkingMinutes,
totalWorkingSeconds: newTotalWorkingSeconds,
};
}, null);
this.setState({
ModeStepTimeArray: ModeStepTimeArray,
ModeStepIndex: 0, // 每次切换组合模式,重置组合步骤
});
console.log("组合时间ModeStepTimeArray", ModeStepTimeArray);
}
// 护理的错误提示
/** 会自动关闭的护理错误提示 */
showTips(ctx) {
if (!ctx) return;
if (showTipsTimer) clearTimeout(showTipsTimer);
@ -1954,6 +2121,19 @@ class IotCarePlanFR200 extends Component<any, any> {
});
}, 2000);
}
/** 不自动关闭的护理错误提示 */
openTips(ctx) {
if (!ctx) return;
this.setState({
errorTips: ctx,
});
}
/** 关闭护理错误提示 */
closeTips() {
this.setState({
errorTips: "",
});
}
/** 结束护理弹窗 */
onEndPlan = async () => {
@ -2129,13 +2309,24 @@ class IotCarePlanFR200 extends Component<any, any> {
// 获取并设置视频时间
GetVideosTime = (event) => {
console.log("获取并设置视频时间GetVideosTime", event?.detail?.duration);
if (event?.detail?.duration) {
let duration = Math.floor(event?.detail?.duration);
let currentTime = s_to_ms(duration);
this.setState({ currentTime });
this.setState({ currentTime, currentVideoTime: currentTime });
}
};
VideoSrcLoad = (video: string = "") => {
this.setState({
currentVideoSrc: "",
});
setTimeout(() => {
this.setState({
currentVideoSrc: video,
});
}, 10);
};
switchVideoPlay = () => {
setTimeout(() => {
let videoRef = Taro.createVideoContext("myVideo", this);
@ -2154,8 +2345,8 @@ class IotCarePlanFR200 extends Component<any, any> {
title,
isConnectShow,
GearData,
stepList,
stepIndex,
waterStepList,
waterStepIndex,
isShowStepTips,
isShowNurse,
isStopNurse,
@ -2170,7 +2361,6 @@ class IotCarePlanFR200 extends Component<any, any> {
isShowCountdown,
countdown,
Electricity,
matrixElectricity,
errorTips,
isEndCarePlan,
currentTime,
@ -2188,6 +2378,8 @@ class IotCarePlanFR200 extends Component<any, any> {
isShowHistoryMsg,
isModeLock,
TestModeStepIndex,
currentVideoSrc,
currentGear,
} = this.state;
return (
@ -2354,7 +2546,7 @@ class IotCarePlanFR200 extends Component<any, any> {
<View>
<Video
className="video-or-image"
src={ActiveModeItem.modeVideo}
src={currentVideoSrc}
loop
id="myVideo"
objectFit="cover"
@ -2376,17 +2568,19 @@ class IotCarePlanFR200 extends Component<any, any> {
)}
</View>
<View className="iot-device">
<View className="fr200-iot-device">
<View className="item">
<Text className="device-time">
<Text className="time">{currentTime}</Text>
<Text className="time">{currentTime}</Text>
</Text>
</View>
<View className="line" />
<View className="item">
<Text className="gear">{currentGear}</Text>
</View>
<View className="line" />
<ElectricityView
Electricity={Electricity}
matrixElectricity={matrixElectricity}
DeviceConnectStatus={DeviceConnectStatus}
/>
</View>
@ -2429,8 +2623,8 @@ class IotCarePlanFR200 extends Component<any, any> {
<WaterTest
isRuningTest={isRuningTest}
TestModeStepIndex={TestModeStepIndex}
stepList={stepList}
stepIndex={stepIndex}
stepList={waterStepList}
stepIndex={waterStepIndex}
></WaterTest>
)}
</View>

@ -0,0 +1,61 @@
import Taro from "@tarojs/taro";
import classnames from "classnames";
import { Block, View, Image, Text } from "@tarojs/components";
import { useState, useEffect } from "react";
// import "./index.less";
interface Props {
Electricity: any;
DeviceConnectStatus: any;
}
function Index({ Electricity, DeviceConnectStatus }: Props) {
return (
<Block>
<View className="electricity-box">
{DeviceConnectStatus === 1 && (
<Block>
<View className="item">
<View className="label"></View>
<View className="value flex aitems">
{Electricity >= 4 && (
<Block>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
</Block>
)}
{Electricity === 3 && (
<Block>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v2 battery_icon"></View>
</Block>
)}
{Electricity === 2 && (
<Block>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
</Block>
)}
{Electricity <= 1 && (
<Block>
<View className="v3 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
</Block>
)}
</View>
</View>
</Block>
)}
</View>
</Block>
);
}
export default Index;
Loading…
Cancel
Save