Files
mp-10550/src/hjm/fence.tsx
2025-06-26 11:41:12 +08:00

117 lines
3.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {useEffect, useState} from "react";
import {useRouter} from '@tarojs/taro'
import {getHjmCar, pageHjmCar} from "@/api/hjm/hjmCar";
import {HjmCar} from "@/api/hjm/hjmCar/model";
import {Image,Cell} from '@nutui/nutui-react-taro'
import './location.scss'
/**
* 电子围栏
* @constructor
*/
const Fence = () => {
const {params} = useRouter();
const [keywords, setKeywords] = useState<string>()
const [item, setItem] = useState<HjmCar>()
// 打开地图选择位置
// const chooseLocation = async () => {
// try {
// const res = await Taro.chooseLocation({
// latitude, // 默认纬度
// longitude // 默认经度
// })
// console.log('选择的位置:', res);
// } catch (err) {
// console.error('选择位置失败:', err);
// }
// }
const reload = () => {
const id = Number(params.id);
// 执行搜索
if (keywords) {
pageHjmCar({keywords}).then(res => {
if (res?.list && res?.list?.length > 0) {
const data = res?.list[0];
setItem(data)
setKeywords(data.code)
}
})
return false;
}
// 获取车辆信息
if (id) {
getHjmCar(id).then(data => {
setItem(data)
setKeywords(data.code)
})
}
}
useEffect(() => {
reload()
}, [])
return (
<>
{/*<div className={'fixed z-20 top-5 left-0 w-full'}>*/}
{/* <div className={'px-4'}>*/}
{/* <div*/}
{/* style={{*/}
{/* display: 'flex',*/}
{/* alignItems: 'center',*/}
{/* background: '#fff',*/}
{/* padding: '0 10px',*/}
{/* borderRadius: '20px'*/}
{/* }}*/}
{/* >*/}
{/* <Search/>*/}
{/* <Input*/}
{/* placeholder="车辆编号"*/}
{/* value={keywords}*/}
{/* onChange={onKeywords}*/}
{/* />*/}
{/* <div*/}
{/* className={'flex items-center'}*/}
{/* >*/}
{/* <Button type="warning" onClick={reload}>*/}
{/* 查询*/}
{/* </Button>*/}
{/* </div>*/}
{/* </div>*/}
{/* </div>*/}
{/*</div>*/}
{item ? (
<div className={'car-info w-full bg-white'}>
<Image src={item?.image} mode={'widthFix'} width={'100%'} className={'bg-gray-50'}/>
<div className={'px-2'}>
<Cell className={'car-info-item-title'}>
{item?.code}
</Cell>
<Cell className={'car-info-item-title'}>
{item?.kuaidi}
</Cell>
<Cell className={'car-info-item-title'}>
{item?.kuaidiAdmin}
</Cell>
<Cell className={'car-info-item-content'}>
{item?.driver}
</Cell>
<Cell className={'car-info-item-content'}>
{item?.insuranceStatus}
</Cell>
<Cell className={'car-info-item-content'}>
GPS编号{item?.gpsNo}
</Cell>
<Cell className={'car-info-item-content'}>
{item?.fenceName}
</Cell>
</div>
</div>
) : ''}
</>
)
}
export default Fence