add:1.蓝牙断开连接错误重连弹窗。2.运行中动态切换设备模式控制逻辑

master
blak-kong 2 years ago
parent 18eaff89e6
commit 0459a45ab4

@ -34,7 +34,7 @@ import {
getTimeCode,
isNeedToUpdate,
} from "@/utils/util";
const log = require("@/utils/log");
// const log = require("@/utils/log");
import commandMap from "@/utils/commandMap";
import { bleCommandSamples } from "./test";
@ -129,7 +129,15 @@ class ConnectionBluetoot extends Component<any, any> {
async onLoad() {}
componentDidMount() {
this.connection();
// 只有非断开状态的弹窗才自动连接蓝牙
if (!this.props.isDisconnect) {
this.connection();
} else {
// 断开状态弹窗:自动设置为错误模式
this.setState({
error: true,
});
}
}
componentWillUnmount() {}
@ -993,6 +1001,15 @@ class ConnectionBluetoot extends Component<any, any> {
onReconnect = () => {
console.log("onReconnect");
// 重置信息并重连
this.setState({
error: false,
searchError: false,
errorText: "",
});
setTimeout(() => {
this.connection();
});
// this.props.confirm("confirm");
};
@ -1006,7 +1023,7 @@ class ConnectionBluetoot extends Component<any, any> {
render() {
let { name, isConnection, connectionSuccess, error } = this.state;
let { deviceInfo } = this.props;
let { deviceInfo, isDisconnect } = this.props;
return (
<Block>
<DeviceConnectPopup

@ -13,12 +13,12 @@
// }
.site-close {
position: absolute;
right: 36rpx;
top: 36rpx;
color: #fff;
right: 16rpx;
top: 16rpx;
color: #000;
font-size: 36rpx;
z-index: 100009;
background-color: #ababab;
background-color: transparent;
border-radius: 50%;
padding: 8rpx;
box-sizing: border-box;
@ -64,7 +64,7 @@
display: flex;
align-items: center;
position: relative;
width: 100%;
width: 84%;
box-sizing: border-box;
display: flex;
// column-gap: 30rpx;
@ -76,6 +76,7 @@
width: 36rpx;
min-width: 36rpx;
height: 36rpx;
margin-right: 36rpx;
image {
width: 100%;
height: 100%;

@ -178,12 +178,13 @@ export default class DeviceConnectPopup extends Component<any, any> {
</View>
</View>
<View className="common-popup-btns">
<Button className="common-popup-btn2" onClick={this.onClose}>
<Button
className="common-popup-btn"
style="background-color: #fff;color: #000"
onClick={this.onClose}
>
</Button>
<Button className="common-popup-btn2" onClick={this.onConfirm}>
</Button>
</View>
</View>
)}
@ -201,7 +202,8 @@ export default class DeviceConnectPopup extends Component<any, any> {
<View className="error-block">
<View className="tip1"></View>
<View className="tip2">
{data.bluetoothConnectFailContent}
{data.bluetoothConnectFailContent ||
"请重启设备后点击重新连接"}
</View>
</View>
</View>

@ -18,12 +18,12 @@
// }
.site-close {
position: absolute;
right: 36rpx;
top: 36rpx;
color: #fff;
right: 16rpx;
top: 16rpx;
color: #000;
font-size: 36rpx;
z-index: 100009;
background-color: #ababab;
background-color: transparent;
border-radius: 50%;
padding: 8rpx;
box-sizing: border-box;

@ -24,6 +24,7 @@ import { go } from "../../utils/traoAPI";
/** props
* isLarge
* isShow
* isFirstEntry
* data
* title
* confirmButtonText
@ -59,6 +60,9 @@ export default class PopupStepTips extends Component<any, any> {
let { isLocal } = this.state;
this.props.close({ isLocal });
};
onConfirm = () => {
this.props.close({ isLocal: true });
};
onClickStop = (e) => {
e.stopPropagation();
@ -94,8 +98,15 @@ export default class PopupStepTips extends Component<any, any> {
};
render() {
let { isShow, data, isLarge, title, content, confirmButtonText } =
this.props;
let {
isShow,
data,
isLarge,
isFirstEntry,
title,
content,
confirmButtonText,
} = this.props;
let { current, isLocal } = this.state;
return (
@ -123,7 +134,7 @@ export default class PopupStepTips extends Component<any, any> {
"margin-samll": isLarge,
})}
>
{data.length > 0 ? data[current].openTitle : "暂无数据"}
{data.length > 0 ? data[current].openTitle : "使用教程"}
</View>
{/* {title && (
<View
@ -164,9 +175,15 @@ export default class PopupStepTips extends Component<any, any> {
<View>
{data.length === 1 && (
<View className="popup-btn-one">
<Button className="popup-btn" onClick={this.onClose}>
{confirmButtonText}
</Button>
{isFirstEntry ? (
<Button className="popup-btn" onClick={this.onConfirm}>
{confirmButtonText}
</Button>
) : (
<Button className="popup-btn" onClick={this.onClose}>
{confirmButtonText}
</Button>
)}
</View>
)}
{data.length > 1 && current === 0 && (
@ -191,21 +208,23 @@ export default class PopupStepTips extends Component<any, any> {
)}
</View>
<View className="setp-footer-btn" onClick={this.onChangeLocal}>
{isLocal ? (
<Image
className="checked"
src={require("../../img/welcome/checked.png")}
></Image>
) : (
<Image
className="checked"
src={require("../../img/welcome/no-checked.png")}
></Image>
)}
<Text className="text"></Text>
</View>
{!isFirstEntry && (
<View className="setp-footer-btn" onClick={this.onChangeLocal}>
{isLocal ? (
<Image
className="checked"
src={require("../../img/welcome/checked.png")}
></Image>
) : (
<Image
className="checked"
src={require("../../img/welcome/no-checked.png")}
></Image>
)}
<Text className="text"></Text>
</View>
)}
</View>
</Popup>
</Block>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

@ -156,16 +156,14 @@ class Index extends Component<any, any> {
}
}
if (Taro.getStorageSync("skip")) {
this.setState({ showEquipment: true })
Taro.removeStorageSync('skip');
this.setState({ showEquipment: true });
Taro.removeStorageSync("skip");
}
}
componentDidMount() {
componentDidMount() {}
}
componentWillUnmount() { }
componentWillUnmount() {}
componentDidShow() {
const tabbar = Taro.getTabBar<CustomTabBar>(this.$instance.page);
@ -174,7 +172,7 @@ class Index extends Component<any, any> {
this.showInit();
}
componentDidHide() { }
componentDidHide() {}
showInit() {
// 判断是否登录
@ -224,7 +222,7 @@ class Index extends Component<any, any> {
this.isSancQrcodeEnter();
}
},
fail: () => { },
fail: () => {},
complete: () => {
// 授权完成运行页面初始化
},
@ -382,7 +380,7 @@ class Index extends Component<any, any> {
this.setState({ isShowSiteSwiper: false });
};
bannerSwiperchange() { }
bannerSwiperchange() {}
gobanner(item) {
// 跳转类型0无跳转、1跳转内部链接、3跳转外部链接、4跳转小程序、5导向视频号、6导向视频号直播间',
@ -655,27 +653,15 @@ class Index extends Component<any, any> {
// return;
}
onUnloginConfirm() {
this.setState({ showEquipment: false })
this.setState({ showEquipment: false });
}
onUnloginClose() {
this.setState({ showEquipment: false })
this.setState({ showEquipment: false });
}
//连接完成时数据的回调
offlineChange = async (e) => {
console.log("offlineChange", e);
// log.info(
// commandMap.versionInfoHome,
// `offlineChange::e::${JSON.stringify(e)}`
// );
//offlineDataList 离线数据
//versioninfo 版本号
let { offlineDataList, versionInfo } = e.detail;
this.setState({
versionInfo,
});
let offlinelist: any = [];
console.log(offlinelist);
this.pairingChange("offlineChange");
};
connectionOpen = async () => {
@ -801,20 +787,20 @@ class Index extends Component<any, any> {
<PopupAlert
isShow={isNotRegister}
isClose
title='提示'
content='暂未授权注册,请点击注册'
confirmButtonText='确定'
textAlgin='center'
type='1'
title="提示"
content="暂未授权注册,请点击注册"
confirmButtonText="确定"
textAlgin="center"
type="1"
close={this.closeAlert}
confirm={this.closeAlert}
/>
<PopupAlert
isShow={isDev}
title='提示'
content='页面正在开发中'
confirmButtonText='确定'
textAlgin='center'
title="提示"
content="页面正在开发中"
confirmButtonText="确定"
textAlgin="center"
close={this.closeDev}
confirm={this.closeDev}
/>
@ -834,25 +820,25 @@ class Index extends Component<any, any> {
/>
<PopupAlert
isShow={isBindingError}
title='提示'
title="提示"
content={
<Block>
<View></View>
<View></View>
</Block>
}
confirmButtonText='知道了'
textAlgin='center'
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
/>
<PopupAlert
isShow={isBeforeBinding}
title='提示'
content='您选择的仪器有误,请重新确认选择'
confirmButtonText='知道了'
textAlgin='center'
title="提示"
content="您选择的仪器有误,请重新确认选择"
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBeforeBindClose}
confirm={this.onBeforeBindConfirm}
@ -860,16 +846,16 @@ class Index extends Component<any, any> {
<PopupAlert
isShow={showEquipment}
title='提示'
title="提示"
content={
<Block>
<View className='mb10'></View>
<View className='mb10'>uniquie14231</View>
<View className='mb10'></View>
<View className="mb10"></View>
<View className="mb10">uniquie14231</View>
<View className="mb10"></View>
</Block>
}
confirmButtonText='知道了'
textAlgin='center'
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onUnloginClose.bind(this)}
confirm={this.onUnloginConfirm.bind(this)}
@ -883,9 +869,9 @@ class Index extends Component<any, any> {
<PopupSiteSwiper
isShow={isShowSiteSwiper}
siteData={sitePopupList}
size='middle'
confirmButtonText='确定'
textAlgin='center'
size="middle"
confirmButtonText="确定"
textAlgin="center"
close={this.closeSiteSwiper}
confirm={this.closeSiteSwiper}
/>
@ -948,29 +934,29 @@ class Index extends Component<any, any> {
leftSlot={
<Block>
<View
className='message'
className="message"
onClick={this.gourl}
data-url='/pages/message/message'
data-url="/pages/message/message"
>
<Image
className='message-img'
className="message-img"
src={require("../../img/index/message.png")}
mode='aspectFill'
mode="aspectFill"
/>
{messagecount ? <View className='tip' /> : ""}
{messagecount ? <View className="tip" /> : ""}
</View>
</Block>
}
/>
<View className='index'>
<View className='date-title' onClick={this.toNursingRecords}>
<Text className='text'></Text>
<View className="index">
<View className="date-title" onClick={this.toNursingRecords}>
<Text className="text"></Text>
<Image
src={require("../../img/index/right.png")}
style='width: 20rpx;height: 20rpx;'
style="width: 20rpx;height: 20rpx;"
/>
</View>
<View className='bg-while'>
<View className="bg-while">
<AtCalendar
hideArrow
isSwiper={false}
@ -982,41 +968,41 @@ class Index extends Component<any, any> {
/>
</View>
</View>
<View className='infobox5'>
<View className="infobox5">
{instrumentList.length > 0 && (
<Block>
<View className='nurse_plan_box flex aitems sb'>
<View className='title'></View>
<View className="nurse_plan_box flex aitems sb">
<View className="title"></View>
<View
className='txt_box flex jcenter aitems'
data-url='/pages/instrument/instrument'
className="txt_box flex jcenter aitems"
data-url="/pages/instrument/instrument"
onClick={this.gourl}
>
<Image
className='right_icon'
className="right_icon"
src={require("../../img/black-add.png")}
mode='aspectFill'
mode="aspectFill"
/>
<View className='txt'></View>
<View className="txt"></View>
</View>
</View>
<View style='overflow-x: auto;'>
<View className='device_list flex'>
<View style="overflow-x: auto;">
<View className="device_list flex">
{instrumentList.map((item, index) => {
if (item.status === 0) {
return (
<View
key={"instrumentList" + index}
className='device_item'
className="device_item"
onClick={this.goNursing.bind(this, item)}
>
<Image
className='banner_img'
className="banner_img"
src={item.banner}
mode='aspectFill'
mode="aspectFill"
/>
<View className='device_name ellipsis1'>
<View className="device_name ellipsis1">
{item.name}
</View>
</View>
@ -1029,32 +1015,32 @@ class Index extends Component<any, any> {
)}
{instrumentList.length === 0 && (
<Block>
<View className='nurse_plan_box flex aitems sb'>
<View className='title'></View>
<View className="nurse_plan_box flex aitems sb">
<View className="title"></View>
</View>
<View className='add_device flex jcenter aitems bg-while'>
<View className='add_device_btn'>
<View className='txt_box flex jcenter aitems'>
<View className="add_device flex jcenter aitems bg-while">
<View className="add_device_btn">
<View className="txt_box flex jcenter aitems">
<View
className='at-icon at-icon-add'
style='color: #fff;font-size: 30rpx;'
className="at-icon at-icon-add"
style="color: #fff;font-size: 30rpx;"
></View>
<View className='txt' onClick={this.addNewDevice}>
<View className="txt" onClick={this.addNewDevice}>
</View>
</View>
</View>
<View className='tips'></View>
<View className="tips"></View>
</View>
</Block>
)}
</View>
<View style='margin: 20px'>
<View style="margin: 20px">
<View onClick={this.goIot}></View>
</View>
<View className='infobox3'>
<View className="infobox3">
<Swiper
autoplay
onAnimationFinish={this.bannerSwiperchange.bind(this)}
@ -1066,13 +1052,13 @@ class Index extends Component<any, any> {
key={"banner_" + index}
onClick={this.gobanner.bind(this, item)}
>
<Image style='width:100%;height:100%' src={item.fileUrl} />
<Image style="width:100%;height:100%" src={item.fileUrl} />
</SwiperItem>
);
})}
</Swiper>
</View>
<View style='height:200rpx'></View>
<View style="height:200rpx"></View>
</Block>
);
}

@ -11,6 +11,7 @@ interface Props {
onEmitStartNurse: Function; // 每次点击item回调事件和数据给父组件
onEmitSwitchChange: Function;
onEmitEndPlan: Function;
onEmitErrorTips: Function; // 不可点击,提示错误
}
function Index({
isCanClick,
@ -19,6 +20,7 @@ function Index({
onEmitStartNurse,
onEmitSwitchChange,
onEmitEndPlan,
onEmitErrorTips,
}: Props) {
const onStartNurse = () => {
onEmitStartNurse();
@ -32,6 +34,10 @@ function Index({
onEmitEndPlan();
};
const onErrorTips = () => {
onEmitErrorTips();
};
return (
<Block>
<View className="footer">
@ -50,27 +56,58 @@ function Index({
)}
{isShowNurse && (
<View className="switch-btn-box">
<View className="btn-item border-right" onClick={onSwitchChange}>
{isStopNurse ? (
<Block>
<Image
className="btn-icon"
src={require("../../../../img/iot/start_nurse.png")}
mode="aspectFill"
/>
<Text className="btn-text"></Text>
</Block>
) : (
<Block>
<Image
className="btn-icon"
src={require("../../../../img/iot/pause_nurse.png")}
mode="aspectFill"
/>
<Text className="btn-text"></Text>
</Block>
)}
</View>
{isCanClick && (
<View className="btn-item border-right" onClick={onSwitchChange}>
{isStopNurse ? (
<Block>
<Image
className="btn-icon"
src={require("../../../../img/iot/start_nurse.png")}
mode="aspectFill"
/>
<Text className="btn-text"></Text>
</Block>
) : (
<Block>
<Image
className="btn-icon"
src={require("../../../../img/iot/pause_nurse.png")}
mode="aspectFill"
/>
<Text className="btn-text"></Text>
</Block>
)}
</View>
)}
{!isCanClick && (
<View className="btn-item border-right" onClick={onErrorTips}>
{isStopNurse ? (
<Block>
<Image
className="btn-icon"
style="color: #ccc"
src={require("../../../../img/iot/start_nurse.png")}
mode="aspectFill"
/>
<Text className="btn-text" style="color: #ccc">
</Text>
</Block>
) : (
<Block>
<Image
className="btn-icon"
style="color: #ccc"
src={require("../../../../img/iot/pause_nurse.png")}
mode="aspectFill"
/>
<Text className="btn-text" style="color: #ccc">
</Text>
</Block>
)}
</View>
)}
<View className="btn-item" onClick={onEndPlan}>
<Image

@ -24,6 +24,7 @@ import PopupStepTips from "@/components/popup/popup-step-tips";
import PopupConfirm from "@/components/popup/popup-confirm";
import PopupAlert from "@/components/popup/popup-alert";
import PopupStatus from "@/components/popup/popup-status";
import ConnectionBluetoot from "@/components/bluetoot/connection";
/* 公共组件 END */
/* 本页组件 */
@ -50,7 +51,14 @@ import {
deviceCommandSamples,
bleCommandSamples,
} from "@/components/bluetoot/connection/test";
import { s_to_s, s_to_m, minSecToS, s_to_ms, sleep } from "@/utils/util";
import {
s_to_s,
s_to_m,
minSecToS,
s_to_ms,
s_to_hms,
sleep,
} from "@/utils/util";
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
import commandMap from "@/utils/commandMap";
@ -147,10 +155,11 @@ class IotCarePlan extends Component<any, any> {
hadShowBreakTips: false, // 是否展示过支架断开提示
popupType: "", // enoughTimePopup: 时间达标提示, endPopup: 结束弹窗
isConnectShow: false, // 是否弹出连蓝牙弹窗:在蓝牙断开时弹出
/** 连接设备 End */
/** 护理过程 */
isCanClick: false, // 是否可以点击开始按钮
isCanClick: false, // 是否可以点击开始按钮/启动暂停
isStandStatus: false, // 当前模式是否舱体/支架模式
isShowStepTips: false, // 是否显示介绍步骤弹窗
isConnectionBlutoot: true, // 是否已连接蓝牙
@ -184,8 +193,6 @@ class IotCarePlan extends Component<any, any> {
countdown: 3,
// 是否结束护理
isEndCarePlan: false,
// 最后执行步骤位置
endPlace: "",
currentTime: "01:00",
// 护理时间不够
@ -195,10 +202,13 @@ class IotCarePlan extends Component<any, any> {
errorTipsText: "", // 护理模式切换错误提示
isShowNursingSuccess: false, // 护理成功弹窗
isShowTipsSave: false, // 切换模式时,提示是否保存部分护理记录
};
}
// 不涉及渲染的页面变量
jsonStatus: any = {}; // 同步设备返回数据,用于结束
tempModeCurrent: any = {}; // 临时保存的当前模式
elapsedTime: any = 0; // 设备已运行时间
workStatus: any = ""; // 工作状态
WL200NursingHistory: any = null; // 护理缓存历史
@ -232,6 +242,7 @@ class IotCarePlan extends Component<any, any> {
}
componentDidHide() {
console.log("Hide");
// 页面隐藏后,下次显示需要重新检查记录
this.hadCheckReport = false;
}
@ -249,9 +260,9 @@ class IotCarePlan extends Component<any, any> {
console.log("info");
// 如果不存在设备模式值,则判断为首次进入,弹窗提示
let isFirstEntry = getStorageSync("isFirstEntry_" + info.model);
let isFirstEntry = getStorageSync("isFirstEntry_" + info.id);
if (!isFirstEntry) {
// this.setState({ isShowStepTips: true });
this.setState({ isShowStepTips: true });
}
}
@ -296,18 +307,15 @@ class IotCarePlan extends Component<any, any> {
console.log("offBLECharacteristicValueChange", res);
});
clearTimeout(loadingTipsTimer);
// 断开蓝牙关闭倒计时
this.setState({
isShowCountdown: false,
});
console.log(commandMap.WL200Command, "监听到蓝牙断开, 打开断开提示");
this.workStatus = "";
// 显示蓝牙断开弹窗
// this.setState({
// workStatus: "",
// currentShowDialog: "connection_break",
// });
this.setState({
isConnectShow: true, // 打开蓝牙链接弹窗
isConnectionBlutoot: false, // 断开蓝牙
isShowCountdown: false, // 关闭倒计时,防止倒计时还在运行
});
};
GetModeList = async (id) => {
@ -362,12 +370,21 @@ class IotCarePlan extends Component<any, any> {
}
/** 选中护理模式 */
modeCurrentFun = async (data) => {
let { isStandStatus } = this.state;
modeCurrentFun = async (data, isNotCheck = false) => {
// 是否跳过护理检查
if (!isNotCheck) {
this.tempModeCurrent = data;
let isReturn = this.modeRuningChange();
if (isReturn) return;
}
let { isStandStatus, isShowNurse } = this.state;
// 舱体模式无法对应的时候,置灰开始按钮
let isCabinMode = data.isCabinMode === 1;
let isCabinMode = isStandStatus
? data.isCabinMode === 1
: data.isCabinMode === 0;
if (isStandStatus === isCabinMode) {
this.setState({ isCanClick: true });
this.setState({ isCanClick: true }); // 是否舱体一致时,可以点击
} else {
this.setState({ isCanClick: false });
}
@ -402,7 +419,46 @@ class IotCarePlan extends Component<any, any> {
this.setCustomMaskData();
}
});
// 如果是正在运行中切换,则直接准备运行
if (isShowNurse) {
this.onStartNurse();
setTimeout(() => {
this.onNursingTap();
}, 500);
}
};
/** 设备运行中切换模式 */
modeRuningChange() {
// 运行中切换模式逻辑
if (
this.workStatus === MODE_WORKING_ENUM.PAUSE ||
this.workStatus === MODE_WORKING_ENUM.WORKING
) {
const { totalWorkingMinutes, totalWorkingSeconds } = DeviceSyncData;
const totalTime = totalWorkingMinutes * 60 + totalWorkingSeconds;
let { ActiveModeItem } = this.state;
if (!ActiveModeItem || totalTime === 0) {
return false;
}
//对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准
const currentScene = ActiveModeItem; // 获取当前的场景
let sceneTime = minSecToS(currentScene.modeTimeStr); // 场景最小护理时间
if (
sceneTime <= totalTime &&
this.state.step == 2 &&
this.state.facialMaskConnectStatus == 1
) {
// 提示切换护理模式
this.hanldeChangeNurseFun();
return true;
}
}
return false;
}
/** 切换护理模式 */
switchModeCurrentFun = async (data) => {
this.setState({
@ -488,17 +544,22 @@ class IotCarePlan extends Component<any, any> {
// }
let { isStandStatus, ActiveModeItem } = this.state;
let isCabinMode = ActiveModeItem.isCabinMode === 1;
let isCabinMode = isStandStatus
? ActiveModeItem.isCabinMode === 1
: ActiveModeItem.isCabinMode === 0;
if (isStandStatus && isCabinMode) {
this.stepNext();
return;
}
this.onEmitErrorTips();
};
/** 不可切换光照提示 */
onEmitErrorTips = async () => {
let { isStandStatus, ActiveModeItem } = this.state;
if (isStandStatus) {
if (ActiveModeItem.isCabinMode === 0) {
this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体");
}
} else {
if (ActiveModeItem.isCabinMode === 1) {
} else {
this.showTips(
"检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源"
);
@ -523,7 +584,7 @@ class IotCarePlan extends Component<any, any> {
closeStepTips = (data) => {
if (data.isLocal) {
setStorageSync("isFirstEntry_" + this.state.ActiveModeItem.model, true); // 关闭首次进入弹窗
setStorageSync("isFirstEntry_" + this.state.currentDevice.id, true); // 关闭首次进入弹窗
}
this.setState({ isShowStepTips: false });
};
@ -554,6 +615,11 @@ class IotCarePlan extends Component<any, any> {
isStandStatus: true,
isCanClick: this.state.isCabinMode === 1,
});
} else {
this.setState({
isStandStatus: false,
isCanClick: this.state.isCabinMode !== 1,
});
}
break;
default:
@ -570,7 +636,9 @@ class IotCarePlan extends Component<any, any> {
console.log("支架是否链接", isStandDevice);
this.setState({
isStandStatus: isStandDevice,
isCanClick: this.state.isCabinMode === 1,
isCanClick: isStandDevice
? this.state.isCabinMode === 1
: this.state.isCabinMode !== 1,
});
// 连上面罩后, 获取仪器记录, 与缓存信息对比
@ -783,8 +851,6 @@ class IotCarePlan extends Component<any, any> {
console.log("场景时间 sceneTime", sceneTime);
console.log("当前显示时间 currentTime", currentTime);
console.log("设备运行时间 totalTime", totalTime);
console.log(" this.state.step", this.state.step);
console.log("sceneTime > totalTime", sceneTime > totalTime);
// 更新界面倒计时
this.resetTimer();
@ -802,13 +868,8 @@ class IotCarePlan extends Component<any, any> {
} else {
this.setState({
currentTime: "00:00",
endPlace: "report",
});
this.judgementWorkStatus(
MODE_WORKING_ENUM.END,
jsonStatus.workMode,
jsonStatus
);
this.judgementWorkStatus(MODE_WORKING_ENUM.END, jsonStatus.workMode);
}
},
};
@ -835,7 +896,7 @@ class IotCarePlan extends Component<any, any> {
*
* params
*/
judgementWorkStatus(nWorkStatus, nWorkMode, jsonStatus) {
judgementWorkStatus(nWorkStatus, nWorkMode) {
const { step, isStandStatus, workMode, ActiveModeItem, ModeList } =
this.state;
const opts: any = {};
@ -956,10 +1017,7 @@ class IotCarePlan extends Component<any, any> {
// 仪器自动上报完成, 直接上报并跳转报告页
clearInterval(currentTimeTimer);
const isEnough = this.checkNurseTime();
if (isEnough && !this.state.endPlace) {
this.setState({
endPlace: "report",
});
if (isEnough) {
this.saveNurseReport(true, "endnursing");
}
} else {
@ -1034,7 +1092,6 @@ class IotCarePlan extends Component<any, any> {
clearInterval(currentTimeTimer);
this.setState({
currentTime: "00:00",
endPlace: "report",
ModeStepIndex: 0,
});
this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束
@ -1168,11 +1225,9 @@ class IotCarePlan extends Component<any, any> {
this.handleWorkStatus(true, MODE_WORKING_ENUM.WORKING);
}
// 结束护理
// 结束护理
endNurseFun() {
this.handleWorkStatus(false, "end");
console.log("this.checkNurseTime()", this.checkNurseTime());
if (this.checkNurseTime()) {
this.PostNursingLogClock();
} else {
@ -1185,6 +1240,19 @@ class IotCarePlan extends Component<any, any> {
}
}
// 手动切换护理
hanldeChangeNurseFun() {
// 满足时间条件,提示是否保存部分护理记录
if (this.checkNurseTime()) {
// 打开提示保存护理弹窗
this.setState({
isShowTipsSave: true,
});
} else {
// 不满足条件,直接切换
}
}
/** 检查时间是否达标仪器最低护理时间 */
checkNurseTime() {
const { currentDevice, ActiveModeItem } = this.state;
@ -1315,12 +1383,18 @@ class IotCarePlan extends Component<any, any> {
return;
}
// 小程序时间和设备时间,谁大用谁
let timeValue =
totalSeconds > this.elapsedTime
? s_to_hms(totalSeconds)
: s_to_hms(this.elapsedTime);
let params = {
instrumentId: currentDevice.id,
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeName: ActiveModeItem.modeName,
nursingTime: s_to_ms(this.elapsedTime),
nursingTime: timeValue,
};
let res: any = await this.PostNursingLogClock(params);
console.log("res", res);
@ -1332,7 +1406,7 @@ class IotCarePlan extends Component<any, any> {
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeName: ActiveModeItem.modeName,
nursingTime: "01:00",
nursingTime: "00:01:00",
};
let res: any = await this.PostNursingLogClock(params);
console.log("res", res);
@ -1378,7 +1452,7 @@ class IotCarePlan extends Component<any, any> {
};
/** 提交护理记录 */
PostNursingLogClock = async (data: any = null) => {
PostNursingLogClock = async (data: any = null, isJump = true) => {
let { currentDevice, ActiveModeItem } = this.state;
let params = {};
@ -1390,7 +1464,7 @@ class IotCarePlan extends Component<any, any> {
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeName: ActiveModeItem.modeName,
nursingTime: s_to_ms(this.elapsedTime),
nursingTime: s_to_hms(this.elapsedTime),
};
}
@ -1398,12 +1472,17 @@ class IotCarePlan extends Component<any, any> {
console.log("PostNursingLogClock", res);
if (res.data.code === 200) {
this.setState({
isShowNursingSuccess: true,
});
setTimeout(() => {
this.goFaceReport();
}, 1000);
if (!isJump) {
this.setState({
isShowNursingSuccess: true,
});
}
if (isJump) {
setTimeout(() => {
this.goFaceReport();
}, 1000);
}
}
};
/*** 护理记录 END ***/
@ -1598,12 +1677,38 @@ class IotCarePlan extends Component<any, any> {
go("/pages/face_report/face_report?id=" + this.state.currentDevice.id);
};
// 完成配对
pairingChange = () => {
this.setState({
isConnectShow: false,
});
};
connectionClose = () => {
this.setState({
isConnectShow: false,
});
};
// 手动护理模式切换:提示是否保存护理
closeTipsSave = () => {
this.setState({
isShowTipsSave: false,
});
this.modeCurrentFun(this.tempModeCurrent, false);
};
confirmTipsSave = async () => {
this.setState({
isShowTipsSave: false,
});
this.PostNursingLogClock(null, false);
this.modeCurrentFun(this.tempModeCurrent, false);
};
render() {
let {
name,
title,
isShowUpdateVersionTip,
isShowVersionUpgrading,
isConnectShow,
isShowStepTips,
isCanClick,
isShowNurse,
@ -1618,7 +1723,6 @@ class IotCarePlan extends Component<any, any> {
activeModeID,
isShowCountdown,
countdown,
ModeStepIndex,
Electricity,
matrixElectricity,
errorTips,
@ -1629,6 +1733,9 @@ class IotCarePlan extends Component<any, any> {
errorTipsText,
isNotEnoughTime,
isShowNursingSuccess,
currentDevice,
isConnectionBlutoot,
isShowTipsSave,
} = this.state;
return (
<Block>
@ -1677,9 +1784,9 @@ class IotCarePlan extends Component<any, any> {
{ActiveModeItem.openSourceData && (
<PopupStepTips
isShow={isShowStepTips}
isLarge={true}
title={"" + "准备中"}
confirmButtonText="开始护理"
isLarge
isFirstEntry
confirmButtonText="知道了"
data={ActiveModeItem.openSourceData}
close={this.closeStepTips}
/>
@ -1709,6 +1816,25 @@ class IotCarePlan extends Component<any, any> {
confirm={this.closeErrorTipsText}
/>
<PopupAlert
isShow={isShowTipsSave}
isClose
zIndex={10020}
myClassName="level-up"
title="提示"
content={
<Block>
<View></View>
<View></View>
</Block>
}
cancelButtonText="取消"
confirmButtonText="确认"
textAlgin="center"
close={this.closeTipsSave}
confirm={this.confirmTipsSave}
/>
<PopupStatus
isShow={isShowNursingSuccess}
isClose
@ -1721,6 +1847,17 @@ class IotCarePlan extends Component<any, any> {
/*不需要做处理*/
}}
/>
{isConnectShow && (
<ConnectionBluetoot
deviceInfo={currentDevice}
close={this.connectionClose}
isDisconnect={!isConnectionBlutoot}
offlineChange={() => {}}
pairingChange={this.pairingChange}
upgradeFun={() => {}}
/>
)}
</View>
<View>
@ -1806,6 +1943,7 @@ class IotCarePlan extends Component<any, any> {
onEmitStartNurse={this.onStartNurse}
onEmitSwitchChange={this.onSwitchChange}
onEmitEndPlan={this.onEndPlan}
onEmitErrorTips={this.onEmitErrorTips}
/>
</View>
</Block>

Loading…
Cancel
Save