From 9a0e253ba02b1eacee4c86bd61f68abc507b91e4 Mon Sep 17 00:00:00 2001 From: rongweikang <1174906669@qq.com> Date: Thu, 21 Mar 2024 09:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/moduleIOT/pages/iotCarePlan/FR200.less | 4 + src/moduleIOT/pages/iotCarePlan/FR200.tsx | 218 ++++++++++-------- .../iotCarePlan/components/Echart/index.tsx | 51 +++- .../moisture_test_report.tsx | 2 +- 4 files changed, 165 insertions(+), 110 deletions(-) diff --git a/src/moduleIOT/pages/iotCarePlan/FR200.less b/src/moduleIOT/pages/iotCarePlan/FR200.less index 231581f..ea47e89 100644 --- a/src/moduleIOT/pages/iotCarePlan/FR200.less +++ b/src/moduleIOT/pages/iotCarePlan/FR200.less @@ -1 +1,5 @@ @import url(./WL200.less); + +.show { + display: none; +} diff --git a/src/moduleIOT/pages/iotCarePlan/FR200.tsx b/src/moduleIOT/pages/iotCarePlan/FR200.tsx index aa1d832..6c92f26 100644 --- a/src/moduleIOT/pages/iotCarePlan/FR200.tsx +++ b/src/moduleIOT/pages/iotCarePlan/FR200.tsx @@ -3,16 +3,15 @@ import dayjs from "dayjs"; import classnames from "classnames"; import { debounce } from "lodash"; -// eslint-disable-next-line import/no-named-as-default import React, { Component, PropsWithChildren, useEffect, useState, } from "react"; - -import Echarts from "./components/Echart/index"; -import Gears from "./components/Gears/index"; +/*** redux ***/ +import { connect } from "react-redux"; +/*** redux end ***/ import { Block, View, @@ -23,9 +22,27 @@ import { Button, } from "@tarojs/components"; -/*** redux ***/ -import { connect } from "react-redux"; -/*** redux end ***/ +import { + notifyBLECharacteristicValueChange, + sendCommand, +} from "@/utils/bluetoothWXAPI"; +import { + deviceCommandSamples, + bleCommandSamples, +} from "@/components/bluetoot/connection/wl200"; + +import { minSecToS, s_to_ms, s_to_hms, sleep, s_to_s } from "@/utils/util"; +// import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; +import { + DeviceToolKit as DeviceToolKitWM, + TResponseFromDevice as TResponseFromDeviceWM, +} from "@flossom-npm/iot-translater"; +import commandMap from "@/utils/commandMap"; +import { Popup } from "@antmjs/vantui"; +import { fr200BleCommand } from "@/components/bluetoot/connection/fr200"; + +import { go, getStorageSync, setStorageSync, msg } from "@/utils/traoAPI"; +import { InstrumentInfo } from "@/utils/Interface"; /* 公共组件 */ import Navbar from "@/components/navbar/navbar"; @@ -45,28 +62,13 @@ import Footer from "./components/Footer/FR200"; import WaterTest from "./components/WaterTest/index"; /* 本页组件 END */ -import { go, getStorageSync, setStorageSync, msg } from "@/utils/traoAPI"; -import { InstrumentInfo } from "@/utils/Interface"; +import Echarts from "./components/Echart"; +import Gears from "./components/Gears"; + + import "./FR200.less"; -import { - notifyBLECharacteristicValueChange, - sendCommand, -} from "@/utils/bluetoothWXAPI"; -import { - deviceCommandSamples, - bleCommandSamples, -} from "@/components/bluetoot/connection/wl200"; -import { minSecToS, s_to_ms, s_to_hms, sleep, s_to_s } from "@/utils/util"; -// import { DeviceToolKit as DeviceToolKitWE100 } from "@flossom-npm/iot-translater-we100"; -import { - DeviceToolKit as DeviceToolKitWM, - TResponseFromDevice as TResponseFromDeviceWM, -} from "@flossom-npm/iot-translater"; -import commandMap from "@/utils/commandMap"; -import { Popup } from "@antmjs/vantui"; -import { fr200BleCommand } from "@/components/bluetoot/connection/fr200"; const deviceToolKitInstanceFR200 = new DeviceToolKitWM("FR200"); let deviceToolKitInstance = deviceToolKitInstanceFR200; @@ -190,6 +192,7 @@ class IotCarePlanFR200 extends Component { // isFirstEntryMode: false, // 模式首次打开 isShowHistoryMsg: false, // 是否显示正在同步历史 + showEcharts: false }; } @@ -231,10 +234,10 @@ class IotCarePlanFR200 extends Component { BaseModeType: string[] = ["face", "eyes"]; async onLoad(option) { - console.log(option,'跳转过来的数据'); + console.log(option, '跳转过来的数据'); if (option.modeId) { this.setState({ activeModeID: option.modeId }) - + } // 保持屏幕常亮 Taro.setKeepScreenOn({ @@ -243,11 +246,11 @@ class IotCarePlanFR200 extends Component { this.initData(); this.getInstrumentClockSummary(); this.getInstrumentClockDetail(); - + } - componentDidMount() {} + componentDidMount() { } - componentWillUnmount() {} + componentWillUnmount() { } componentDidShow() { console.log("页面显示了"); @@ -376,7 +379,7 @@ class IotCarePlanFR200 extends Component { instrumentId: id, }; let res = await InstrumentInfo.modeInfoList(params); - + if (res.data.code === 200) { if (res.data.data.length > 0) { this.setState({ @@ -392,7 +395,7 @@ class IotCarePlanFR200 extends Component { } }) } - let res1= res.data.data.find(e =>e.id == this.state.activeModeID) + let res1 = res.data.data.find(e => e.id == this.state.activeModeID) setTimeout(() => { this.modeCurrentFun(res1); }, 100); @@ -436,7 +439,7 @@ class IotCarePlanFR200 extends Component { * @name 选中/切换护理模式 * */ modeCurrentFun = async (data, isNotCheck = false) => { - let { isShowNurse,activeModeID } = this.state; + let { isShowNurse, activeModeID } = this.state; // 护理检查改变模式,是否提示切换护理模式 // isNotCheck为真时,不进行校验,直接切换 this.tempModeCurrent = data; @@ -491,8 +494,8 @@ class IotCarePlanFR200 extends Component { if (data.serviceData.length > 0) { this.setServiceTimeData(); } - - + + }); // 开发中,暂时允许直接切换 @@ -630,9 +633,15 @@ class IotCarePlanFR200 extends Component { this.showTips("检测到您的设备没有紧贴肌肤,请紧贴肌肤后重新尝试"); }); }; + look() { + this.setState({ showEcharts: !this.state.showEcharts }); + } + updata() { + + } // 绘制能量图 - drawProwerPicture() {} + drawProwerPicture() { } /** 切换光照 */ onSwitchChange = async () => { @@ -1945,11 +1954,11 @@ class IotCarePlanFR200 extends Component { let report = true; go( "/recoding/pages/face_report_one/face_report_one?id=" + - id + - "&report=" + - report + - "&obj=" + - JSON.stringify(obj) + id + + "&report=" + + report + + "&obj=" + + JSON.stringify(obj) ); } else if ("moistureTest" === nursingData.workMode) { console.log("水分测试"); @@ -2083,6 +2092,7 @@ class IotCarePlanFR200 extends Component { isShowHistoryMsg, isModeLock, TestModeStepIndex, + showEcharts } = this.state; return ( @@ -2098,19 +2108,19 @@ class IotCarePlanFR200 extends Component { { isLarge isClose isShow={isEndCarePlan} - title="提示" - content="是否结束护理" - textAlgin="center" - cancelButtonText="取消" - confirmButtonText="确定" + title='提示' + content='是否结束护理' + textAlgin='center' + cancelButtonText='取消' + confirmButtonText='确定' close={this.cancelEndBtn} confirm={this.confirmEndBtn} /> @@ -2134,7 +2144,7 @@ class IotCarePlanFR200 extends Component { isLarge isClose isShow={isSwitchActiveMode} - title="护理模式切换" + title='护理模式切换' content={ { onModeLockOpen={this.onModeLockOpen} /> } - textAlgin="center" - cancelButtonText="取消" - confirmButtonText="确定" + textAlgin='center' + cancelButtonText='取消' + confirmButtonText='确定' close={this.cancelModeSwitchBtn} confirm={this.confirmModeSwitchBtn} /> @@ -2160,7 +2170,7 @@ class IotCarePlanFR200 extends Component { isShow={isShowStepTips} isLarge isFirstEntry={false} - confirmButtonText="知道了" + confirmButtonText='知道了' data={ActiveModeItem.openSourceData} close={this.closeStepTips} /> @@ -2169,10 +2179,10 @@ class IotCarePlanFR200 extends Component { @@ -2181,11 +2191,11 @@ class IotCarePlanFR200 extends Component { isShow={isShowErrorTipsText} isClose zIndex={10020} - myClassName="level-up" - title="提示" + myClassName='level-up' + title='提示' content={errorTipsText} - confirmButtonText="知道了" - textAlgin="center" + confirmButtonText='知道了' + textAlgin='center' close={this.closeErrorTipsText} confirm={this.closeErrorTipsText} /> @@ -2194,17 +2204,17 @@ class IotCarePlanFR200 extends Component { isShow={isShowTipsSave} isClose zIndex={10020} - myClassName="level-up" - title="提示" + myClassName='level-up' + title='提示' content={ 当前模式已护理部分时间 是否保存护理记录 } - cancelButtonText="取消" - confirmButtonText="确认" - textAlgin="center" + cancelButtonText='取消' + confirmButtonText='确认' + textAlgin='center' close={this.closeTipsSave} cancel={this.cancelTipsSave} confirm={this.confirmTipsSave} @@ -2213,11 +2223,11 @@ class IotCarePlanFR200 extends Component { { /*不需要做处理*/ }} @@ -2228,28 +2238,28 @@ class IotCarePlanFR200 extends Component { deviceInfo={currentDevice} close={this.connectionClose} isDisconnect={!isConnectionBlutoot} - offlineChange={() => {}} + offlineChange={() => { }} pairingChange={this.pairingChange} - upgradeFun={() => {}} + upgradeFun={() => { }} /> )} - 正在同步护理记录... + 正在同步护理记录... - - + + {!isShowNurse && ( - - - + + + 护理时间: - {currentTime} + {currentTime} - + { onModeLockOpen={this.onModeLockOpen} /> )} + + + - {(ActiveModeItem.modeType === "face" || - ActiveModeItem.modeType === "eyes") && } + + {/* {(ActiveModeItem.modeType === "face" || + ActiveModeItem.modeType === "eyes") && } */} {(ActiveModeItem.modeType === "maskPenetration" || ActiveModeItem.modeType === "essence") && ( - - )} + + )} {ActiveModeItem.modeType === "moistureTest" && ( (null); - const option: EChartOption = { - + const [options, setOptions] = useState({ + animation:false, grid: { // 让图表占满容器 top: "28rpx", @@ -258,14 +258,51 @@ function Index() { }, }, ], - }; + }) const level = [8, 7, 6, 5, 4, 3, 2]; + const [newOptions, setNewOptions] = useState(options) const full = () => { - let box = document.getElementById("box"); - box?.classList.add('fullscreen') + // let box = document.getElementById("box"); + // box?.classList.add('fullscreen') + + + let stop = 0 + let time = setInterval(function () { + stop++ + let option = JSON.parse(JSON.stringify(options)) + let num = Math.floor(Math.random() * 9) + let count = 0 + options.series.map(item => { + if (item.type === 'line') { + item.data.splice(0, 1) + item.data.push(num) + } + if (item.type === 'bar') { + count++ + item.data.splice(0, 1) + if (count <= num) { + item.data.push(1) + } else { + item.data.push(0) + } + } + }) + console.log(option); + + // 更新图表数据 + setNewOptions(option) + if (stop > 10) { + clearInterval(time) + } + }, 1000) + } + + useEffect(() => { + setOptions(newOptions) + }, [newOptions]); // 当 someProp 变化时执行 // const quanping = () => { // T.setPageOrientation({ // orientation: "portrait", @@ -284,7 +321,7 @@ function Index() { { constructor(props) {