|
|
|
|
@ -2,25 +2,23 @@ import Taro from "@tarojs/taro";
|
|
|
|
|
import classnames from "classnames";
|
|
|
|
|
import { Block, View, Image, Text, Input } from "@tarojs/components";
|
|
|
|
|
import { Popup, Progress, Slider } from "@antmjs/vantui";
|
|
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
|
|
|
import { useEffect, useRef, useState, useCallback } from "react";
|
|
|
|
|
import Echarts, { EChartOption, EchartsHandle } from "taro-react-echarts";
|
|
|
|
|
import echarts from "@/utils/echarts.min.js";
|
|
|
|
|
|
|
|
|
|
import "./index.less";
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
Electricity: any;
|
|
|
|
|
matrixElectricity: any;
|
|
|
|
|
facialMaskConnectStatus: any;
|
|
|
|
|
data: any
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Index() {
|
|
|
|
|
|
|
|
|
|
function Index({ data }: Props) {
|
|
|
|
|
const buttonRef = useRef(null);
|
|
|
|
|
const echartsRef = useRef<EchartsHandle>(null);
|
|
|
|
|
const [options, setOptions] = useState({
|
|
|
|
|
animation:false,
|
|
|
|
|
animation: false,
|
|
|
|
|
grid: {
|
|
|
|
|
// 让图表占满容器
|
|
|
|
|
top: "28rpx",
|
|
|
|
|
@ -262,47 +260,78 @@ function Index() {
|
|
|
|
|
|
|
|
|
|
const level = [8, 7, 6, 5, 4, 3, 2];
|
|
|
|
|
const [newOptions, setNewOptions] = useState(options)
|
|
|
|
|
const full = () => {
|
|
|
|
|
const [newData, setNewData] = useState(0)
|
|
|
|
|
const full = useCallback(() => {
|
|
|
|
|
// 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)
|
|
|
|
|
}
|
|
|
|
|
// 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)
|
|
|
|
|
})
|
|
|
|
|
console.log(option);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 更新图表数据
|
|
|
|
|
setNewOptions(option)
|
|
|
|
|
// if (stop > 20) {
|
|
|
|
|
// clearInterval(time)
|
|
|
|
|
// }
|
|
|
|
|
// }, 1000)
|
|
|
|
|
|
|
|
|
|
}, [data])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setOptions(newOptions)
|
|
|
|
|
}, [newOptions]); // 当 someProp 变化时执行
|
|
|
|
|
}, [newOptions]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setNewData(data)
|
|
|
|
|
}, [data]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let option = JSON.parse(JSON.stringify(options))
|
|
|
|
|
let num = Math.floor(newData * 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, data);
|
|
|
|
|
|
|
|
|
|
// 更新图表数据
|
|
|
|
|
setNewOptions(option)
|
|
|
|
|
}, [newData])
|
|
|
|
|
// 当 someProp 变化时执行
|
|
|
|
|
// const quanping = () => {
|
|
|
|
|
// T.setPageOrientation({
|
|
|
|
|
// orientation: "portrait",
|
|
|
|
|
@ -315,6 +344,7 @@ function Index() {
|
|
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Block>
|
|
|
|
|
<View id='box' className='box'>
|
|
|
|
|
@ -328,7 +358,7 @@ function Index() {
|
|
|
|
|
style={{ width: "630rpx", height: "260rpx", zIndex: 1 }}
|
|
|
|
|
/>
|
|
|
|
|
<View className='box_background'>
|
|
|
|
|
<Image className='full' src={require("@/img/full-scran.png")} onClick={full}></Image>
|
|
|
|
|
<Image className='full' ref={buttonRef} src={require("@/img/full-scran.png")} onClick={full}></Image>
|
|
|
|
|
<View className='power'>实时能量</View>
|
|
|
|
|
{level.map((item) => (
|
|
|
|
|
<View className='line' key={item}>
|
|
|
|
|
|