Compare commits

...

4 Commits

Author SHA1 Message Date
2bf6c083b1 Merge remote-tracking branch 'refs/remotes/origin/main' 2024-03-28 11:41:24 +08:00
412fffe506 feat: 功能完善 2024-03-28 11:41:17 +08:00
cf8f4d72ad feat:: 下拉刷新功能示例 2024-03-28 11:39:45 +08:00
564f0fa177 feat: 禁止页面滚动 2024-03-28 11:37:20 +08:00
12 changed files with 161 additions and 129 deletions

View File

@ -1,93 +1,106 @@
import { View } from "@tarojs/components"
import { useState } from "react"
import Taro from "@tarojs/taro"
import TabWrapper from "../../components/customized/tabWrapper"
import { ScrollView } from "@tarojs/components"
const EquipMent = () => {
const [selectedMenuId, setSelectedMenuId] = useState('all')
const topMenus = [
{
id: '1',
title: '基地1'
},
{
id: '2',
title: '基地2'
},
{
id: '3',
title: '基地3'
},
]
const [selectedMenuId, setSelectedMenuId] = useState('all')
const topMenus = [
{
id: 'all',
title: '全部'
},
{
id: '1',
title: '基地1'
},
{
id: '2',
title: '基地2'
},
{
id: '3',
title: '基地3'
},
]
const dataList = [
{
id: '1',
},
{
id: '2',
},
{
id: '3',
},
]
return (
<View className="p-1 h-full">
<View className="h-full flex flex-col">
<View className="flex px-2 py-1">
{
topMenus.map(item => {
return (
<View
className={`p-1 px-3 ${selectedMenuId === item.id ? 'border-b-4 border-lime-800' : ''}`}
key={item.id}
style={{ color: 'white' }}
onClick={() => setSelectedMenuId(item.id)}
>{ item.title }</View>
)
})
}
</View>
<View className="h-full flex flex-col space-y-3 p-2 rounded-sm">
{
dataList.map(item => {
return (
<View
className="px-4 py-2 rounded-md shadow-xl flex space-x-4 bg-white border border-slate-200 items-center"
// onClick={() => {
// Taro.navigateTo({ url: '/pages/weatherStation/index?id=' + item.id })
// }}
>
{/* <View className="w-12 h-12 relative top-1">
const dataList = [
{
id: '1',
},
{
id: '2',
},
{
id: '3',
},
]
const [refreshTrigger, setRefreshTrigger] = useState(false)
const refreshFunc = (): Promise<void> => {
return new Promise((resolve, reject) => { resolve() })
}
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="pb-2" style={{ height: 'calc(100% - 2.4rem)', width: '100%' }}>
<ScrollView
className="w-full h-full"
scrollY
scrollWithAnimation
refresherEnabled
scrollLeft={10}
refresherBackground="#00000000"
refresherTriggered={refreshTrigger}
onRefresherRefresh={() => {
console.log('触发下拉刷新');
setRefreshTrigger(true)
refreshFunc().then(() => setRefreshTrigger(false))
}}
>
{
dataList.map(item => {
return (
<View
className="px-4 py-2 m-2 w-[100% - 1rem] rounded-md shadow-xl flex space-x-4 bg-white border border-slate-200 items-center"
// onClick={() => {
// Taro.navigateTo({ url: '/pages/weatherStation/index?id=' + item.id })
// }}
>
{/* <View className="w-12 h-12 relative top-1">
<Image src={img} className="w-12 h-12"></Image>
</View> */}
<View className="w-full flex flex-col justify-between items-start pb-1">
<View className="text-lg pb-1"></View>
<View className="w-full flex items-center space-x-8">
<View className="flex items-center space-x-2">
<View></View>
<View style={{ color: 'green' }}>3</View>
</View>
<View className="flex items-center space-x-2">
<View></View>
<View style={{ color: 'red' }}>3</View>
</View>
</View>
</View>
<View
className="rounded-xl w-20 bg-green-500 text-center py-1"
style={{ color: 'white' }}
onClick={() => {
Taro.navigateTo({ url: '/inspectionManager/inspection/index?id=' + item.id})
}}
></View>
</View>
)
})
}
</View>
</View>
</View>
)
<View className="w-full flex flex-col justify-between items-start pb-1">
<View className="text-lg pb-1"></View>
<View className="w-full flex items-center space-x-8">
<View className="flex items-center space-x-2">
<View></View>
<View style={{ color: 'green' }}>3</View>
</View>
<View className="flex items-center space-x-2">
<View></View>
<View style={{ color: 'red' }}>3</View>
</View>
</View>
</View>
<View
className="rounded-xl w-20 bg-green-500 text-center py-1"
style={{ color: 'white' }}
onClick={() => {
Taro.navigateTo({ url: '/inspectionManager/inspection/index?id=' + item.id })
}}
></View>
</View>
)
})
}
</ScrollView>
</View>
</View>
</View>
)
}
export default EquipMent;

View File

@ -20,11 +20,12 @@ const getDeviceList = (data) => {
const UrlMap = {
'气象监测': '/iotManager/weatherStation/index?id=1',
'土壤监测': '/iotManager/soilMoisture/index?id=1',
'虫情监测': '',
'环境检测': '',
'虫情监测': '/iotManager/bugMonitor/index',
'环境检测': '/iotManager/envMonitor/index',
'其他摄像头': '',
'棚内环境监测': '/iotManager/envMonitor/index?id=1',
'设备监控': '/iotManager/deviceMonitor/index?id=1'
'设备监控': '/iotManager/deviceMonitor/index?id=1',
'增氧设备': '/iotManager/deviceMonitor/index'
}
const getDeviceInfoCard = () => {
@ -52,6 +53,8 @@ const Iot = () => {
return new Promise((resolve, reject) => {
if (selectedMenuId === 'all') {
getDeviceInfoCard().then(({ data }) => {
console.log('物联网列表all->', data);
if (Array.isArray(data.category)) {
setDataList(data.category.map((item, index) => ({
id: index,
@ -70,6 +73,7 @@ const Iot = () => {
}
if (!selectedMenuId) return;
getDeviceList({ parkId: selectedMenuId }).then(({ data }) => {
console.log('物联网列表part->', data);
setDataList(data.map((item, index) => ({
id: index,
title: item.categoryName,

View File

@ -1,6 +1,6 @@
import { View } from "@tarojs/components"
const BasicStatus = (status = true) => {
const BasicStatus = ({status = true}) => {
return (
<View
style={{ backgroundColor: status ? '#0fc87c' : '#ff0000', 'color': 'white' }}

View File

@ -13,8 +13,6 @@ export const request = ({
if (isToken) header['Authorization'] = 'Bearer ' + Taro.getStorageSync('token')
let requestParams = '?'
if (method === 'GET') requestParams += stringify(data, { indices: false })
console.log('requestParams', requestParams);
return new Promise((resolve, reject) => {
Taro.showLoading({ title: '加载中...' })
Taro.request({

View File

@ -1,3 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '气象站'
navigationBarTitleText: '气象站',
disableScroll: true
})

View File

@ -1,69 +1,82 @@
import { View, Image } from "@tarojs/components";
import PageWrapper from "../../components/customized/pageWrapper";
import { useState } from "react";
import { useEffect, useState } from "react";
import { request } from "../../config/axios";
import BasicStatus from "../../components/iot/basicStatus";
const getMonitorDevices = (data) => {
return request({
url: '/agriculture/big-screen/monitorDeviceByPark',
method: 'GET',
data
})
}
const DeviceInfoCard = ({ title, info, status, imgSrc }) => {
return (
<View
className="bg-white px-5 py-4 rounded-md shadow-xl mb-2"
className="bg-white pb-2 px-5 py-4 rounded-md shadow-xl mb-2"
>
<View className="flex space-x-4">
<View className="w-16 h-14 border">
<Image src={imgSrc} className="w-16 h-14"></Image>
<View className="w-20 h-14">
<Image
src={imgSrc}
className=" w-20 h-14"
style={{ objectFit: 'contain' }}
></Image>
</View>
<View className="w-full">
<View className="font-bold text-[.9rem]">{ title }</View>
<View className="text-[.8rem] text-slate-600 pb-1">{ info }</View>
<View className="flex">{ status }</View>
<View className="flex">
<BasicStatus status={status} />
</View>
</View>
</View>
<View className="w-full h-[1px] bg-slate-300 my-2"></View>
<View className="flex flex-row-reverse">
<View className="p-1 rounded-xl border" style={{ color: '#49d49b', 'borderColor': '#49d49b' }}></View>
<View
className="p-1 px-3 rounded-xl border"
style={{
color: '#49d49b',
'borderColor': '#49d49b',
fontSize: '.8rem'
}}
></View>
</View>
</View>
)
}
const DeviceMonitor = () => {
const [curDeviceId, setCurDeviceId] = useState('1')
const deviceList = [
{
id: '1',
title: '设备1'
},
{
id: '2',
title: '设备2'
},
{
id: '3',
title: '设备3'
},
]
const [dataList, setDataList] = useState<Array<any>>([])
const getDataList = async () => {
const { data } = await getMonitorDevices({
belongPark: '1769896538700668928',
belongPlot: '1769908355099721728'
})
console.log('getDataList', data);
setDataList(data)
}
useEffect(() => { getDataList() }, [])
return (
<PageWrapper title="设备监控">
<View className="h-full flex flex-col px-1">
<View className="flex px-2 py-1">
<View className="h-full overflow-auto p-3">
{
deviceList.map(item => {
dataList.map(item => {
return (
<View
className={`p-1 px-3 ${curDeviceId === item.id ? 'text-lime-600 border-b-4 border-lime-800' : ''}`}
key={item.id}
style={{ color: 'white' }}
onClick={() => setCurDeviceId(item.id)}
>{ item.title }</View>
<DeviceInfoCard
title={item.deviceName}
info={`经纬度:${item.longitude}${item.latitude}`}
status={item.deviceStatus === 'online'}
imgSrc={item.imgId}
/>
)
})
}
</View>
<View className="h-full overflow-auto p-3">
<DeviceInfoCard title="监控摄像头-枪机" info="经纬度110.003129.323" status="NKLI179" imgSrc="http://img.img" />
<DeviceInfoCard title="监控摄像头-枪机" info="经纬度110.003129.323" status="NKLI179" imgSrc="http://img.img" />
<DeviceInfoCard title="监控摄像头-枪机" info="经纬度110.003129.323" status="NKLI179" imgSrc="http://img.img" />
</View>
</View>
</PageWrapper>
)

View File

@ -29,7 +29,7 @@ const BasicInfoCard = ({ title, info, status, imgSrc }) => {
<View className="w-full">
<View className="font-bold text-[.9rem]">{ title }</View>
<View className="text-[.8rem] text-slate-600 pb-2">{ info }</View>
<View className="flex">{ status ? BasicStatus() : '' }</View>
<View className="flex">{ status ? <BasicStatus /> : '' }</View>
</View>
</View>
)

View File

@ -30,7 +30,7 @@ const BasicInfoCard = ({ title, info, status, imgSrc }) => {
<View className="w-full">
<View className="font-bold text-[.9rem]">{ title }</View>
<View className="text-[.8rem] text-slate-600 pb-2">{ info }</View>
<View className="flex">{ status ? BasicStatus() : '' }</View>
<View className="flex">{ status ? <BasicStatus /> : '' }</View>
</View>
</View>
)

View File

@ -1,3 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '气象站'
navigationBarTitleText: '气象站',
disableScroll: true
})

View File

@ -29,7 +29,7 @@ const BasicInfoCard = ({ title, info, status, imgSrc }) => {
<View className="w-full">
<View className="font-bold text-[.9rem]">{ title }</View>
<View className="text-[.8rem] text-slate-600 pb-2">{ info }</View>
<View className="flex">{ status ? BasicStatus() : '' }</View>
<View className="flex">{ status ? <BasicStatus /> : '' }</View>
</View>
</View>
)

View File

@ -1,3 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '消息详情'
navigationBarTitleText: '消息详情',
disableScroll: true
})

View File

@ -1,3 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '登录'
navigationBarTitleText: '登录',
disableScroll: true
})