<template>
	<view class="carManageContent">
		<VNavigationBar class="navigationBar" title="车辆管理">
			<template v-slot:extra>
				<uni-icons size="28" type="plus" color="#fff" @click="goupdata('')"></uni-icons>
			</template>
		</VNavigationBar>
		<scroll-view class="carManangeScrollView" scroll-y @scrolltolower="scrolltolower">
			<view class="ail">
				<view class="_box" v-for="(item,index) in carList" :key="index" @click="goupdata(item.id)">
					<view class="_box-content">
						<view class="img_">
							<image :src="baseUrl+item.carImage" mode="aspectFill"></image>
						</view>
						<view class="right_">
							<view class="cphInfo" style="">
								<image class="cphIcon" src="../../static/icons/carManage/carNumIcon.png" mode="aspectFit"></image>
								<view class="cph">{{item.rescueCarNum}}</view>
							</view>
							<view class="right-top">
								<view class="timesize">保养到期时间:</view>
								<view class="time">{{item.carKeepTime}}</view>
							</view>
							<view class="right-top">
								<view class="timesize">保险到期时间:</view>
								<view class="time">{{item.carInsuranceTime}}</view>
							</view>
							<view class="right-top">
								<view class="timesize">年检到期时间:</view>
								<view class="time">{{item.carCheckTime}}</view>
							</view>
						</view>
					</view>
					<view class="_box-footer">
						<view class="tag">{{item.rescueCarTypeStr}}</view>
						<view class="tag">{{item.rescueCarBrand}}</view>
					</view>
				</view>
			</view>
		</scroll-view>
		<tabBar msg="1"></tabBar>
	<!-- 	<view class="anniu" @click="goupdata('')">
			<u-icon name="plus" color="#fff" size="34"></u-icon>


		</view> -->
	</view>
</template>

<script>
	import request from '../../utils/request'
	import VNavigationBar from '@/components/VNavigationBar.vue'
	import tabBarVue from '../../components/tabBar/tabBar.vue'
	export default {
		components: {
			VNavigationBar,
			tabBarVue
		},
		data() {
			return {
				baseUrl: this.$baseUrl,
				carList: [],
				searchName: null,
				pageNum: 1,
				pageSize: 10,
				totalNum: '',
			}
		},
		onShow() {
			this.getCarList()
		},
		methods: {
			scrolltolower() {
				if (this.carList.length >= this.totalNum) {
					uni.showToast({
						title: '没有下一页数据',
						icon: 'none'
					})
				} else {
					this.pageNum++
					this.getCarList()
				}
			},
			getback() {
				uni.navigateBack()
			},
			async getCarList() {
				request({
					url: "/system/rescueCar/list",
					method: 'get',
					params: {
						rescueCarNum: this.searchName,
						pageNum: this.pageNum,
						pageSize: this.pageSize,
					}

				}).then(res => {
					if (this.pageNum != 1) {
						this.carList = this.carList.concat(res.rows)
					} else {
						this.carList = res.rows
					}
					console.log(this.carList.length);
					this.totalNum = res.total

				})
			},
			goupdata(id) {
				uni.navigateTo({
					url: '/pages/my/carManageForm?id=' + id
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.carManageContent {
		height: 100%;
		display: flex;
		flex-direction: column;
		background-color: #F7F8FC;
	}

	.carManangeScrollView {
		flex: 1;
		height: 0;
	}

	.top-icon {
		display: flex;
		align-items: center;
	}

	.ail {
		width: 100%;
		box-sizing: border-box;
		padding: 15px;
	}

	._box {
		width: 100%;
		box-sizing: border-box;
		padding: 50rpx 46rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(0, 0, 0, 0.06);
		border-radius: 16rpx;
		margin: 24rpx 0;
	}

	._box-content {
		display: flex;
		align-items: center;
		justify-content: space-between;
		column-gap: 32rpx;
	}

	.img_ {
		width: 196rpx;
		height: 196rpx;
		background: #D8D8D8;
		border-radius: 16rpx;
		overflow: hidden;
		// border: 2rpx solid #979797;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.right_ {
		width: 70%;

	}

	.cphInfo {
		display: flex;
		align-items: center;
		column-gap: 10rpx;
		margin-bottom: 18rpx;
	}

	.cphIcon {
		width: 100rpx;
		height: 44rpx;
	}

	.cph {
		font-weight: 500;
		font-size: 32rpx;
		color: #000000;
		line-height: 1.5;
	}

	.right-top {
		width: 100%;
		display: flex;
		align-items: center;
		font-size: 28rpx;
		color: #000000;
		margin: 10rpx 0 0;
	}

	._box-footer {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		column-gap: 40rpx;
		padding-top: 22rpx;
	}

	.tag {
		width: 104rpx;
		height: 48rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: rgba(70, 190, 55, 0.1);
		border-radius: 4rpx;
		font-size: 24rpx;
		color: #30B922;
		line-height: 1;
	}

	.anniu {
		width: 55px;
		height: 55px;
		background: #0000ff;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		bottom: 30px;
		right: 15px;
	}
</style>