feat:武隆鲁渝协作示范村数字化赋能 移动端 消息中心研发

This commit is contained in:
Zxuyoubin 2024-03-27 17:41:40 +08:00
parent c2b58175b4
commit 92cd25d7be
2 changed files with 51 additions and 99 deletions

View File

@ -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 (
<View className="px-1 h-full">
<View className="h-full flex flex-col justify-start">
<TabWrapper options={topMenus} selectedId={selectedMenuId} callback={setSelectedMenuId}></TabWrapper>
<View className='flex flex-col space-y-3 p-2' style={{ overflow: 'auto', height: 'calc(100% - 2.4rem)' }}>
{
contList.map((item,index)=>{
return (
<View className='rounded-md shadow-xl cont' key={index} onClick={() => { Taro.navigateTo({ url: '/msgManager/msgDetail/index' }) }}>
<Image src={item.id=='1'|| item.id=='2'?rang:warn} className='w-11 h-11' style={{marginTop:'-10px'}}></Image>
<View className='right'>
<View className='right-top'>
<View className='top-left'>{item.title}</View>
<View className='top-right'>{item.time}</View>
</View>
<View className={item.id=='1'|| item.id=='2'?'rang':'warn'}>{item.message}</View>
contList.map((item,index)=>{
return (
<View className='rounded-md shadow-xl cont' key={index} onClick={() => { Taro.navigateTo({ url: `/msgManager/msgDetail/index?id=${item.id}` }) }}>
<Image src={rang} className='w-11 h-11' style={{marginTop:'-10px'}}></Image>
<View className='right'>
<View className='right-top'>
<View className='top-left'>{item.warnType}</View>
<View className='top-right'>{new Date().toLocaleString(item.warnTime)}</View>
</View>
<View className='rang'>{item.warnInfo}</View>
</View>
)
})
</View>
)
})
}
</View>
</View>

View File

@ -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 (
<PageWrapper title="消息详情">
<View className="h-full flex flex-col px-3 py-3">
<View className='detail rounded-md shadow-xl' style={{backgroundColor:'#fff'}}>
<View className='detailTop'>
<Image src={rang} className='w-12 h-12'></Image>
<View style={{marginLeft:'20px',fontWeight:700}}>EC值预警</View>
<View style={{marginLeft:'20px',fontWeight:700}}>{obj.warnInfo}</View>
</View>
<View style={{marginTop:'15px'}}>
<View style={{marginTop:'10px',fontWeight:600,fontSize:'12px'}}> 1</View>