<template>
	<view>
		<view class="c-top">
			<view class="top-icon" @click="getback()">
				<uni-icons type="left" size="18"></uni-icons>
				<view class="">返回</view>
			</view>
			<view class="">车辆管理</view>
			<view style="width: 10%; height: 100%; "></view>
		</view>

		<view class="ail">
			<view class="_box" v-for="(item,index) in carList" :key="index" @click="goupdata(item.id)">
				<view class="img_">
					<image :src="baseUrl+item.carImage" mode=""></image>
				</view>
				<view class="right_">
					<view class="right-top" style="justify-content: space-between;">
						<view class="cph">{{item.rescueCarNum}}</view>
						<!-- 	<view class="title_">{{item.rescueCarTypeStr}}</view> -->
						<u-tag type="success" :text="item.rescueCarTypeStr"></u-tag>
						<u-tag :text="item.rescueCarBrand"></u-tag>
						<!-- <view class="size_">{{item.rescueCarBrand}}</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>
		<view class="anniu" @click="goupdata('')">
			<u-icon name="plus" color="#fff" size="34"></u-icon>


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

<script>
	import request from '../../utils/request'
	export default {
		data() {
			return {
				baseUrl: this.$baseUrl,
				carList: [],
				searchName: null,
				pageNum: 1,
				pageSize: 10,
				totalNum: '',
			}
		},
		onShow() {
			this.getCarList()
		},
		onReachBottom() {
			if (this.carList.length >= this.totalNum) {
				uni.showToast({
					title: '没有下一页数据',
					icon: 'none'
				})
			} else {
				this.pageNum++
				this.getCarList()
			}
		},
		methods: {
			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">
	.c-top {
		width: 100%;
		height: 88px;
		display: flex;
		align-items: center;
		justify-content: space-between;

	}

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

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

	._box {
		width: 100%;
		border-bottom: 1px solid #d8d8d8;
		box-sizing: border-box;
		padding: 10px 0px;
		display: flex;

		justify-content: space-between;
	}

	.img_ {
		width: 100px;
		height: 100px;

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

	.right_ {
		width: 70%;

	}

	.right-top {
		width: 100%;
		display: flex;
		align-items: center;
		margin-bottom: 5px;
	}

	.title_ {
		font-size: 16px;
		font-weight: bold;
	}

	.cph {
		font-size: 16px;
		color: #0796ef;
	}

	.size_ {
		font-size: 16px;
	}

	.timesize {
		font-size: 16px;
		margin-right: 5px;
		color: #a6a6a6;
	}

	.time {
		font-size: 16px;
	}

	.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>