From 0d94fc1f720167e9d8d23d7dc9510f2ac2784762 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Fri, 28 Jul 2023 16:56:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A9=E6=B0=94=E6=8E=A5=E5=85=A5=E5=8F=8A?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/waterconservancy.js | 4 +- .../water-prevention/components/left-top.js | 48 ++++++++-- .../water-prevention/components/weather.js | 91 +------------------ .../water-prevention/constants/weather.js | 89 ++++++++++++++++++ .../water-prevention/containers/gis.js | 18 ++-- .../water-prevention/containers/gis.less | 2 +- super-screen/routes/weather/index.js | 23 ++++- 7 files changed, 160 insertions(+), 115 deletions(-) create mode 100644 super-screen/client/src/sections/water-prevention/constants/weather.js diff --git a/super-screen/client/src/sections/water-prevention/actions/waterconservancy.js b/super-screen/client/src/sections/water-prevention/actions/waterconservancy.js index 29f8dd2..c8ffe30 100644 --- a/super-screen/client/src/sections/water-prevention/actions/waterconservancy.js +++ b/super-screen/client/src/sections/water-prevention/actions/waterconservancy.js @@ -73,8 +73,8 @@ export function getWaterAlarms(query) { return dispatch => basicAction({ type: 'post', query, - // data: { "keywords": "", "status": "new", "levels": [1, 2, 3], "orderBy": "endTime", "orderDirection": "desc", "limit": 10, "offset": 0, "structures": null, "types": [1] }, - data: { "structures": null, "orderBy": "endTime", "endTime": "2022-06-30 23:59:59", "keywords": "", "levels": [1, 2, 3], "startTime": "2022-06-01 00:00:00", "orderDirection": "desc", "status": "history", "offset": 0, "types": [1], "limit": 10 }, + data: { "keywords": "", "status": "new", "levels": [1, 2, 3], "orderBy": "endTime", "orderDirection": "desc", "limit": 10, "offset": 0, "structures": null, "types": [1] }, + // data: { "structures": null, "orderBy": "endTime", "endTime": "2022-06-30 23:59:59", "keywords": "", "levels": [1, 2, 3], "startTime": "2022-06-01 00:00:00", "orderDirection": "desc", "status": "history", "offset": 0, "types": [1], "limit": 10 }, dispatch: dispatch, actionType: 'GET_WATER_ALARMS', url: `${ApiTable.getWaterAlarms}`, diff --git a/super-screen/client/src/sections/water-prevention/components/left-top.js b/super-screen/client/src/sections/water-prevention/components/left-top.js index 6da58ca..8b1132c 100644 --- a/super-screen/client/src/sections/water-prevention/components/left-top.js +++ b/super-screen/client/src/sections/water-prevention/components/left-top.js @@ -1,8 +1,38 @@ -import React from 'react' +import React, { useEffect, useState, useMemo } from 'react'; +import { RouteRequest } from '@peace/utils'; +import { WEATHERArr, WEATHERMARGIN, ICONSMAP } from '../constants/weather'; import { Box } from '$components'; import { Select } from 'antd'; const { Option } = Select; + function BasicInfo() { + const [weather, setWeather] = useState([]); + + const queryWeather = () => { + RouteRequest.get(`/query/weather/3d?location=101240101`).then((res) => { + if (res?.daily?.length === 3) { + setWeather(res.daily); + } + }); + }; + + useEffect(() => { + queryWeather(); + const timeUpdate = setInterval(() => { + queryWeather(); + }, WEATHERMARGIN); + return () => { + clearInterval(timeUpdate); + }; + }, []); + + const iconSrc = useMemo(() => { + if (weather.length === 3) { + const icon = [ICONSMAP[weather[0].textDay], ICONSMAP[weather[1].textDay], ICONSMAP[weather[2].textDay]]; + return icon; + } + return []; + }, [weather]); const renderSubtitle = () => (