diff --git a/src/components/popup/popup-status.less b/src/components/popup/popup-status.less new file mode 100644 index 0000000..5675648 --- /dev/null +++ b/src/components/popup/popup-status.less @@ -0,0 +1,14 @@ +.popup-status-title { + margin-bottom: 50rpx; +} +.popup-status-box { + width: 120rpx; + height: 120rpx; + border-radius: 50%; + margin: 0 auto; + margin-bottom: 50rpx; + .popup-status { + width: 100%; + height: 100%; + } +} diff --git a/src/components/popup/popup-status.tsx b/src/components/popup/popup-status.tsx new file mode 100644 index 0000000..23fb1e0 --- /dev/null +++ b/src/components/popup/popup-status.tsx @@ -0,0 +1,159 @@ +import classnames from "classnames"; +import { Component } from "react"; + +import { + Block, + View, + Image, + Text, + Button, + PageMeta, + ScrollView, +} from "@tarojs/components"; + +import { Popup } from "@antmjs/vantui"; + +import "./popup.less"; +import "./popup-status.less"; + +/** props + * isLarge 是否大尺寸 + * isShow 是否显示 + * isClose 右上角关闭图标 + * title 弹窗标题 + * content 弹窗内容 + * confirmButtonText 确定按钮 + * textAlgin 文本对齐 left right center + * type: 1注册 + * @confirm 关闭回调 + */ +export default class PopupStatus extends Component { + constructor(props) { + super(props); + this.state = { + name: "图标状态提示组件", + }; + } + + async onLoad() {} + componentDidMount() {} + + componentWillUnmount() {} + + componentDidShow() {} + + componentDidHide() {} + + async initData() {} + + onClose = () => { + this.props.close(); + }; + + onConfirm = () => { + this.props.confirm(); + }; + + onClickStop = (e) => { + e.stopPropagation(); + }; + + onTouchMove = () => { + return true; + }; + + render() { + let { + title, + content, + confirmButtonText, + textAlgin, + isShow, + isClose, + isBtn, + isLarge, + myClassName, + zIndex, + type, + } = this.props; + if (!zIndex) zIndex = 10001; + return ( + + + + {isClose && ( + + )} + + {title && ( + + {title} + + )} + + + + {type === "success" && ( + + )} + {type === "error" && ( + + )} + + {content} + + + + {isBtn && ( + + + + )} + + + + ); + } +} diff --git a/src/img/qrcode-test.jpg b/src/img/qrcode-test.jpg index 7d3741d..66e7fab 100644 Binary files a/src/img/qrcode-test.jpg and b/src/img/qrcode-test.jpg differ diff --git a/src/img/status/error.png b/src/img/status/error.png new file mode 100644 index 0000000..53295da Binary files /dev/null and b/src/img/status/error.png differ diff --git a/src/img/status/success.png b/src/img/status/success.png new file mode 100644 index 0000000..fb0a084 Binary files /dev/null and b/src/img/status/success.png differ diff --git a/src/pages/face_report/face_report.tsx b/src/pages/face_report/face_report.tsx index 420f567..cf0937b 100644 --- a/src/pages/face_report/face_report.tsx +++ b/src/pages/face_report/face_report.tsx @@ -1,7 +1,7 @@ import Taro from "@tarojs/taro"; import classnames from "classnames"; import { Component, PropsWithChildren, useEffect, useState } from "react"; -import { Progress } from '@antmjs/vantui' +import { Progress } from "@antmjs/vantui"; import { Block, View, Text, Image, Input, Button } from "@tarojs/components"; import { date, getdates, previewImage } from "../../utils/util"; @@ -9,7 +9,7 @@ import { date, getdates, previewImage } from "../../utils/util"; /** 自定义组件 **/ import Navbar from "../../components/navbar/navbar"; import PopupAlert from "../../components/popup/popup-alert"; -import { InstrumentInfo } from '../../utils/Interface' +import { InstrumentInfo } from "../../utils/Interface"; /** 自定义组件 **/ import "./face_report.less"; @@ -21,54 +21,53 @@ export default class Index extends Component { name: "template模板页", statistics: {}, recordList: [], - recordData: {} + recordData: {}, }; } - componentDidMount() { } + componentDidMount() {} - componentWillUnmount() { } + componentWillUnmount() {} // 查询用户护理记录的当月统计信息 async getStatistics(id) { - let data = {} + let data = {}; if (id != null) { - data['instrumentId'] = id + data["instrumentId"] = id; } - let res = await InstrumentInfo.apiNursingLog.getStatistics(data) + let res = await InstrumentInfo.apiNursingLog.getStatistics(data); if (res.data.code === 200) { - this.setState({ statistics: res.data.data }) + this.setState({ statistics: res.data.data }); } } async getRecord(id, recordId) { - let data = {} + let data = {}; if (id != null) { - data['instrumentId'] = id + data["instrumentId"] = id; } - let res = await InstrumentInfo.apiNursingLog.getRecord(data) + let res = await InstrumentInfo.apiNursingLog.getRecord(data); if (res.data.code === 200) { - res.data.rows.map(item => { - item.nursingTime = this.getTime(item.nursingTime) - item.createTime = getdates(item.createTime).replace(/-/g, '.') + res.data.rows.map((item) => { + item.nursingTime = this.getTime(item.nursingTime); + item.createTime = getdates(item.createTime).replace(/-/g, "."); if (item.id == recordId) { - this.setState({ recordData: item }) + this.setState({ recordData: item }); } - }) - this.setState({ recordList: res.data.rows.filter(item => item.id != recordId) }) - + }); + this.setState({ + recordList: res.data.rows.filter((item) => item.id != recordId), + }); } } getRouteId() { const searchParams = new URLSearchParams(window.location.search); - const id = searchParams.get('id'); - const recordId = searchParams.get('recordId'); - this.getStatistics(id) - this.getRecord(id, recordId) + const id = searchParams.get("id"); + const recordId = searchParams.get("recordId"); + this.getStatistics(id); + this.getRecord(id, recordId); console.log(recordId); - - } getTime(time) { const hour = time.slice(0, 2); @@ -76,188 +75,145 @@ export default class Index extends Component { const second = time.slice(6, 8); if (hour > 0) { - return hour + '时' + minute + '分' + second + '秒' + return hour + "时" + minute + "分" + second + "秒"; } else { - return minute + '分' + second + '秒' + return minute + "分" + second + "秒"; } } async onLoad() { - this.getRouteId() + this.getRouteId(); } - componentDidShow() { } + componentDidShow() {} - componentDidHide() { } + componentDidHide() {} - async initData() { } + async initData() {} render() { let { name, statistics, recordList, recordData } = this.state; return ( - - {/* {{reportData.curDate}} */} - {/* */} - - {/* */} - - - 3 - - - {/* - 本月护理天数 - */} - - 本月护理天数 - - {/* {{options.type == 'led' ? '本月光照天数': '本月促渗天数'}} */} - 本月光照天数 - - - - 28:00 - {/* {{options.type == 'led' ? '本月护理时间': '本月促渗时间'}} */} - 本月护理时间 - - {/* */} - {/* */} - - + + + + {statistics.nursingNum} - - - - 本月护理天数 + + 本月护理天数 - - {statistics.nursingTime} - 本月护理时间 + + {statistics.nursingTime} + 本月护理时间 {/* */} - - {/* */} - - - {recordData.createTime} - {recordData.online == 1 ? '在线' : '离线'} + + + + {recordData.createTime} + + {recordData.online == 1 ? "在线" : "离线"} + - - - - - {recordData.instrumentName} - - 模式:{recordData.modeName} - 护理时间:{recordData.nursingTime} + + + + + {recordData.instrumentName} + + 模式:{recordData.modeName} + + 护理时间:{recordData.nursingTime} + - + 完成度: - - {recordData.completionPercentage * 100}% + + + {" "} + {recordData.completionPercentage * 100}% + - 历史记录 - {recordList.map(item => ( - - - {item.createTime} - {item.online == 1 ? '在线' : '离线'} + 历史记录 + {recordList.map((item) => ( + + + {item.createTime} + + {item.online == 1 ? "在线" : "离线"} + - - - - - {item.instrumentName} - - 模式:{item.modeName} - 护理时间:{item.nursingTime} + + + + + {item.instrumentName} + + 模式:{item.modeName} + 护理时间:{item.nursingTime} - + 完成度: - - {item.completionPercentage * 100}% + 100 + ? 100 + : item.completionPercentage * 100 + } + strokeWidth="12" + color="linearGradient(to right, #eecda1, #ffe9c7) !important" + /> + + {" "} + {item.completionPercentage * 100 > 100 + ? 100 + : item.completionPercentage * 100} + % + ))} - - {/* */} - {/* */} - {/* - - 2024.01.01 - 在线 - - - - - - 光能厂美侧板 - - 模式:维护修复 - 护理时间:10:00 - - - - 完成度: - - 80% - - - - - */} - {/* 历史记录 - - - 2024.01.01 - 在线 - - - - - - 光能厂美侧板 - - 模式:维护修复 - 护理时间:10:00 - - - - 完成度: - - 80% - - - - */} - {/* */} - - 前往打卡 - + + 前往打卡 + 跳过 - + - - {/* */} - ); } diff --git a/src/pages/iotCarePlan/iotCarePlan.tsx b/src/pages/iotCarePlan/iotCarePlan.tsx index 4c0e4ee..238d78c 100644 --- a/src/pages/iotCarePlan/iotCarePlan.tsx +++ b/src/pages/iotCarePlan/iotCarePlan.tsx @@ -23,6 +23,7 @@ import PopupCountdown from "@/components/popup/popup-countdown"; import PopupStepTips from "@/components/popup/popup-step-tips"; import PopupConfirm from "@/components/popup/popup-confirm"; import PopupAlert from "@/components/popup/popup-alert"; +import PopupStatus from "@/components/popup/popup-status"; /* 公共组件 END */ /* 本页组件 */ @@ -32,7 +33,7 @@ import ModeContent from "./components/ModeContent/index"; import Footer from "./components/Footer"; /* 本页组件 END */ -import { getStorageSync, setStorageSync } from "@/utils/traoAPI"; +import { go, getStorageSync, setStorageSync } from "@/utils/traoAPI"; import { InstrumentInfo } from "@/utils/Interface"; import "./iotCarePlan.less"; @@ -188,13 +189,18 @@ class IotCarePlan extends Component { endPlace: "", currentTime: "01:00", + // 护理时间不够 + isNotEnoughTime: false, // 通用错误提示 isShowErrorTipsText: false, // 护理模式切换错误弹窗 errorTipsText: "", // 护理模式切换错误提示 + + isShowNursingSuccess: false, // 护理成功弹窗 }; } // 不涉及渲染的页面变量 + elapsedTime: any = 0; // 设备已运行时间 workStatus: any = ""; // 工作状态 WL200NursingHistory: any = null; // 护理缓存历史 hadCheckReport = false; // 是否已检查仪器护理记录 @@ -217,6 +223,11 @@ class IotCarePlan extends Component { componentDidShow() { this.initData(); + + this.getWL200NursingHistory(); + // 重置初始值,每次进入页面重新检查面罩护理记录 + this.hadCheckReport = false; + this.hadGotInstrumentHistoryData = false; } componentDidHide() {} @@ -474,17 +485,21 @@ class IotCarePlan extends Component { // } let { isStandStatus, ActiveModeItem } = this.state; - if (isStandStatus && ActiveModeItem.isCabinMode) { + let isCabinMode = ActiveModeItem.isCabinMode === 1; + if (isStandStatus && isCabinMode) { this.stepNext(); return; } if (isStandStatus) { - console.log("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); - this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); + if (ActiveModeItem.isCabinMode === 0) { + this.showTips("检测到面罩与舱体仍在连接中,该模式需要分离面罩和舱体"); + } } else { - this.showTips( - "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" - ); + if (ActiveModeItem.isCabinMode === 1) { + this.showTips( + "检测到面罩与舱体未连接成功,请确认面罩是否和舱体连接并接通舱体电源" + ); + } } }; /** 切换光照 */ @@ -956,7 +971,7 @@ class IotCarePlan extends Component { } }; - // 重置计时器 + // 重置并同步计时器 resetTimer = () => { // 切换模式后, 需要重新设置计时器, 以防进行中的计时器 currentTimeTimer && clearInterval(currentTimeTimer); @@ -980,6 +995,7 @@ class IotCarePlan extends Component { let checkTime = totalSeconds - currentSeconds; console.log("设备已运行多少秒", checkTime); console.log("ModeStepTimeArray", ModeStepTimeArray); + this.elapsedTime = checkTime; if (currentSeconds >= 1) { this.setState({ currentTime: s_to_ms(--currentSeconds), @@ -1152,13 +1168,22 @@ class IotCarePlan extends Component { } // 开始执行护理 this.handleWorkStatus(true, MODE_WORKING_ENUM.WORKING); - this.showCountdownFun(3, () => {}); // 倒计时弹窗 + + let downNum = CountDownTime[ActiveModeItem.modeName] || 3; + this.showCountdownFun(downNum, () => {}); // 倒计时弹窗 } // 结束护理? endNurseFun() { this.handleWorkStatus(false, "end"); - this.PostNursingLogClock(); + + console.log("this.checkNurseTime()", this.checkNurseTime()); + if (this.checkNurseTime()) { + this.PostNursingLogClock(); + } else { + this.showTips("护理时间不足,请重新连接护理"); + } + // setTimeout(() => { // //TODO IOS关闭蓝牙太快导致关机指令没发出去,暂时这么解决 // const isEnough = this.checkNurseTime(); @@ -1322,7 +1347,7 @@ class IotCarePlan extends Component { instrumentName: currentDevice.name, modeId: ActiveModeItem.id, modeName: ActiveModeItem.modeName, - nursingTime: ActiveModeItem.modeTimeStr, + nursingTime: s_to_ms(this.elapsedTime), }; let res: any = await this.PostNursingLogClock(params); console.log("res", res); @@ -1345,8 +1370,28 @@ class IotCarePlan extends Component { console.log("同步异常,但设备运行中"); } }; + /** 获取小程序本地缓存的历史记录 */ + getWL200NursingHistory() { + this.WL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); + } /** 设置WL200护理历史 */ - setWL200NursingHistory = (jsonStatus: any) => {}; + setWL200NursingHistory = (jsonStatus: any) => { + let { currentDevice, ActiveModeItem, ModeList } = this.state; + const params = { + createDate: dayjs().format("YYYY-MM-DD"), + workMode: jsonStatus.workMode, + instrumentId: currentDevice.id, + instrumentName: currentDevice.name, + modeId: ActiveModeItem.id, + modeName: ActiveModeItem.modeName, + id: jsonStatus.id, + neededTotalSeconds: jsonStatus.neededTotalSeconds, + jsonStatus, + }; + this.WL200NursingHistory = JSON.parse(JSON.stringify(params)); + Taro.setStorageSync("WL200NursingHistory", params); + console.log("保存setWL200NursingHistory"); + }; /** 删除WL200护理历史 */ rmWL200NursingHistory = (WL200NursingHistory, hard = false) => { const nowWL200NursingHistory = Taro.getStorageSync("WL200NursingHistory"); @@ -1358,8 +1403,9 @@ class IotCarePlan extends Component { }; /** 提交护理记录 */ - PostNursingLogClock = async (data: any) => { + PostNursingLogClock = async (data: any = null) => { let { currentDevice, ActiveModeItem } = this.state; + let params = {}; if (data) { params = data; @@ -1369,12 +1415,14 @@ class IotCarePlan extends Component { instrumentName: currentDevice.name, modeId: ActiveModeItem.id, modeName: ActiveModeItem.modeName, - nursingTime: ActiveModeItem.modeTimeStr, + nursingTime: s_to_ms(this.elapsedTime), }; } let res: any = await InstrumentInfo.apiNursingLog.addLog(params); console.log("PostNursingLogClock", res); + + this.goFaceReport(); }; /*** 护理记录 END ***/ @@ -1394,8 +1442,10 @@ class IotCarePlan extends Component { getServiceTimeData() { const { ActiveModeItem } = this.state; let serviceData = ActiveModeItem.serviceData.map((item) => { - let totalWorkingMinutes = parseInt(item.modeTimeStr.split(":")[0]); // 仅分钟数 - let totalWorkingSeconds = parseInt(item.modeTimeStr.split(":")[1]); // 仅秒数 + let totalWorkingMinutes = parseInt( + item.serviceStartTimeStr.split(":")[0] + ); // 仅分钟数 + let totalWorkingSeconds = parseInt(item.serviceEndTimeStr.split(":")[1]); // 仅秒数 // let totalWorkingMinutes = 1; // 仅分钟数 // let totalWorkingSeconds = 0; // 仅秒数 return { @@ -1519,8 +1569,17 @@ class IotCarePlan extends Component { }); }; confirmEndBtn = () => { - this.endNurseFun(); - this.cancelEndBtn(); + console.log("confirmEndBtn", this.checkNurseTime()); + if (this.checkNurseTime()) { + this.endNurseFun(); + this.cancelEndBtn(); + } else { + this.handleWorkStatus(false, "end"); + this.setState({ + isEndCarePlan: false, + isNotEnoughTime: true, + }); + } }; cancelEndBtn = () => { this.setState({ @@ -1543,6 +1602,20 @@ class IotCarePlan extends Component { }); }; + closeNotEnoughTime = () => { + this.setState({ + isNotEnoughTime: false, + }); + Taro.switchTab({ + url: "/pages/index/index", + }); + }; + + /** 完成护理提交:跳转护理报告页 */ + goFaceReport = () => { + go("/pages/face_report/face_report?id=" + this.state.currentDevice.id); + }; + render() { let { name, @@ -1572,6 +1645,8 @@ class IotCarePlan extends Component { facialMaskConnectStatus, isShowErrorTipsText, errorTipsText, + isNotEnoughTime, + isShowNursingSuccess, } = this.state; return ( @@ -1628,6 +1703,17 @@ class IotCarePlan extends Component { /> )} + + { close={this.closeErrorTipsText} confirm={this.closeErrorTipsText} /> + + { + /*不需要做处理*/ + }} + />