feat(hjm): 实现车辆位置坐标转换与违章查询功能

- 新增 GPS 坐标转换工具类,支持 WGS84、GCJ02 和 BD09 坐标系互转
- 在车辆定位页面集成坐标转换逻辑,确保地图显示准确性
-优化车辆列表分页加载功能,提升大数据量下的用户体验- 修改车辆热销组件属性类型定义,增强代码可维护性
- 调整违章记录列表页面,新增通过车辆编号查询功能
- 更新最佳销售车辆组件键值生成逻辑,提高组件稳定性
- 完善地图组件 markers 和 polygons 数据校验,防止无效坐标渲染
- 在车辆详情页增加违章查询跳转按钮,方便用户操作
- 移除违章记录删除功能,避免误删重要数据
-优化空状态提示文案,使用户理解更清晰
This commit is contained in:
2025-10-27 17:19:03 +08:00
parent 78f94c0afa
commit 0ff976b4e9
6 changed files with 497 additions and 69 deletions

View File

@@ -1,4 +1,4 @@
import {useEffect, useState} from "react";
import {useEffect, useState, CSSProperties} from "react";
import {Search} from '@nutui/icons-react-taro'
import {Button, Input, InfiniteLoading} from '@nutui/nutui-react-taro'
import {pageHjmCar} from "@/api/hjm/hjmCar";
@@ -8,6 +8,14 @@ import './location.scss'
import BestSellers from "./BestSellers";
import {getUserInfo} from "@/api/layout";
const InfiniteUlStyle: CSSProperties = {
height: '80vh',
width: '100%',
padding: '0',
overflowY: 'auto',
overflowX: 'hidden',
}
/**
* 文章终极列表
* @constructor
@@ -15,14 +23,20 @@ import {getUserInfo} from "@/api/layout";
const List = () => {
const [keywords, setKeywords] = useState<string>('')
const [list, setList] = useState<HjmCar[]>([])
const [page, setPage] = useState(1)
const [hasMore, setHasMore] = useState(true)
const [loading, setLoading] = useState(false)
const onKeywords = (keywords: string) => {
setKeywords(keywords)
}
const reload = async () => {
const loadList = async (pageNum: number, isRefresh = false) => {
if (loading) return;
setLoading(true)
// 搜索条件
const where = {status: 1, deleted: 0, keywords}
const where = {status: 1, deleted: 0, keywords, page: pageNum, limit: 10}
// 读取用户信息
const user = await getUserInfo();
@@ -46,20 +60,53 @@ const List = () => {
where.installerId = user.userId;
}
if(roleCode == 'user'){
setLoading(false)
return false;
}
// 获取车辆列表
pageHjmCar(where).then(res => {
setList(res?.list || [])
})
try {
const res = await pageHjmCar(where);
if (res?.list && res?.list.length > 0) {
if (isRefresh) {
setList(res.list);
} else {
setList(prevList => [...prevList, ...res.list]);
}
setHasMore(res.list.length >= 10); // 如果返回的数据少于10条说明没有更多了
} else {
if (isRefresh) {
setList([]);
}
setHasMore(false);
}
} catch (error) {
console.error('获取车辆列表失败:', error);
if (isRefresh) {
setList([]);
}
setHasMore(false);
} finally {
setLoading(false);
}
}
const reload = async () => {
setPage(1);
await loadList(1, true);
}
const loadMore = async () => {
if (!hasMore || loading) return;
const nextPage = page + 1;
setPage(nextPage);
await loadList(nextPage);
}
useEffect(() => {
reload()
}, [])
return (
<>
<div className={'fixed z-20 top-5 left-0 w-full'}>
@@ -90,12 +137,19 @@ const List = () => {
</div>
</div>
</div>
<InfiniteLoading
className={'w-full fixed left-0 top-20'}
>
<BestSellers data={list}/>
</InfiniteLoading>
<div style={InfiniteUlStyle} id="scroll">
<InfiniteLoading
target="scroll"
className={'w-full fixed left-0 top-20'}
hasMore={hasMore}
onLoadMore={loadMore}
loadingText="加载中..."
loadMoreText="没有更多了"
>
<BestSellers data={list}/>
</InfiniteLoading>
</div>
</>
)
}
export default List
export default List