<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" :key="index">
				<view class="top-box">
					<view class="d-s">
						<view class="icon-box"></view>
						<view class="title-">{{item.coachName}}</view>
					</view>
					<view class="d-s">
						<view class="qd-a" v-if="item.stuSignState == 0" @click="qdclick(item.id,1)">签到</view>
						<view class="qt-a" v-if="item.stuSignState == 1" @click="qdclick(item.id,2)">签退</view>
					</view>
					
					<view class="d-s">
						<view class="qd-a" v-if="item.auditStatus == 0">待审核</view>
						<view class="qt-a" v-if="item.auditStatus == 1">通过</view>
						<view class="qt-a" v-if="item.auditStatus == 2">拒绝</view>
					</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 class="" v-if="item.timePeriod == 1 ">上午</view>
					<view class="" v-if="item.timePeriod == 2 ">下午</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: [],
			}
		},
		onLoad() {
			console.log("123");
			this.getReservationCourseListByUserId()
		},
		// 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 qdclick(id, num) {
				let res = await request({
					url: '/drivingSchool/system/reservationCourse',
					method: 'put',
					data: {
						id: id,
						stuSignState: num
					}
				})
				console.log(res);
				this.getReservationCourseListByUserId()


			},
			async getReservationCourseListByUserId() {
				console.log('1');
				let res = await request({
					url: '/drivingSchool/system/reservationCourse/applet/getReservationCourseListByUserId',
					method: 'get',
				})
				this.yyCenterList = res.data
			},


			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;
	}

	.d-s {
		display: flex;
		align-items: center;
	}

	.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;
		justify-content: space-between;
		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;
	}

	.qd-a {
		width: 40px;
		height: 25px;
		font-size: 12px;
		background: #4aa76f;
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 4px;
		margin-right: 10px;
	}

	.qt-a {
		width: 40px;
		height: 25px;
		font-size: 12px;
		background: #e91636;
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 4px;
		margin-right: 10px;
	}
</style>
