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号棚内虫害数量接近阈值数量报警