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,
})}
>
{data[current].openTitle}
{data.length > 0 ? data[current].openTitle : "暂无数据"}
</View>
{/* {title && (
<View

@ -624,12 +624,12 @@ class Index extends Component<any, any> {
/**
* WE100,WL200
*/
async pairingChange(e) {
pairingChange = (e) => {
console.log("===epairingChange===》", e);
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
this.connectionClose();
}
};
async goIot() {
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
@ -387,6 +359,13 @@ class IotCarePlan extends Component<any, any> {
activeModeID: data.id,
ModeID: "mode_" + data.id,
});
setTimeout(() => {
// 存在组合模式时,设置组合模式
if (data.combineData.length > 0) {
this.setCustomMaskData();
}
});
};
/** 切换护理模式 */
switchModeCurrentFun = async (data) => {
@ -421,6 +400,13 @@ class IotCarePlan extends Component<any, any> {
ActiveModeItem: SwitchActiveModeItem,
});
this.cancelModeSwitchBtn();
setTimeout(() => {
// 存在组合模式时,设置组合模式
if (SwitchActiveModeItem.combineData.length > 0) {
this.setCustomMaskData();
}
});
}, 100);
};
@ -439,6 +425,32 @@ class IotCarePlan extends Component<any, any> {
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) => {
if (data.isLocal) {
@ -462,15 +474,13 @@ class IotCarePlan extends Component<any, any> {
case "BleStatusSync":
switch (jsonStatus.connectMessage?.deviceName) {
case "WL200":
console.log(
"BleStatusSync 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上",
jsonStatus.connectMessage?.connectType == "CONNECTED"
);
if (jsonStatus.connectMessage?.connectType == "CONNECTED") {
// 已连接WL200
this.setState({ isConnectionBlutoot: true });
if (
!this.state.customModeData.setCustomSuc &&
!this.state.customModeData.hadSetCustom
) {
this.setCustomMaskData();
}
// 附属设备连接成功,如何区分是哪个设备?
this.setState({
@ -488,6 +498,7 @@ class IotCarePlan extends Component<any, any> {
// WL200连接失败
// deviceToolKitInstance = deviceToolKitInstanceWE100;
// // TODO 护理中(step==2)时, 如果断开, 可能需要暂停
console.log("WL200连接失败或断开");
this.setState({
facialMaskConnectStatus: 0,
});
@ -524,19 +535,12 @@ class IotCarePlan extends Component<any, any> {
console.log("支架是否链接", isStandDevice);
console.log("面罩是否链接", 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 (
// isConnectedMask &&
@ -622,12 +626,6 @@ class IotCarePlan extends Component<any, any> {
workStatus: jsonStatus.workStatus,
workMode: jsonStatus?.workMode,
});
// this.setState({
// fr200Electricity: jsonStatus.battery,
// matrixElectricity: jsonStatus.matrixBattery,
// workStatus: jsonStatus.workStatus,
// workMode: jsonStatus?.workMode,
// });
// 判断是否在step == 2(护理中)
if (
this.state.step == 2 &&
@ -668,25 +666,26 @@ class IotCarePlan extends Component<any, any> {
switch (jsonStatus.infoQueryType) {
// 自定义模式设置
case "customModeSet":
console.log(">>>>>>>>>>>>>>>自定义模式》》》》》》");
console.log(
"InfoQuery customModeSet responseStatus=====>",
jsonStatus
);
let { customModeData } = this.state;
// 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") {
// customModeData.setCustomSuc = true;
// this.setState({
// customModeData,
// });
// console.log("设置成功自定义模式");
// } else {
// customModeData.hadSetCustom = false;
// customModeData.setCustomSuc = false;
// this.setState({
// customModeData,
// });
// }
break;
// 自定义模式信息
case "customModeInfo":
@ -712,7 +711,7 @@ class IotCarePlan extends Component<any, any> {
break;
// 当前报告
case "currentMaskReportInfo":
console.log("currentMaskReportInfo", jsonStatus);
console.log("当前面罩报告 currentMaskReportInfo", jsonStatus);
// if (!this.state.hadCheckReport) {
// this.state.hadCheckReport = true;
// 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)
updateDeviceSyncData = (newData, jsonStatus) => {
DeviceSyncData = {
@ -948,13 +932,6 @@ class IotCarePlan extends Component<any, any> {
// fix: 启动非支架模式倒计时时连上支架仪器的状态变为standby
opts.step = 1;
}
// if (loadingTipsTimer) {
// clearTimeout(loadingTipsTimer);
// }
// 本来用于更新时间的,但是产生了 ID1000367 bug先移除
// if (nowModeItem) {
// opts.currentTime = nowModeItem.time;
// }
},
setting: () => {
// 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) {
const startTime = dayjs().set("minute", start).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) {
console.log("facialMaskConnectStatus", facialMaskConnectStatus);
this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴");
return;
}
}
// // 工作状态,开始组合模式
// if (
// this.state.ActiveModeItem.combineData.length &&
// this.state.workStatus == MODE_WORKING_ENUM.WORKING
// ) {
// this.startCombinationMode();
// }
const sendParams = {
...deviceCommandSamples.pause,
workMode: WORK_MODE_Chinese_NAME[ActiveModeItem.modeName], // 使用模式
workMode: ActiveModeItem.modeType, // 使用模式
workStatus: newWorkStatus,
};
const pauseArrayBuffer = deviceToolKitInstance.toBleCommand(
@ -1229,7 +1186,7 @@ class IotCarePlan extends Component<any, any> {
console.info(
commandMap.WL200Command,
"点击开始护理按钮",
`当前模式: ${ActiveModeItem}`,
`当前模式: ${ActiveModeItem.modeType}`,
`当前面罩状态:${facialMaskConnectStatus}`,
`当前仪器模式:${workStatus}`
);
@ -1242,17 +1199,18 @@ class IotCarePlan extends Component<any, any> {
);
if (facialMaskConnectStatus != 1) {
console.log("facialMaskConnectStatus 开始处", facialMaskConnectStatus);
this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴");
return;
}
if (
workStatus !== MODE_WORKING_ENUM.WORKING &&
workStatus !== MODE_WORKING_ENUM.STANDBY &&
workStatus !== MODE_WORKING_ENUM.PAUSE
) {
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(
@ -1263,12 +1221,13 @@ class IotCarePlan extends Component<any, any> {
this.showTips(`检测到面罩仍和舱体连接中,请分离后切换`);
return;
}
if (modelActiveItem.isCustomMode && !customModeData.setCustomSuc) {
this.showTips(`${modelActiveItem.modeName}模式设置失败,请联系小助手`);
return;
}
// if (!customModeData.setCustomSuc) {
// this.showTips(`${modelActiveItem.modeName}模式设置失败,请联系小助手`);
// 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("setCustomMaskData");
console.log("================");
const { customModeData, ActiveModeItem } = this.state;
const customItem = ActiveModeItem;
if (!customItem.isCustomMode) {
let { customModeData } = this.state;
customModeData.hadSetCustom = false;
customModeData.setCustomSuc = false;
this.setState({
customModeData,
const { ModeList, ActiveModeItem } = this.state;
// 发送组合模式指令到设备存储
const combineData = ActiveModeItem.combineData.map((item) => item.modeId);
let modesArray = ModeList.filter((item) =>
combineData.includes(item.id)
).map((item) => {
return {
workMode: item.modeType,
totalWorkingMinutes: s_to_m(item.modeTimeStr),
totalWorkingSeconds: s_to_s(item.modeTimeStr),
};
});
return;
}
if (
!customModeData.setCustomSuc &&
customItem &&
!customModeData.hadSetCustom
) {
this.state.customModeData.hadSetCustom = true;
// 设置组
let customModeSetCommand = customItem.customModeSetCommand;
console.log("自定义模式:", customModeSetCommand);
// log.info('自定义模式:', customModeSetCommand);
let commandBuffer =
deviceToolKitInstanceWL200.toBleCommand(customModeSetCommand);
console.log("》》》》》》");
console.log("组合模式modesArray", modesArray);
let customModeSetCommand = {
commandType: "InfoQuery",
infoQueryType: "customModeSet",
modesArray,
};
let commandBuffer = deviceToolKitInstance.toBleCommand(
customModeSetCommand as any
);
sendCommand({
value: commandBuffer,
}).then((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