From 0ff976b4e9406b9c88aef069a308355ea7083f0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com>
Date: Mon, 27 Oct 2025 17:19:03 +0800
Subject: [PATCH] =?UTF-8?q?feat(hjm):=20=E5=AE=9E=E7=8E=B0=E8=BD=A6?=
=?UTF-8?q?=E8=BE=86=E4=BD=8D=E7=BD=AE=E5=9D=90=E6=A0=87=E8=BD=AC=E6=8D=A2?=
=?UTF-8?q?=E4=B8=8E=E8=BF=9D=E7=AB=A0=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 新增 GPS 坐标转换工具类,支持 WGS84、GCJ02 和 BD09 坐标系互转
- 在车辆定位页面集成坐标转换逻辑,确保地图显示准确性
-优化车辆列表分页加载功能,提升大数据量下的用户体验- 修改车辆热销组件属性类型定义,增强代码可维护性
- 调整违章记录列表页面,新增通过车辆编号查询功能
- 更新最佳销售车辆组件键值生成逻辑,提高组件稳定性
- 完善地图组件 markers 和 polygons 数据校验,防止无效坐标渲染
- 在车辆详情页增加违章查询跳转按钮,方便用户操作
- 移除违章记录删除功能,避免误删重要数据
-优化空状态提示文案,使用户理解更清晰
---
src/hjm/BestSellers.tsx | 17 +--
src/hjm/list.tsx | 80 +++++++++++---
src/hjm/location.tsx | 216 +++++++++++++++++++++++++++++++------
src/hjm/query.tsx | 9 ++
src/hjm/violation/list.tsx | 41 +++----
src/utils/gpsUtil.js | 203 ++++++++++++++++++++++++++++++++++
6 files changed, 497 insertions(+), 69 deletions(-)
create mode 100644 src/utils/gpsUtil.js
diff --git a/src/hjm/BestSellers.tsx b/src/hjm/BestSellers.tsx
index e58b323..4647d3a 100644
--- a/src/hjm/BestSellers.tsx
+++ b/src/hjm/BestSellers.tsx
@@ -1,10 +1,15 @@
import {useEffect} from "react";
import {Image, Space} from '@nutui/nutui-react-taro'
import Taro from '@tarojs/taro'
+import {HjmCar} from "@/api/hjm/hjmCar/model";
-const BestSellers = (props: any) => {
+interface BestSellersProps {
+ data: HjmCar[];
+}
+
+const BestSellers = (props: BestSellersProps) => {
const reload = () => {
-
+ // 可以在这里添加重新加载逻辑
}
useEffect(() => {
@@ -16,7 +21,7 @@ const BestSellers = (props: any) => {
{props.data?.map((item, index) => {
return (
-
Taro.navigateTo({url: '/hjm/query?id=' + item.code})}>
{ item.image && (
{
)
})}
- {props.data.length === 0 && (
-
+ {(!props.data || props.data.length === 0) && (
+
)}
@@ -50,4 +55,4 @@ const BestSellers = (props: any) => {
)
}
-export default BestSellers
+export default BestSellers
\ No newline at end of file
diff --git a/src/hjm/list.tsx b/src/hjm/list.tsx
index 7541ef8..903daef 100644
--- a/src/hjm/list.tsx
+++ b/src/hjm/list.tsx
@@ -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
('')
const [list, setList] = useState([])
+ 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 (
<>
@@ -90,12 +137,19 @@ const List = () => {
-