简单完成光照到护理记录提交

master
blak-kong 2 years ago
parent 08f0c2ac84
commit 0af51bc474

@ -597,7 +597,6 @@ class Index extends Component<any, any> {
Taro.getSystemInfo({
success: (res) => {
console.log("getSystemInfo", res);
this.setState({ isConnectShow: true });
let { locationEnabled, locationAuthorized, bluetoothEnabled } = res;
if (!locationEnabled || !locationAuthorized) {
showModal({
@ -615,7 +614,7 @@ class Index extends Component<any, any> {
});
} else {
// 打开连接弹窗
this.setState({ isConnectShow: true });
this.connectionOpen();
}
},
});
@ -628,7 +627,8 @@ class Index extends Component<any, any> {
async pairingChange(e) {
console.log("===epairingChange===》", e);
go("/pages/iotCarePlan/iotCarePlan"); // 画页面直接跳转
// return;
this.connectionClose();
}
async goIot() {
@ -743,14 +743,15 @@ class Index extends Component<any, any> {
console.log(offlinelist);
};
connectionClose = async (data) => {
console.log("connectionClose", data);
this.setState({ isConnectShow: false });
connectionOpen = async () => {
this.setState({ isConnectShow: true });
};
connectionConfirm = async (data) => {
console.log("connectionConfirm", data);
connectionClose = async () => {
this.setState({ isConnectShow: false });
};
connectionConfirm = async () => {
this.connectionClose();
};
/*蓝牙 END*/
render() {

@ -0,0 +1,119 @@
import Taro from "@tarojs/taro";
import classnames from "classnames";
import { Block, View, Image, Text } from "@tarojs/components";
import { useState, useEffect } from "react";
// import "./index.less";
interface Props {
Electricity: any;
matrixElectricity: any;
facialMaskConnectStatus: any;
}
function Index({
Electricity,
matrixElectricity,
facialMaskConnectStatus,
}: Props) {
return (
<Block>
<View className="electricity-box">
<View className="item">
<View className="label">WE200 :</View>
<View className="value flex aitems">
{matrixElectricity >= 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>
</Block>
)}
{matrixElectricity === 3 && (
<Block>
<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>
)}
{matrixElectricity === 2 && (
<Block>
<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>
)}
{matrixElectricity === 1 && (
<Block>
<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>
)}
{matrixElectricity === 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>
</Block>
)}
</View>
</View>
{facialMaskConnectStatus === 1 && (
<Block>
<View className="item">
<View className="label"> :</View>
<View className="value flex aitems">
{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>
</Block>
)}
{Electricity === 3 && (
<Block>
<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 === 2 && (
<Block>
<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 === 1 && (
<Block>
<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 === 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>
</Block>
)}
</View>
</View>
</Block>
)}
</View>
</Block>
);
}
export default Index;

@ -5,51 +5,55 @@ import { useState, useEffect } from "react";
import "./index.less";
interface Props {
ModeID: any;
activeModeID: any;
ModeList: any;
ModeType: string; // all visor cabin yimeish
ActiveModeItem: any;
isShowNurse: boolean; // 是否已进入护理详情页
isPop: boolean; // 是否弹窗
onEmit: Function; // 每次点击item回调事件和数据给父组件
onEmitShowAll: Function; // 打开弹窗按钮
}
function Index({
isShowNurse,
isPop,
ModeList,
ModeType,
isShowNurse,
ActiveModeItem,
ModeID,
activeModeID,
onEmit,
onEmitShowAll,
}: Props) {
let VisorList = ModeList.filter((item) => item.modeClass === 1); // 面罩模式
let CabinList = ModeList.filter((item) => item.modeClass === 2); // 舱体模式
let YimeishList = ModeList.filter((item) => item.modeClass === 3); // 医美术后
const [ModeID, setModeID] = useState<any>("mode_" + ActiveModeItem.id);
const [activeID, setActiveID] = useState<any>(ActiveModeItem.id);
console.log("ModeID", ModeID, activeID);
// const [ModeID, setModeID] = useState<any>("mode_" + ActiveModeItem.id);
// const [activeModeID, setactiveModeID] = useState<any>(ActiveModeItem.id);
const yimeishClick = (item) => {
onEmit(item);
setActiveID(item.id);
setModeID("mode_" + item.id);
};
const cabinClick = (item) => {
onEmit(item);
setActiveID(item.id);
setModeID("mode_" + item.id);
};
const visorClick = (item) => {
onEmit(item);
setActiveID(item.id);
setModeID("mode_" + item.id);
};
const showAll = () => {
onEmitShowAll();
};
return (
<Block>
<View className="mode-list-main">
{ModeList.length > 0 && isShowNurse && (
<View className="change-all-mode-btn">
{!isPop && ModeList.length > 0 && isShowNurse && (
<View className="change-all-mode-btn" onClick={showAll}>
<View className="title"></View>
<Image
className="icon"
@ -58,7 +62,7 @@ function Index({
</View>
)}
{VisorList.length > 0 &&
(ModeType === "all" || ModeType === "visor") && (
(ModeType === "all" || ModeType === "visor" || isPop) && (
<ScrollView
className="mode-list-box"
scroll-x="true"
@ -72,7 +76,7 @@ function Index({
key={"visor_" + index}
id={"visor_" + item.id}
className={classnames("mode-item", {
"mode-item-active": activeID === item.id,
"mode-item-active": activeModeID === item.id,
})}
onClick={visorClick.bind(this, item)}
>
@ -85,19 +89,21 @@ function Index({
</View>
<View className="mode-info">
<View className="mode-info-title">{item.modeName}</View>
<View className="mode-info-time">{item.modeTime}</View>
<View className="mode-info-time">
{item.modeTimeStr}
</View>
<View
className={classnames("mode-info-select", {
"is-select": activeID === item.id,
"is-select": activeModeID === item.id,
})}
>
{activeID === item.id && (
{activeModeID === item.id && (
<View className="mode-info-select-point"></View>
)}
</View>
</View>
{activeID === item.id && (
{activeModeID === item.id && (
<View className="mode-pic">
<Image src={item.modeBanner} mode="aspectFill" />
</View>
@ -110,7 +116,7 @@ function Index({
</ScrollView>
)}
{CabinList.length > 0 &&
(ModeType === "all" || ModeType === "cabin") && (
(ModeType === "all" || ModeType === "cabin" || isPop) && (
<ScrollView
className="mode-list-box"
scrollX={true}
@ -125,7 +131,7 @@ function Index({
id={"cabin_" + item.id}
onClick={cabinClick.bind(this, item)}
className={classnames("mode-item", {
"mode-item-active": activeID === item.id,
"mode-item-active": activeModeID === item.id,
})}
>
<View
@ -137,19 +143,21 @@ function Index({
</View>
<View className="mode-info">
<View className="mode-info-title">{item.modeName}</View>
<View className="mode-info-time">{item.modeTime}</View>
<View className="mode-info-time">
{item.modeTimeStr}
</View>
<View
className={classnames("mode-info-select", {
"is-select": activeID === item.id,
"is-select": activeModeID === item.id,
})}
>
{activeID === item.id && (
{activeModeID === item.id && (
<View className="mode-info-select-point"></View>
)}
</View>
</View>
{activeID === item.id && (
{activeModeID === item.id && (
<View className="mode-pic">
<Image src={item.modeBanner} mode="aspectFill" />
</View>
@ -162,7 +170,7 @@ function Index({
)}
{YimeishList.length > 0 &&
(ModeType === "all" || ModeType === "yimeish") && (
(ModeType === "all" || ModeType === "yimeish" || isPop) && (
<ScrollView
className="mode-list-box"
scrollX={true}
@ -177,7 +185,7 @@ function Index({
id={"yimeish_" + item.id}
onClick={yimeishClick.bind(this, item)}
className={classnames("mode-item", {
"mode-item-active": activeID === item.id,
"mode-item-active": activeModeID === item.id,
})}
>
<View
@ -189,19 +197,21 @@ function Index({
</View>
<View className="mode-info">
<View className="mode-info-title">{item.modeName}</View>
<View className="mode-info-time">{item.modeTime}</View>
<View className="mode-info-time">
{item.modeTimeStr}
</View>
<View
className={classnames("mode-info-select", {
"is-select": activeID === item.id,
"is-select": activeModeID === item.id,
})}
>
{activeID === item.id && (
{activeModeID === item.id && (
<View className="mode-info-select-point"></View>
)}
</View>
</View>
{activeID === item.id && (
{activeModeID === item.id && (
<View className="mode-pic">
<Image src={item.modeBanner} mode="aspectFill" />
</View>

@ -30,23 +30,46 @@
.video-or-image {
display: block;
width: 690rpx;
height: 690rpx;
height: 640rpx;
border-radius: 30rpx;
}
.iot-device {
width: 690rpx;
height: 100rpx;
height: 150rpx;
display: flex;
align-items: center;
.item {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
justify-content: center;
.device-time {
font-size: 26rpx;
color: #000;
font-weight: 400;
.time {
font-size: 30rpx;
font-weight: 800;
}
}
.line {
width: 1rpx;
height: 50rpx;
background: #dddddd;
margin-left: 69rpx;
margin-right: 60rpx;
}
.border-right {
border-right: 1px solid #ddd;
.electricity-box {
display: flex;
flex-direction: column;
.item {
display: flex;
align-items: center;
justify-content: left;
height: 50rpx;
.label {
width: 154rpx;
font-size: 26rpx;
color: #000;
margin-right: 14rpx;
}
}
}
}
.msg-tips {

@ -25,6 +25,7 @@ import PopupConfirm from "@/components/popup/popup-confirm";
/* 公共组件 END */
/* 本页组件 */
import ElectricityView from "./components/ElectricityView/index";
import ModeListView from "./components/ModeList/index";
import ModeContent from "./components/ModeContent/index";
import Footer from "./components/Footer";
@ -46,12 +47,10 @@ import {
bleCommandSamples,
} from "@/components/bluetoot/connection/test";
import {
hourMinSecToS,
minSecToS,
s_to_s,
s_to_m,
minSecToS,
s_to_ms,
s_to_hms,
isNeedToUpdate,
} from "@/utils/util";
import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100";
@ -59,6 +58,7 @@ import commandMap from "@/utils/commandMap";
const deviceToolKitInstanceWE100 = new DeviceToolKitWE100("WE100", "M01");
const deviceToolKitInstanceWL200 = new DeviceToolKitWE100("WE100", "WL200");
let currentTimeTimer: any = null; // 当前项目时间定时器
let CountdownTimer: any = null;
let timer: any = null;
let checkVersionTimeout: any = null;
@ -84,22 +84,6 @@ const WORK_MODE_NAME_ENUM = {
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",
};
// 组合模式:分别对应的是哪几个模式类型
// 黄光590nm
// 红光630nm
@ -121,21 +105,6 @@ const WORK_MODE_Chinese_NAME = {
: "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", // 工作
@ -159,7 +128,6 @@ let CountDownTime = {
ScalpCare: 6,
};
let KeepCheckingLink = true;
let DeviceSyncData = {
totalWorkingMinutes: 0,
totalWorkingSeconds: 0,
@ -173,6 +141,10 @@ class IotCarePlan extends Component<any, any> {
name: "iotCarePlan",
title: "美容仪名字", // 页面标题
instrument: "WE200",
currentDevice: {
name: "",
model: "",
}, // 当前设备
/** 连接设备 */
hasVersion: false, // 是否已查询到版本号
@ -183,18 +155,10 @@ class IotCarePlan extends Component<any, any> {
isStandStatus: false, // 支架开启状态(支架就是舱体)
facialMaskConnectStatus: 0, // 面罩连接状态 0未连接 1已连接
workStatus: "", // 工作状态
Electricity: 0, // WL200电量
matrixElectricity: 0, // matrix电量
Electricity: 4, // WL200电量
matrixElectricity: 4, // WE200发箍电量
workMode: "", //当前模式
showCombinationModeDialog: false, // 组合模式弹窗
combinationModeList: [], // 可选的组合模式列表
combinationList: [], // 选择的组合模式列表
combinationModeInfo: {}, // 组合模式缓存的信息
originCombinationList: [], // 原始组合模式列表
originCombinationModeInfo: {}, // 原始组合模式缓存的信息
isCurrentModeCombination: false, // 当前模式是否是组合模式
isSendModeCombination: false, // 当前是否在发送组合模式
gear: { gear: 1 },
currentShowDialog: "",
@ -222,10 +186,14 @@ class IotCarePlan extends Component<any, any> {
errorTips: "", // 错误提示
// 模式列表
isSwitchActiveMode: false, // 是否显示弹窗切换模式
ModeList: [],
ModeType: "all", // all visor面罩 cabin舱体 yimeish医美
modeClass: "", // 1面罩 2舱体 3医美
ActiveModeItem: {}, // 当前选中模式
SwitchActiveModeItem: {}, // 切换选中模式
ModeID: "mode_",
activeModeID: "",
ModeStepIndex: 0, // 当前护理功效步骤:每个步骤时间不定,所以时间另外计算,根据步骤显示
// 倒计时
@ -237,7 +205,7 @@ class IotCarePlan extends Component<any, any> {
// 最后执行步骤位置
endPlace: "",
currentTime: "00:01:00",
currentTime: "01:00",
};
}
@ -266,6 +234,11 @@ class IotCarePlan extends Component<any, any> {
let objStr = getStorageSync("instrument_detail");
if (objStr) {
let info = JSON.parse(objStr);
this.setState({
currentDevice: info,
});
this.GetModeList(info.id);
console.log("info");
@ -367,7 +340,8 @@ class IotCarePlan extends Component<any, any> {
if (isStopNurse) {
// 开始光照逻辑
this.showCountdownFun(3, () => {});
this.handleWorkStatus(false, MODE_WORKING_ENUM.WORKING);
// this.handleWorkStatus(false, MODE_WORKING_ENUM.WORKING);
this.onNursingTap();
} else {
// 暂停光照逻辑
this.handleWorkStatus(false, MODE_WORKING_ENUM.PAUSE);
@ -406,9 +380,48 @@ class IotCarePlan extends Component<any, any> {
}, 0);
}
/** 选中护理模式 */
modeCurrentFun = async (data) => {
console.log("modeCurrentFun", data);
this.setState({ ActiveModeItem: data });
this.setState({
ActiveModeItem: data,
activeModeID: data.id,
ModeID: "mode_" + data.id,
});
};
/** 切换护理模式 */
switchModeCurrentFun = async (data) => {
this.setState({
SwitchActiveModeItem: data,
activeModeID: data.id,
ModeID: "mode_" + data.id,
});
};
// 打开模式切换弹窗
openModeSwitch = () => {
console.log("openModeSwitch");
this.setState({
isSwitchActiveMode: true,
});
};
// 取消并关闭切换护理模式弹窗
cancelModeSwitchBtn = () => {
this.setState({
isSwitchActiveMode: false,
});
};
// 弹窗确定切换护理模式
confirmModeSwitchBtn = () => {
let { SwitchActiveModeItem } = this.state;
let modeArray = ["all", "visor", "cabin", "yimeish"];
this.setState({
ModeType: modeArray[SwitchActiveModeItem.modeClass],
});
setTimeout(() => {
this.setState({
ActiveModeItem: SwitchActiveModeItem,
});
this.cancelModeSwitchBtn();
}, 100);
};
stepNext = () => {
@ -421,6 +434,7 @@ class IotCarePlan extends Component<any, any> {
isStopNurse: true,
isStandStatus: this.state.ActiveModeItem.isCabinMode === 1,
workStatus: "pause",
step: 2,
});
this.handleWorkStatus(false, MODE_WORKING_ENUM.STANDBY);
@ -509,21 +523,9 @@ class IotCarePlan extends Component<any, any> {
}
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(
// `检测到舱体未连接成功,请确认面罩开机后与舱体连接,并接通舱体电源`
// );
if (isConnectedMask) {
this.setState({ isConnectionBlutoot: true });
}
// 连上面罩后, 设置自定义模式 -- 不在这里设置自定义模式
if (
@ -615,7 +617,7 @@ class IotCarePlan extends Component<any, any> {
);
this.setState({
Electricity: jsonStatus.battery,
fr200Electricity: jsonStatus.battery,
// fr200Electricity: jsonStatus.battery,
matrixElectricity: jsonStatus.matrixBattery,
workStatus: jsonStatus.workStatus,
workMode: jsonStatus?.workMode,
@ -640,12 +642,13 @@ class IotCarePlan extends Component<any, any> {
);
}
if (jsonStatus.workMode && this.state.step == 2) {
if (
jsonStatus.workMode === MODE_WORKING_ENUM.WORKING &&
this.state.step == 2
) {
const { ActiveModeItem } = this.state;
const item = ActiveModeItem;
if (
jsonStatus.workMode !== WORK_MODE_ENGLISH_NAME[item.model_type]
) {
if (jsonStatus.workMode !== item.modeType) {
clearTimeout(loadingTipsTimer);
this.setState({
isShowCountdown: false,
@ -832,31 +835,54 @@ class IotCarePlan extends Component<any, any> {
renderDeviceStatus = {
renderWorkTime: (jsonStatus) => {
const { totalWorkingMinutes, totalWorkingSeconds } = DeviceSyncData;
const { ActiveModeItem, currentTime } = this.state;
let { ActiveModeItem, currentTime } = this.state;
const totalTime = totalWorkingMinutes * 60 + totalWorkingSeconds;
console.log("仪器上报的已经运行的总秒数", totalTime);
console.log("时间校准频率默认5秒一次", TIME_CALIBRATION_FREQUENCY);
//对比仪器上报运行的总秒数 和小程序页面运行的已经运行的总秒数,如果不一致就进行校准
const currentScene = ActiveModeItem; // 获取当前的场景
let sceneTime = hourMinSecToS(currentScene.modeTime); // 场景时间
let sceneTime = minSecToS(currentScene.modeTimeStr); // 场景时间
console.log("场景时间 sceneTime", sceneTime);
console.log("当前显示时间 currentTime", currentTime);
console.log("设备运行时间 totalTime", totalTime);
console.log(" this.state.step", this.state.step);
console.log("sceneTime > totalTime", sceneTime > totalTime);
// 更新界面倒计时
// clearInterval(currentTimeTimer);
// currentTimeTimer = setInterval(() => {
// let currentSeconds = minSecToS(this.state.currentTime);
// if (currentSeconds > 1) {
// this.setState({
// currentTime: s_to_ms(--currentSeconds),
// });
// }
// }, 1000);
this.resetTimer();
console.log(
"sceneTime > totalTime &&this.state.step == 2 &&this.state.facialMaskConnectStatus == 1",
sceneTime > totalTime &&
this.state.step == 2 &&
this.state.facialMaskConnectStatus == 1
);
const timeRemaining = sceneTime - hourMinSecToS(currentTime); // 小程序上已运行的总秒数
if (
Math.abs(timeRemaining - totalTime) >= 0 &&
sceneTime > totalTime &&
this.state.step == 2 &&
this.state.facialMaskConnectStatus == 1
) {
this.resetTimer();
// 界面倒计时同步设备时间
const t = sceneTime - totalTime; // 场景时间 - 已运行时间 = 剩余时间
let { ActiveModeItem } = this.state;
ActiveModeItem.seconds = t; //修复时间跳变的问题
this.setState({
currentTime: s_to_hms(t),
ActiveModeItem,
currentTime: s_to_ms(t),
});
} else {
this.setState({
currentTime: "00:00",
endPlace: "report",
});
}
if (Math.abs(timeRemaining - totalTime) < 0) {
this.judgementWorkStatus(
MODE_WORKING_ENUM.END,
jsonStatus.workMode,
@ -922,9 +948,9 @@ class IotCarePlan extends Component<any, any> {
// fix: 启动非支架模式倒计时时连上支架仪器的状态变为standby
opts.step = 1;
}
if (loadingTipsTimer) {
clearTimeout(loadingTipsTimer);
}
// if (loadingTipsTimer) {
// clearTimeout(loadingTipsTimer);
// }
// 本来用于更新时间的,但是产生了 ID1000367 bug先移除
// if (nowModeItem) {
// opts.currentTime = nowModeItem.time;
@ -980,6 +1006,7 @@ class IotCarePlan extends Component<any, any> {
});
},
pause: () => {
clearInterval(currentTimeTimer);
this.setState({
isShowCountdown: false,
});
@ -997,18 +1024,22 @@ class IotCarePlan extends Component<any, any> {
// that.onPauseTap();
// }
// 已进入了报告阶段, 防止重复进入, 主要防止在手动点击结束护理接收到仪器消息
if (this.state.endPlace) return;
// 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下
const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus;
if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) {
const sceneTime = hourMinSecToS(ActiveModeItem.modeTime); // 模式的总时长
const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长
const timeRemaining = sceneTime - runTime; // 剩余未运行时间
this.setState({
currentTime: s_to_hms(timeRemaining),
});
}
console.log("END 护理结束");
clearInterval(currentTimeTimer);
this.endnursing(true);
// if (this.state.endPlace) return;
// 获取仪器运行时间,更新currentTime, 判断仪器返回时间正常的情况下
// const { totalWorkingSeconds, totalWorkingMinutes } = jsonStatus;
// if (totalWorkingSeconds != 0 || totalWorkingMinutes != 0) {
// const sceneTime = minSecToS(ActiveModeItem.modeTimeStr); // 模式的总时长
// const runTime = totalWorkingMinutes * 60 + totalWorkingSeconds; //仪器运行时长
// const timeRemaining = sceneTime - runTime; // 剩余未运行时间
// this.setState({
// currentTime: s_to_ms(timeRemaining),
// });
// }
// this.rmWL200NursingHistory(this.state.WL200NursingHistory);
},
};
@ -1023,34 +1054,7 @@ 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);
// // }
this.endNurseFun();
};
/**
@ -1060,7 +1064,7 @@ class IotCarePlan extends Component<any, any> {
endnursing = (isAuto) => {
if (isAuto == true) {
// 仪器自动上报完成, 直接上报并跳转报告页
clearInterval(timer);
clearInterval(currentTimeTimer);
const isEnough = this.checkTime();
if (isEnough && !this.state.endPlace) {
this.setState({
@ -1068,7 +1072,6 @@ class IotCarePlan extends Component<any, any> {
});
this.saveNurseReport(true, "endnursing");
}
// this.handleTimeCheck(that.endNurseFun)
} else {
// 手动点击结束, 弹出弹窗, 看看是否需要结束
this.onEndPlan();
@ -1123,54 +1126,33 @@ class IotCarePlan extends Component<any, any> {
}
// 重置计时器
resetTimer() {
resetTimer = () => {
// 切换模式后, 需要重新设置计时器, 以防进行中的计时器
timer && clearInterval(timer);
timer = setInterval(() => {
currentTimeTimer && clearInterval(currentTimeTimer);
currentTimeTimer = setInterval(() => {
if (
this.state.workStatus == MODE_WORKING_ENUM.WORKING &&
this.state.step == 2 &&
this.state.facialMaskConnectStatus == 1
) {
/*if(that.data.workMode !== WORK_MODE_NAME_ENUM.POWERFULSOOTHING){*/
let currentSeconds;
if (this.state.isCurrentModeCombination) {
// 组合模式逻辑
// that.data.combinationModeInfo.seconds -= 1;
// that.setData({
// currentTime: s_to_ms(that.data.combinationModeInfo.seconds)
// })
// currentSeconds = that.data.combinationModeInfo.seconds
let currentSeconds = minSecToS(this.state.currentTime);
if (currentSeconds > 1) {
this.setState({
currentTime: s_to_ms(--currentSeconds),
});
} else {
const { ActiveModeItem, currentTime } = this.state;
currentSeconds = hourMinSecToS(currentTime);
clearInterval(currentTimeTimer);
this.setState({
currentTime: s_to_hms(--currentSeconds),
currentTime: "00:00",
endPlace: "report",
});
console.log(ActiveModeItem.isCustomMode);
if (ActiveModeItem.isCustomMode) {
this.setCustomModeData();
}
}
if (currentSeconds <= 0) {
clearInterval(timer);
// 统一接收仪器结束指令
// that.data.endPlace = 'report';
// that.saveNurseReport(true, 'setTimer');
this.saveNurseReport(true, "setTimer"); // 保存护理计划,并且结束
}
/*} else {
that.data.standInfo.seconds -= 1;
that.setData({ currentTime: s_to_ms(that.data.standInfo.seconds) })
if(that.data.standInfo.seconds <= 0){
clearInterval(timer);
this.showNurseSuccessDialog()
}
}*/
}
}, 1000);
}
};
// 工作状态
// 检测并控制工作状态
handleWorkStatus = (isBtnClick: boolean, workStatus) => {
const { facialMaskConnectStatus, isStandStatus, ActiveModeItem } =
this.state;
@ -1291,42 +1273,47 @@ class IotCarePlan extends Component<any, any> {
// 结束护理?
endNurseFun() {
// this.handleWorkStatus(false, "end");
setTimeout(() => {
//TODO IOS关闭蓝牙太快导致关机指令没发出去暂时这么解决
const isEnough = this.checkTime();
if (!isEnough) {
Taro.showModal({
title: "提示",
content: "护理时间不足,请重新连接护理",
showCancel: false,
success: (res) => {
if (!this.state.endPlace || this.state.endPlace !== "report") {
// back();
console.log("back");
}
// this.state.innerAudioContext.destroy();
Taro.closeBluetoothAdapter();
},
});
} else {
if (!this.state.endPlace || this.state.endPlace !== "report") {
// back();
console.log("back");
}
// this.state.innerAudioContext.destroy();
Taro.closeBluetoothAdapter();
}
}, 500);
this.handleWorkStatus(false, "end");
this.PostNursingLogClock();
// setTimeout(() => {
// //TODO IOS关闭蓝牙太快导致关机指令没发出去暂时这么解决
// const isEnough = this.checkTime();
// if (!isEnough) {
// Taro.showModal({
// title: "提示",
// content: "护理时间不足,请重新连接护理",
// showCancel: false,
// success: (res) => {
// if (!this.state.endPlace || this.state.endPlace !== "report") {
// // back();
// console.log("back");
// }
// // this.state.innerAudioContext.destroy();
// Taro.closeBluetoothAdapter();
// },
// });
// } else {
// if (!this.state.endPlace || this.state.endPlace !== "report") {
// // back();
// console.log("back");
// }
// // this.state.innerAudioContext.destroy();
// Taro.closeBluetoothAdapter();
// }
// }, 500);
}
// 检查时间是否达标
checkTime() {
const { curDeviceInfo, ActiveModeItem } = this.state;
const { currentDevice, ActiveModeItem } = this.state;
const currentScene = ActiveModeItem;
let sceneTime = hourMinSecToS(currentScene.modeTime);
const timeRemaining = sceneTime - hourMinSecToS(this.state.currentTime);
if (timeRemaining >= Number(curDeviceInfo?.nursingTime) * 60) {
let sceneTime = minSecToS(currentScene.modeTimeStr);
const timeRemaining = sceneTime - minSecToS(this.state.currentTime); // 当前模式已运行时间
let nursingTimeStr = currentDevice?.nursingTimeStr;
let nursingTime = nursingTimeStr ? minSecToS(nursingTimeStr) : 60; // 设备生成护理记录至少需要运行时间
if (timeRemaining >= nursingTime) {
return true;
} else {
return false;
@ -1412,6 +1399,7 @@ class IotCarePlan extends Component<any, any> {
});
};
confirmEndBtn = () => {
this.endNurseFun();
this.cancelEndBtn();
};
cancelEndBtn = () => {
@ -1421,6 +1409,22 @@ class IotCarePlan extends Component<any, any> {
};
/** 弹窗 END*/
/** 护理记录 */
// apiClock
PostNursingLogClock = async () => {
let { currentDevice, ActiveModeItem } = this.state;
let params = {
instrumentId: currentDevice.id,
instrumentName: currentDevice.name,
modeId: ActiveModeItem.id,
modeName: ActiveModeItem.modeName,
nursingTime: ActiveModeItem.modeTime,
};
let res: any = await InstrumentInfo.apiNursingLog.addLog(params);
console.log("PostNursingLogClock", res);
};
/** 护理记录 End */
render() {
let {
name,
@ -1432,13 +1436,19 @@ class IotCarePlan extends Component<any, any> {
isShowNurse,
isStopNurse,
ActiveModeItem,
SwitchActiveModeItem,
isSwitchActiveMode,
ModeID,
activeModeID,
isShowCountdown,
countdown,
ModeStepIndex,
Electricity,
matrixElectricity,
errorTips,
isEndCarePlan,
currentTime,
facialMaskConnectStatus,
} = this.state;
return (
<Block>
@ -1458,6 +1468,31 @@ class IotCarePlan extends Component<any, any> {
close={this.cancelEndBtn}
confirm={this.confirmEndBtn}
/>
<PopupConfirm
isLarge={true}
isShow={isSwitchActiveMode}
isClose={true}
title="护理模式切换"
content={
<ModeListView
ModeID={ModeID}
activeModeID={activeModeID}
isPop={true}
isShowNurse={isShowNurse}
ModeList={ModeList}
ModeType={ModeType}
ActiveModeItem={SwitchActiveModeItem}
onEmit={this.switchModeCurrentFun}
onEmitShowAll={this.openModeSwitch}
/>
}
textAlgin="center"
cancelButtonText="取消"
confirmButtonText="确定"
close={this.cancelModeSwitchBtn}
confirm={this.confirmModeSwitchBtn}
/>
{ActiveModeItem.openSourceData && (
<PopupStepTips
isShow={isShowStepTips}
@ -1515,64 +1550,32 @@ class IotCarePlan extends Component<any, any> {
</View>
<View className="iot-device">
<View className="item border-right">
<Text>{currentTime}</Text>
</View>
<View className="item">
<Text>WE200</Text>
<View className="value flex aitems">
{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>
</Block>
)}
{Electricity === 3 && (
<Block>
<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 === 2 && (
<Block>
<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 === 1 && (
<Block>
<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 === 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>
</Block>
)}
</View>
<Text className="device-time">
<Text className="time">{currentTime}</Text>
</Text>
</View>
<View className="line" />
<ElectricityView
Electricity={Electricity}
matrixElectricity={matrixElectricity}
facialMaskConnectStatus={facialMaskConnectStatus}
/>
</View>
</View>
{ModeList.length > 0 && (
<ModeListView
isPop={false}
isShowNurse={isShowNurse}
ModeList={ModeList}
ModeType={ModeType}
isShowNurse={isShowNurse}
ModeID={ModeID}
activeModeID={activeModeID}
ActiveModeItem={ActiveModeItem}
onEmit={this.modeCurrentFun}
onEmitShowAll={this.openModeSwitch}
/>
)}

Loading…
Cancel
Save