设备模式对接

master
blak-kong 2 years ago
parent 3350094fd6
commit b9563350a5

@ -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 {

@ -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<any, any> {
e.stopPropagation();
};
onTouchMove = () => {
return true;
};
render() {
let {
title,
@ -101,6 +113,7 @@ export default class PopupAlert extends Component<any, any> {
className={classnames("common-box", {
"common-large": isLarge,
})}
catchMove
>
{title && (
<View
@ -112,7 +125,8 @@ export default class PopupAlert extends Component<any, any> {
</View>
)}
<View className="common-popup-content-box">
<View
<ScrollView
scrollY
className={classnames("common-popup-content", {
"text-left": textAlgin === "left",
"text-right": textAlgin === "right",
@ -120,7 +134,7 @@ export default class PopupAlert extends Component<any, any> {
})}
>
{content}
</View>
</ScrollView>
</View>
{type === "3" && (

@ -47,7 +47,6 @@ export default class PopupClock extends Component<any, any> {
onConfirm = () => {
let { type } = this.props;
this.props.confirm();
};
@ -75,7 +74,7 @@ export default class PopupClock extends Component<any, any> {
show={isShow}
closeOnClickOverlay={false}
round
overlayStyle='width: 100vw;padding: 0;'
overlayStyle="width: 100vw;padding: 0;"
onClick={this.onClickStop}
>
{/* <View
@ -84,7 +83,7 @@ export default class PopupClock extends Component<any, any> {
></View> */}
{isClose && (
<View
className='at-icon at-icon-close common-close'
className="at-icon at-icon-close common-close"
onClick={this.onClose}
></View>
)}
@ -92,6 +91,7 @@ export default class PopupClock extends Component<any, any> {
className={classnames("common-box", {
"common-large": isLarge,
})}
catchMove
>
{title && (
<View
@ -102,7 +102,7 @@ export default class PopupClock extends Component<any, any> {
{title}
</View>
)}
<View className='common-popup-content-box'>
<View className="common-popup-content-box">
<View
className={classnames("common-popup-content", {
"text-left": textAlgin === "left",
@ -115,18 +115,18 @@ export default class PopupClock extends Component<any, any> {
</View>
{type === "3" && (
<View className='type3btn' onClick={this.onConfirm}>
<View className="type3btn" onClick={this.onConfirm}>
<Image
className='checked'
className="checked"
src={require("../../img/welcome/checked.png")}
></Image>
<Text className='text'></Text>
<Text className="text"></Text>
</View>
)}
{type !== "3" && (
<View className='alert-popup-btns'>
<Button className='alert-popup-btn' onClick={this.onConfirm}>
<View className="alert-popup-btns">
<Button className="alert-popup-btn" onClick={this.onConfirm}>
{confirmButtonText}
</Button>
</View>

@ -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<any, any> {
isShow,
isClose,
isLarge,
type,
} = this.props;
return (
<Block>
@ -94,6 +92,7 @@ export default class PopupConfirm extends Component<any, any> {
className={classnames("common-box", {
"common-large": isLarge,
})}
catchMove
>
{title && (
<View

@ -63,7 +63,7 @@ export default class PopupCountdown extends Component<any, any> {
onClick={this.onClose}
></View>
)}
<View className={classnames("common-box", "countdown-box")}>
<View className={classnames("common-box", "countdown-box")} catchMove>
<View
className={classnames("common-popup-title", "countdown-title")}
>

@ -85,6 +85,7 @@ export default class PopupDrawer extends Component<any, any> {
"common-big-large"
)}
style="margin: auto;"
catchMove
>
<View
className={classnames("common-popup-title", "drawer-popup-title")}

@ -115,7 +115,7 @@ export default class PopupPrivacy extends Component<any, any> {
></View>
)}
<View className={classnames("common-box", "common-large")}>
<View className={classnames("common-box", "common-large")} catchMove>
<View className="common-popup-title"></View>
<View className="common-popup-content-box">
<View className="common-popup-content">

@ -781,80 +781,82 @@ class Index extends Component<any, any> {
return (
<Block>
<PopupAlert
isShow={isNotRegister}
isClose={true}
title="提示"
content="暂未授权注册,请点击注册"
confirmButtonText="确定"
textAlgin="center"
type="1"
close={this.closeAlert}
confirm={this.closeAlert}
/>
<PopupAlert
isShow={isDev}
title="提示"
content="页面正在开发中"
confirmButtonText="确定"
textAlgin="center"
close={this.closeDev}
confirm={this.closeDev}
/>
<PopupPrivacy
isShow={isShowPrivacyPopup}
closePrivacy={this.closePrivacy}
/>
<View catchMove>
<PopupAlert
isShow={isNotRegister}
isClose={true}
title="提示"
content="暂未授权注册,请点击注册"
confirmButtonText="确定"
textAlgin="center"
type="1"
close={this.closeAlert}
confirm={this.closeAlert}
/>
<PopupAlert
isShow={isDev}
title="提示"
content="页面正在开发中"
confirmButtonText="确定"
textAlgin="center"
close={this.closeDev}
confirm={this.closeDev}
/>
<PopupPrivacy
isShow={isShowPrivacyPopup}
closePrivacy={this.closePrivacy}
/>
<PopupBinding
type={instrumentInfo.bindingStatus}
isShow={isVisibleBinding}
isRegisterBoolean={isRegisterBoolean}
isExchangeBinding={isExchangeBinding}
data={instrumentInfo}
close={this.closeBinding}
confirm={this.confirmBinding}
/>
<PopupAlert
isShow={isBindingError}
title="提示"
content={
<Block>
<View></View>
<View></View>
</Block>
}
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
></PopupAlert>
<PopupAlert
isShow={isBeforeBinding}
title="提示"
content="您选择的仪器有误,请重新确认选择"
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBeforeBindClose}
confirm={this.onBeforeBindConfirm}
></PopupAlert>
{/* <PopupPrivacyTest
<PopupBinding
type={instrumentInfo.bindingStatus}
isShow={isVisibleBinding}
isRegisterBoolean={isRegisterBoolean}
isExchangeBinding={isExchangeBinding}
data={instrumentInfo}
close={this.closeBinding}
confirm={this.confirmBinding}
/>
<PopupAlert
isShow={isBindingError}
title="提示"
content={
<Block>
<View></View>
<View></View>
</Block>
}
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBindErrorClose}
confirm={this.onBindErrorConfirm}
></PopupAlert>
<PopupAlert
isShow={isBeforeBinding}
title="提示"
content="您选择的仪器有误,请重新确认选择"
confirmButtonText="知道了"
textAlgin="center"
isClose={false}
close={this.onBeforeBindClose}
confirm={this.onBeforeBindConfirm}
></PopupAlert>
{/* <PopupPrivacyTest
closePrivacy={this.closePrivacy.bind(this)}
initData={this.initData.bind(this)}
></PopupPrivacyTest> */}
<PopupSiteSwiper
isShow={isShowSiteSwiper}
siteData={sitePopupList}
size="middle"
confirmButtonText="确定"
textAlgin="center"
close={this.closeSiteSwiper}
confirm={this.closeSiteSwiper}
/>
<PopupSiteSwiper
isShow={isShowSiteSwiper}
siteData={sitePopupList}
size="middle"
confirmButtonText="确定"
textAlgin="center"
close={this.closeSiteSwiper}
confirm={this.closeSiteSwiper}
/>
</View>
{isConnectShow && (
<ConnectionBluetoot

@ -359,51 +359,53 @@ class IntegralList extends Component<any, any> {
} = this.state;
return (
<Block>
<PopupAlert
myClassName="integral"
isLarge={true}
isClose={true}
isShow={isIntegral}
title="积分规则"
content={<RichText nodes={nodes} />}
confirmButtonText="我知道了"
textAlgin="center"
close={this.integralPopupClose}
confirm={this.integralPopupClose}
/>
<PopupAlert
myClassName="officialAccount"
isLarge={true}
isClose={true}
isShow={isOfficialAccount}
title="过期积分提醒"
type="3"
content={
// <View style={{ height: "700rpx" }}> // 删除测试阶段标签后需改回700rpx
<View style={{ height: "750rpx" }}>
<Image
style={{
width: "100%",
height: "600rpx",
// backgroundColor: "#666",
}}
showMenuByLongpress={true} // 长按识别二维码
src={require("../../img/qrcode-test.jpg")}
mode="aspectFit"
/>
<View style={{ marginTop: "20rpx" }}>
</View>
<View style={{ marginTop: "10rpx", color: "#666" }}>
(广)
<View catchMove>
<PopupAlert
myClassName="integral"
isLarge={true}
isClose={true}
isShow={isIntegral}
title="积分规则"
content={<RichText nodes={nodes} />}
confirmButtonText="我知道了"
textAlgin="center"
close={this.integralPopupClose}
confirm={this.integralPopupClose}
/>
<PopupAlert
myClassName="officialAccount"
isLarge={true}
isClose={true}
isShow={isOfficialAccount}
title="过期积分提醒"
type="3"
content={
// <View style={{ height: "700rpx" }}> // 删除测试阶段标签后需改回700rpx
<View style={{ height: "750rpx" }}>
<Image
style={{
width: "100%",
height: "600rpx",
// backgroundColor: "#666",
}}
showMenuByLongpress={true} // 长按识别二维码
src={require("../../img/qrcode-test.jpg")}
mode="aspectFit"
/>
<View style={{ marginTop: "20rpx" }}>
</View>
<View style={{ marginTop: "10rpx", color: "#666" }}>
(广)
</View>
</View>
</View>
}
confirmButtonText="我知道了"
textAlgin="center"
close={this.officialPopupClose}
confirm={this.officialPopupConfirm}
/>
}
confirmButtonText="我知道了"
textAlgin="center"
close={this.officialPopupClose}
confirm={this.officialPopupConfirm}
/>
</View>
<Navbar titleSlot="我的积分" isBack={true} />

@ -49,25 +49,25 @@ function Index({
</Block>
)}
{isShowNurse && (
<View className="switch-btn-box" onClick={onSwitchChange}>
<View className="btn-item border-right">
<View className="switch-btn-box">
<View className="btn-item border-right" onClick={onSwitchChange}>
{isStopNurse ? (
<Block>
<Image
className="btn-icon"
src={require("../../../../img/iot/pause_nurse.png")}
src={require("../../../../img/iot/start_nurse.png")}
mode="aspectFill"
/>
<Text className="btn-text"></Text>
<Text className="btn-text"></Text>
</Block>
) : (
<Block>
<Image
className="btn-icon"
src={require("../../../../img/iot/start_nurse.png")}
src={require("../../../../img/iot/pause_nurse.png")}
mode="aspectFill"
/>
<Text className="btn-text"></Text>
<Text className="btn-text"></Text>
</Block>
)}
</View>

@ -105,6 +105,7 @@ function Index({
</View>
);
})}
<View style="width:120rpx;min-width:120rpx;height:40rpx;display:flex"></View>
</View>
</ScrollView>
)}

@ -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<any, any> {
super(props);
this.state = {
name: "iotCarePlan",
title: "美容仪名字",
title: "美容仪名字", // 页面标题
instrument: "WE200",
/** 连接设备 */
@ -170,10 +172,12 @@ class IotCarePlan extends Component<any, any> {
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<any, any> {
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<any, any> {
/** 连接设备 End */
// isMuted: false, // 视频是否静音
isMusicPlay: false, // 声音播放状态
isShowStepTips: false, // 是否显示介绍步骤弹窗
isConnectionBlutoot: false, // 是否已连接蓝牙
isShowNurse: false, // 是否开始并显示护理
@ -225,11 +222,10 @@ class IotCarePlan extends Component<any, any> {
// 倒计时
isShowCountdown: false, // 倒计时弹窗
countdown: 6,
// startSettingCountDown: false, // 是否开始倒计时
countdown: 3,
// 音乐
// innerAudioContext: null,
// 是否结束护理
isEndCarePlan: false,
// 最后执行步骤位置
endPlace: "",
@ -271,8 +267,17 @@ class IotCarePlan extends Component<any, any> {
}
}
// 开发者工具
const platform = Taro.getSystemInfoSync().platform;
//开发者工具
if (platform !== "devtools") {
// 初始化蓝牙
this.init();
}
// 初始化蓝牙
this.init();
// this.init();
}
async init() {
@ -293,7 +298,7 @@ class IotCarePlan extends Component<any, any> {
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<any, any> {
}
};
changeMusicStatus = () => {
let { isMusicPlay } = this.state;
this.setState({ isMusicPlay: !isMusicPlay });
};
/** 开始护理按钮:点击开始,页面进行到下一步 */
onStartNurse = async () => {
this.stepNext();
@ -355,17 +355,47 @@ class IotCarePlan extends Component<any, any> {
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<any, any> {
// //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<any, any> {
// 如果设备配对链接发送配对码的时候,设备应答小程序配对码是否正确。
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<any, any> {
!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<any, any> {
// 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<any, any> {
) {
// 发送启动指令
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<any, any> {
checkVersion = () => {
this.sendCheckVersion();
this.setState({
checkedMaskVersion: true,
isCheckedMaskVersion: true,
});
if (checkVersionTimeout) clearTimeout(checkVersionTimeout);
checkVersionTimeout = setTimeout(() => {
@ -758,7 +803,7 @@ class IotCarePlan extends Component<any, any> {
);
if (isNeedToUpdateBl) {
this.setState({
askedOta: true,
isAskedOta: true,
// currentShowDialog: 'offlineDialog',
});
// this.confirmOta();
@ -791,18 +836,17 @@ class IotCarePlan extends Component<any, any> {
}
};
// 待完善以后更新页面状态的方法在这里执行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<any, any> {
}
}
// 设备上报不同状态
/**
*
* params
*/
judgementWorkStatus(nWorkStatus, nWorkMode, jsonStatus) {
const {
workStatus,
@ -852,7 +899,6 @@ class IotCarePlan extends Component<any, any> {
} = 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<any, any> {
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<any, any> {
title: "正在护理",
isStopNurse: false,
});
// 处理音乐
// this.musicStatusChange();
}
// else if (modeItem?.isStandMode) {
// 支架模式也使用gif图, 不需要播放视频了, 所以注释
// that.onPlayTap();
// }
this.setState({
isShowCountdown: false,
@ -949,7 +984,7 @@ class IotCarePlan extends Component<any, any> {
this.setState({
isShowCountdown: false,
});
if (modeItem.isStandMode) {
if (ActiveModeItem.isCabinMode) {
// this.onPauseTap();
this.setState({
title: "暂停护理",
@ -967,7 +1002,7 @@ class IotCarePlan extends Component<any, any> {
// 获取仪器运行时间,更新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<any, any> {
});
}
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<any, any> {
* 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<any, any> {
}
}
// 设置自定义模式数据
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<any, any> {
}
// 工作状态
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<any, any> {
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<any, any> {
// 如果是强效舒缓,需要判断是否连接支架
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<any, any> {
}, 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<any, any> {
// 删除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<any, any> {
}, 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<any, any> {
ModeStepIndex,
Electricity,
errorTips,
isEndCarePlan,
} = this.state;
return (
<Block>
<Navbar titleSlot={title} isBack={true} />
<PopupCountdown isShow={isShowCountdown} countdown={countdown} />
{ActiveModeItem.openSourceData && (
<PopupStepTips
isShow={isShowStepTips}
<View catchMove>
<PopupCountdown isShow={isShowCountdown} countdown={countdown} />
<PopupConfirm
isLarge={true}
title={"" + "准备中"}
confirmButtonText="开始护理"
data={ActiveModeItem.openSourceData}
close={this.closeStepTips}
isShow={isEndCarePlan}
isClose={true}
title="提示"
content="是否结束护理"
textAlgin="center"
cancelButtonText="取消"
confirmButtonText="确定"
close={this.cancelEndBtn}
confirm={this.confirmEndBtn}
/>
)}
{ActiveModeItem.openSourceData && (
<PopupStepTips
isShow={isShowStepTips}
isLarge={true}
title={"" + "准备中"}
confirmButtonText="开始护理"
data={ActiveModeItem.openSourceData}
close={this.closeStepTips}
/>
)}
</View>
<View>
<View className="iot-main">
<View className="banner-box">
<View className="music-btn" onClick={this.changeMusicStatus}>
{isMusicPlay ? (
<Image
className="music-btn_icon"
src={require("../../img/iot/volume_icon.png")}
mode="aspectFill"
/>
) : (
<Image
className="music-btn_icon"
src={require("../../img/iot/mute_icon.png")}
mode="aspectFill"
/>
)}
</View>
<View>
{!isShowNurse && (
<Video
className="video-or-image"
src={ActiveModeItem.modeVideo}
muted={isMusicPlay}
/>
)}
@ -1540,12 +1560,22 @@ class IotCarePlan extends Component<any, any> {
<View className="item">
<Text>WE200</Text>
<View className="value flex aitems">
{Electricity === 5 && (
<Block>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
</Block>
)}
{Electricity === 4 && (
<Block>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v2 battery_icon"></View>
</Block>
)}
{Electricity === 3 && (
@ -1554,6 +1584,7 @@ class IotCarePlan extends Component<any, any> {
<View className="v1 battery_icon"></View>
<View className="v1 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
</Block>
)}
{Electricity === 2 && (
@ -1562,6 +1593,7 @@ class IotCarePlan extends Component<any, any> {
<View className="v1 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
</Block>
)}
{Electricity === 1 && (
@ -1570,14 +1602,16 @@ class IotCarePlan extends Component<any, any> {
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
</Block>
)}
{Electricity === 1 && (
{Electricity === 0 && (
<Block>
<View className="v3 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
<View className="v2 battery_icon"></View>
</Block>
)}
</View>

@ -205,17 +205,20 @@ class User extends Component<any, any> {
close={this.closeDev}
confirm={this.closeDev}
/> */}
<PopupAlert
isShow={isNotRegister}
isClose={true}
title="提示"
content="暂未授权注册,请点击注册"
confirmButtonText="确定"
textAlgin="center"
type="1"
close={this.closeRegisterAlert}
confirm={this.closeRegisterAlert}
/>
<View catchMove>
<PopupAlert
isShow={isNotRegister}
isClose={true}
title="提示"
content="暂未授权注册,请点击注册"
confirmButtonText="确定"
textAlgin="center"
type="1"
close={this.closeRegisterAlert}
confirm={this.closeRegisterAlert}
/>
</View>
<Navbar transparent={true}></Navbar>
<View className="user_bg_card">
<Image
@ -400,28 +403,29 @@ class User extends Component<any, any> {
</View>
</View>
<PopupDrawer
isShow={isShowCustomerService}
isClose={true}
title="留言反馈"
content={
<Block>
<Textarea
className="service-textarea"
maxlength={100}
showCount={true}
placeholder="请在此处写下您的意见与反馈"
placeholderStyle="font-weight: 400;font-size:28rpx;"
onInput={this.onInputTextarea}
></Textarea>
</Block>
}
confirmButtonText="提交"
textAlgin="left"
close={this.closeCustomerService}
confirm={this.confirmCustomerService}
/>
{/* <Toast_ /> */}
<View catchMove>
<PopupDrawer
isShow={isShowCustomerService}
isClose={true}
title="留言反馈"
content={
<Block>
<Textarea
className="service-textarea"
maxlength={100}
showCount={true}
placeholder="请在此处写下您的意见与反馈"
placeholderStyle="font-weight: 400;font-size:28rpx;"
onInput={this.onInputTextarea}
></Textarea>
</Block>
}
confirmButtonText="提交"
textAlgin="left"
close={this.closeCustomerService}
confirm={this.confirmCustomerService}
/>
</View>
</Block>
);
}

@ -12,6 +12,12 @@ const deviceInfoReducer = createSlice({
characteristicsuuid1: "",
characteristicId: "",
},
OtaDeviceTypeEnum: {
WL200: "WL200",
WE100: "WE100",
FACIALMASK: "FacialMask",
STAND: "Stand",
},
},
reducers: {
setDeviceInfo(state, { payload }) {

@ -616,6 +616,7 @@ const getTimeCode = () => {
return value;
};
/**
* 是否需要版本升级
* @param currentVersionNo
* @param latestVersionNo
* @returns needToUpdate

Loading…
Cancel
Save