新页面和修改对应逻辑

This commit is contained in:
not-like-juvenile
2026-01-26 17:12:37 +08:00
parent b1c845d571
commit 1c83f29f7d
10 changed files with 1297 additions and 157 deletions

View File

@@ -3,6 +3,11 @@
<view class="vehicle-container">
<!-- 头部标题 -->
<view class="page-header">
<!-- 返回按钮:左上角垂直居中 -->
<view class="back-box" @click="goBack">
<text class="back-icon"></text>
<text class="back-text">返回</text>
</view>
<text class="page-title">车辆管理</text>
</view>
@@ -55,42 +60,64 @@ export default {
this.loadVehicles()
},
onShow() {
// 页面每次显示时都检查是否有新添加的车辆
this.loadVehicles()
},
methods: {
// 返回上一页
goBack() {
uni.navigateBack()
},
// 加载车辆信息
loadVehicles() {
// TODO: 调用API获取车辆列表
this.vehicleList = [
{
id: '1',
plate_number: '京A12345',
vehicle_type: 1,
vehicle_type_name: '电动车',
status: 1, // 1: 正常, 2: 维修中, 3: 停用
driver_id: 'driver001',
created_at: '2024-01-01',
updated_at: '2024-12-01'
},
{
id: '2',
plate_number: '沪B67890',
vehicle_type: 2,
vehicle_type_name: '摩托车',
status: 2, // 维修中
driver_id: 'driver001',
created_at: '2024-01-02',
updated_at: '2024-12-02'
},
{
id: '3',
plate_number: '粤C11223',
vehicle_type: 3,
vehicle_type_name: '汽车',
status: 3, // 停用
driver_id: 'driver001',
created_at: '2024-01-03',
updated_at: '2024-12-03'
}
]
// 1. 从本地存储获取新添加的车辆(如果存在)
const newVehicleFromStorage = uni.getStorageSync('new_vehicle_for_list')
if (newVehicleFromStorage) {
// 2. 清除本地存储,防止重复添加
uni.removeStorageSync('new_vehicle_for_list')
// 3. 将新车辆添加到列表开头
this.vehicleList.unshift(newVehicleFromStorage)
return // 如果有新数据,直接使用,不加载旧的模拟数据
}
// 4. 如果没有新数据才加载旧的模拟数据实际项目中应从API获取
if (this.vehicleList.length === 0) { // 避免重复加载模拟数据
this.vehicleList = [
{
id: '1',
plate_number: '京A12345',
vehicle_type: 1,
vehicle_type_name: '电动车',
status: 1, // 1: 正常, 2: 维修中, 3: 停用
driver_id: 'driver001',
created_at: '2024-01-01',
updated_at: '2024-12-01'
},
{
id: '2',
plate_number: '沪B67890',
vehicle_type: 2,
vehicle_type_name: '摩托车',
status: 2, // 维修中
driver_id: 'driver001',
created_at: '2024-01-02',
updated_at: '2024-12-02'
},
{
id: '3',
plate_number: '粤C11223',
vehicle_type: 3,
vehicle_type_name: '汽车',
status: 3, // 停用
driver_id: 'driver001',
created_at: '2024-01-03',
updated_at: '2024-12-03'
}
]
}
},
// 获取车辆状态文本
@@ -147,6 +174,10 @@ type VehicleType = {
driver_id: string
created_at: string
updated_at: string
brand?: string
color?: string
image?: string
remark?: string
}
</script>
@@ -162,6 +193,40 @@ type VehicleType = {
padding: 20rpx 30rpx;
border-bottom: 1rpx solid #e9ecef;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
position: relative;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
}
.back-box {
position: absolute;
left: 30rpx;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
cursor: pointer;
padding: 10rpx;
border-radius: 8rpx;
transition: background-color 0.2s ease;
}
.back-box:active {
background-color: #f0f0f0;
}
.back-icon {
font-size: 36rpx;
color: #333;
margin-right: 5rpx;
}
.back-text {
font-size: 28rpx;
color: #333;
font-weight: 500;
}
.page-title {