master
blak-kong 2 years ago
parent 0af51bc474
commit 95fd2eee48

@ -123,7 +123,7 @@ export default class PopupStepTips extends Component<any, any> {
"margin-samll": isLarge, "margin-samll": isLarge,
})} })}
> >
{data[current].openTitle} {data.length > 0 ? data[current].openTitle : "暂无数据"}
</View> </View>
{/* {title && ( {/* {title && (
<View <View

@ -624,12 +624,12 @@ class Index extends Component<any, any> {
/** /**
* WE100,WL200 * WE100,WL200
*/ */
async pairingChange(e) { pairingChange = (e) => {
console.log("===epairingChange===》", e); console.log("===epairingChange===》", e);
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转 go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
this.connectionClose(); this.connectionClose();
} };
async goIot() { async goIot() {
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转 go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转

@ -322,34 +322,6 @@ class IotCarePlan extends Component<any, any> {
} }
}; };
/** 开始护理按钮:点击开始,页面进行到下一步 */
onStartNurse = async () => {
this.stepNext();
return;
let { isConnectionBlutoot } = this.state;
if (isConnectionBlutoot) {
this.stepNext();
} else {
// todo 提示未连接蓝牙
}
};
/** 切换光照 */
onSwitchChange = async () => {
// todo
let { isStopNurse } = this.state;
if (isStopNurse) {
// 开始光照逻辑
this.showCountdownFun(3, () => {});
// this.handleWorkStatus(false, MODE_WORKING_ENUM.WORKING);
this.onNursingTap();
} else {
// 暂停光照逻辑
this.handleWorkStatus(false, MODE_WORKING_ENUM.PAUSE);
}
this.setState({
isStopNurse: !isStopNurse,
});
};
/** /**
* *
* param * param
@ -387,6 +359,13 @@ class IotCarePlan extends Component<any, any> {
activeModeID: data.id, activeModeID: data.id,
ModeID: "mode_" + data.id, ModeID: "mode_" + data.id,
}); });
setTimeout(() => {
// 存在组合模式时,设置组合模式
if (data.combineData.length > 0) {
this.setCustomMaskData();
}
});
}; };
/** 切换护理模式 */ /** 切换护理模式 */
switchModeCurrentFun = async (data) => { switchModeCurrentFun = async (data) => {
@ -421,6 +400,13 @@ class IotCarePlan extends Component<any, any> {
ActiveModeItem: SwitchActiveModeItem, ActiveModeItem: SwitchActiveModeItem,
}); });
this.cancelModeSwitchBtn(); this.cancelModeSwitchBtn();
setTimeout(() => {
// 存在组合模式时,设置组合模式
if (SwitchActiveModeItem.combineData.length > 0) {
this.setCustomMaskData();
}
});
}, 100); }, 100);
}; };
@ -439,6 +425,32 @@ class IotCarePlan extends Component<any, any> {
this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY); this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY);
}; };
/** 开始护理按钮:点击开始,页面进行到下一步 */
onStartNurse = async () => {
this.stepNext();
return;
let { isConnectionBlutoot } = this.state;
if (isConnectionBlutoot) {
this.stepNext();
} else {
// todo 提示未连接蓝牙
}
};
/** 切换光照 */
onSwitchChange = async () => {
// todo
let { isStopNurse } = this.state;
if (isStopNurse) {
// 开始光照逻辑
this.onNursingTap();
} else {
// 暂停光照逻辑
this.handleWorkStatus(false, MODE_WORKING_ENUM.PAUSE);
}
this.setState({
isStopNurse: !isStopNurse,
});
};
closeStepTips = (data) => { closeStepTips = (data) => {
if (data.isLocal) { if (data.isLocal) {
@ -462,15 +474,13 @@ class IotCarePlan extends Component<any, any> {
case "BleStatusSync": case "BleStatusSync":
switch (jsonStatus.connectMessage?.deviceName) { switch (jsonStatus.connectMessage?.deviceName) {
case "WL200": case "WL200":
console.log(
"BleStatusSync 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上",
jsonStatus.connectMessage?.connectType == "CONNECTED"
);
if (jsonStatus.connectMessage?.connectType == "CONNECTED") { if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
// 已连接WL200 // 已连接WL200
this.setState({ isConnectionBlutoot: true }); this.setState({ isConnectionBlutoot: true });
if (
!this.state.customModeData.setCustomSuc &&
!this.state.customModeData.hadSetCustom
) {
this.setCustomMaskData();
}
// 附属设备连接成功,如何区分是哪个设备? // 附属设备连接成功,如何区分是哪个设备?
this.setState({ this.setState({
@ -488,6 +498,7 @@ class IotCarePlan extends Component<any, any> {
// WL200连接失败 // WL200连接失败
// deviceToolKitInstance = deviceToolKitInstanceWE100; // deviceToolKitInstance = deviceToolKitInstanceWE100;
// // TODO 护理中(step==2)时, 如果断开, 可能需要暂停 // // TODO 护理中(step==2)时, 如果断开, 可能需要暂停
console.log("WL200连接失败或断开");
this.setState({ this.setState({
facialMaskConnectStatus: 0, facialMaskConnectStatus: 0,
}); });
@ -524,19 +535,12 @@ class IotCarePlan extends Component<any, any> {
console.log("支架是否链接", isStandDevice); console.log("支架是否链接", isStandDevice);
console.log("面罩是否链接", isConnectedMask); console.log("面罩是否链接", isConnectedMask);
if (isConnectedMask) { if (isConnectedMask) {
this.setState({ isConnectionBlutoot: true }); this.setState({
isConnectionBlutoot: true,
facialMaskConnectStatus: 1,
});
} }
// 连上面罩后, 设置自定义模式 -- 不在这里设置自定义模式
if (
this.state.ActiveModeItem &&
isConnectedMask &&
!this.state.customModeData.setCustomSuc &&
!this.state.customModeData.hadSetCustom &&
this.state.ActiveModeItem.isCustomMode
) {
this.setCustomMaskData();
}
// 连上面罩后, 获取仪器记录, 与缓存信息对比, // 连上面罩后, 获取仪器记录, 与缓存信息对比,
// if ( // if (
// isConnectedMask && // isConnectedMask &&
@ -622,12 +626,6 @@ class IotCarePlan extends Component<any, any> {
workStatus: jsonStatus.workStatus, workStatus: jsonStatus.workStatus,
workMode: jsonStatus?.workMode, workMode: jsonStatus?.workMode,
}); });
// this.setState({
// fr200Electricity: jsonStatus.battery,
// matrixElectricity: jsonStatus.matrixBattery,
// workStatus: jsonStatus.workStatus,
// workMode: jsonStatus?.workMode,
// });
// 判断是否在step == 2(护理中) // 判断是否在step == 2(护理中)
if ( if (
this.state.step == 2 && this.state.step == 2 &&
@ -668,25 +666,26 @@ class IotCarePlan extends Component<any, any> {
switch (jsonStatus.infoQueryType) { switch (jsonStatus.infoQueryType) {
// 自定义模式设置 // 自定义模式设置
case "customModeSet": case "customModeSet":
console.log(">>>>>>>>>>>>>>>自定义模式》》》》》》");
console.log( console.log(
"InfoQuery customModeSet responseStatus=====>", "InfoQuery customModeSet responseStatus=====>",
jsonStatus jsonStatus
); );
let { customModeData } = this.state; // let { customModeData } = this.state;
if (jsonStatus.responseStatus == "OK") { // if (jsonStatus.responseStatus == "OK") {
customModeData.setCustomSuc = true; // customModeData.setCustomSuc = true;
this.setState({ // this.setState({
customModeData, // customModeData,
}); // });
console.log("设置成功自定义模式"); // console.log("设置成功自定义模式");
} else { // } else {
customModeData.hadSetCustom = false; // customModeData.hadSetCustom = false;
customModeData.setCustomSuc = false; // customModeData.setCustomSuc = false;
this.setState({ // this.setState({
customModeData, // customModeData,
}); // });
} // }
break; break;
// 自定义模式信息 // 自定义模式信息
case "customModeInfo": case "customModeInfo":
@ -712,7 +711,7 @@ class IotCarePlan extends Component<any, any> {
break; break;
// 当前报告 // 当前报告
case "currentMaskReportInfo": case "currentMaskReportInfo":
console.log("currentMaskReportInfo", jsonStatus); console.log("当前面罩报告 currentMaskReportInfo", jsonStatus);
// if (!this.state.hadCheckReport) { // if (!this.state.hadCheckReport) {
// this.state.hadCheckReport = true; // this.state.hadCheckReport = true;
// that.checkInstrumentRecord(jsonStatus); // that.checkInstrumentRecord(jsonStatus);
@ -805,21 +804,6 @@ class IotCarePlan extends Component<any, any> {
} }
}; };
// 发送启动组合模式指令
startCombinationMode() {
const jsonCommand = {
commandType: "DeviceControl",
workStatus: "working",
workMode: "MaskCustom",
};
let commandBuffer = deviceToolKitInstance.toBleCommand(jsonCommand as any);
sendCommand({
value: commandBuffer,
}).then(() => {
console.info("发送启动组合模式指令成功 参数为 =>", jsonCommand);
});
}
//待完善,以后同步设备数据到小程序的事件,在这个事件里判断是否需要更新页面(是否需要触发setData) //待完善,以后同步设备数据到小程序的事件,在这个事件里判断是否需要更新页面(是否需要触发setData)
updateDeviceSyncData = (newData, jsonStatus) => { updateDeviceSyncData = (newData, jsonStatus) => {
DeviceSyncData = { DeviceSyncData = {
@ -948,13 +932,6 @@ class IotCarePlan extends Component<any, any> {
// fix: 启动非支架模式倒计时时连上支架仪器的状态变为standby // fix: 启动非支架模式倒计时时连上支架仪器的状态变为standby
opts.step = 1; opts.step = 1;
} }
// if (loadingTipsTimer) {
// clearTimeout(loadingTipsTimer);
// }
// 本来用于更新时间的,但是产生了 ID1000367 bug先移除
// if (nowModeItem) {
// opts.currentTime = nowModeItem.time;
// }
}, },
setting: () => { setting: () => {
// that.data.hadShowBreakTips = false; // that.data.hadShowBreakTips = false;
@ -1078,36 +1055,6 @@ class IotCarePlan extends Component<any, any> {
} }
}; };
// 设置自定义模式数据
setCustomModeData() {
// const { ActiveModeItem, currentTime } = this.state;
// const modeItem = ActiveModeItem;
// const group = modeItem.group;
// if (group.length == 1) return; // 只有1项不用管
// let inTimeScopeIndex = -1; // 选择的index
// group.forEach((item, index) => {
// let startMinute = item.scope[0];
// let endMinute = item.scope[1];
// let targetMinute = currentTime.split(":")[0];
// let targetSecond = currentTime.split(":")[1];
// const isInTime = this.isInTimeScope(
// startMinute,
// endMinute,
// targetMinute,
// targetSecond
// );
// if (isInTime) inTimeScopeIndex = index;
// });
// if (modeItem.timeScopeIndex !== inTimeScopeIndex) {
// // this.setState({
// // [`basicModeList[${modelActiveIndex}].timeScopeIndex`]: inTimeScopeIndex,
// // [`basicModeList[${modelActiveIndex}].desc`]: group[inTimeScopeIndex].desc,
// // [`basicModeList[${modelActiveIndex}].technique`]: group[inTimeScopeIndex].technique,
// // [`basicModeList[${modelActiveIndex}].pause_img`]: group[inTimeScopeIndex].pause_img,
// // [`basicModeList[${modelActiveIndex}].running_img`]: group[inTimeScopeIndex].running_img,
// // })
// }
}
isInTimeScope(start, end, targetMinute, targetSecond) { isInTimeScope(start, end, targetMinute, targetSecond) {
const startTime = dayjs().set("minute", start).set("second", 0); const startTime = dayjs().set("minute", start).set("second", 0);
const endTime = dayjs().set("minute", end).set("second", 0); const endTime = dayjs().set("minute", end).set("second", 0);
@ -1171,13 +1118,23 @@ class IotCarePlan extends Component<any, any> {
} }
// 非舱体模式 // 非舱体模式
if (!ActiveModeItem.isCabinMode && facialMaskConnectStatus != 1) { if (!ActiveModeItem.isCabinMode && facialMaskConnectStatus != 1) {
console.log("facialMaskConnectStatus", facialMaskConnectStatus);
this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴"); this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴");
return; return;
} }
} }
// // 工作状态,开始组合模式
// if (
// this.state.ActiveModeItem.combineData.length &&
// this.state.workStatus == MODE_WORKING_ENUM.WORKING
// ) {
// this.startCombinationMode();
// }
const sendParams = { const sendParams = {
...deviceCommandSamples.pause, ...deviceCommandSamples.pause,
workMode: WORK_MODE_Chinese_NAME[ActiveModeItem.modeName], // 使用模式 workMode: ActiveModeItem.modeType, // 使用模式
workStatus: newWorkStatus, workStatus: newWorkStatus,
}; };
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand( const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
@ -1229,7 +1186,7 @@ class IotCarePlan extends Component<any, any> {
console.info( console.info(
commandMap.WL200Command, commandMap.WL200Command,
"点击开始护理按钮", "点击开始护理按钮",
`当前模式: ${ActiveModeItem}`, `当前模式: ${ActiveModeItem.modeType}`,
`当前面罩状态:${facialMaskConnectStatus}`, `当前面罩状态:${facialMaskConnectStatus}`,
`当前仪器模式:${workStatus}` `当前仪器模式:${workStatus}`
); );
@ -1242,17 +1199,18 @@ class IotCarePlan extends Component<any, any> {
); );
if (facialMaskConnectStatus != 1) { if (facialMaskConnectStatus != 1) {
console.log("facialMaskConnectStatus 开始处", facialMaskConnectStatus);
this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴"); this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴");
return; return;
} }
if ( // if (
workStatus !== MODE_WORKING_ENUM.WORKING && // workStatus !== MODE_WORKING_ENUM.WORKING &&
workStatus !== MODE_WORKING_ENUM.STANDBY && // workStatus !== MODE_WORKING_ENUM.STANDBY &&
workStatus !== MODE_WORKING_ENUM.PAUSE // workStatus !== MODE_WORKING_ENUM.PAUSE
) { // ) {
this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴"); // this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴");
return; // return;
} // }
// 如果是强效舒缓,需要判断是否连接支架 // 如果是强效舒缓,需要判断是否连接支架
if (modelActiveItem.isStandMode && !isStandStatus) { if (modelActiveItem.isStandMode && !isStandStatus) {
this.showTips( this.showTips(
@ -1263,12 +1221,13 @@ class IotCarePlan extends Component<any, any> {
this.showTips(`检测到面罩仍和舱体连接中,请分离后切换`); this.showTips(`检测到面罩仍和舱体连接中,请分离后切换`);
return; return;
} }
if (modelActiveItem.isCustomMode && !customModeData.setCustomSuc) { // if (!customModeData.setCustomSuc) {
this.showTips(`${modelActiveItem.modeName}模式设置失败,请联系小助手`); // this.showTips(`${modelActiveItem.modeName}模式设置失败,请联系小助手`);
return; // return;
} // }
// 开始执行护理 // 开始执行护理
this.handleWorkStatus(false, MODE_WORKING_ENUM.WORKING); this.handleWorkStatus(true, MODE_WORKING_ENUM.WORKING);
this.showCountdownFun(3, () => {}); // 倒计时弹窗
} }
// 结束护理? // 结束护理?
@ -1347,35 +1306,49 @@ class IotCarePlan extends Component<any, any> {
console.log("================"); console.log("================");
console.log("setCustomMaskData"); console.log("setCustomMaskData");
console.log("================"); console.log("================");
const { customModeData, ActiveModeItem } = this.state; const { ModeList, ActiveModeItem } = this.state;
const customItem = ActiveModeItem;
if (!customItem.isCustomMode) { // 发送组合模式指令到设备存储
let { customModeData } = this.state; const combineData = ActiveModeItem.combineData.map((item) => item.modeId);
customModeData.hadSetCustom = false; let modesArray = ModeList.filter((item) =>
customModeData.setCustomSuc = false; combineData.includes(item.id)
this.setState({ ).map((item) => {
customModeData, return {
workMode: item.modeType,
totalWorkingMinutes: s_to_m(item.modeTimeStr),
totalWorkingSeconds: s_to_s(item.modeTimeStr),
};
}); });
return; console.log("》》》》》》");
} console.log("组合模式modesArray", modesArray);
if (
!customModeData.setCustomSuc && let customModeSetCommand = {
customItem && commandType: "InfoQuery",
!customModeData.hadSetCustom infoQueryType: "customModeSet",
) { modesArray,
this.state.customModeData.hadSetCustom = true; };
// 设置组 let commandBuffer = deviceToolKitInstance.toBleCommand(
let customModeSetCommand = customItem.customModeSetCommand; customModeSetCommand as any
console.log("自定义模式:", customModeSetCommand); );
// log.info('自定义模式:', customModeSetCommand);
let commandBuffer =
deviceToolKitInstanceWL200.toBleCommand(customModeSetCommand);
sendCommand({ sendCommand({
value: commandBuffer, value: commandBuffer,
}).then((res) => { }).then((res) => {
console.info("发送切换组合模式指令成功", res); console.info("发送切换组合模式指令成功", res);
}); });
} }
// 发送启动组合模式指令
startCombinationMode() {
const jsonCommand = {
commandType: "DeviceControl",
workStatus: "working",
workMode: "MaskCustom",
};
let commandBuffer = deviceToolKitInstance.toBleCommand(jsonCommand as any);
sendCommand({
value: commandBuffer,
}).then(() => {
console.info("发送启动组合模式指令成功 参数为 =>", jsonCommand);
});
} }
// 护理的错误提示 // 护理的错误提示

Loading…
Cancel
Save