修复已知问题

This commit is contained in:
2025-06-06 18:23:07 +08:00
parent 3ac3fd8cb2
commit 7ff3e3f064
51 changed files with 2503 additions and 1257 deletions

162
src/hjm/bx/bx.tsx Normal file
View File

@@ -0,0 +1,162 @@
import {useEffect, useState} from "react";
import {InfiniteLoading, Loading, Empty, Button, Input} from '@nutui/nutui-react-taro'
import {Search, Plus} from '@nutui/icons-react-taro'
import Taro from '@tarojs/taro'
import {pageHjmCar} from "@/api/hjm/hjmCar";
import {HjmCar} from "@/api/hjm/hjmCar/model";
import BestSellers from "./BestSellers";
/**
* 一键报险 - 车辆列表页面
* @constructor
*/
const InsuranceList = () => {
const [list, setList] = useState<HjmCar[]>([])
const [loading, setLoading] = useState<boolean>(false)
const [keywords, setKeywords] = useState<string>('')
const [refreshing, setRefreshing] = useState<boolean>(false)
const reload = async (showLoading = true) => {
try {
if (showLoading) setLoading(true)
setRefreshing(true)
// 获取车辆列表 - 只获取正常状态的车辆
const res = await pageHjmCar({
status: 1,
keywords: keywords.trim() || undefined
})
setList(res?.list || [])
} catch (error) {
console.error('获取车辆列表失败:', error)
Taro.showToast({
title: '获取车辆列表失败',
icon: 'error'
})
} finally {
setLoading(false)
setRefreshing(false)
}
}
const onSearch = () => {
reload()
}
const onKeywordsChange = (value: string) => {
setKeywords(value)
}
const onAddInsurance = () => {
Taro.navigateTo({
url: '/hjm/bx/bx-add'
})
}
useEffect(() => {
reload()
}, [])
return (
<>
{/* 搜索栏 */}
<div style={{
position: 'fixed',
top: '20px',
left: 0,
right: 0,
zIndex: 20,
padding: '0 16px',
backgroundColor: '#f5f5f5'
}}>
<div style={{
display: 'flex',
alignItems: 'center',
backgroundColor: '#fff',
padding: '8px 12px',
borderRadius: '20px',
boxShadow: '0 2px 8px rgba(0,0,0,0.1)'
}}>
<Search size={16} color="#999"/>
<Input
placeholder="搜索车辆编号或快递公司"
value={keywords}
onChange={onKeywordsChange}
onConfirm={onSearch}
style={{
border: 'none',
backgroundColor: 'transparent',
flex: 1,
marginLeft: '8px'
}}
/>
<Button
type="primary"
size="small"
onClick={onSearch}
loading={loading}
>
</Button>
</div>
</div>
{/* 车辆列表 */}
<div style={{
marginTop: '80px',
paddingBottom: '80px'
}}>
{loading && list.length === 0 ? (
<div style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '200px'
}}>
<Loading type="spinner">...</Loading>
</div>
) : list.length === 0 ? (
<Empty description="暂无车辆数据">
<Button type="primary" onClick={() => reload()}>
</Button>
</Empty>
) : (
<InfiniteLoading
style={{width: '100%'}}
hasMore={false}
onLoadMore={() => {}}
>
<BestSellers data={list} onRefresh={() => reload(false)}/>
</InfiniteLoading>
)}
</div>
{/* 浮动添加按钮 */}
<div style={{
position: 'fixed',
bottom: '20px',
right: '20px',
zIndex: 30
}}>
<Button
type="primary"
shape="round"
size="large"
onClick={onAddInsurance}
style={{
width: '56px',
height: '56px',
borderRadius: '28px',
boxShadow: '0 4px 12px rgba(0,0,0,0.15)'
}}
>
<Plus size={24}/>
</Button>
</div>
</>
)
}
export default InsuranceList