From b9563350a5f5ef1e738f316255173fe1f9595f32 Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Tue, 20 Feb 2024 20:33:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=A8=A1=E5=BC=8F=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/calendar/body/isFolding.less | 3 +- src/components/popup/popup-alert.tsx | 20 +- src/components/popup/popup-clock.tsx | 18 +- src/components/popup/popup-confirm.tsx | 3 +- src/components/popup/popup-countdown.tsx | 2 +- src/components/popup/popup-drawer.tsx | 1 + src/components/popup/popup-privacy.tsx | 2 +- src/pages/index/index.tsx | 140 ++--- src/pages/integral_list/integral_list.tsx | 90 ++-- .../iotCarePlan/components/Footer/index.tsx | 12 +- .../iotCarePlan/components/ModeList/index.tsx | 1 + src/pages/iotCarePlan/iotCarePlan.tsx | 510 ++++++++++-------- src/pages/user/user.tsx | 70 +-- src/store/features/deviceInfo.js | 6 + src/utils/util.js | 1 + 15 files changed, 472 insertions(+), 407 deletions(-) diff --git a/src/components/calendar/body/isFolding.less b/src/components/calendar/body/isFolding.less index 8cef091..a21e599 100644 --- a/src/components/calendar/body/isFolding.less +++ b/src/components/calendar/body/isFolding.less @@ -145,8 +145,9 @@ transition-property: all; transition-duration: 0.5s; width: 24rpx; - height: 100%; + height: 20rpx; margin: 0 auto; + padding-top: 10rpx; } .arrow-rotate { diff --git a/src/components/popup/popup-alert.tsx b/src/components/popup/popup-alert.tsx index d7347b5..92dcb76 100644 --- a/src/components/popup/popup-alert.tsx +++ b/src/components/popup/popup-alert.tsx @@ -1,7 +1,15 @@ import classnames from "classnames"; import { Component } from "react"; -import { Block, View, Image, Text, Button, PageMeta } from "@tarojs/components"; +import { + Block, + View, + Image, + Text, + Button, + PageMeta, + ScrollView, +} from "@tarojs/components"; import { Popup } from "@antmjs/vantui"; @@ -64,6 +72,10 @@ export default class PopupAlert extends Component { e.stopPropagation(); }; + onTouchMove = () => { + return true; + }; + render() { let { title, @@ -101,6 +113,7 @@ export default class PopupAlert extends Component { className={classnames("common-box", { "common-large": isLarge, })} + catchMove > {title && ( { )} - { })} > {content} - + {type === "3" && ( diff --git a/src/components/popup/popup-clock.tsx b/src/components/popup/popup-clock.tsx index 4a42169..d0f3e8f 100644 --- a/src/components/popup/popup-clock.tsx +++ b/src/components/popup/popup-clock.tsx @@ -47,7 +47,6 @@ export default class PopupClock extends Component { onConfirm = () => { let { type } = this.props; - this.props.confirm(); }; @@ -75,7 +74,7 @@ export default class PopupClock extends Component { show={isShow} closeOnClickOverlay={false} round - overlayStyle='width: 100vw;padding: 0;' + overlayStyle="width: 100vw;padding: 0;" onClick={this.onClickStop} > {/* { > */} {isClose && ( )} @@ -92,6 +91,7 @@ export default class PopupClock extends Component { className={classnames("common-box", { "common-large": isLarge, })} + catchMove > {title && ( { {title} )} - + { {type === "3" && ( - + - 今年不再提示 + 今年不再提示 )} {type !== "3" && ( - - diff --git a/src/components/popup/popup-confirm.tsx b/src/components/popup/popup-confirm.tsx index 5a98075..ca51f13 100644 --- a/src/components/popup/popup-confirm.tsx +++ b/src/components/popup/popup-confirm.tsx @@ -11,7 +11,6 @@ import "./popup.less"; * isLarge 是否大尺寸 * isShow 是否显示 * isClose 右上角关闭图标 - * type 确认弹窗类型 1 是否换绑 * title 弹窗标题 * content 弹窗内容 * cancelButtonText 取消按钮 @@ -70,7 +69,6 @@ export default class PopupConfirm extends Component { isShow, isClose, isLarge, - type, } = this.props; return ( @@ -94,6 +92,7 @@ export default class PopupConfirm extends Component { className={classnames("common-box", { "common-large": isLarge, })} + catchMove > {title && ( { onClick={this.onClose} > )} - + diff --git a/src/components/popup/popup-drawer.tsx b/src/components/popup/popup-drawer.tsx index 73d18b6..353ff33 100644 --- a/src/components/popup/popup-drawer.tsx +++ b/src/components/popup/popup-drawer.tsx @@ -85,6 +85,7 @@ export default class PopupDrawer extends Component { "common-big-large" )} style="margin: auto;" + catchMove > { > )} - + 用户隐私保护提示 diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 10b540a..1aecc9e 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -781,80 +781,82 @@ class Index extends Component { return ( - - - + + + + - - - 序列号信息仍在更新,请联系微信小助理 - 协助您绑定仪器 - - } - confirmButtonText="知道了" - textAlgin="center" - isClose={false} - close={this.onBindErrorClose} - confirm={this.onBindErrorConfirm} - > - - - {/* + + 序列号信息仍在更新,请联系微信小助理 + 协助您绑定仪器 + + } + confirmButtonText="知道了" + textAlgin="center" + isClose={false} + close={this.onBindErrorClose} + confirm={this.onBindErrorConfirm} + > + + + {/* */} - + + {isConnectShow && ( { } = this.state; return ( - } - confirmButtonText="我知道了" - textAlgin="center" - close={this.integralPopupClose} - confirm={this.integralPopupClose} - /> - // 删除测试阶段标签后,需改回700rpx - - - - 长按图片关注公众号,可以接收积分过期提醒 - - - (测试阶段公众号为:广州云强信息科技有限公司) + + } + confirmButtonText="我知道了" + textAlgin="center" + close={this.integralPopupClose} + confirm={this.integralPopupClose} + /> + // 删除测试阶段标签后,需改回700rpx + + + + 长按图片关注公众号,可以接收积分过期提醒 + + + (测试阶段公众号为:广州云强信息科技有限公司) + - - } - confirmButtonText="我知道了" - textAlgin="center" - close={this.officialPopupClose} - confirm={this.officialPopupConfirm} - /> + } + confirmButtonText="我知道了" + textAlgin="center" + close={this.officialPopupClose} + confirm={this.officialPopupConfirm} + /> + diff --git a/src/pages/iotCarePlan/components/Footer/index.tsx b/src/pages/iotCarePlan/components/Footer/index.tsx index b380f92..0061056 100644 --- a/src/pages/iotCarePlan/components/Footer/index.tsx +++ b/src/pages/iotCarePlan/components/Footer/index.tsx @@ -49,25 +49,25 @@ function Index({ )} {isShowNurse && ( - - + + {isStopNurse ? ( - 暂停光照 + 开始光照 ) : ( - 开始光照 + 暂停光照 )} diff --git a/src/pages/iotCarePlan/components/ModeList/index.tsx b/src/pages/iotCarePlan/components/ModeList/index.tsx index a6b797e..5fc4718 100644 --- a/src/pages/iotCarePlan/components/ModeList/index.tsx +++ b/src/pages/iotCarePlan/components/ModeList/index.tsx @@ -105,6 +105,7 @@ function Index({ ); })} + )} diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index 3eb3208..fea9964 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -21,6 +21,7 @@ import { connect } from "react-redux"; import Navbar from "@/components/navbar/navbar"; import PopupCountdown from "@/components/popup/popup-countdown"; import PopupStepTips from "@/components/popup/popup-step-tips"; +import PopupConfirm from "@/components/popup/popup-confirm"; /* 公共组件 END */ /* 本页组件 */ @@ -56,12 +57,13 @@ import commandMap from "@/utils/commandMap"; const deviceToolKitInstanceWE100 = new DeviceToolKitWE100("WE100", "M01"); const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200"); +let CountdownTimer: any = null; let timer: any = null; let checkVersionTimeout: any = null; let showTipsTimer: any = null; let loadingTipsTimer: any = null; // 蓝牙连接提示 let switchModeStatus = "free"; // 用于标记是否在切换模式中, free: 空闲, switching: 切换中 -//时间校准频率,每多少秒校准一次 +// 设备运行时间校准频率,每多少秒校准一次 const TIME_CALIBRATION_FREQUENCY = 5; // 模式类型 @@ -127,8 +129,8 @@ const WORK_MODE_TYPE = { }; const MODE_WORKING_ENUM = { - STANDBY: "standby", - WORKING: "working", + STANDBY: "standby", // 待命 + WORKING: "working", // 工作 PAUSE: "pause", END: "end", }; @@ -161,7 +163,7 @@ class IotCarePlan extends Component { super(props); this.state = { name: "iotCarePlan", - title: "美容仪名字", + title: "美容仪名字", // 页面标题 instrument: "WE200", /** 连接设备 */ @@ -170,10 +172,12 @@ class IotCarePlan extends Component { basicModeList: [], //模式列表 modelActiveIndex: 0, //模式下标 sliderProgress: 22, - isStandStatus: false, //支架开启状态(支架就是舱体) - workStatus: "", //工作状态 - Electricity: 0, //fr200电量 - matrixElectricity: 0, //matrix电量 + isStandStatus: false, // 支架开启状态(支架就是舱体) + facialMaskConnectStatus: 0, // 面膜?暂时认为是面罩连接状态 0未连接 1已连接 + workStatus: "", // 工作状态 + Electricity: 0, // WL200电量 + matrixElectricity: 0, // matrix电量 + workMode: "", //当前模式 showCombinationModeDialog: false, // 组合模式弹窗 combinationModeList: [], // 可选的组合模式列表 @@ -183,22 +187,17 @@ class IotCarePlan extends Component { originCombinationModeInfo: {}, // 原始组合模式缓存的信息 isCurrentModeCombination: false, // 当前模式是否是组合模式 isSendModeCombination: false, // 当前是否在发送组合模式 + gear: { gear: 1 }, currentShowDialog: "", // countdown: 3, // 倒计时 step: 1, // 1:选择模式并播放视频, 2:护理中 - facialMaskConnectStatus: 0, // 面膜连接状态 - checkedMaskVersion: false, //是否检查过固件版本了 - askedOta: false, //询问过用户是否需要OTA + isCheckedMaskVersion: false, // 是否检查过固件版本了 + isAskedOta: false, // 询问过用户是否需要OTA showVideoPlayBtn: true, // 视频播放按钮 duration: 0, // 视频总时长 hadShowBreakTips: false, // 是否展示过支架断开提示 popupType: "", // enoughTimePopup: 时间达标提示, endPopup: 结束弹窗 - safeAreaBottom: 0, - video_guide: "", // 指导视频 - wl200CustomMode: [], // wl200所有的自定义模式 - joinModeId: 0, - todayMode: 0, // 今日场景id customModeData: { hadCustom: false, hadSetCustom: false, // 是否设置过 -- 代码逻辑使用 @@ -207,8 +206,6 @@ class IotCarePlan extends Component { /** 连接设备 End */ - // isMuted: false, // 视频是否静音 - isMusicPlay: false, // 声音播放状态 isShowStepTips: false, // 是否显示介绍步骤弹窗 isConnectionBlutoot: false, // 是否已连接蓝牙 isShowNurse: false, // 是否开始并显示护理 @@ -225,11 +222,10 @@ class IotCarePlan extends Component { // 倒计时 isShowCountdown: false, // 倒计时弹窗 - countdown: 6, - // startSettingCountDown: false, // 是否开始倒计时 + countdown: 3, - // 音乐 - // innerAudioContext: null, + // 是否结束护理 + isEndCarePlan: false, // 最后执行步骤位置 endPlace: "", @@ -271,8 +267,17 @@ class IotCarePlan extends Component { } } + // 开发者工具 + const platform = Taro.getSystemInfoSync().platform; + + //开发者工具 + if (platform !== "devtools") { + // 初始化蓝牙 + this.init(); + } + // 初始化蓝牙 - this.init(); + // this.init(); } async init() { @@ -293,7 +298,7 @@ class IotCarePlan extends Component { Taro.onBLEConnectionStateChange(this.listener); await this.notifyBLECharacteristicValueChange(); - this.handleWorkStatus(null, MODE_WORKING_ENUM.STANDBY); + this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY); } listener = (res) => { console.log("listener res", res); @@ -335,11 +340,6 @@ class IotCarePlan extends Component { } }; - changeMusicStatus = () => { - let { isMusicPlay } = this.state; - this.setState({ isMusicPlay: !isMusicPlay }); - }; - /** 开始护理按钮:点击开始,页面进行到下一步 */ onStartNurse = async () => { this.stepNext(); @@ -355,17 +355,47 @@ class IotCarePlan extends Component { onSwitchChange = async () => { // todo let { isStopNurse } = this.state; - let switchStatus = !isStopNurse; - if (switchStatus) { + if (isStopNurse) { // 开始光照逻辑 + this.showCountdownFun(3, () => {}); + this.handleWorkStatus(false, MODE_WORKING_ENUM.WORKING); } else { // 暂停光照逻辑 + this.handleWorkStatus(false, MODE_WORKING_ENUM.PAUSE); } - this.setState({ isStopNurse: switchStatus }); - }; - onEndPlan = async () => { - // todo + this.setState({ + isStopNurse: !isStopNurse, + }); }; + /** + * 倒计时弹窗 + * param 重置倒计时 + * callback 回调函数 + */ + showCountdownFun(count = 3, callback: any = null) { + this.setState({ + countdown: count, + }); + setTimeout(() => { + clearInterval(CountdownTimer); + this.setState({ + isShowCountdown: true, + }); + CountdownTimer = setInterval(() => { + if (this.state.countdown === 0) { + clearInterval(CountdownTimer); + this.setState({ + isShowCountdown: false, + }); + if (callback) callback(); + } else { + this.setState({ + countdown: this.state.countdown - 1, + }); + } + }, 1000); + }, 0); + } modeCurrentFun = async (data) => { console.log("modeCurrentFun", data); @@ -376,8 +406,15 @@ class IotCarePlan extends Component { // //0未定义(全部) 1面罩模式 2舱体模式 3医美术后 let modeArray = ["all", "visor", "cabin", "yimeish"]; let modeClass = this.state.ActiveModeItem.modeClass; - this.setState({ ModeType: modeArray[modeClass] }); - this.setState({ isShowNurse: true }); + this.setState({ + ModeType: modeArray[modeClass], + isShowNurse: true, + isStopNurse: true, + isStandStatus: this.state.ActiveModeItem.isCabinMode === 1, + workStatus: "pause", + }); + + this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY); }; closeStepTips = (data) => { @@ -393,12 +430,12 @@ class IotCarePlan extends Component { // 如果设备配对链接发送配对码的时候,设备应答小程序配对码是否正确。 case "SendMatchCode": if (jsonStatus.matchedSuccess) { - // msg('配对成功') - console.log("配对成功"); + console.log("设备配对成功"); // log.info(commandMap.WL200Command, "配对成功"); } break; - //附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了 + + // 附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了 case "BleStatusSync": switch (jsonStatus.connectMessage?.deviceName) { case "WL200": @@ -409,50 +446,57 @@ class IotCarePlan extends Component { !this.state.customModeData.setCustomSuc && !this.state.customModeData.hadSetCustom ) { - // this.setCustomMaskData(); + this.setCustomMaskData(); + } + + // 附属设备连接成功,如何区分是哪个设备? + this.setState({ + facialMaskConnectStatus: 1, // 面罩已连接 + }); + deviceToolKitInstance = deviceToolKitInstanceWL200; + console.log( + "检查版本isCheckedMaskVersion", + this.state.isCheckedMaskVersion + ); + if (!this.state.isCheckedMaskVersion) { + this.checkVersion(); } - // that.setData({ - // facialMaskConnectStatus: 1, - // }); - // this.deviceToolKitInstance = deviceToolKitInstanceWL200; - // console.log( - // "checkedMaskVersion", - // this.data.checkedMaskVersion - // ); - // if (!this.data.checkedMaskVersion) { - // this.checkVersion(); - // } } else { + // WL200连接失败 // deviceToolKitInstance = deviceToolKitInstanceWE100; // // TODO 护理中(step==2)时, 如果断开, 可能需要暂停 - // that.setData({ - // facialMaskConnectStatus: 0, - // }); + this.setState({ + facialMaskConnectStatus: 0, + }); } break; + // 是否附属设备是否连接支架 case "Stand": - // that.setData({ - // isStandStatus: - // jsonStatus.connectMessage?.connectType == "CONNECTED", - // }); - + if (jsonStatus.connectMessage?.connectType == "CONNECTED") { + this.setState({ + isStandStatus: true, + }); + } break; default: break; } break; + //小程序主动问主机,现在链接了哪些附属设备,这时候主机给小程序的回复消息 case "QueryMatchStatus": const isStandDevice = jsonStatus?.subDeviceList?.includes("Stand") || false; const isConnectedMask = jsonStatus?.subDeviceList?.includes("WL200") || false; + deviceToolKitInstance = isConnectedMask ? deviceToolKitInstanceWL200 : deviceToolKitInstanceWE100; - console.log(isConnectedMask, "更改成功deviceToolKitInstance"); - if (!this.state.checkedMaskVersion && isConnectedMask) { - this.checkVersion(); + + console.log("连接and更改成功 deviceToolKitInstance", isConnectedMask); + if (!this.state.isCheckedMaskVersion && isConnectedMask) { + this.checkVersion(); // 检查版本 } console.log("支架是否链接", isStandDevice); console.log("面罩是否链接", isConnectedMask); @@ -469,7 +513,7 @@ class IotCarePlan extends Component { // that.standVideoContext.seek(0); // // that.showTips('检测到支架未连接成功,请确认面罩开机后与支架连接,并接通支架电源'); // that.showTips( - // `检测到${that.data.deviceChineseName.WL200Stand}未连接成功,请确认面罩开机后与${that.data.deviceChineseName.WL200Stand}连接,并接通${that.data.deviceChineseName.WL200Stand}电源` + // `检测到舱体未连接成功,请确认面罩开机后与舱体连接,并接通舱体电源` // ); // 连上面罩后, 设置自定义模式 -- 不在这里设置自定义模式 @@ -548,25 +592,26 @@ class IotCarePlan extends Component { ) { // 发送启动指令 this.startCombinationMode(); - const totalTime = this.state.combinationList.reduce( - (total, item) => { - return total + minSecToS(item.time); - }, - 0 - ); + + // const totalTime = this.state.combinationList.reduce( + // (total, item) => { + // return total + minSecToS(item.time); + // }, + // 0 + // ); // 设备启动后小程序操作 - this.setState({ - showCombinationModeDialog: false, - combinationModeInfo: { - time: s_to_hs(totalTime), - seconds: totalTime, - }, - modelActiveIndex: -1, - currentTime: s_to_hs(totalTime), - isCurrentModeCombination: true, - isSendModeCombination: false, - }); + // this.setState({ + // showCombinationModeDialog: false, + // combinationModeInfo: { + // time: s_to_hs(totalTime), + // seconds: totalTime, + // }, + // modelActiveIndex: -1, + // currentTime: s_to_hs(totalTime), + // isCurrentModeCombination: true, + // isSendModeCombination: false, + // }); setTimeout(() => { console.log("currentTime", this.state.currentTime); }); @@ -723,7 +768,7 @@ class IotCarePlan extends Component { checkVersion = () => { this.sendCheckVersion(); this.setState({ - checkedMaskVersion: true, + isCheckedMaskVersion: true, }); if (checkVersionTimeout) clearTimeout(checkVersionTimeout); checkVersionTimeout = setTimeout(() => { @@ -758,7 +803,7 @@ class IotCarePlan extends Component { ); if (isNeedToUpdateBl) { this.setState({ - askedOta: true, + isAskedOta: true, // currentShowDialog: 'offlineDialog', }); // this.confirmOta(); @@ -791,18 +836,17 @@ class IotCarePlan extends Component { } }; - // 待完善,以后更新页面状态的方法,在这里执行setData + // 渲染页面时间状态 renderDeviceStatus = { - renderWorkTime() { - // const that = this; + renderWorkTime: () => { const { totalWorkingMinutes, totalWorkingSeconds } = DeviceSyncData; const { ActiveModeItem, currentTime } = this.state; const totalTime = totalWorkingMinutes * 60 + totalWorkingSeconds; console.log("仪器上报的已经运行的总秒数", totalTime); - // console.log('时间校准频率,默认5秒一次',TIME_CALIBRATION_FREQUENCY) + console.log("时间校准频率,默认5秒一次", TIME_CALIBRATION_FREQUENCY); //对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准 const currentScene = ActiveModeItem; // 获取当前的场景 - let sceneTime = minSecToS(currentScene.time); // 场景时间 + let sceneTime = minSecToS(currentScene.modeTime); // 场景时间 const timeRemaining = sceneTime - minSecToS(currentTime); // 小程序上已运行的总秒数 if ( @@ -840,7 +884,10 @@ class IotCarePlan extends Component { } } - // 设备上报不同状态 + /** + * 设备上报不同状态 + * params 工作状态 工作模式 响应状态 + */ judgementWorkStatus(nWorkStatus, nWorkMode, jsonStatus) { const { workStatus, @@ -852,7 +899,6 @@ class IotCarePlan extends Component { } = this.state; const opts: any = {}; // ActiveModeItem - const modeItem = ActiveModeItem; let nowModeItem; if (nWorkMode) { const nowModeType = WORK_MODE_TYPE[nWorkMode]; @@ -890,18 +936,13 @@ class IotCarePlan extends Component { this.setState({ hadShowBreakTips: false, }); - if (step != 2 && !modeItem.isStandMode) { + if (step != 2 && !ActiveModeItem.isCabinMode) { opts.step = 2; this.setState({ title: "正在护理", isStopNurse: false, }); - // Taro.setNavigationBarTitle({ - // title: "正在护理", - // }); - // 处理音乐 - this.musicStatusChange(); - } else if (step != 2 && modeItem.isStandMode) { + } else if (step != 2 && ActiveModeItem.isCabinMode) { opts.step = 2; // this.setState({ // title: "正在护理", @@ -932,13 +973,7 @@ class IotCarePlan extends Component { title: "正在护理", isStopNurse: false, }); - // 处理音乐 - // this.musicStatusChange(); } - // else if (modeItem?.isStandMode) { - // 支架模式也使用gif图, 不需要播放视频了, 所以注释 - // that.onPlayTap(); - // } this.setState({ isShowCountdown: false, @@ -949,7 +984,7 @@ class IotCarePlan extends Component { this.setState({ isShowCountdown: false, }); - if (modeItem.isStandMode) { + if (ActiveModeItem.isCabinMode) { // this.onPauseTap(); this.setState({ title: "暂停护理", @@ -967,7 +1002,7 @@ class IotCarePlan extends Component { // 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下 const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus; if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) { - const sceneTime = minSecToS(modeItem.currentTime); // 模式的总时长 + const sceneTime = minSecToS(ActiveModeItem.modeTime); // 模式的总时长 const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长 const timeRemaining = sceneTime - runTime; // 剩余未运行时间 this.setState({ @@ -975,7 +1010,7 @@ class IotCarePlan extends Component { }); } this.endnursing(null, true); - this.rmWL200NursingHistory(this.state.WL200NursingHistory); + // this.rmWL200NursingHistory(this.state.WL200NursingHistory); }, }; statusF[nWorkStatus] && statusF[nWorkStatus](); @@ -989,34 +1024,34 @@ class IotCarePlan extends Component { * 1.是否跳转 2.数据 * */ saveNurseReport = async (isJump = true, from) => { - const { isStandStatus, standInfo, ActiveModeItem, options } = this.state; - const currentScene = ActiveModeItem; - let sceneTime = minSecToS(currentScene.time); - const timeRemaining = sceneTime - minSecToS(this.state.currentTime); - const form = { - second: timeRemaining, - screne_id: currentScene.screne_id, - screne_name: currentScene.screne_name, - instrument_id: options?.devId, - report: JSON.stringify({ - positionRatio: Math.floor((timeRemaining / sceneTime) * 100), - }), - }; - // log.info(commandMap.WL200Command, '保存护理报告saveNurseReport', '来自方法from:' + from, '护理时间timeRemaining:'+timeRemaining); - console.log("timeRemaining=>", timeRemaining); - console.log("currentScene=>", currentScene); - console.log("form=>", form); - // const { data } = await UserNursingLogAdd(form) - // // 清除缓存 - // that.rmWL200NursingHistory(that.data.WL200NursingHistory, true); - // if (data.code == 200 && isJump) { - // that.setData({ - // showNurseSuccess: true - // }); - // setTimeout(()=>{ - // wx.redirectTo({ url: `/pages/MatrixWL200/pages/nursingRecord/nursingRecord?instrument_id=${options?.devId}&id=${data.data}` }) - // }, 2000); - // } + // const { isStandStatus, standInfo, ActiveModeItem, options } = this.state; + // const currentScene = ActiveModeItem; + // let sceneTime = minSecToS(currentScene.time); + // const timeRemaining = sceneTime - minSecToS(this.state.currentTime); + // const form = { + // second: timeRemaining, + // screne_id: currentScene.screne_id, + // screne_name: currentScene.screne_name, + // instrument_id: options?.devId, + // report: JSON.stringify({ + // positionRatio: Math.floor((timeRemaining / sceneTime) * 100), + // }), + // }; + // // log.info(commandMap.WL200Command, '保存护理报告saveNurseReport', '来自方法from:' + from, '护理时间timeRemaining:'+timeRemaining); + // console.log("timeRemaining=>", timeRemaining); + // console.log("currentScene=>", currentScene); + // console.log("form=>", form); + // // const { data } = await UserNursingLogAdd(form) + // // // 清除缓存 + // // that.rmWL200NursingHistory(that.data.WL200NursingHistory, true); + // // if (data.code == 200 && isJump) { + // // that.setData({ + // // showNurseSuccess: true + // // }); + // // setTimeout(()=>{ + // // wx.redirectTo({ url: `/pages/MatrixWL200/pages/nursingRecord/nursingRecord?instrument_id=${options?.devId}&id=${data.data}` }) + // // }, 2000); + // // } }; /** @@ -1048,35 +1083,35 @@ class IotCarePlan extends Component { } } + // 设置自定义模式数据 setCustomModeData() { - const { basicModeList, modelActiveIndex, currentTime } = that.data; - const modeItem = basicModeList[modelActiveIndex]; - 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, - // }) - } + // 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); @@ -1143,31 +1178,31 @@ class IotCarePlan extends Component { } // 工作状态 - handleWorkStatus = (_, workStatus) => { + handleWorkStatus = (isBtnClick: boolean, workStatus) => { const { facialMaskConnectStatus, isStandStatus, ActiveModeItem } = this.state; - const modeItem = ActiveModeItem; let newWorkStatus = workStatus || (this.state.workStatus == MODE_WORKING_ENUM.WORKING ? "pause" : "working"); - if (_ && newWorkStatus == "working") { - if (modeItem.modeClass === 2 && !isStandStatus) { + if (isBtnClick && newWorkStatus == "working") { + // 舱体模式 + if (ActiveModeItem.isCabinMode === 1 && !isStandStatus) { this.showTips( - `检测到${this.state.deviceChineseName.WL200Stand}未连接成功,请确认面罩开机后与${this.state.deviceChineseName.WL200Stand}连接,并接通${this.state.deviceChineseName.WL200Stand}电源` + `检测到舱体未连接成功,请确认面罩开机后与舱体连接,并接通舱体电源` ); return; } - if (!modeItem.isStandMode && facialMaskConnectStatus != 1) { + // 非舱体模式 + if (!ActiveModeItem.isCabinMode && facialMaskConnectStatus != 1) { this.showTips("检测到面罩未连接成功,请确认面罩开机并佩戴"); return; } } - const curModeData = ActiveModeItem; const sendParams = { ...deviceCommandSamples.pause, - workMode: WORK_MODE_ENGLISH_NAME[curModeData.model_type], + workMode: WORK_MODE_Chinese_NAME[ActiveModeItem.modeName], // 使用模式 workStatus: newWorkStatus, }; const pauseArrayBuffer = deviceToolKitInstance.toBleCommand( @@ -1180,14 +1215,6 @@ class IotCarePlan extends Component { workStatus: newWorkStatus, }); this.setTimer(); - // 支架模式, 暂停, 需暂停视频播放 - if (newWorkStatus == MODE_WORKING_ENUM.PAUSE && modeItem.isStandMode) { - this.onPauseTap(); - } - // 支架模式, 开始播放, 需播放视频 - if (newWorkStatus == MODE_WORKING_ENUM.WORKING && modeItem.isStandMode) { - this.onPlayTap(); - } console.info( `handleWorkStatus 发送${newWorkStatus}指令成功 参数为 =>`, sendParams @@ -1254,29 +1281,24 @@ class IotCarePlan extends Component { // 如果是强效舒缓,需要判断是否连接支架 if (modelActiveItem.isStandMode && !isStandStatus) { this.showTips( - `检测到${this.state.deviceChineseName.WL200Stand}未连接成功,请确认面罩开机后与${this.state.deviceChineseName.WL200Stand}连接,并接通${this.state.deviceChineseName.WL200Stand}电源` + `检测到舱体未连接成功,请确认面罩开机后与舱体连接,并接通舱体电源` ); - // that.showTips('检测到支架未连接成功,请确认面罩开机后与支架连接,并接通支架电源'); return; } else if (!modelActiveItem.isStandMode && isStandStatus) { - this.showTips( - `检测到面罩仍和${this.state.deviceChineseName.WL200Stand}连接中,请分离后切换` - ); + this.showTips(`检测到面罩仍和舱体连接中,请分离后切换`); return; } if (modelActiveItem.isCustomMode && !customModeData.setCustomSuc) { - this.showTips( - `${modelActiveItem.nursing_name}模式设置失败,请联系小助手` - ); + this.showTips(`${modelActiveItem.modeName}模式设置失败,请联系小助手`); return; } // 开始执行护理 - this.handleWorkStatus(null, MODE_WORKING_ENUM.WORKING); + this.handleWorkStatus(false, MODE_WORKING_ENUM.WORKING); } // 结束护理? endNurseFun() { - // this.handleWorkStatus(null, "end"); + // this.handleWorkStatus(false, "end"); setTimeout(() => { //TODO IOS关闭蓝牙太快导致关机指令没发出去,暂时这么解决 const isEnough = this.checkTime(); @@ -1305,23 +1327,6 @@ class IotCarePlan extends Component { }, 500); } - /** - * 音乐暂停播放时间 - */ - musicStatusChange() { - const { step, ActiveModeItem } = this.state; - const modeItem = ActiveModeItem; - this.setState({ - musicStatus: !this.state.musicStatus, - }); - // if (step == 2 && !modeItem.isStandMode) { - // if (this.state.musicStatus) { - // this.state.innerAudioContext?.play(); // 播放 - // } else { - // this.state.innerAudioContext?.pause(); //暂停 - // } - // } - } // 检查时间是否达标 checkTime() { const { curDeviceInfo, workStatus, ActiveModeItem } = this.state; @@ -1370,12 +1375,12 @@ class IotCarePlan extends Component { // 删除WL200护理历史 rmWL200NursingHistory(WL200NursingHistory, hard = false) { - const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); - if (nowWL200NursingHistory.id == WL200NursingHistory.id) { - Taro.removeStorageSync("WL200NursingHistory"); - } else if (hard) { - Taro.removeStorageSync("WL200NursingHistory"); - } + // const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); + // if (nowWL200NursingHistory.id == WL200NursingHistory.id) { + // Taro.removeStorageSync("WL200NursingHistory"); + // } else if (hard) { + // Taro.removeStorageSync("WL200NursingHistory"); + // } } //蓝牙断开连接处理 @@ -1440,11 +1445,26 @@ class IotCarePlan extends Component { }, 2000); } + /** 结束护理弹窗 */ + onEndPlan = async () => { + this.setState({ + isEndCarePlan: true, + }); + }; + confirmEndBtn = () => { + this.cancelEndBtn(); + }; + cancelEndBtn = () => { + this.setState({ + isEndCarePlan: false, + }); + }; + /** 弹窗 END*/ + render() { let { name, title, - isMusicPlay, isShowStepTips, ModeList, ModeType, @@ -1457,46 +1477,46 @@ class IotCarePlan extends Component { ModeStepIndex, Electricity, errorTips, + isEndCarePlan, } = this.state; return ( - - {ActiveModeItem.openSourceData && ( - + + - )} + {ActiveModeItem.openSourceData && ( + + )} + - - {isMusicPlay ? ( - - ) : ( - - )} - {!isShowNurse && (