<template>
	<view class="pageBgImg">
		<topNavbar title="我的排课详情"></topNavbar>
		<view class="pad">
			<view class="card">
				<view class="info">
					<view class="row">
						<view class="lab">训练科目：</view>
						<view class="val">{{subjectText[info.subject]}}</view>
					</view>
					<view class="row">
						<view class="lab">预约车辆：</view>
						<view class="val">{{ info.carNumber }}</view>
					</view>
					<view class="row">
						<view class="lab">开放范围：</view>
						<view class="val">{{ info.openRange==0?'自己的学员': '所有学员'}}</view>
					</view>
				</view>
			</view>
			<view class="h1">预约学员</view>
			<view class="ul">
				<view class="li" v-for="(item,index) in list" :key="index">
					<view class="name">{{ item.studentName}} <text> {{ item.studentPhone }}</text></view>
					<view class="time">提交预约时间：{{item.classDate}}  <text style="margin-left: 6px;">{{item.classTime}}</text></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { scheduleClassGetById, getBookingDetailByClassId } from '@/config/api.js'
	export default {
		data() {
			return {
				info: {},
				id: '',
				subjectText: ['不限', '科目二', '科目三'],//0：不限；2：科目二；3：科目三
				list: []
			}
		},
		onLoad(options) {
			this.id = options.id
			this.scheduleClassGetByIdFn()
		},
		onPullDownRefresh() {
			this.scheduleClassGetByIdFn().then(()=>{
				uni.stopPullDownRefresh()
			})
		},
		methods: {
			async scheduleClassGetByIdFn() {
				const {data: res} = await scheduleClassGetById({id: this.id})
				this.info = res
				console.log(res)
				this.getBookingDetailByClassIdFn(res.id)
			},
			async getBookingDetailByClassIdFn(id) {
				const {data: res} = await getBookingDetailByClassId({classId: id})
				if(!res.length) return
				this.list = res
				console.log(res)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.pad {
	  .card {
		  padding: 0 28rpx;
	    .info {
			padding: 20rpx 0;
	      .row {
			  display: flex;
			  font-size: 28rpx;
			  color: #333;
			  padding: 20rpx 0;
	        .lab {
				width: 150rpx;
	        }
	
	        .val {
	
	        }
	      }
	    }
	  }
	
	  .h1 {
		line-height: 108rpx;
	  }
	
	  .ul {
		  
	    .li {
			height: 180rpx;
			display: flex;
			flex-direction: column;
			background: #FFFFFF;
			border-radius: 16rpx;
			justify-content: center;
			margin-bottom: 20rpx;
			padding: 0 28rpx;
	      .name {
			font-size: 32rpx;
			font-weight: 600;
			text {
				font-weight: 400;
				margin-left: 10rpx;
			}
	      }
	
	      .time {
			font-size: 28rpx;
			margin-top: 24rpx;
			color: #ADADAD;
	      }
	    }
	  }
	}
</style>