diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 62e23ee..9602450 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -138,6 +138,9 @@ class Index extends Component { isShowVersionUpgrading: false, // 升级中 isShowVersionUpgradFinish: false, // 升级完成:升级内容公告 versionUpgradFinishNodes: "", // 公告内容 + + // 设备是否重连弹窗 + isShowReConnectDeviceRecordWL200: false, }; } @@ -588,7 +591,6 @@ class Index extends Component { // 跳转仪器介绍页 goNursing = (item) => { - console.log("goNursing", item); setStorageSync("instrument_detail", JSON.stringify(item)); this.setState({ connectInstrument: item }); setTimeout(() => this.bindBlockLeft()); @@ -729,6 +731,35 @@ class Index extends Component { }; /** iot版本升级 END */ + /** + * @name 初始化WL200设备护理历史 + * @description 如果存在护理历史,则提示是否连接设备,重新读取 + */ + initDeviceNursingHistory = async () => { + let WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); + if (WL200NursingHistory) { + this.setState({ + isShowReConnectDeviceRecordWL200: true, + }); + } + }; + + closeReConnectDeviceRecordWL200 = () => { + Taro.removeStorageSync("WL200NursingHistory"); + this.setState({ + isShowReConnectDeviceRecordWL200: false, + }); + }; + confirmReConnectDeviceRecordWL200 = () => { + let WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); + console.log("WL200NursingHistory", WL200NursingHistory); + this.setState({ + isShowReConnectDeviceRecordWL200: false, + }); + + // this.goNursing() + }; + render() { let { calendarComplete, @@ -752,7 +783,6 @@ class Index extends Component { instrumentInfo, instrumentList, showEquipment, - bindEquipment, // 升级弹窗 isShowUpdateVersionTip, @@ -763,30 +793,31 @@ class Index extends Component { // 蓝牙连接 isConnectShow, connectInstrument, + // 设备存在记录,是否重连 + isShowReConnectDeviceRecordWL200, } = this.state; return ( - {/* - 仪器{} - 仪器{} - 仪器{} - - } - cancelButtonText="暂不绑定" - confirmButtonText="确认" - textAlgin="center" - close={this.closeBindConfirm} - confirm={this.confirmBindConfirm} - /> */} + + 检测到您上一次护理的记录未生成, + 是否重新读取 + + } + cancelButtonText="暂不绑定" + confirmButtonText="确认" + textAlgin="center" + close={this.closeReConnectDeviceRecordWL200} + confirm={this.confirmReConnectDeviceRecordWL200} + /> { }, 300); } else { msg("请求失败,尝试重新请求"); - this.WCUserLogin(); + // 防止快速请求 + setTimeout(() => { + this.WCUserLogin(); + }, 2000); } } diff --git a/src/pages/iotCarePlan/components/Footer/index.less b/src/pages/iotCarePlan/components/Footer/index.less index e69de29..f62877e 100644 --- a/src/pages/iotCarePlan/components/Footer/index.less +++ b/src/pages/iotCarePlan/components/Footer/index.less @@ -0,0 +1,76 @@ +.iot-footer { + position: fixed; + bottom: 0; + z-index: 99; + display: flex; + align-items: baseline; + width: 100%; + height: 153rpx; + background: #ffffff; + box-shadow: 0rpx -3rpx 7rpx 1rpx rgba(173, 191, 207, 0.21); + padding-bottom: env(safe-area-inset-bottom); + box-sizing: border-box; + .btn { + width: 690rpx; + height: 90rpx; + background: #000; + border-radius: 45rpx; + color: #fff; + line-height: 90rpx; + text-align: center; + margin: 21rpx 49rpx 42rpx 30rpx; + font-size: 32rpx; + } + + .text { + display: flex; + align-items: center; + font-size: 32rpx; + font-weight: bold; + color: #000; + } + + .btn-disable { + background-color: #ccc !important; /* 设置按钮背景颜色为灰色 */ + color: #fff !important; /* 设置按钮文字颜色为白色 */ + border-color: #ccc !important; /* 设置按钮边框颜色为灰色 */ + } + + .switch-btn-box { + width: 100vw; + display: flex; + align-items: center; + margin-top: 34rpx; + .btn-item { + height: 70rpx; + display: flex; + flex: 1; + align-items: center; + justify-content: center; + .btn-icon { + width: 36rpx; + height: 36rpx; + margin-right: 18rpx; + } + .btn-text { + font-size: 32rpx; + font-family: PingFang SC; + font-weight: bold; + color: #000000; + } + } + .border-right { + border-right: 1px solid #ddd; + } + .btn-disable { + color: #fff !important; /* 设置按钮文字颜色为白色 */ + border-color: #ccc !important; /* 设置按钮边框颜色为灰色 */ + background-color: #fff !important; /* 设置按钮背景颜色为灰色 */ + .btn-text { + color: #ccc !important; /* 设置按钮文字颜色为白色 */ + border-color: #ccc !important; /* 设置按钮边框颜色为灰色 */ + background-color: #fff !important; /* 设置按钮背景颜色为灰色 */ + } + } + } +} diff --git a/src/pages/iotCarePlan/components/Footer/index.tsx b/src/pages/iotCarePlan/components/Footer/index.tsx index 20c91cf..bffa3e9 100644 --- a/src/pages/iotCarePlan/components/Footer/index.tsx +++ b/src/pages/iotCarePlan/components/Footer/index.tsx @@ -42,7 +42,7 @@ function Index({ return ( - + {!isShowNurse && ( {isDisabled ? ( diff --git a/src/pages/iotCarePlan/components/ModeList/index.tsx b/src/pages/iotCarePlan/components/ModeList/index.tsx index 1427d60..8a2ffdc 100644 --- a/src/pages/iotCarePlan/components/ModeList/index.tsx +++ b/src/pages/iotCarePlan/components/ModeList/index.tsx @@ -9,7 +9,6 @@ interface Props { activeModeID: any; ModeList: any; ModeType: string; // all visor cabin yimeish - ActiveModeItem: any; isShowNurse: boolean; // 是否已进入护理详情页 isPop: boolean; // 是否弹窗 onEmit: Function; // 每次点击item,回调事件和数据给父组件 @@ -20,7 +19,6 @@ function Index({ isPop, ModeList, ModeType, - ActiveModeItem, ModeID, activeModeID, onEmit, @@ -30,9 +28,7 @@ function Index({ let CabinList = ModeList.filter((item) => item.modeClass === 2); // 舱体模式 let YimeishList = ModeList.filter((item) => item.modeClass === 3); // 医美术后 - // const [ModeID, setModeID] = useState("mode_" + ActiveModeItem.id); - // const [activeModeID, setactiveModeID] = useState(ActiveModeItem.id); - + console.log("ModeType", ModeType); const yimeishClick = (item) => { onEmit(item); }; diff --git a/src/pages/iotCarePlan/iotCarePlan.less b/src/pages/iotCarePlan/iotCarePlan.less index 9d7ea6f..c17455d 100644 --- a/src/pages/iotCarePlan/iotCarePlan.less +++ b/src/pages/iotCarePlan/iotCarePlan.less @@ -75,10 +75,10 @@ } .msg-tips { position: absolute; - top: 50%; + top: 40%; left: 0; right: 0; - transform: translateY(-50%); + transform: translateY(-40%); display: flex; align-items: center; max-width: 635rpx; @@ -121,73 +121,6 @@ } } -.footer { - position: fixed; - bottom: 0; - z-index: 99; - display: flex; - align-items: baseline; - width: 100%; - height: 153rpx; - background: #ffffff; - box-shadow: 0rpx -3rpx 7rpx 1rpx rgba(173, 191, 207, 0.21); - padding-bottom: env(safe-area-inset-bottom); - box-sizing: border-box; - .btn { - width: 690rpx; - height: 90rpx; - background: #000; - border-radius: 45rpx; - color: #fff; - line-height: 90rpx; - text-align: center; - margin: 21rpx 49rpx 42rpx 30rpx; - font-size: 32rpx; - } - - .text { - display: flex; - align-items: center; - font-size: 32rpx; - font-weight: bold; - color: #000; - } - - .btn-disable { - background-color: #ccc !important; /* 设置按钮背景颜色为灰色 */ - color: #fff !important; /* 设置按钮文字颜色为白色 */ - border-color: #ccc !important; /* 设置按钮边框颜色为灰色 */ - } - - .switch-btn-box { - width: 100vw; - display: flex; - align-items: center; - margin-top: 34rpx; - .btn-item { - height: 70rpx; - display: flex; - flex: 1; - align-items: center; - justify-content: center; - .btn-icon { - width: 36rpx; - height: 36rpx; - margin-right: 18rpx; - } - .btn-text { - font-size: 32rpx; - font-family: PingFang SC; - font-weight: bold; - color: #000000; - } - } - .border-right { - border-right: 1px solid #ddd; - } - } -} - .battery_icon { width: 8rpx; height: 20rpx; diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index 6d9b4f2..cde56e4 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -227,6 +227,7 @@ class IotCarePlan extends Component { Taro.setKeepScreenOn({ keepScreenOn: true, }); + this.getWL200NursingHistory(); this.initData(); } componentDidMount() {} @@ -339,7 +340,7 @@ class IotCarePlan extends Component { Taro.onBLEConnectionStateChange(this.listener); await this.notifyBLECharacteristicValueChange(); - this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY); + // this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY); } listener = (res) => { console.log("listener res", res); @@ -518,43 +519,16 @@ class IotCarePlan extends Component { }; // 弹窗确定切换护理模式 confirmModeSwitchBtn = () => { - let { SwitchActiveModeItem, ActiveModeItem, isStandStatus } = this.state; - let modeArray = ["all", "visor", "cabin", "yimeish"]; - // 切换护理模式时,需判断舱体和面罩是否切换 - // if (SwitchActiveModeItem.isCabinMode !== ActiveModeItem.isCabinMode) { - // if (SwitchActiveModeItem.isCabinMode === 1) { - // // 判断舱体是否连接成功 - // if (!isStandStatus) { - // console.log( - // "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" - // ); - // this.showTips( - // "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" - // ); - // // this.openErrorTipsText( - // // "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" - // // ); - // // return; - // } - // } else { - // // 判断舱体是否断开连接 - // if (isStandStatus) { - // console.log("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); - // this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); - // // this.openErrorTipsText( - // // "检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体" - // // ); - // // return; - // } - // } - // } + let { SwitchActiveModeItem } = this.state; + this.cancelModeSwitchBtn(); + this.modeCurrentFun(SwitchActiveModeItem); + let modeArray = ["all", "visor", "cabin", "yimeish"]; this.setState({ ModeType: modeArray[SwitchActiveModeItem.modeClass], }); setTimeout(() => { - this.modeCurrentFun(SwitchActiveModeItem); - this.cancelModeSwitchBtn(); + console.log("ModeType", this.state.ModeType); }, 100); }; @@ -590,15 +564,14 @@ class IotCarePlan extends Component { * @description isCabinMode是否舱体模式。 0.检测面罩与舱体是否仍在连接中,需要分离 1.检测是否连接失败,需要重新连接 */ onEmitErrorTips = async () => { - let { isStandStatus, ActiveModeItem } = this.state; - if (isStandStatus) { - if (ActiveModeItem.isCabinMode === 0) { - this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); - } else { - this.showTips( - "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" - ); - } + let { ActiveModeItem } = this.state; + + if (ActiveModeItem.isCabinMode === 0) { + this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); + } else { + this.showTips( + "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" + ); } }; @@ -650,12 +623,11 @@ class IotCarePlan extends Component { case "WL200": if (jsonStatus.connectMessage?.connectType == "CONNECTED") { } else { - // 清除时间倒计时定时器 this.setState({ facialMaskConnectStatus: 0, // 蓝牙断开 isFooterBtnDisabled: false, // 蓝牙断开所以不可点击 }); - // 断开连接直接暂停 + // 断开连接直接暂停:会自动暂停定时器 this.judgementWorkStatus( MODE_WORKING_ENUM.PAUSE, ActiveModeItem?.modeType @@ -697,6 +669,10 @@ class IotCarePlan extends Component { isStopNurse: true, ActiveModeItem, }); + + setTimeout(() => { + this.onEmitErrorTips(); + }, 500); } break; default: @@ -780,6 +756,18 @@ class IotCarePlan extends Component { jsonStatus ); + // 判断设备主动上报的关机事件 + if (jsonStatus.workStatus === MODE_WORKING_ENUM.END) { + this.rmWL200NursingHistory(this.WL200NursingHistory, true); + // 判断护理时间,如果不足,则提示不足 + if (!this.isCheckNurseTime()) { + this.setState({ isNotEnoughTime: true }); + } else { + this.endNurseFun(); + } + return; + } + this.workStatus = jsonStatus.workStatus; this.setState({ Electricity: jsonStatus.battery, @@ -931,7 +919,9 @@ class IotCarePlan extends Component { console.log("时间校准频率,默认5秒一次", TIME_CALIBRATION_FREQUENCY); //对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准 const currentScene = ActiveModeItem; // 获取当前的场景 - let sceneTime = minSecToS(currentScene.modeTimeStr); // 场景时间 + let sceneTime = ActiveModeItem?.breakTimeStr + ? minSecToS(ActiveModeItem.breakTimeStr) + : minSecToS(currentScene.modeTimeStr); // 场景时间 console.log("场景时间 sceneTime", sceneTime); console.log("当前显示时间 currentTime", currentTime); @@ -997,6 +987,13 @@ class IotCarePlan extends Component { }); } opts.workStatus = nWorkStatus; + + let nowCurrentTime = ActiveModeItem.modeTimeStr; + // 完成重连同步则删除重连时间字段 + if (ActiveModeItem?.breakTimeStr) { + nowCurrentTime = ActiveModeItem?.breakTimeStr; + } + const statusF = { sleep: () => { this.setState({ @@ -1008,7 +1005,7 @@ class IotCarePlan extends Component { isShowCountdown: false, }); if (nowModeItem?.isCabinMode && step == 2) { - opts.currentTime = nowModeItem.modeTimeStr; + opts.currentTime = nowCurrentTime; } else if (!nowModeItem?.isCabinMode && step == 2) { // fix: 启动非支架模式倒计时时,连上支架,仪器的状态变为standby opts.step = 1; @@ -1036,7 +1033,7 @@ class IotCarePlan extends Component { }); } if (nowModeItem) { - opts.currentTime = nowModeItem.modeTimeStr; + opts.currentTime = nowCurrentTime; } // startSettingCountDown 用于标记打开了倒计时loading if (!this.state.isShowCountdown) { @@ -1133,17 +1130,21 @@ class IotCarePlan extends Component { step == 2 && facialMaskConnectStatus == 1 ) { - let totalSeconds = minSecToS(ActiveModeItem.modeTimeStr); - // 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算 - let currentSeconds = ActiveModeItem?.breakTimeStr + let totalSeconds = ActiveModeItem?.breakTimeStr ? minSecToS(ActiveModeItem.breakTimeStr) - : minSecToS(currentTime); + : minSecToS(ActiveModeItem.modeTimeStr); + // 现在的倒计时剩余时间:同步时检查是否断开重连,如果是,则使用断开的剩余时长,进行倒计时计算 + let currentSeconds = minSecToS(currentTime); let checkTime = totalSeconds - currentSeconds; + + // 缓存经过的时间:用于接口提交 this.elapsedTime = checkTime; - // 完成重连同步则删除重连时间字段 + // 如果存在中断时间,则要加上间隔的时间 if (ActiveModeItem?.breakTimeStr) { - delete ActiveModeItem?.breakTimeStr; - this.setState({ ActiveModeItem }); + let intervalTime = + minSecToS(ActiveModeItem.modeTimeStr) - + minSecToS(ActiveModeItem.breakTimeStr); + this.elapsedTime += intervalTime; } // 判断剩余时间是否大于1 @@ -1480,6 +1481,7 @@ class IotCarePlan extends Component { console.log("同步异常,但设备运行中"); } }; + /** 获取小程序本地缓存的历史记录 */ getWL200NursingHistory() { this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); @@ -1530,7 +1532,12 @@ class IotCarePlan extends Component { console.log("更新updateWL200NursingHistory"); } }; - /** 删除WL200护理历史 */ + /** + * @name 删除WL200护理历史 + * @description 参数1 护理历史 参数2 强制删除 + * 如果传入护理历史ID与现有ID相等,则删除。 + * 如果参数二为真,则强制删除 + */ rmWL200NursingHistory = (WL200NursingHistory, hard = false) => { const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); if (nowWL200NursingHistory.id == WL200NursingHistory.id) { @@ -1561,6 +1568,7 @@ class IotCarePlan extends Component { console.log("PostNursingLogClock", res); if (res.data.code === 200) { + this.rmWL200NursingHistory(this.WL200NursingHistory); // 护理完成,删除记录 if (isJump) { this.setState({ isShowNursingSuccess: true, @@ -1773,11 +1781,13 @@ class IotCarePlan extends Component { this.setState({ isConnectShow: false, }); + this.onNursingTap(); }; connectionClose = () => { this.setState({ isConnectShow: false, }); + Taro.switchTab({ url: "/pages/index/index" }); }; // 手动护理模式切换:提示是否保存护理 @@ -1834,7 +1844,22 @@ class IotCarePlan extends Component { let isCanClick = isStandStatus ? this.tempModeCurrent?.isCabinMode === 1 : this.tempModeCurrent?.isCabinMode === 0; - let isFooterBtnDisabled = !(isStandStatus === isCanClick); + // 如果舱体状态和模式类型不相等,则禁用 + let isFooterBtnDisabled = false; + + if (isStandStatus) { + if (!isCanClick) { + isFooterBtnDisabled = true; + } + } else { + if (!isCanClick) { + isFooterBtnDisabled = true; + } + } + + console.log("isStandStatus", isStandStatus); + console.log("isFooterBtnDisabled", isFooterBtnDisabled); + console.log("isCanClick", isCanClick); this.setState({ isFooterBtnDisabled: isFooterBtnDisabled, }); @@ -1917,7 +1942,6 @@ class IotCarePlan extends Component { isShowNurse={isShowNurse} ModeList={ModeList} ModeType={ModeType} - ActiveModeItem={SwitchActiveModeItem} onEmit={this.switchModeCurrentFun} onEmitShowAll={this.openModeSwitch} /> @@ -1983,25 +2007,6 @@ class IotCarePlan extends Component { confirm={this.confirmTipsSave} /> - - 检测到您上一次护理的记录未生成, - 是否重新读取 - - } - cancelButtonText="取消" - confirmButtonText="确认" - textAlgin="center" - close={this.closeTipsSave} - confirm={this.confirmTipsSave} - /> - { ModeType={ModeType} ModeID={ModeID} activeModeID={activeModeID} - ActiveModeItem={ActiveModeItem} onEmit={this.modeCurrentFun} onEmitShowAll={this.openModeSwitch} />