我的车位,我的车辆

This commit is contained in:
wangyuxin
2026-05-13 17:20:31 +08:00
parent 10505e8000
commit 3ab6450b8c
14 changed files with 1916 additions and 3174 deletions

View File

@@ -1,181 +1,172 @@
<template>
<view class="contentStyle" style="">
<view class="contentStyle">
<view class="status-bar"></view>
<uni-nav-bar title="我的车位" left-icon="left" @clickLeft="goBack" backgroundColor="transparent" :border="false">
</uni-nav-bar>
<scroll-view class="page" scroll-y="true">
<view v-if="parkingSpaceList.length === 0" class="empty-state">
<uni-icons type="info" size="60" color="#ccc"></uni-icons>
<text class="empty-text">
{{ '暂无数据'}}
</text>
<text class="empty-text">暂无数据</text>
</view>
<!-- 车位列表 v-for 渲染 -->
<view class="parkingSpace-list">
<view class="parkingSpace-card" v-for="(item, index) in parkingSpaceList" :key="index"
@click="tapParkingSpace(item)">
<!-- 标题 + 状态 -->
<view class="card-header">
<view class="title-box">
<text class="parkingSpace-name">{{ item.parkingSpaceName }}</text>
<text class="parkingSpace-name">{{ item.villageName }}</text>
</view>
<text class="status-tag" :class="item.statusClass">{{ item.statusText }}</text>
<text class="status-tag"
:class="item.checkStatus=='0'?'pending':item.checkStatus=='1'?'success':item.checkStatus=='2'?'fail':''">{{ item.checkStatus=='0'?'未认证':item.checkStatus=='1'?'认证成功':item.checkStatus=='2'?'认证失败':'' }}</text>
</view>
<!-- 车位信息 -->
<view class="card-body">
<view class="left">
<view class="line">
<view class="row">
<text class="label">车位楼层</text>
<view class="value-box">
<text class="value">{{ item.floorNo }}</text>
<text class="value">{{ item.areaName }}</text>
</view>
</view>
</view>
<view class="line">
<view class="row">
<text class="label">车位编号</text>
<text class="value">{{ item.parkingSpaceNumber }}</text>
<text class="value">{{ item.parkingCode }}</text>
</view>
</view>
<view class="line">
<view class="row">
<text class="label">车位状态</text>
<text class="value">{{ item.parkingSpaceStatus }}</text>
<text class="value">{{ item.parkingStatus }}</text>
</view>
</view>
<view class="line">
<view class="row">
<text class="label">绑定车辆</text>
<text class="value">{{ item.bindCarNum }}</text>
<text class="value">{{ item.carNum }}</text>
</view>
</view>
</view>
<view class="right">
<image src="http://47.104.199.163:9090/images/propertyImgs/myParkingSpace.png"
class="imgItem" mode="widthFix">
</image>
<image :src="item.carImageUrl?item.carImageUrl:'http://47.104.199.163:9090/images/propertyImgs/myParkingSpace.png'"
class="imgItem" mode="widthFix"></image>
</view>
</view>
</view>
</view>
</scroll-view>
<!-- 底部添加按钮 -->
<view class="bottom-btn">
<button class="add-btn" @click="addParkingSpace">添加车位</button>
</view>
</view>
</template>
<script>
export default {
onReady: function(e) {},
components: {
<script setup>
import {
ref,
onMounted
} from 'vue'
import {
getCarList
} from '@/pageSubPack/api/apiSub.js'
import {
onReachBottom,
onPullDownRefresh
} from '@dcloudio/uni-app'
},
const statusBarHeight = ref(20)
const parkingSpaceList = ref([])
computed: {
// ==================== 上拉加载更多(页面生命周期) ====================
onReachBottom(() => {
getList()
})
// ==================== 下拉刷新 ====================
const refresh = () => {
// 重置所有状态
pageNum = 1
pageSize = 10
noMoreData = false
parkingSpaceList = []
loadingMore = false
getList()
}
onPullDownRefresh(() => {
refresh()
})
},
created() {
// 页面加载时请求第一页
onMounted(() => {
getList()
})
},
onShow() {
const loadingMore = ref(false)
const noMoreData = ref(false)
},
onUnload() {
// 页面卸载时清除定时器
if (this.timer) clearInterval(this.timer)
},
mounted() {},
data() {
return {
/* 设定状态栏默认高度 */
statusBarHeight: 20,
parkingSpaceList: [{
id: 1,
parkingSpaceName: "北境碧桂园小区地下停车场",
floorNo: "B2",
parkingSpaceNumber: "202",
parkingSpaceStatus: "租赁",
bindCarNum: '京A88888',
statusText: "认证成功",
statusClass: "success",
},
{
id: 2,
parkingSpaceName: "北境碧桂园小区停车场",
floorNo: "B2",
parkingSpaceNumber: "202",
parkingSpaceStatus: "自用",
bindCarNum: '京A88888',
statusText: "认证中",
statusClass: "pending",
},
{
id: 3,
parkingSpaceName: "北境碧桂园小区停车场",
floorNo: "2号楼1层",
floorNo: "B2",
parkingSpaceNumber: "202",
parkingSpaceStatus: "闲置",
bindCarNum: '京A88888',
statusText: "认证失败",
statusClass: "fail",
},
]
const pageNum = ref(1)
const pageSize = ref(10)
// ==================== 获取列表数据 ====================
const getList = async () => {
// 防重复请求
if (loadingMore.value || noMoreData.value) return
loadingMore.value = true
try {
const res = await getCarList({
pageNum: pageNum.value,
pageSize: pageSize.value,
residentId: uni.getStorageSync('userId')
})
const data = res
const newList = data.rows || []
// 第一页 → 覆盖数据
if (pageNum.value === 1) {
parkingSpaceList.value = newList
} else {
// 后续页 → 追加数据
parkingSpaceList.value = [...parkingSpaceList.value, ...newList]
}
},
// 判断是否没有更多数据
if (newList.length < pageSize.value) {
noMoreData.value = true
} else {
pageNum.value++
}
} catch (err) {
uni.showToast({
title: '加载失败',
icon: 'none'
})
console.error('列表接口报错:', err)
} finally {
loadingMore.value = false
uni.stopPullDownRefresh() // 关闭下拉刷新
}
}
const tapParkingSpace = (item) => {
console.log(item);
uni.redirectTo({
url: '/pageSubPack/my/parkingSpaceDetail?id=' + item.parkingId + '&statusClass=' + item.checkStatus
})
}
methods: {
tapParkingSpace(item) {
uni.redirectTo({
url: '/pageSubPack/my/parkingSpaceDetail?id=' + item.id + '&statusClass=' + item.statusClass,
success: res => {},
fail: () => {},
complete: () => {}
});
},
addParkingSpace() {
uni.setStorageSync('operationType', 'add');
uni.redirectTo({
url: '/pageSubPack/my/addParkingSpace',
success: res => {},
fail: () => {},
complete: () => {}
});
},
goBack() {
uni.switchTab({
url: '/pages/myIndex/myIndex',
success: res => {},
fail: () => {},
complete: () => {}
});
},
},
const addParkingSpace = () => {
uni.setStorageSync('operationType', 'add')
uni.redirectTo({
url: '/pageSubPack/my/addParkingSpace'
})
}
const goBack = () => {
uni.switchTab({
url: '/pages/myIndex/myIndex'
})
}
</script>
<style lang="scss">
page {
background: #F9F9F9;
@@ -183,11 +174,15 @@
</style>
<style scoped>
.status-bar {
width: 100vw;
height: 46px;
}
.contentStyle {
display: flex;
flex-direction: column;
height: 100vh;
/* 关键:占满屏幕高度 */
background-color: #f5f7fa;
}
@@ -198,7 +193,6 @@
box-sizing: border-box;
}
/* 空状态 */
.empty-state {
display: flex;
flex-direction: column;
@@ -215,14 +209,10 @@
margin-bottom: 10rpx;
}
/* 底部按钮 */
.bottom-btn {
padding: 20rpx 30rpx 40rpx;
}
/* 列表 */
.parkingSpace-list {}
.parkingSpace-card {
background: #fff;
border-radius: 12rpx;
@@ -230,10 +220,8 @@
overflow: hidden;
}
/* 头部 */
.card-header {
padding: 30rpx;
/* border-bottom: 1rpx solid #f0f0f0; */
display: flex;
justify-content: space-between;
align-items: center;
@@ -251,12 +239,8 @@
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
/* 状态标签 */
.status-tag {
font-size: 24rpx;
padding: 4rpx 16rpx;
@@ -280,7 +264,6 @@
color: #fff;
}
/* 内容行 */
.card-body {
padding: 0rpx 30rpx 30rpx 30rpx;
display: flex;
@@ -292,16 +275,11 @@
margin-bottom: 20rpx;
}
.row {
display: flex;
width: 100%;
}
.label {
width: 80px;
font-size: 28rpx;
@@ -316,19 +294,10 @@
}
.value {
font-size: 28rpx;
color: #666;
}
.set-default {
color: #007aff;
font-weight: 600;
font-size: 28rpx;
}
.add-btn {
width: 100%;
height: 88rpx;
@@ -349,9 +318,4 @@
.imgItem {
width: 100%;
}
.status-bar {
width: 100vw;
height: 46px;
}
</style>