仪器时间步骤切换

master
blak-kong 2 years ago
parent 95fd2eee48
commit 6b44f79caf

@ -343,10 +343,9 @@ export default class Instrument extends Component<any, any> {
});
Taro.hideLoading();
if (res.data.code === 200) {
// this.setState({ isVisibleBinding: false });
this.binding();
} else if (res.data.code === 204) {
this.setState({ isBindingCheckError: false });
this.setState({ isBindingCheckError: true });
} else {
this.setState({ isBindingError: true });
}

@ -170,11 +170,6 @@ class IotCarePlan extends Component<any, any> {
duration: 0, // 视频总时长
hadShowBreakTips: false, // 是否展示过支架断开提示
popupType: "", // enoughTimePopup: 时间达标提示, endPopup: 结束弹窗
customModeData: {
hadCustom: false,
hadSetCustom: false, // 是否设置过 -- 代码逻辑使用
setCustomSuc: false, // 是否设置成功 -- 页面需要用于判断
}, // 自定义模式判断
/** 连接设备 End */
@ -192,9 +187,17 @@ class IotCarePlan extends Component<any, any> {
modeClass: "", // 1面罩 2舱体 3医美
ActiveModeItem: {}, // 当前选中模式
SwitchActiveModeItem: {}, // 切换选中模式
ModeID: "mode_",
activeModeID: "",
ModeID: "mode_", // 模式KEY
activeModeID: "", // 当前选中模式ID:用于高亮
ModeStepIndex: 0, // 当前护理功效步骤:每个步骤时间不定,所以时间另外计算,根据步骤显示
ModeStepTimeArray: [], // 护理功效时间步骤用于切换显示GIF
currentServiceData: {
// 当前展示的开启暂停GIF: 因为时间判断不方便,所以单独领出来
startSource: "",
stopSource: "",
},
// 模式组合
isCombineSuccess: false, // 组合模式是否设置成功
// 倒计时
isShowCountdown: false, // 倒计时弹窗
@ -313,9 +316,7 @@ class IotCarePlan extends Component<any, any> {
ModeList: res.data.data,
});
setTimeout(() => {
console.log("ActiveModeItem", this.state.ActiveModeItem);
});
this.modeCurrentFun(res.data.data[0]);
} else {
this.setState({ ModeList: res.data.data });
}
@ -354,13 +355,29 @@ class IotCarePlan extends Component<any, any> {
/** 选中护理模式 */
modeCurrentFun = async (data) => {
let currentServiceData = {
startSource: "",
stopSource: "",
};
if (data.serviceData.length) {
currentServiceData = data.serviceData[0];
}
let currentTime = data.modeTimeStr;
this.setState({
ActiveModeItem: data,
activeModeID: data.id,
ModeID: "mode_" + data.id,
currentServiceData,
ModeStepIndex: 0,
currentTime,
});
setTimeout(() => {
// 设置时间组合
if (data.serviceData.length > 0) {
this.setServiceTimeData();
}
// 存在组合模式时,设置组合模式
if (data.combineData.length > 0) {
this.setCustomMaskData();
@ -396,17 +413,8 @@ class IotCarePlan extends Component<any, any> {
ModeType: modeArray[SwitchActiveModeItem.modeClass],
});
setTimeout(() => {
this.setState({
ActiveModeItem: SwitchActiveModeItem,
});
this.modeCurrentFun(SwitchActiveModeItem);
this.cancelModeSwitchBtn();
setTimeout(() => {
// 存在组合模式时,设置组合模式
if (SwitchActiveModeItem.combineData.length > 0) {
this.setCustomMaskData();
}
});
}, 100);
};
@ -601,17 +609,9 @@ class IotCarePlan extends Component<any, any> {
case "DeviceControl":
console.log("小程序控制设备,给设备发送指令", jsonStatus);
// if (
// jsonStatus.responseStatus == "OK" &&
// this.state.isSendModeCombination
// ) {
// // 发送启动指令
// this.startCombinationMode();
// setTimeout(() => {
// console.log("currentTime", this.state.currentTime);
// });
// }
break;
//设备主动上报给小程序的指令 一般是工作状态改变
case "DeviceStatusSync":
@ -653,39 +653,24 @@ class IotCarePlan extends Component<any, any> {
});
}
}
// 根据工作状态:执行逻辑
// if (jsonStatus.workMode && this.state.step == 2) {
// // this.judgementModel(jsonStatus.workMode);
// // that.data.startSettingCountDown = false;
// }
break;
//设备信息查询返回
case "InfoQuery":
switch (jsonStatus.infoQueryType) {
// 自定义模式设置
case "customModeSet":
console.log(">>>>>>>>>>>>>>>自定义模式》》》》》》");
console.log(">>>>>>>>>>>>>>>自定义模式>>>>>>>>>>>>>>>");
console.log(
"InfoQuery customModeSet responseStatus=====>",
jsonStatus
);
// let { customModeData } = this.state;
// if (jsonStatus.responseStatus == "OK") {
// customModeData.setCustomSuc = true;
// this.setState({
// customModeData,
// });
// console.log("设置成功自定义模式");
// } else {
// customModeData.hadSetCustom = false;
// customModeData.setCustomSuc = false;
// this.setState({
// customModeData,
// });
// }
if (jsonStatus.responseStatus == "OK") {
console.log("设置成功自定义模式");
this.setState({
isCombineSuccess: true,
});
}
break;
// 自定义模式信息
case "customModeInfo":
@ -693,6 +678,7 @@ class IotCarePlan extends Component<any, any> {
"InfoQuery customModeInfo responseStatus=====>",
jsonStatus
);
break;
case "versionInfo":
console.log(
@ -834,24 +820,8 @@ class IotCarePlan extends Component<any, any> {
console.log("sceneTime > totalTime", sceneTime > totalTime);
// 更新界面倒计时
// clearInterval(currentTimeTimer);
// currentTimeTimer = setInterval(() => {
// let currentSeconds = minSecToS(this.state.currentTime);
// if (currentSeconds > 1) {
// this.setState({
// currentTime: s_to_ms(--currentSeconds),
// });
// }
// }, 1000);
this.resetTimer();
console.log(
"sceneTime > totalTime &&this.state.step == 2 &&this.state.facialMaskConnectStatus == 1",
sceneTime > totalTime &&
this.state.step == 2 &&
this.state.facialMaskConnectStatus == 1
);
if (
sceneTime > totalTime &&
this.state.step == 2 &&
@ -998,26 +968,13 @@ class IotCarePlan extends Component<any, any> {
end: () => {
// 仪器返回护理结束, 支架模式不需要了
// if (modeItem.isStandMode) {
// that.onPauseTap();
// this.onPauseTap();
// }
// 已进入了报告阶段, 防止重复进入, 主要防止在手动点击结束护理接收到仪器消息
console.log("END 护理结束");
clearInterval(currentTimeTimer);
this.endnursing(true);
// if (this.state.endPlace) return;
// 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下
// const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus;
// if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) {
// const sceneTime = minSecToS(ActiveModeItem.modeTimeStr); // 模式的总时长
// const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长
// const timeRemaining = sceneTime - runTime; // 剩余未运行时间
// this.setState({
// currentTime: s_to_ms(timeRemaining),
// });
// }
// this.rmWL200NursingHistory(this.state.WL200NursingHistory);
},
};
statusF[nWorkStatus] && statusF[nWorkStatus]();
@ -1077,21 +1034,68 @@ class IotCarePlan extends Component<any, any> {
// 切换模式后, 需要重新设置计时器, 以防进行中的计时器
currentTimeTimer && clearInterval(currentTimeTimer);
currentTimeTimer = setInterval(() => {
let {
workStatus,
step,
facialMaskConnectStatus,
currentTime,
ModeStepTimeArray,
ModeStepIndex,
ActiveModeItem,
} = this.state;
if (
this.state.workStatus == MODE_WORKING_ENUM.WORKING &&
this.state.step == 2 &&
this.state.facialMaskConnectStatus == 1
workStatus == MODE_WORKING_ENUM.WORKING &&
step == 2 &&
facialMaskConnectStatus == 1
) {
let currentSeconds = minSecToS(this.state.currentTime);
if (currentSeconds > 1) {
let totalSeconds = minSecToS(ActiveModeItem.modeTimeStr);
let currentSeconds = minSecToS(currentTime);
let checkTime = totalSeconds - currentSeconds;
console.log("设备已运行多少秒", checkTime);
console.log("ModeStepTimeArray", ModeStepTimeArray);
if (currentSeconds >= 1) {
this.setState({
currentTime: s_to_ms(--currentSeconds),
});
let length = ModeStepTimeArray.length;
if (length) {
// 模式多个步骤节点切换
// 已运行时间达到下一节点时,切换
if (checkTime > ModeStepTimeArray[ModeStepIndex]) {
// 已运行时间达到下一节点,步骤切换时更新
if (ModeStepIndex < length) {
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,
currentServiceData,
});
}
}
}
} else {
clearInterval(currentTimeTimer);
this.setState({
currentTime: "00:00",
endPlace: "report",
ModeStepIndex: 0,
});
this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束
}
@ -1135,6 +1139,7 @@ class IotCarePlan extends Component<any, any> {
const sendParams = {
...deviceCommandSamples.pause,
workMode: ActiveModeItem.modeType, // 使用模式
// workMode: "MaskCustom",
workStatus: newWorkStatus,
};
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
@ -1203,14 +1208,6 @@ class IotCarePlan extends Component<any, any> {
this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴");
return;
}
// if (
// workStatus !== MODE_WORKING_ENUM.WORKING &&
// workStatus !== MODE_WORKING_ENUM.STANDBY &&
// workStatus !== MODE_WORKING_ENUM.PAUSE
// ) {
// this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴");
// return;
// }
// 如果是强效舒缓,需要判断是否连接支架
if (modelActiveItem.isStandMode && !isStandStatus) {
this.showTips(
@ -1221,10 +1218,13 @@ class IotCarePlan extends Component<any, any> {
this.showTips(`检测到面罩仍和舱体连接中,请分离后切换`);
return;
}
// if (!customModeData.setCustomSuc) {
// this.showTips(`${modelActiveItem.modeName}模式设置失败,请联系小助手`);
// return;
// }
if (
ActiveModeItem.modeType === "MaskCustom" &&
!this.state.isCombineSuccess
) {
this.showTips(`${modelActiveItem.modeName}模式设置失败,请联系小助手`);
return;
}
// 开始执行护理
this.handleWorkStatus(true, MODE_WORKING_ENUM.WORKING);
this.showCountdownFun(3, () => {}); // 倒计时弹窗
@ -1280,14 +1280,7 @@ class IotCarePlan extends Component<any, any> {
}
// 删除WL200护理历史
rmWL200NursingHistory(WL200NursingHistory, hard = false) {
// const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory");
// if (nowWL200NursingHistory.id == WL200NursingHistory.id) {
// Taro.removeStorageSync("WL200NursingHistory");
// } else if (hard) {
// Taro.removeStorageSync("WL200NursingHistory");
// }
}
rmWL200NursingHistory(WL200NursingHistory, hard = false) {}
//蓝牙断开连接处理
bluetoothDisconnectProcessing() {
@ -1301,25 +1294,98 @@ class IotCarePlan extends Component<any, any> {
}
}
// 获取护理时间组合
getServiceTimeData() {
const { ActiveModeItem } = this.state;
let serviceData = ActiveModeItem.serviceData.map((item) => {
// let totalWorkingMinutes = parseInt(item.modeTimeStr.split(":")[0]); // 仅分钟数
// let totalWorkingSeconds = parseInt(item.modeTimeStr.split(":")[1]); // 仅秒数
let totalWorkingMinutes = 1; // 仅分钟数
let totalWorkingSeconds = 0; // 仅秒数
return {
totalWorkingMinutes,
totalWorkingSeconds,
};
});
console.log(
"组合时间ServiceTimeData",
serviceData,
ActiveModeItem.serviceData
);
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;
console.log("value", value);
ModeStepTimeArray.push(value);
return {
totalWorkingMinutes: newTotalWorkingMinutes,
totalWorkingSeconds: newTotalWorkingSeconds,
};
}
console.log("curTime", curTime);
ModeStepTimeArray.push(curTime);
return {
totalWorkingMinutes: newTotalWorkingMinutes,
totalWorkingSeconds: newTotalWorkingSeconds,
};
}, null);
this.setState({
ModeStepTimeArray: ModeStepTimeArray,
ModeStepIndex: 0, // 每次切换组合模式,重置组合步骤
});
console.log("组合时间ModeStepTimeArray", ModeStepTimeArray);
}
/* 组合模式 */
setCustomMaskData() {
console.log("================");
console.log("setCustomMaskData");
console.log("================");
// 获取自定义组合模式原数组
getOriginModesArray = () => {
const { ModeList, ActiveModeItem } = this.state;
// 发送组合模式指令到设备存储
const combineData = ActiveModeItem.combineData.map((item) => item.modeId);
const combineIds = ActiveModeItem.combineData.map(
(item) => item.combineModeId
);
let modesArray = ModeList.filter((item) => combineIds.includes(item.id));
return modesArray;
};
// 获取自定义组合模式数组
getCustomModesArray = () => {
const { ModeList, ActiveModeItem } = this.state;
const combineIds = ActiveModeItem.combineData.map(
(item) => item.combineModeId
);
let modesArray = ModeList.filter((item) =>
combineData.includes(item.id)
combineIds.includes(item.id)
).map((item) => {
let totalWorkingMinutes = parseInt(item.modeTimeStr.split(":")[0]); // 仅分钟数
let totalWorkingSeconds = parseInt(item.modeTimeStr.split(":")[1]); // 仅秒数
return {
workMode: item.modeType,
totalWorkingMinutes: s_to_m(item.modeTimeStr),
totalWorkingSeconds: s_to_s(item.modeTimeStr),
totalWorkingMinutes,
totalWorkingSeconds,
};
});
console.log("》》》》》》");
return modesArray;
};
setCustomMaskData() {
console.log("================");
console.log("setCustomMaskData");
console.log("================");
// modesArray 发送组合模式数组指令到设备存储
let modesArray = this.getCustomModesArray();
console.log("组合模式modesArray", modesArray);
let customModeSetCommand = {
@ -1403,11 +1469,12 @@ class IotCarePlan extends Component<any, any> {
name,
title,
isShowStepTips,
ModeList,
ModeType,
isConnectionBlutoot,
isShowNurse,
isStopNurse,
ModeList,
ModeType,
currentServiceData,
ActiveModeItem,
SwitchActiveModeItem,
isSwitchActiveMode,
@ -1494,16 +1561,12 @@ class IotCarePlan extends Component<any, any> {
{isStopNurse ? (
<Image
className="video-or-image"
src={
ActiveModeItem.serviceData[ModeStepIndex].stopSource
}
src={currentServiceData.stopSource}
/>
) : (
<Image
className="video-or-image"
src={
ActiveModeItem.serviceData[ModeStepIndex].startSource
}
src={currentServiceData.startSource}
/>
)}
</Block>

@ -59,14 +59,14 @@ export const Ajax = (params) => {
return;
}
if (res.statusCode !== 200) {
Taro.showModal({
title: "提示",
content: String("错误码:" + res.statusCode),
showCancel: false,
});
return false;
}
// if (res.statusCode !== 200) {
// Taro.showModal({
// title: "提示",
// content: String("错误码:" + res.statusCode),
// showCancel: false,
// });
// return false;
// }
if (res.data.code === 500) {
let msg = "系统异常,请联系管理人员";

Loading…
Cancel
Save