From 298a7388b25b16f35027a89e3e71d9e5c0f2d97d Mon Sep 17 00:00:00 2001 From: blak-kong <546598185@qq.com> Date: Wed, 7 Feb 2024 17:26:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E8=BF=9E=E6=8E=A5=E8=B0=83?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/bluetoot/connection/index.tsx | 2 + .../popup/popup-instrument-upload-tips.tsx | 7 +- src/components/popup/popup-step-tips.less | 98 +++ src/components/popup/popup-step-tips.tsx | 214 +++++++ src/img/welcome/no-checked.png | Bin 0 -> 449 bytes src/pages/index/index.tsx | 287 +-------- .../components/ModeList/index.less | 20 + .../iotCarePlan/components/ModeList/index.tsx | 21 + src/pages/iotCarePlan/iotCarePlan.tsx | 600 +++++++++++++++++- 9 files changed, 952 insertions(+), 297 deletions(-) create mode 100644 src/components/popup/popup-step-tips.less create mode 100644 src/components/popup/popup-step-tips.tsx create mode 100644 src/img/welcome/no-checked.png diff --git a/src/components/bluetoot/connection/index.tsx b/src/components/bluetoot/connection/index.tsx index 27bfa92..91e6a77 100644 --- a/src/components/bluetoot/connection/index.tsx +++ b/src/components/bluetoot/connection/index.tsx @@ -468,6 +468,8 @@ class ConnectionBluetoot extends Component { connectionStatus, islian: true, // 不需要离线记录,但暂未完全删除这部分逻辑,所以直接设为true }); + + this.pairingChange(this.state); // 临时添加,用于跳转 // this.detectVersionUpdate(); // 获取升级信息 // todo 连接成功需删除离线记录,暂时未缓存离线记录 if (this.state.connectionSuccess) return; diff --git a/src/components/popup/popup-instrument-upload-tips.tsx b/src/components/popup/popup-instrument-upload-tips.tsx index f29a017..35c6abc 100644 --- a/src/components/popup/popup-instrument-upload-tips.tsx +++ b/src/components/popup/popup-instrument-upload-tips.tsx @@ -153,12 +153,7 @@ export default class PopupInstrumentUploadTips extends Component { mode="aspectFit" > - - {item.message} - {item.message} - {item.message} - {item.message} - + {item.message} ); })} diff --git a/src/components/popup/popup-step-tips.less b/src/components/popup/popup-step-tips.less new file mode 100644 index 0000000..804bad4 --- /dev/null +++ b/src/components/popup/popup-step-tips.less @@ -0,0 +1,98 @@ +.step-popup-content-box { + margin: 0; +} +.step-absolutely { + width: 600rpx; + height: 720rpx; + text-align: left; + margin: 0 auto; +} +.step-img { + display: block; + width: 600rpx; + height: 600rpx; + border-radius: 30rpx; +} +// .van-popup { +// background-color: transparent; +// } +.site-close { + position: absolute; + right: 36rpx; + top: 36rpx; + color: #fff; + font-size: 36rpx; + z-index: 100009; + background-color: #ababab; + border-radius: 50%; + padding: 8rpx; + box-sizing: border-box; +} + +.step-popup-btn { + position: absolute; + bottom: 100rpx; + left: calc(50% - 120rpx); + width: 240rpx; + height: 70rpx; + line-height: 70rpx; + font-size: 28rpx; + text-align: center; + border: 1rpx solid #000; + border-radius: 40rpx; + background-color: #000; + color: #fff; + box-sizing: border-box; +} + +.step-tips-common-box { + padding: 50rpx 35rpx 74rpx 35rpx; + .tips-message { + margin-top: 70rpx; + font-size: 28rpx; + font-family: PingFang SC; + font-weight: 400; + color: #030000; + line-height: 60rpx; + } +} + +.popup-btn-one { + display: flex; + margin-top: 60rpx; + justify-content: center; + .popup-btn { + width: 270rpx; + height: 90rpx; + line-height: 90rpx; + font-size: 32rpx; + font-weight: 500; + text-align: center; + border: 1rpx solid #000; + border-radius: 45rpx; + color: #fff; + background-color: #000; + font-family: PingFang SC; + } +} + +.setp-footer-btn { + display: flex; + justify-content: center; + align-items: center; + text-align: center; + height: 30rpx; + // padding: 10rpx; + margin-top: 50rpx; + .checked { + width: 30rpx; + height: 30rpx; + margin-right: 26rpx; + } + .text { + font-family: PingFang SC; + font-size: 28rpx; + color: #666; + font-weight: 400; + } +} diff --git a/src/components/popup/popup-step-tips.tsx b/src/components/popup/popup-step-tips.tsx new file mode 100644 index 0000000..6af9936 --- /dev/null +++ b/src/components/popup/popup-step-tips.tsx @@ -0,0 +1,214 @@ +import classnames from "classnames"; +import Taro from "@tarojs/taro"; +import { Component } from "react"; + +import { + Block, + View, + Image, + Text, + Button, + PageMeta, + Swiper, + SwiperItem, +} from "@tarojs/components"; + +import { Popup } from "@antmjs/vantui"; + +import "./popup.less"; +import "./popup-step-tips.less"; +import "./fade.css"; + +import { go } from "../../utils/traoAPI"; + +/** props + * isLarge 是否大尺寸 + * isShow 是否显示 + * data 数据 + * title 动态标题 + * confirmButtonText 确定关闭按钮 + * @confirm 关闭回调 + * ***/ +export default class PopupStepTips extends Component { + constructor(props) { + super(props); + this.state = { + name: "步骤介绍弹窗", // 当前IOT使用 + current: 0, + isLocal: false, // 是否缓存关闭,以后不再显示准备步骤 + }; + } + + async onLoad() {} + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + initData = () => { + if (this.props.siteData) { + let arr = JSON.parse(JSON.stringify(this.props.siteData)); + this.setState({ siteList: arr }); + } + }; + + onClose = () => { + let { isLocal } = this.state; + this.props.close({ isLocal }); + }; + + onClickStop = (e) => { + e.stopPropagation(); + }; + + // onChange(event) { + // const current = event.detail.current; + // const { current: curCurrent } = this.state; + // const { siteData } = this.props; + // if (curCurrent + 2 === siteData.length && current + 1 === siteData.length) { + // this.setState({ toRight: true }); + // } + // this.setState({ current }); + // } + + onPrev = async () => { + let { current } = this.state; + this.setState({ current: current - 1 }); + }; + onNext = async () => { + let { current } = this.state; + + if (current === this.props.data.length) { + this.onClose(); + } else { + this.setState({ current: current + 1 }); + } + }; + + onChangeLocal = () => { + let { isLocal } = this.state; + this.setState({ isLocal: !isLocal }); + }; + + render() { + let { isShow, data, isLarge, title, content, confirmButtonText } = + this.props; + let { current, isLocal } = this.state; + + return ( + + + + + + + {data[current].openTitle} + + {/* {title && ( + + {title} + + )} */} + + + {data.map((item, index) => { + return ( + + + + + {item.openContent} + + ); + })} + + + + + {data.length === 1 && ( + + + + )} + {data.length > 1 && current === 0 && ( + + + + )} + {data.length > 1 && ( + + + + + )} + + + + {isLocal ? ( + + ) : ( + + )} + + 以后不再提示准备步骤 + + + + + ); + } +} diff --git a/src/img/welcome/no-checked.png b/src/img/welcome/no-checked.png new file mode 100644 index 0000000000000000000000000000000000000000..703e0c80fbc1bb1335dac9554119bbbbdbe97730 GIT binary patch literal 449 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw3=&b&bO2Ij0X`wFK>7hG;Q#;sU%!4$dT;+9 zsFS}W$S;`Tu*Ao+_M4XTdpw?6Qy3~cV}B_F1EaR5i(`n#@ukxpH?=76xXf-~>bq6- z|Mb7R^Dh~)orwN?N-4;b{rr?&&$hT2>1nRtxrQ_y^@q)9@pzUyQF9`vo(j?TB}vtHc$Th+ABrU@rVC*D$Dws^E350zb<(z6u3FpJZWLlY&~%mt!*!j6oWVVPM6dc zy7uQ(Y9;iz1>)XZel>sg-+5onRNSry3i`h;HLbnBL-K#g*Pe*$1>cWy z)i3zyuIb_5A?#oCg(ciQUwz>ZM@})e}#CIG8hA4xltDnm{ Hr-UW|WhmcF literal 0 HcmV?d00001 diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index a5e3a89..f598ffc 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -592,13 +592,10 @@ class Index extends Component { go("/pages/instrumentClickinUpload/index"); }, 10); } else { - go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转 - return; Taro.getSystemInfo({ success: (res) => { console.log("getSystemInfo", res); this.setState({ isConnectShow: true }); - return; let { locationEnabled, locationAuthorized, bluetoothEnabled } = res; if (!locationEnabled || !locationAuthorized) { showModal({ @@ -627,98 +624,18 @@ class Index extends Component { * WE100,WL200配对完成回调 */ async pairingChange(e) { - console.log("epairingChange", e); - return; - const { connectInstrument } = this.state; - let latestVersionNo, isNeedToUpdateBl; - //当前版本号 - const deviceVersionNo = e.detail.deviceVersionNo; - console.info("配对完成回调", e, deviceVersionNo); - //最新版本号 - latestVersionNo = connectInstrument.iot_versions; - //TODO 这些信息需要放在WL200的接口里,现在没有。 暂时的方案,如果是WL200 需要查WE200的相关信息 - if (connectInstrument.type == instrumentTypeEnum.WL200) { - this.pureData.mianmo_id = app.globalData.bindinfo.mianmo_id; - const { data: resData } = await InstrumentInfo({ - id: this.pureData.mianmo_id, - }); - // if (resData) {} - // const mianmo_item = this.data.instruments.find(item=>{ - // return this.pureData.mianmo_id == item.id; - // }) - // if (mianmo_item) { - // const {iot_versions,type} = mianmo_item - // this.pureData.mianmo_iot_versions = iot_versions; - // this.pureData.mianmo_type = type; - // latestVersionNo = iot_versions - // } - // const {data: resData} = await UserInstrumentInfo({id: this.pureData.mianmo_id}); - if (resData.code == 200) { - const { data } = resData; - const { iot_versions, type } = data.info; - this.pureData.mianmo_iot_versions = iot_versions; - this.pureData.mianmo_type = type; - latestVersionNo = iot_versions; - } - isNeedToUpdateBl = isNeedToUpdate(deviceVersionNo, latestVersionNo); - console.log( - `设备版本号: ${deviceVersionNo}`, - `后台版本号: ${latestVersionNo}`, - `是否需要升级: ${isNeedToUpdateBl}` - ); - // 2023.11.29 18:00 经与黄工讨论, 后续版本暂时都需要进行强更 - // this.gotoOta(); - // return - if (isNeedToUpdateBl) { - this.gotoOta(); - return; - this.setData({ - params: "offlineDialog", - offlineDialogType: 2, - otaDeviceName: "skinpilot", - }); - return; - } - go(`/pages/MatrixWL200/pages/index/index?devId=${connectInstrument.id}`); - this.setData({ - params: "", - }); - } else if (connectInstrument.type == instrumentTypeEnum.M01) { - isNeedToUpdateBl = isNeedToUpdate(deviceVersionNo, latestVersionNo); - console.log( - `设备版本号: ${deviceVersionNo}`, - `后台版本号: ${latestVersionNo}`, - `是否需要升级: ${isNeedToUpdateBl}` - ); - if (isNeedToUpdateBl) { - // 2023.11.17 22:00 经与黄工讨论, 后续版本暂时都需要进行强更 - this.gotoOta(); - return; - this.setData({ - params: "offlineDialog", - offlineDialogType: 2, - otaDeviceName: "skinpilot", - offlineDialogForce: 1, - }); - return; - } - go( - `/pages/MatrixM01/pages/index/index?devId=${this.data.connectInstrument.id}` - ); - // this.setData({ - // params: "", - // }); - } + console.log("===epairingChange===》", e); + go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转 + // return; } //连接完成时数据的回调 offlineChange = async (e) => { console.log("offlineChange", e); - const that = this; - log.info( - commandMap.versionInfoHome, - `offlineChange::e::${JSON.stringify(e)}` - ); + // log.info( + // commandMap.versionInfoHome, + // `offlineChange::e::${JSON.stringify(e)}` + // ); //offlineDataList 离线数据 //versioninfo 版本号 let { offlineDataList, versionInfo } = e.detail; @@ -817,196 +734,6 @@ class Index extends Component { } }); console.log(offlinelist); - let nowyear = new Date().getFullYear(); - let nowmonth = String(new Date().getMonth() + 1).padStart(2, "0"); - let nowday = String(new Date().getDate()).padStart(2, "0"); - // await IOTHistorySynchronization({ - // //把离线数据同步到后台 - // instrument_id: app.globalData.bindid, - // clock_times: offlinelist, - // }); - // offlinelist.map((item, index) => { - // // console.log(new Date(item.clock_day.replace(/-/g,'/')).getTime()) - // if (item.clock_day == `${nowyear}-${nowmonth}-${nowday}`) { - // //今日有离线护理 弹出 检测到您今天已进行护理,是否跳过护理直接前往打卡,或选择继续进行护理 - // if (item.second >= this.data.connectInstrument.times * 60) { - // console.log("今日有离线护理"); - // let screneList2 = { - // lianbuobj: { - // fen: String(s_to_h(item.model_face_use)).padStart("2", 0), - // miao: String(s_to_s(item.model_face_use)).padStart("2", 0), - // total: item.model_face_use, - // }, - // yanbuobj: { - // fen: String(s_to_h(item.model_eye_use)).padStart("2", 0), - // miao: String(s_to_s(item.model_eye_use)).padStart("2", 0), - // total: item.model_eye_use, - // }, - // ledobj: { - // fen: 0, - // miao: 0, - // total: 0, - // }, - // }; - // this.setData({ - // screneList2, - // }); - - // let screneList3 = { - // second: item.second, //总秒 - // screne_id: "", //场景id - // screne_name: "离线记录", //场景名称 - // model_face_ward: item.model_face_ward, //脸部场景档位 - // model_face_use: item.model_face_use, //脸部场景使用时长 - // model_face_type: "", //脸部模式类型 - // model_eye_ward: item.model_eye_ward, //眼部场景档位 - // model_eye_use: item.model_eye_use, //眼部场景使用时长 - // model_eye_type: "", //眼部模式类型 - // }; - - // /** - // * 如果今天有打过卡,需要累加 - // */ - // // if (this.data?.todayclockin?.id) { - // // screneList3.second += this.data.todayclockin.clock_info[0].second - // // screneList3.model_face_use += this.data.todayclockin.clock_info[0].model_face_use - // // screneList3.model_eye_use += this.data.todayclockin.clock_info[0].model_eye_use - // // } - // // - // // console.log(this.data.todayclockin) - // this.setData({ - // screneList3, - // }); - // console.log(this.data.screneList3, "2222222222222222222"); - - // this.setData({ - // params: "offlineDialog", - // offlineDialogType: 1, - // todayofflineData: item, - // }); - // } - // } - // }); - - // if (this.data.params == "connection_guide") { - // // this.setData({ - // // params: 'offlineDialog', - // // offlineDialogType:2 - // // }) - // console.log("设备版本号" + versioninfo.version); - // console.log("后台版本号" + this.data.connectInstrument.iot_versions); - // log.info( - // commandMap.versionInfoHome, - // `设备版本号: ${versioninfo.version}` - // ); - // log.info( - // commandMap.versionInfoHome, - // `后台版本号: ${that.data.connectInstrument.iot_versions}` - // ); - // console.log( - // "后台版本号H" + - // Number(this.data.connectInstrument.iot_versions.substring(0, 2)) + - // "版本号H" + - // Number(String(versioninfo.v1).padStart("2", 0)) - // ); - // log.info( - // commandMap.versionInfoHome, - // `后台版本号H: ${Number( - // that.data.connectInstrument.iot_versions.substring(0, 2) - // )} ,版本号H: ${Number(String(versioninfo.v1).padStart("2", 0))}` - // ); - // console.log( - // "后台版本号M" + - // Number(this.data.connectInstrument.iot_versions.substring(2, 4)) + - // "版本号M" + - // Number(String(versioninfo.v2).padStart("2", 0)) - // ); - // log.info( - // commandMap.versionInfoHome, - // "后台版本号M" + - // Number(this.data.connectInstrument.iot_versions.substring(2, 4)) + - // "版本号M" + - // Number(String(versioninfo.v2).padStart("2", 0)) - // ); - // console.log( - // "后台版本号L" + - // Number(this.data.connectInstrument.iot_versions.substring(4, 6)) + - // "版本号L" + - // Number(String(versioninfo.v3).padStart("2", 0)) - // ); - // log.info( - // commandMap.versionInfoHome, - // "后台版本号L" + - // Number(this.data.connectInstrument.iot_versions.substring(4, 6)) + - // "版本号L" + - // Number(String(versioninfo.v3).padStart("2", 0)) - // ); - // //这是有问题的固件,强制升级 - // if ( - // versioninfo.v1 == "01" && - // versioninfo.v2 == "02" && - // versioninfo.v3 == "00" - // ) { - // this.gotoOta(); - // return; - // } - // if ( - // this.data.connectInstrument.iot_versions.substring(0, 2) == - // versioninfo.v1 - // ) { - // if ( - // Number(this.data.connectInstrument.iot_versions.substring(2, 4)) > - // Number(versioninfo.v2) - // ) { - // this.setData({ - // params: "offlineDialog", - // offlineDialogType: 2, - // otaDeviceName: "设备", - // }); - // } else if ( - // Number(this.data.connectInstrument.iot_versions.substring(2, 4)) == - // Number(versioninfo.v2) - // ) { - // if ( - // Number(this.data.connectInstrument.iot_versions.substring(4, 6)) > - // Number(versioninfo.v3) - // ) { - // this.setData({ - // params: "offlineDialog", - // offlineDialogType: 2, - // otaDeviceName: "设备", - // }); - // } else { - // this.setData({ - // params: "", - // }); - // go( - // "/pages/nursing/nursing?id=&iid=" + - // app.globalData.bindid + - // `&type=fr200&version=${versioninfo?.version}` - // ); - // } - // } else { - // this.setData({ - // params: "", - // }); - // go( - // "/pages/nursing/nursing?id=&iid=" + - // app.globalData.bindid + - // `&type=fr200&version=${versioninfo?.version}` - // ); - // } - // } else { - // this.setData({ - // params: "", - // }); - // go( - // "/pages/nursing/nursing?id=&iid=" + - // app.globalData.bindid + - // `&type=fr200&version=${versioninfo?.version}` - // ); - // } - // } }; connectionClose = async (data) => { diff --git a/src/pages/iotCarePlan/components/ModeList/index.less b/src/pages/iotCarePlan/components/ModeList/index.less index 73a4d67..a0ade45 100644 --- a/src/pages/iotCarePlan/components/ModeList/index.less +++ b/src/pages/iotCarePlan/components/ModeList/index.less @@ -58,6 +58,7 @@ margin-right: 20rpx; } .mode-item { + position: relative; display: flex; min-width: 140rpx; height: 160rpx; @@ -70,6 +71,25 @@ transition: all 0.3s; flex-shrink: 0; overflow: hidden; + .new { + display: none; + position: absolute; + left: 0; + top: 0; + width: 48rpx; + height: 24rpx; + font-size: 16rpx; + font-family: PingFang SC; + font-weight: bold; + color: #ffffff; + text-align: center; + background-color: #eb5858; + border-radius: 15rpx 10rpx 12rpx 0rpx; + z-index: 20; + } + .is-new { + display: block; + } .mode-info { min-width: 140rpx; padding-left: 10rpx; diff --git a/src/pages/iotCarePlan/components/ModeList/index.tsx b/src/pages/iotCarePlan/components/ModeList/index.tsx index 8bce79c..b5ce7a6 100644 --- a/src/pages/iotCarePlan/components/ModeList/index.tsx +++ b/src/pages/iotCarePlan/components/ModeList/index.tsx @@ -69,6 +69,13 @@ function Index({ ModeList, ModeType, ActiveModeItem, onEmit }: Props) { })} onClick={visorClick.bind(this, item)} > + + NEW + {item.modeName} {item.modeTime} @@ -113,6 +120,13 @@ function Index({ ModeList, ModeType, ActiveModeItem, onEmit }: Props) { "mode-item-active": activeID === item.id, })} > + + NEW + {item.modeName} {item.modeTime} @@ -158,6 +172,13 @@ function Index({ ModeList, ModeType, ActiveModeItem, onEmit }: Props) { "mode-item-active": activeID === item.id, })} > + + NEW + {item.modeName} {item.modeTime} diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index b249e03..8bbe126 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -15,12 +15,11 @@ import { /*** redux ***/ import { connect } from "react-redux"; /*** redux end ***/ -// import log from "@/utils/log"; -// log.info("123456info", 123456, { sdfasdf: 123 }); /* 公共组件 */ import Navbar from "@/components/navbar/navbar"; import PopupCountdown from "@/components/popup/popup-countdown"; +import PopupStepTips from "@/components/popup/popup-step-tips"; /* 公共组件 END */ /* 本页组件 */ @@ -33,12 +32,163 @@ import { getStorageSync, setStorageSync } from "@/utils/traoAPI"; import { InstrumentInfo } from "@/utils/Interface"; import "./iotCarePlan.less"; +// import log from "@/utils/log"; +// log.info("123456info", 123456, { sdfasdf: 123 }); + +import { + notifyBLECharacteristicValueChange, + sendCommand, +} from "@/utils/bluetoothWXAPI"; +import { + deviceCommandSamples, + bleCommandSamples, +} from "@/components/bluetoot/connection/test"; +import { + minSecToS, + s_to_h, + s_to_hs, + s_to_s, + isNeedToUpdate, +} from "@/utils/util"; +import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; +import commandMap from "@/utils/commandMap"; +const deviceToolKitInstanceWE100 = new DeviceToolKitWE100("WE100", "M01"); +const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200"); + +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; + +const WORK_MODE_NAME_ENUM = { + POWERFULSOOTHING: "powerfulSoothing", + STABILITY: "Stability", + BRIGHTEN: "Brighten", + FIRMSKIN: "FirmSkin", + MaskCustom: "MaskCustom", + BrightenStand: "BrightenStand", + FirmSkinStand: "FirmSkinStand", + SmallpoxSoothingPro: "SmallpoxSoothingPro", + SmallpoxSoothing: "SmallpoxSoothing", + MixNursePro: "MixNursePro", + MixNurse: "MixNurse", + ScalpCare: "ScalpCare", +}; + +const WORK_MODE_ENGLISH_NAME = { + 6: "powerfulSoothing", + 7: "Stability", + 8: "Brighten", + 9: "FirmSkin", + MaskCustom: "MaskCustom", + 21: "BrightenStand", + 22: "FirmSkinStand", + 23: "SmallpoxSoothingPro", + 24: "SmallpoxSoothing", + 25: "MixNursePro", + 26: "MixNurse", + 27: "ScalpCare", +}; + +const WORK_MODE_TYPE = { + powerfulSoothing: 6, + Stability: 7, + Brighten: 8, + FirmSkin: 9, + MaskCustom: "MaskCustom", + BrightenStand: 21, + FirmSkinStand: 22, + SmallpoxSoothingPro: 23, + SmallpoxSoothing: 24, + MixNursePro: 25, + MixNurse: 26, + ScalpCare: 27, +}; + +const MODE_WORKING_ENUM = { + STANDBY: "standby", + WORKING: "working", + PAUSE: "pause", + END: "end", +}; + +const countDownTime = { + powerfulSoothing: 6, + Stability: 4, + Brighten: 4, + FirmSkin: 4, + MaskCustom: 6, + BrightenStand: 6, + FirmSkinStand: 6, + SmallpoxSoothingPro: 6, + SmallpoxSoothing: 4, + MixNursePro: 6, + MixNurse: 4, + ScalpCare: 6, +}; + +const keepCheckingLink = true; +const deviceSyncData = { + totalWorkingMinutes: 0, + totalWorkingSeconds: 0, +}; +let deviceToolKitInstance = deviceToolKitInstanceWE100; // we100 + class IotCarePlan extends Component { constructor(props) { super(props); this.state = { name: "iotCarePlan", + + /** 连接设备 */ + hasVersion: false, // 是否已查询到版本号 + curDeviceInfo: {}, // 当前设备信息 + basicModeList: [], //模式列表 + modelActiveIndex: 0, //模式下标 + sliderProgress: 22, + isStandStatus: false, //支架开启状态 + workStatus: "", //工作状态 + Electricity: 0, //fr200电量 + matrixElectricity: 0, //matrix电量 + workMode: "", //当前模式 + showCombinationModeDialog: false, // 组合模式弹窗 + combinationModeList: [], // 可选的组合模式列表 + combinationList: [], // 选择的组合模式列表 + combinationModeInfo: {}, // 组合模式缓存的信息 + originCombinationList: [], // 原始组合模式列表 + originCombinationModeInfo: {}, // 原始组合模式缓存的信息 + isCurrentModeCombination: false, // 当前模式是否是组合模式 + isSendModeCombination: false, // 当前是否在发送组合模式 + gear: { gear: 1 }, + currentShowDialog: "", + // countdown: 3, // 倒计时 + step: 1, // 1:选择模式并播放视频, 2:护理中 + facialMaskConnectStatus: 0, // 面膜连接状态 + errorTips: "", + checkedMaskVersion: false, //是否检查过固件版本了 + askedOta: 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, // 是否设置过 -- 代码逻辑使用 + setCustomSuc: false, // 是否设置成功 -- 页面需要用于判断 + }, // 自定义模式判断 + + /** 连接设备 End */ + isMusicPlay: false, // 声音播放状态 + isShowStepTips: false, // 是否显示介绍步骤弹窗 isConnectionBlutoot: false, // 是否已连接蓝牙 isShowNurse: false, // 是否开始并显示护理 isStopNurse: false, // 是否暂停护理 @@ -48,6 +198,7 @@ class IotCarePlan extends Component { ModeList: [], ModeType: "all", // all visor cabin yimeish ActiveModeItem: {}, // 当前选中模式 + ModeStepIndex: 0, // 当前护理功效步骤:每个步骤时间不定,所以时间另外计算,根据步骤显示 // 倒计时 isShowCountdown: false, @@ -55,7 +206,12 @@ class IotCarePlan extends Component { }; } - async onLoad() {} + async onLoad() { + // 保持屏幕常亮 + Taro.setKeepScreenOn({ + keepScreenOn: true, + }); + } componentDidMount() {} componentWillUnmount() {} @@ -71,8 +227,54 @@ class IotCarePlan extends Component { if (objStr) { let info = JSON.parse(objStr); this.GetModeList(info.id); + console.log("info"); + + // 如果不存在设备模式值,则判断为首次进入,弹窗提示 + let isFirstEntry = getStorageSync("isFirstEntry_" + info.model); + if (!isFirstEntry) { + // this.setState({ isShowStepTips: true }); + } } + + // 初始化蓝牙 + this.init(); + } + + async init() { + // 查询自定义设备指令 + const queryInstructionParams = { + commandType: "InfoQuery", + infoQueryType: "customModeInfo", + }; + let commandBuffer = deviceToolKitInstance.toBleCommand( + queryInstructionParams as any + ); + sendCommand({ value: commandBuffer }).then((res) => { + console.log( + "查询自定义组合模式指令发送成功 参数为=>", + queryInstructionParams + ); + }); + Taro.onBLEConnectionStateChange(this.listener); + await this.notifyBLECharacteristicValueChange(); } + listener = (res) => { + console.log("listener res", res); + if (res?.connected) return; + Taro.offBLECharacteristicValueChange((res) => { + console.log("offBLECharacteristicValueChange", res); + }); + clearTimeout(loadingTipsTimer); + // this.setState({ + // startSettingCountDown: false + // }) + console.log(commandMap.WL200Command, "监听到蓝牙断开, 打开断开提示"); + // 显示蓝牙断开弹窗 + // this.setState({ + // workStatus: "", + // currentShowDialog: "connection_break", + // }); + }; GetModeList = async (id) => { let params = { @@ -133,10 +335,329 @@ class IotCarePlan extends Component { this.setState({ isShowNurse: true }); }; + closeStepTips = (data) => { + if (data.isLocal) { + setStorageSync("isFirstEntry_" + this.state.ActiveModeItem.model, true); // 关闭首次进入弹窗 + } + this.setState({ isShowStepTips: false }); + }; + + /** 蓝牙相关 */ + + notifyBLECharacteristicValueChange = () => { + console.log("notifyBLECharacteristicValueChange deviceInfo 参数为=>"); + const bluetoothInfo = this.props.bluetoothInfo; + notifyBLECharacteristicValueChange({ + deviceId: bluetoothInfo.deviceId, + servicesuuid: bluetoothInfo.servicesuuid, + characteristicsuuid1: bluetoothInfo.characteristicsuuid1, + characteristicsuuid0: bluetoothInfo.characteristicsuuid0, + }).then((res) => { + Taro.onBLECharacteristicValueChange((value) => { + const jsonStatus: any = deviceToolKitInstance.toJsonStatus(value.value); + // end 和 endWork 都是护理结束, endWork不关机, end 关机, 对小程序而已处理流程都一样 + console.log( + "onBLECharacteristicValueChange jsonStatus => ", + jsonStatus + ); + // log.info(commandMap.WL200Command, 'onBLECharacteristicValueChange jsonStatus =>', jsonStatus); + if (!jsonStatus || jsonStatus == null) { + return; + } + if (jsonStatus.workStatus && jsonStatus.workStatus == "endWork") { + jsonStatus.workStatus = "end"; + console.log(jsonStatus.workStatus, "改了状态了"); + } + switch (jsonStatus?.commandType) { + //蓝牙相关指令 + case "BleMatch": + switch (jsonStatus.bleCommandType) { + //如果设备配对链接发送配对码的时候,设备应答小程序配对码是否正确。 + case "SendMatchCode": + if (jsonStatus.matchedSuccess) { + // msg('配对成功') + console.log("配对成功"); + // log.info(commandMap.WL200Command, "配对成功"); + } + break; + //附属设备状态主动上报,这种指令是主机主动上报某个附属设备断开或者连上了 + case "BleStatusSync": + switch (jsonStatus.connectMessage?.deviceName) { + case "WL200": + if (jsonStatus.connectMessage?.connectType == "CONNECTED") { + // if ( + // !that.data.customModeData.setCustomSuc && + // !that.data.customModeData.hadSetCustom + // ) { + // that.setCustomMaskData(); + // } + // that.setData({ + // facialMaskConnectStatus: 1, + // }); + // this.deviceToolKitInstance = deviceToolKitInstanceWL200; + // console.log( + // "checkedMaskVersion", + // this.data.checkedMaskVersion + // ); + // if (!this.data.checkedMaskVersion) { + // this.checkVersion(); + // } + } else { + // deviceToolKitInstance = deviceToolKitInstanceWE100; + // // TODO 护理中(step==2)时, 如果断开, 可能需要暂停 + // that.setData({ + // facialMaskConnectStatus: 0, + // }); + } + break; + case "Stand": + // that.setData({ + // isStandStatus: + // jsonStatus.connectMessage?.connectType == "CONNECTED", + // }); + + 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("支架是否链接", isStandDevice); + console.log("面罩是否链接", isConnectedMask); + //这里bug 先注释掉 bug是拔掉支架之后启动面罩工作就会一直弹 + // let { basicModeList, modelActiveIndex } = that.data; + // if ( + // that.data.step == 2 && + // !isStandDevice && + // basicModeList[modelActiveIndex].isStandMode && + // !that.data.hadShowBreakTips + // ) { + // that.data.hadShowBreakTips = true; + // that.onPauseTap(); + // that.standVideoContext.seek(0); + // // that.showTips('检测到支架未连接成功,请确认面罩开机后与支架连接,并接通支架电源'); + // that.showTips( + // `检测到${that.data.deviceChineseName.WL200Stand}未连接成功,请确认面罩开机后与${that.data.deviceChineseName.WL200Stand}连接,并接通${that.data.deviceChineseName.WL200Stand}电源` + // ); + } + // 连上面罩后, 设置自定义模式 -- 不在这里设置自定义模式 + // if ( + // isConnectedMask && + // !that.data.customModeData.setCustomSuc && + // !that.data.customModeData.hadSetCustom && + // basicModeList[modelActiveIndex].isCustomMode + // ) { + // that.setCustomMaskData(); + // } + // 连上面罩后, 获取仪器记录, 与缓存信息对比, + // if ( + // isConnectedMask && + // !this.state.hadGotInstrumentHistoryData + // ) { + // // 如果不延时, 无法获取到仪器状态 + // const queryDeviceArrayBuffer = + // deviceToolKitInstance.toBleCommand( + // bleCommandSamples.queryDeviceStatus as any + // ); + // console.log("发送查询设备指令"); + // sendCommand({ + // value: queryDeviceArrayBuffer, + // }); + // // 打开ota页面需要关闭 + // // that.data.getInstrumentHistoryDataTimer = setTimeout(() => { + // // that.getInstrumentHistoryData(); + // // }, 3000); + // } + // this.setData({ + // isStandStatus: isStandDevice, + // facialMaskConnectStatus: `${isConnectedMask ? 1 : 0}`, + // // currentTime: this.data.standInfo.currentTime + // }); + break; + + case "DeviceControl": + console.log("设备控制,给设备发送指令", jsonStatus); + if ( + jsonStatus.responseStatus == "OK" && + this.state.isSendModeCombination + ) { + // 发送启动指令 + // this.startCombinationMode() + // const totalTime = this.data.combinationList.reduce((total, item) => { + // return total + minSecToS(item.time) + // }, 0) + // that.setData({ + // showCombinationModeDialog: false, + // combinationModeInfo: { + // time: s_to_hs(totalTime), + // seconds: totalTime, + // }, + // modelActiveIndex: -1, + // currentTime: s_to_hs(totalTime), + // isCurrentModeCombination: true, + // isSendModeCombination: false, + // }) + } + break; + //设备主动上报给小程序的指令 一般是工作状态改变 + case "DeviceStatusSync": + console.log( + "设备主动上报给小程序的指令 一般是工作状态改变", + jsonStatus + ); + this.setState({ + Electricity: jsonStatus.battery, + matrixElectricity: jsonStatus.matrixBattery, + workStatus: jsonStatus.workStatus, + workMode: jsonStatus?.workMode, + }); + // that.setData({ + // fr200Electricity: jsonStatus.battery, + // matrixElectricity: jsonStatus.matrixBattery, + // workStatus: jsonStatus.workStatus, + // workMode: jsonStatus?.workMode, + // }); + // 判断是否在step == 2(护理中) + // if ( + // that.data.step == 2 && + // jsonStatus.workStatus != MODE_WORKING_ENUM.END + // ) { + // that.updateDeviceSyncData({ + // totalWorkingMinutes: jsonStatus.totalWorkingMinutes, + // totalWorkingSeconds: jsonStatus.totalWorkingSeconds, + // }); + // } + // if (jsonStatus.workMode && that.data.step == 2) { + // const { basicModeList, modelActiveIndex } = that.data; + // const item = basicModeList[modelActiveIndex]; + // if ( + // jsonStatus.workMode != WORK_MODE_ENGLISH_NAME[item.model_type] + // ) { + // clearTimeout(loadingTipsTimer); + // that.data.startSettingCountDown = false; + // } + // } + // // 我忘记了为啥要这样传参... 埋坑了... + // this.judgementWorkStatus( + // jsonStatus.workStatus, + // jsonStatus.workMode, + // jsonStatus + // ); + if (jsonStatus.workMode && this.state.step == 2) { + // this.judgementModel(jsonStatus.workMode); + // that.data.startSettingCountDown = false; + } + break; + //设备信息查询返回 + case "InfoQuery": + switch (jsonStatus.infoQueryType) { + case "customModeSet": + console.log( + "responseStatus=====>", + jsonStatus.responseStatus, + 1 + ); + console.log( + "responseStatus=====>", + jsonStatus.responseStatus, + 2 + ); + console.log( + "responseStatus=====>", + jsonStatus.responseStatus, + 3 + ); + // if (jsonStatus.responseStatus == "OK") { + // that.setData({ + // "customModeData.setCustomSuc": true, + // }); + // console.log("设置成功自定义模式"); + // } else { + // that.setData({ + // "customModeData.hadSetCustom": false, + // "customModeData.setCustomSuc": false, + // }); + // } + break; + case "customModeInfo": + break; + case "versionInfo": + if (jsonStatus.versionNo) { + // 清理计时器 + // if (checkVersionTimeout) clearTimeout(checkVersionTimeout); + // if (that.data.hasVersion) return; + // that.setData({ + // hasVersion: true, + // }); + // this.checkOta(jsonStatus.versionNo); + } + break; + // 当前报告 + case "currentMaskReportInfo": + console.log("currentMaskReportInfo", jsonStatus); + // if (!that.data.hadCheckReport) { + // that.data.hadCheckReport = true; + // that.checkInstrumentRecord(jsonStatus); + // } else { + // that.setWL200NursingHistory(jsonStatus); + // } + + break; + default: + break; + } + break; + // default: + // break; + } + }); + + /** + * 延迟500毫秒获取附属设备状态 + */ + const querySubDeviceArrayBuffer = deviceToolKitInstance.toBleCommand({ + ...bleCommandSamples.querySubDevice, + queryType: "WL200", + } as any); + setTimeout(() => { + console.log("发送查询指令"); + sendCommand({ + value: querySubDeviceArrayBuffer, + }); + }, 500); + + /** + * 延迟500毫秒获取设备电量 + */ + const queryDeviceArrayBuffer = deviceToolKitInstance.toBleCommand( + bleCommandSamples.queryDeviceStatus as any + ); + setTimeout(() => { + console.log("发送查询设备指令"); + sendCommand({ + value: queryDeviceArrayBuffer, + }); + }, 500); + }); + }; + render() { let { name, isMusicPlay, + isShowStepTips, ModeList, ModeType, isConnectionBlutoot, @@ -145,11 +666,24 @@ class IotCarePlan extends Component { ActiveModeItem, isShowCountdown, countdown, + ModeStepIndex, + Electricity, } = this.state; return ( + {ActiveModeItem.openSourceData && ( + + )} + @@ -176,10 +710,25 @@ class IotCarePlan extends Component { /> )} - {/* { isShowNurse && } */} + {isShowNurse && ( + + {isStopNurse ? ( + + ) : ( + + )} + + )} @@ -189,9 +738,38 @@ class IotCarePlan extends Component { WE200电量: - - - + {Electricity === 4 && ( + + + + + + + )} + {Electricity === 3 && ( + + + + + + + )} + {Electricity === 2 && ( + + + + + + + )} + {Electricity === 1 && ( + + + + + + + )} @@ -227,7 +805,7 @@ class IotCarePlan extends Component { } const mapStateToProps = (state) => ({ - // background: state.navigation.background, + bluetoothInfo: state.deviceInfo.bluetoothInfo, }); const mapDispatchToProps = (dispatch) => ({ // userRefresh(data) {