diff --git a/src/components/bluetoot/device-connection-popup/device-connection-popup.less b/src/components/bluetoot/device-connection-popup/device-connection-popup.less index 1be0996..6dfc090 100644 --- a/src/components/bluetoot/device-connection-popup/device-connection-popup.less +++ b/src/components/bluetoot/device-connection-popup/device-connection-popup.less @@ -83,12 +83,16 @@ } } } + .block { margin-top: 40rpx; } .block2 { margin-top: 40rpx; } +.block-msg-one { + margin-top: 80rpx; +} .images, .videos { diff --git a/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx b/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx index f288875..2eab03c 100644 --- a/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx +++ b/src/components/bluetoot/device-connection-popup/device-connection-popup.tsx @@ -125,7 +125,7 @@ export default class DeviceConnectPopup extends Component { {currentDeviceType === "WE200" && ( - + { {isConnection ? ( - + { ) : ( - + { isRegisterBoolean, isClose, isLarge, - type, } = this.props; // let serial = Taro.getStorageSync("serial"); @@ -119,55 +118,49 @@ export default class PopupBinding extends Component { > )} - {isRegisterBoolean && - (type === 1 || type === 2) && - !isExchangeBinding && ( - - - 仪器:{data.instrumentName} - 序列号:{data.serial} - - 请问是否确认绑定该仪器? - - - - } - confirmButtonText="确认" - cancelButtonText="暂不绑定" - close={this.onClose} - confirm={this.onConfirm} - > - )} - {isRegisterBoolean && - (type === 1 || type === 2) && - isExchangeBinding && ( - - - 仪器:{data.instrumentName} - 序列号:{data.serial} - - 检测到您的序列号与扫码序列号不一致, - 是否进行换绑操作? - + {isRegisterBoolean && !isExchangeBinding && ( + + + 仪器:{data.instrumentName} + 序列号:{data.serial} + 请问是否确认绑定该仪器? + + + } + confirmButtonText="确认" + cancelButtonText="暂不绑定" + close={this.onClose} + confirm={this.onConfirm} + > + )} + {isRegisterBoolean && isExchangeBinding && ( + + + 仪器:{data.instrumentName} + 序列号:{data.serial} + + 检测到您的序列号与扫码序列号不一致, + 是否进行换绑操作? - - } - confirmButtonText="确认" - cancelButtonText="暂不换绑" - close={this.onClose} - confirm={this.onConfirm} - > - )} + + + } + confirmButtonText="确认" + cancelButtonText="暂不换绑" + close={this.onClose} + confirm={this.onConfirm} + > + )} ); } diff --git a/src/moduleIOT/pages/iotCarePlan/components/ModeContent/index.tsx b/src/moduleIOT/pages/iotCarePlan/components/ModeContent/index.tsx index 9e76729..f6177b4 100644 --- a/src/moduleIOT/pages/iotCarePlan/components/ModeContent/index.tsx +++ b/src/moduleIOT/pages/iotCarePlan/components/ModeContent/index.tsx @@ -7,8 +7,9 @@ import "./index.less"; interface Props { isShowNurse: boolean; ActiveModeItem: any; + ModeStepIndex: number; } -function Index({ isShowNurse, ActiveModeItem }: Props) { +function Index({ isShowNurse, ActiveModeItem, ModeStepIndex }: Props) { const ModeColor = { "590nm": "#CF231D", "630nm": "#CF231D", @@ -16,17 +17,35 @@ function Index({ isShowNurse, ActiveModeItem }: Props) { }; return ( - {isShowNurse && ( + {isShowNurse && ActiveModeItem?.combineData.length > 0 && ( 模式功效 - {ActiveModeItem.modeDesc} + + {ActiveModeItem.combineData[ModeStepIndex].effectContent} + - {ActiveModeItem?.combineData && ( - - 当前输出技术 - - {ActiveModeItem.combineData.map((item) => { + + 当前输出技术 + + + + + {ActiveModeItem.combineData[ModeStepIndex].technologyInfo} + + + {/* {ActiveModeItem.combineData.map((item) => { return ( ); - })} - + })} */} - )} + )} diff --git a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.less b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.less index c17455d..5b0d95d 100644 --- a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.less +++ b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.less @@ -146,3 +146,37 @@ width: 690rpx; height: 320rpx; } + +.custom-popup { + background: none !important; +} +.van-popup { + border-radius: 30rpx; + .sync-history-msg { + // box-sizing: border-box; + // width: 670rpx; + // height: 840rpx; + // background: #ffffff; + // border-radius: 30rpx; + // position: relative; + // padding: 42rpx 30rpx 0; + -webkit-box-sizing: border-box; + box-sizing: border-box; + width: 670rpx; + height: 250rpx; + background: rgba(0, 0, 0, 0.4); + border-radius: 30rpx; + position: relative; + text-align: center; + color: #ffff; + line-height: 250rpx; + opacity: 0.8; + .close_icon { + position: absolute; + width: 50rpx; + height: 50rpx; + top: 34rpx; + right: 34rpx; + } + } +} diff --git a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx index 30691ea..e433007 100644 --- a/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/moduleIOT/pages/iotCarePlan/iotCarePlan.tsx @@ -56,9 +56,10 @@ import { bleCommandSamples, } from "@/components/bluetoot/connection/wl200"; -import { minSecToS, s_to_ms, s_to_hms, sleep } from "@/utils/util"; +import { minSecToS, s_to_ms, s_to_hms, sleep, s_to_s } from "@/utils/util"; import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; import commandMap from "@/utils/commandMap"; +import { Popup } from "@antmjs/vantui"; const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WL200", "WL200"); @@ -217,6 +218,7 @@ class IotCarePlan extends Component { // 不涉及渲染的页面变量 isRuning: any = false; // 设备是否运行中 jsonStatus: any = {}; // 同步设备返回数据,用于结束 + workJsonStatus: any = {}; // 同步工作中的仪器 tempModeCurrent: any = {}; // 临时保存的当前模式 elapsedTime: any = 0; // 设备已运行时间 workStatus: any = ""; // 工作状态 @@ -443,6 +445,7 @@ class IotCarePlan extends Component { } let currentTime = data.modeTimeStr; + let modeArray = ["all", "visor", "cabin", "yimeish"]; this.setState({ ActiveModeItem: data, activeModeID: data.id, @@ -450,6 +453,7 @@ class IotCarePlan extends Component { currentServiceData, ModeStepIndex: 0, currentTime, + ModeType: modeArray[data.modeClass], }); setTimeout(() => { @@ -536,9 +540,6 @@ class IotCarePlan extends Component { this.setState({ ModeType: modeArray[SwitchActiveModeItem.modeClass], }); - setTimeout(() => { - console.log("ModeType", this.state.ModeType); - }, 100); }; stepNext = () => { @@ -800,7 +801,10 @@ class IotCarePlan extends Component { jsonStatus ); + this.workJsonStatus = jsonStatus; this.workStatus = jsonStatus.workStatus; + + setTimeout(() => console.log("this.workStatus", this.workStatus)); this.setState({ Electricity: jsonStatus.battery, // fr200Electricity: jsonStatus.battery, @@ -816,7 +820,6 @@ class IotCarePlan extends Component { 500 ); } - return; } @@ -1440,21 +1443,39 @@ class IotCarePlan extends Component { checkInstrumentRecord = async (jsonStatus: any) => { console.log("检查护理记录"); let { currentDevice, ActiveModeItem, ModeList } = this.state; - if (jsonStatus) { - } - // 1.判断是否存在工作状态:如果不存在,则等待两秒用于连接设备与赋值,再执行后面的代码 - if (!this.workStatus) { - await sleep(2); - } + + await sleep(2); let isSyncHistory = Taro.getStorageSync("isSyncHistory"); if (isSyncHistory) { this.setState({ isShowHistoryMsg: false }); Taro.removeStorageSync("isSyncHistory"); } + console.log( + "this.workJsonStatus", + this.workJsonStatus, + this.workJsonStatus.workMode + ); + + this.setState({ + isFooterBtnDisabled: false, + }); + if (this.workJsonStatus.workMode) { + console.log("this.workJsonStatus.workMode", this.workJsonStatus.workMode); + if (this.workJsonStatus.workMode.indexOf("Stand") > -1) { + console.log( + "this.workJsonStatus.workMode", + this.workJsonStatus.workMode + ); + this.setState({ + isStandStatus: true, + }); + setTimeout(() => this.footerIsDisabled(), 100); + } + } // 2.判断是否已存在缓存的护理记录:如果没有历史,则缓存 - let workStatus = this.workStatus; + let workStatus = this.workJsonStatus.workStatus; let WL200NursingHistory = this.WL200NursingHistory; if (!this.WL200NursingHistory) { console.log("小程序缓存没有数据, 忽略"); @@ -1484,6 +1505,19 @@ class IotCarePlan extends Component { return; } + console.log("workStatus", workStatus); + console.log("jsonStatus", jsonStatus, this.workJsonStatus); + console.log("currentTime", WL200NursingHistory.currentTime); + console.log("isStandStatus", this.state.isStandStatus); + + let historyElapsedTime = + minSecToS(recordModeItem.modeTimeStr) - + minSecToS(WL200NursingHistory.currentTime); + + this.elapsedTime = + this.elapsedTime > historyElapsedTime + ? this.elapsedTime + : historyElapsedTime; // 4.判断设备状态-未运行/已完成/待机 if ( workStatus == MODE_WORKING_ENUM.STANDBY || @@ -1494,12 +1528,7 @@ class IotCarePlan extends Component { if (jsonStatus.id == WL200NursingHistory.id) { console.log("id一致, 设备没有运行/已完成/待机"); let totalSeconds = jsonStatus.totalSeconds; // 从仪器上获取的使用时间 - let neededTotalSeconds = jsonStatus.neededTotalSeconds; // 从仪器上获取的使用时间 - console.log( - "从仪器上获取的使用时间 totalSeconds: %d neededTotalSeconds: %d", - totalSeconds, - neededTotalSeconds - ); + let nursingTimeStr = currentDevice?.nursingTimeStr; let nursingTime = nursingTimeStr ? minSecToS(nursingTimeStr) : 60; // 设备生成护理记录至少需要运行时间 @@ -1523,6 +1552,7 @@ class IotCarePlan extends Component { modeName: ActiveModeItem.modeName, nursingTime: timeValue, }; + this.handleWorkStatus(false, "end"); let res: any = await this.PostNursingLogClock(params); console.log("res", res); this.rmWL200NursingHistory(WL200NursingHistory); @@ -1535,15 +1565,23 @@ class IotCarePlan extends Component { modeName: ActiveModeItem.modeName, nursingTime: "00:01:00", }; + this.handleWorkStatus(false, "end"); let res: any = await this.PostNursingLogClock(params); console.log("res", res); this.rmWL200NursingHistory(WL200NursingHistory); } } else { - // 5.判断设备状态-运行中 正常逻辑,这里不做处理,如果用户操作,则按正常流程判断 - console.log("同步异常,但设备运行中"); - console.log("同步异常,但设备运行中"); - console.log("同步异常,但设备运行中"); + console.log("id一致, 设备运行中或暂停"); + // 5.判断设备状态-运行中 + // 同步时间 + if (jsonStatus.id == WL200NursingHistory.id) { + if (WL200NursingHistory.currentTime) { + this.setState({ + step: 2, + }); + this.resetTimer(); + } + } } }; @@ -1554,11 +1592,27 @@ class IotCarePlan extends Component { // 是否同步历史记录 let isSyncHistory = Taro.getStorageSync("isSyncHistory"); if (isSyncHistory) { + let ActiveModeItem = this.WL200NursingHistory.ActiveModeItem; // 直接进入开始护理状态 - this.setState({ isShowNurse: true, isShowHistoryMsg: true, + currentServiceData: this.WL200NursingHistory.currentServiceData, + tempModeCurrent: ActiveModeItem, + ActiveModeItem: ActiveModeItem, + activeModeID: ActiveModeItem.id, + ModeID: "mode_" + ActiveModeItem.id, + currentTime: this.WL200NursingHistory.currentTime, + }); + setTimeout(() => { + // 设置时间组合 + if (ActiveModeItem.serviceData.length > 0) { + this.setServiceTimeData(); + } + // 存在组合模式时,设置组合模式 + if (ActiveModeItem.combineData.length > 0) { + this.setCustomMaskData(); + } }); } } @@ -1575,6 +1629,7 @@ class IotCarePlan extends Component { id: jsonStatus.id, neededTotalSeconds: jsonStatus.neededTotalSeconds, jsonStatus, + ActiveModeItem: this.state.ActiveModeItem, }; this.WL200NursingHistory = JSON.parse(JSON.stringify(params)); Taro.setStorageSync("WL200NursingHistory", params); @@ -1977,6 +2032,7 @@ class IotCarePlan extends Component { isStopNurse, ModeList, ModeType, + ModeStepIndex, currentServiceData, ActiveModeItem, SwitchActiveModeItem, @@ -2003,6 +2059,7 @@ class IotCarePlan extends Component { isShowReReadRecordSave, isFooterBtnDisabled, isShowHistoryMsg, + stepIndex, } = this.state; return ( @@ -2141,11 +2198,15 @@ class IotCarePlan extends Component { upgradeFun={() => {}} /> )} - - {isShowHistoryMsg && ( - 正在同步护理记录... - )} + + 正在同步护理记录... + + @@ -2220,6 +2281,7 @@ class IotCarePlan extends Component { )} diff --git a/src/pages/index/index.less b/src/pages/index/index.less index cf1dd32..f86ec0a 100644 --- a/src/pages/index/index.less +++ b/src/pages/index/index.less @@ -2,7 +2,7 @@ page { background: #f3f3f3; } -.mb10{ +.mb10 { margin-bottom: 20rpx; font-size: 32rpx; } @@ -997,7 +997,7 @@ page { padding-top: 32rpx; background-color: #fff; box-shadow: 0rpx 2rpx 25rpx 18rpx rgba(210, 210, 210, 0.1); - border-radius:30rpx; + border-radius: 30rpx; .date-title { position: absolute; top: 32rpx; @@ -1015,7 +1015,7 @@ page { } } } - .custom-popup{ +.custom-popup { background: none !important; } .van-popup { @@ -1032,7 +1032,7 @@ page { box-sizing: border-box; width: 670rpx; height: 250rpx; - background: rgba(0,0,0,0.6); + background: rgba(0, 0, 0, 0.6); border-radius: 30rpx; position: relative; text-align: center; @@ -1046,6 +1046,5 @@ page { top: 34rpx; right: 34rpx; } - } -} \ No newline at end of file +} diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index c5e9f9c..f2d8273 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -680,10 +680,7 @@ class Index extends Component { (item) => item.id === instrumentInfo.id ); if (isBind) { - this.setState({ - isBeforeBindingError: true, - BeforeBindingErrorText: "序列号已绑定", - }); + msg("序列号已绑定"); } else { this.setState({ isBeforeBindingError: true, @@ -761,14 +758,16 @@ class Index extends Component { this.getInstrumentIntroInfo(instrumentInfo.id); }, 1000); return; + } else if (data.code === 204) { + this.setState({ + isBeforeBindingError: true, + BeforeBindingErrorText: "您选择的仪器有误,请重新选择确认", + }); } else if (data.code === 203) { this.setState({ isBindingError203: true }); } else if (data.code === 202) { // 换绑操作 this.setState({ isExchangeBinding: true, isVisibleBinding: true }); - } else if (data.code === 201) { - // 跳转联系客服 - this.setState({ isBindingError: true }); } else { this.setState({ isBindingError: true }); } @@ -1162,7 +1161,6 @@ class Index extends Component { /> { isRegisterBoolean: false, isExchangeBinding: false, - /** INPUT序列号:拎出来,防止上传图片被清空bug */ + instrumentInfo: {}, }; } $instance = Taro.getCurrentInstance(); @@ -274,6 +274,44 @@ export default class Instrument extends Component { } }; + // 根据扫码的序列号获取仪器信息 + getInstrumentInfoBySerial = async (serial) => { + let { data } = await InstrumentInfo.getInstrumentInfoBySerial({ + serial: serial, + }); + if (data.code === 200) { + let instrumentInfo = data.data; + // 更新扫码进入仪器信息 + this.setState({ instrumentInfo: instrumentInfo }); + } + }; + /**删除扫码缓存*/ + removeScanFun = () => { + Taro.removeStorageSync("isScan"); // 扫码弹窗显示完后,不需要再判断是否扫码 + Taro.removeStorageSync("serial"); // 扫码弹窗显示完后,删除缓存的扫码序列号 + }; + + /** 查询是否可以绑定 */ + isBindingSerial = async () => { + Taro.showLoading({ + title: "请求中...", + mask: true, + }); + let { instrumentInfo } = this.state; + let res = await InstrumentInfo.isBindingSerial({ + serial: instrumentInfo.serial, + }); + console.log("isBindingSerial", res); + if (res.data.code === 201) { + // 绑定 + this.setState({ isExchangeBinding: false, isVisibleBinding: true }); + } else if (res.data.code === 202) { + // 换绑 + this.setState({ isExchangeBinding: true, isVisibleBinding: true }); + } + Taro.hideLoading(); + }; + /** * @name 手写绑定仪器 * @return code===204 用户选择的仪器与序列号对应的仪器不一致 @@ -285,6 +323,7 @@ export default class Instrument extends Component { }); let { channelInfo } = this.state; + await this.getInstrumentInfoBySerial(channelInfo.serialCode); let res = await InstrumentInfo.manualCodeBinding({ serial: channelInfo.serialCode, serialImage: channelInfo.serialImage, @@ -293,38 +332,42 @@ export default class Instrument extends Component { Taro.hideLoading(); // 文件上传接口返回格式,不需要加data let code = Number(res.code); // 强制类型转换 - if (code === 200) { - msg("绑定成功"); - setTimeout(() => { - setStorageSync("instrument_item", JSON.stringify(channelInfo)); - go("/pages/instrument/intro?id=" + channelInfo.id); - }, 1000); - } else if (res.data.code === 202) { - this.changeBindBox(); - } else if (res.data.code === 203) { - this.setState({ isBindingError203: true }); - } else if (res.data.code === 204) { - this.onBindCheckErrorOpen(); - } else if (res.data.code === 205 || res.data.code === 206) { - this.onBindErrorOpen(); - } + setTimeout(() => { + if (code === 200) { + // msg("绑定成功"); + // setTimeout(() => { + // setStorageSync("instrument_item", JSON.stringify(channelInfo)); + // go("/pages/instrument/intro?id=" + channelInfo.id); + // }, 1000); + this.openBindingVisible(); + } else if (code === 202) { + this.changeBindBox(); + } else if (code === 203) { + this.setState({ isBindingError203: true }); + } else if (code === 204) { + this.onBindCheckErrorOpen(); + } else if (code === 205 || code === 206) { + this.onBindErrorOpen(); + } + }, 100); }; /** * @name 扫码绑定仪器 * @return code===204 用户选择的仪器与序列号对应的仪器不一致 */ scanCodeBinding = async () => { - // Taro.showLoading({ - // title: "请求中...", - // mask: true, - // }); + Taro.showLoading({ + title: "请求中...", + mask: true, + }); let { channelInfo } = this.state; + await this.getInstrumentInfoBySerial(channelInfo.serialCode); let res = await InstrumentInfo.scanCodeBinding({ serial: channelInfo.serialCode, instrumentId: channelInfo.id, }); - // Taro.hideLoading(); + Taro.hideLoading(); let code = Number(res.data.code); console.log("scanCodeBinding code", code); setTimeout(() => { @@ -361,7 +404,7 @@ export default class Instrument extends Component { Taro.hideLoading(); setTimeout(() => { if (res.data.code === 200) { - // this.setState({ isVisibleBinding: false }); + this.setState({ isVisibleBinding: false }); msg("绑定成功"); setStorageSync("instrument_item", JSON.stringify(channelInfo)); setTimeout(() => { @@ -378,6 +421,7 @@ export default class Instrument extends Component { } }, 100); }; + // 换绑仪器 exchangeBinding = async () => { Taro.showLoading({ @@ -436,7 +480,16 @@ export default class Instrument extends Component { // 打开绑定弹窗 openBindingVisible = () => { - this.setState({ isVisibleBinding: true }); + setTimeout(() => { + this.setState({ isVisibleBinding: true, isExchangeBinding: false }); + }, 10); + setTimeout(() => { + console.log( + "openBindingVisible", + this.state.isVisibleBinding, + this.state.channelInfo + ); + }, 100); }; closeBinding = () => { this.setState({ isVisibleBinding: false }); @@ -460,6 +513,7 @@ export default class Instrument extends Component { isBindingCheckError, show, channelInfo, + instrumentInfo, inputType, style, equipmentList, @@ -488,11 +542,10 @@ export default class Instrument extends Component { @@ -704,7 +757,7 @@ export default class Instrument extends Component { {inputType == 1 && ( 确认绑定