<template>
	<view class="content">
		<view class="container">
			<headers :titles="titles"></headers>
			<u-empty text="暂无预约记录" mode="list" v-if="!yyCenterList||yyCenterList.length==0"></u-empty>
			<view v-else class="box-list" v-for="(item,index) in yyCenterList"
				@click="goBookingInfo(item.driveSchoolCourse.id, item.startPay, item.jlId, item.id)" :key="index">
				<view class="top-box">
					<view class="icon-box"></view>
					<view class="title-">{{item.driveSchoolCoach.instructorName}}</view>
				</view>
				<!-- <view class="d-ail">
					<uni-icons type="person" size="18px"></uni-icons>
					<view style="margin-left: 5px;">{{item.name}}</view>
				</view> -->
				<view class="d-ail">
					<u-icon name="clock" color="#999999" size="18"></u-icon>

					<view style="margin-left: 5px;">{{item.createTime}}</view>
				</view>
				<view class="d-ail">
					<uni-icons type="location" size="18px"></uni-icons>
					<view style="margin-left: 5px;">{{item.driveSchoolInfo.address}}</view>
				</view>
			</view>

			<u-loadmore :status="status" v-if="show == true" />
			<view style="width: 100%; height: 60px; "></view>
		</view>
		<tabbar :msg='msg'></tabbar>
	</view>
</template>

<script>
	import headers from '../../components/header/headers.vue'
	import tabbar from '../../components/tabbar/tabbar.vue'
	import request from '@/utils/request.js'
	import {
		getToken
	} from '@/utils/auth'
	export default {
		data() {
			return {
				titles: "预约中心",
				msg: "2",
				List: [],
				show: false,
				status: 'loading',
				yyCenterList: [],
			}
		},
		onShow() {
			if (getToken()) {
				this.findyyCenterListAll()
			}


		},
		onPullDownRefresh() {
			console.log("刷新");
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			// this.show = true
			setTimeout(() => {
				console.log("加载执行");
			}, 2000)
		},
		components: {
			headers,
			tabbar
		},
		methods: {
			goback() {
				uni.navigateBack()
			},
			async findyyCenterListAll() {
				let res = await request({
					url: '/driving/findPayListAll',
					method: 'get',
				})
				this.yyCenterList = res
			},
			goBookingInfo(id, startPay, jlId, userId) {
				if (id === null || jlId === null || startPay === null || userId === null) return
				uni.navigateTo({
					// url: '/pages/index/bookingInfo?bookingId=' + id
					url: `/pages/index/bookingInfo?bookingId=${id}&startPay=${startPay}&jlId=${jlId}&userId=${userId}`
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		background: #f4f5f6;

		height: 100vh;
	}

	.container {
		width: 100%;
		background: #f4f5f6;
		box-sizing: border-box;
		padding-top: 88px;
	}

	.box-list {
		width: 95%;
		border-radius: 8px;
		background: #fff;
		box-sizing: border-box;
		padding: 15px;
		margin: 15px auto;
	}

	.top-box {
		width: 100%;
		display: flex;
		align-items: center;
		border-bottom: 1px solid #DDDDDD;
		box-sizing: border-box;
		padding-bottom: 15px;
	}

	.icon-box {
		width: 22px;
		height: 22px;
		background: #4AA76F;
		border-radius: 50%;
		overflow: hidden;
		margin-right: 10px;
	}

	.title- {
		font-weight: bold;
		font-size: 16px;
		color: #333333;
	}

	.d-ail {
		font-size: 14px;
		color: #999999;
		display: flex;
		align-items: center;
		margin: 10px 0px;
	}
</style>
