diff --git a/src/components/bluetoot/connection/index.tsx b/src/components/bluetoot/connection/index.tsx index 30f890a..c743bd7 100644 --- a/src/components/bluetoot/connection/index.tsx +++ b/src/components/bluetoot/connection/index.tsx @@ -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 { 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 { 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 { render() { let { name, isConnection, connectionSuccess, error } = this.state; - let { deviceInfo } = this.props; + let { deviceInfo, isDisconnect } = this.props; return ( { - - )} @@ -201,7 +202,8 @@ export default class DeviceConnectPopup extends Component { 未搜索到设备 - {data.bluetoothConnectFailContent} + {data.bluetoothConnectFailContent || + "请重启设备后点击重新连接"} diff --git a/src/components/popup/popup-step-tips.less b/src/components/popup/popup-step-tips.less index 804bad4..a482350 100644 --- a/src/components/popup/popup-step-tips.less +++ b/src/components/popup/popup-step-tips.less @@ -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; diff --git a/src/components/popup/popup-step-tips.tsx b/src/components/popup/popup-step-tips.tsx index 5014d39..d8fa922 100644 --- a/src/components/popup/popup-step-tips.tsx +++ b/src/components/popup/popup-step-tips.tsx @@ -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 { 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 { }; 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 { "margin-samll": isLarge, })} > - {data.length > 0 ? data[current].openTitle : "暂无数据"} + {data.length > 0 ? data[current].openTitle : "使用教程"} {/* {title && ( { {data.length === 1 && ( - + {isFirstEntry ? ( + + ) : ( + + )} )} {data.length > 1 && current === 0 && ( @@ -191,21 +208,23 @@ export default class PopupStepTips extends Component { )} - - {isLocal ? ( - - ) : ( - - )} - - 以后不再提示准备步骤 - + {!isFirstEntry && ( + + {isLocal ? ( + + ) : ( + + )} + + 以后不再提示准备步骤 + + )} diff --git a/src/img/bluetooth.png b/src/img/bluetooth.png new file mode 100644 index 0000000..76b9941 Binary files /dev/null and b/src/img/bluetooth.png differ diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 81b77f1..8ba44cd 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -156,16 +156,14 @@ class Index extends Component { } } 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(this.$instance.page); @@ -174,7 +172,7 @@ class Index extends Component { this.showInit(); } - componentDidHide() { } + componentDidHide() {} showInit() { // 判断是否登录 @@ -224,7 +222,7 @@ class Index extends Component { this.isSancQrcodeEnter(); } }, - fail: () => { }, + fail: () => {}, complete: () => { // 授权完成运行页面初始化 }, @@ -382,7 +380,7 @@ class Index extends Component { this.setState({ isShowSiteSwiper: false }); }; - bannerSwiperchange() { } + bannerSwiperchange() {} gobanner(item) { // 跳转类型:0无跳转、1跳转内部链接、3跳转外部链接、4跳转小程序、5导向视频号、6导向视频号直播间', @@ -655,27 +653,15 @@ class Index extends Component { // 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 { @@ -834,25 +820,25 @@ class Index extends Component { /> 序列号信息仍在更新,请联系微信小助理 协助您绑定仪器 } - confirmButtonText='知道了' - textAlgin='center' + confirmButtonText="知道了" + textAlgin="center" isClose={false} close={this.onBindErrorClose} confirm={this.onBindErrorConfirm} /> { - 仪器:小紫单美容仪 - 序列号:uniquie14231 - 您需要完成注册登录才能进行一起绑定 + 仪器:小紫单美容仪 + 序列号:uniquie14231 + 您需要完成注册登录才能进行一起绑定 } - 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 { @@ -948,29 +934,29 @@ class Index extends Component { leftSlot={ - {messagecount ? : ""} + {messagecount ? : ""} } /> - - - 护理记录 + + + 护理记录 - + { /> - + {instrumentList.length > 0 && ( - - 前往护理 + + 前往护理 - 添加新设备 + 添加新设备 - - + + {instrumentList.map((item, index) => { if (item.status === 0) { return ( - + {item.name} @@ -1029,32 +1015,32 @@ class Index extends Component { )} {instrumentList.length === 0 && ( - - 前往护理 + + 前往护理 - - - + + + - + 添加新设备 - 您暂时还没有绑定任何设备 + 您暂时还没有绑定任何设备 )} - + 假按钮跳转蓝牙调试设备页 - + { key={"banner_" + index} onClick={this.gobanner.bind(this, item)} > - + ); })} - + ); } diff --git a/src/pages/iotCarePlan/components/Footer/index.tsx b/src/pages/iotCarePlan/components/Footer/index.tsx index f4e3fe3..fed6aba 100644 --- a/src/pages/iotCarePlan/components/Footer/index.tsx +++ b/src/pages/iotCarePlan/components/Footer/index.tsx @@ -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 ( @@ -50,27 +56,58 @@ function Index({ )} {isShowNurse && ( - - {isStopNurse ? ( - - - 开始光照 - - ) : ( - - - 暂停光照 - - )} - + {isCanClick && ( + + {isStopNurse ? ( + + + 启动光照 + + ) : ( + + + 暂停光照 + + )} + + )} + {!isCanClick && ( + + {isStopNurse ? ( + + + + 启动光照 + + + ) : ( + + + + 暂停光照 + + + )} + + )} { 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 { countdown: 3, // 是否结束护理 isEndCarePlan: false, - // 最后执行步骤位置 - endPlace: "", currentTime: "01:00", // 护理时间不够 @@ -195,10 +202,13 @@ class IotCarePlan extends Component { 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 { } componentDidHide() { + console.log("Hide"); // 页面隐藏后,下次显示需要重新检查记录 this.hadCheckReport = false; } @@ -249,9 +260,9 @@ class IotCarePlan extends Component { 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 { 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 { } /** 选中护理模式 */ - 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 { 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 { // } 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 { 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 { 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 { 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 { 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 { } 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 { * 设备上报不同状态 * 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 { // 仪器自动上报完成, 直接上报并跳转报告页 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 { clearInterval(currentTimeTimer); this.setState({ currentTime: "00:00", - endPlace: "report", ModeStepIndex: 0, }); this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束 @@ -1168,11 +1225,9 @@ class IotCarePlan extends Component { 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 { } } + // 手动切换护理 + hanldeChangeNurseFun() { + // 满足时间条件,提示是否保存部分护理记录 + if (this.checkNurseTime()) { + // 打开提示保存护理弹窗 + this.setState({ + isShowTipsSave: true, + }); + } else { + // 不满足条件,直接切换 + } + } + /** 检查时间是否达标仪器最低护理时间 */ checkNurseTime() { const { currentDevice, ActiveModeItem } = this.state; @@ -1315,12 +1383,18 @@ class IotCarePlan extends Component { 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 { 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 { }; /** 提交护理记录 */ - 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 { 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 { 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 { 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 { activeModeID, isShowCountdown, countdown, - ModeStepIndex, Electricity, matrixElectricity, errorTips, @@ -1629,6 +1733,9 @@ class IotCarePlan extends Component { errorTipsText, isNotEnoughTime, isShowNursingSuccess, + currentDevice, + isConnectionBlutoot, + isShowTipsSave, } = this.state; return ( @@ -1677,9 +1784,9 @@ class IotCarePlan extends Component { {ActiveModeItem.openSourceData && ( @@ -1709,6 +1816,25 @@ class IotCarePlan extends Component { confirm={this.closeErrorTipsText} /> + + 当前模式已护理部分时间 + 是否保存护理记录 + + } + cancelButtonText="取消" + confirmButtonText="确认" + textAlgin="center" + close={this.closeTipsSave} + confirm={this.confirmTipsSave} + /> + { /*不需要做处理*/ }} /> + + {isConnectShow && ( + {}} + pairingChange={this.pairingChange} + upgradeFun={() => {}} + /> + )} @@ -1806,6 +1943,7 @@ class IotCarePlan extends Component { onEmitStartNurse={this.onStartNurse} onEmitSwitchChange={this.onSwitchChange} onEmitEndPlan={this.onEndPlan} + onEmitErrorTips={this.onEmitErrorTips} />