From 92cd25d7be036fb06dd5e4d5420b621030c6f1bd Mon Sep 17 00:00:00 2001 From: Zxuyoubin Date: Wed, 27 Mar 2024 17:41:40 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=AD=A6=E9=9A=86=E9=B2=81?= =?UTF-8?q?=E6=B8=9D=E5=8D=8F=E4=BD=9C=E7=A4=BA=E8=8C=83=E6=9D=91=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E5=8C=96=E8=B5=8B=E8=83=BD=20=20=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=20=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83=E7=A0=94?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/basePage/msgCenter/index.tsx | 126 +++++++---------------------- src/msgManager/msgDetail/index.tsx | 24 +++++- 2 files changed, 51 insertions(+), 99 deletions(-) diff --git a/src/basePage/msgCenter/index.tsx b/src/basePage/msgCenter/index.tsx index cb41ca3..c431284 100644 --- a/src/basePage/msgCenter/index.tsx +++ b/src/basePage/msgCenter/index.tsx @@ -1,84 +1,26 @@ import { View,Image } from "@tarojs/components" -import { useState } from "react" -import warn from './assets/warn.png' +import { useEffect, useState } from "react" import rang from './assets/rang.png' import './index.css' import Taro from "@tarojs/taro" import TabWrapper from "../../components/customized/tabWrapper" +import { request } from "../../config/axios/index" const MsgCenter = () => { const [selectedMenuId, setSelectedMenuId] = useState('all') - let contList=[ - { - title:'土壤EC值预警', - time:'2024/3/13 16:30', - url:'./assets/rang.png', - message:'1号基地土壤EC值低于0.4阈值报警', - id:'1' - }, - { - title:'棚内温度报警', - url:'./assets/rang.png', - time:'2024/3/1 10:30', - message:'3号棚内温度39度,超过阈值37度,建议打开放风机', - id:'2' - }, - { - title:'系统通知', - url:'./assets/warn.png', - time:'2024/3/13 8:30', - message:'今日设备巡检结果尚未填报', - id:'0' - }, - { - title:'虫情预警', - url:'./assets/rang.png', - time:'2024/3/13 6:30', - message:'1号棚内虫害数量接近阈值预警', - id:'1' - }, - { - title:'虫情预警', - url:'./assets/rang.png', - time:'2024/3/13 6:30', - message:'1号棚内虫害数量接近阈值预警', - id:'1' - }, - { - title:'虫情预警', - url:'./assets/rang.png', - time:'2024/3/13 6:30', - message:'1号棚内虫害数量接近阈值预警', - id:'1' - }, - { - title:'虫情预警', - url:'./assets/rang.png', - time:'2024/3/13 6:30', - message:'1号棚内虫害数量接近阈值预警', - id:'1' - }, - { - title:'虫情预警', - url:'./assets/rang.png', - time:'2024/3/13 6:30', - message:'1号棚内虫害数量接近阈值预警', - id:'1' - }, - { - title:'虫情预警', - url:'./assets/rang.png', - time:'2024/3/13 6:30', - message:'1号棚内虫害数量接近阈值预警', - id:'1' - }, - { - title:'虫情预警', - url:'./assets/rang.png', - time:'2024/3/13 6:30', - message:'1号棚内虫害数量接近阈值预警', - id:'1' - }, - ] + const getList = () => { + return request({ + url: '/agriculture/warning-record-big-screen/warningRecordInfo', + method: 'GET', + }) + } + const [contList, setContList] = useState([]) + useEffect(() => { + //获取列表 + getList().then(res=>{ + setContList(res.data) + }) + }, []) + const topMenus = [ { id: 'all', @@ -93,7 +35,6 @@ const MsgCenter = () => { title: '通知' }, ] - const dataList = [ { id: '1', @@ -102,36 +43,27 @@ const MsgCenter = () => { id: '2', }, ] - let val=0 - let val2=0 - contList.forEach(item => { - if(item.id=='1'){ - val++ - }else if(item.id=='0'){ - val2++ - } - }); return ( { - contList.map((item,index)=>{ - return ( - { Taro.navigateTo({ url: '/msgManager/msgDetail/index' }) }}> - - - - {item.title} - {item.time} - - {item.message} - + contList.map((item,index)=>{ + return ( + { Taro.navigateTo({ url: `/msgManager/msgDetail/index?id=${item.id}` }) }}> + + + + {item.warnType} + {new Date().toLocaleString(item.warnTime)} + {item.warnInfo} + - ) - }) + + ) + }) } diff --git a/src/msgManager/msgDetail/index.tsx b/src/msgManager/msgDetail/index.tsx index 17e7d42..b82b58c 100644 --- a/src/msgManager/msgDetail/index.tsx +++ b/src/msgManager/msgDetail/index.tsx @@ -1,18 +1,38 @@ import { View,Image } from "@tarojs/components" +import { useEffect, useState } from "react" import rang from './assets/rang.png' import yxImg from './assets/yxImg.png' import image from './assets/image.png' import "./index.css" import PageWrapper from "../../components/customized/pageWrapper" - +import { request } from "../../config/axios/index" +import Taro, { useRouter } from '@tarojs/taro'; const MsgDetail = () => { + let router=useRouter() + let id:any=router.params.id + + const getList=(data)=>{ + return request({ + url: '/agriculture/warning-record-big-screen/getRecordInfo', + method: 'GET', + data + }) + } + const [ obj ,setObj]=useState({}) + useEffect(()=>{ + + getList({id}).then(res=>{ + console.log(res,'获取详情信息'); + setObj(res.data) + }) + },[]) return ( - 土壤EC值预警 + {obj.warnInfo} 报警内容: 1号棚内虫害数量接近阈值数量报警