<template>
	<view class="course_layout">
		<view class="course_list">
			<view class="course_item" v-for="(item,index) in productList" :key="index">
				<view class="course_title">
					<view class="left">
						<image :src="item.image"></image>
					</view>
					<view class="right">
						<view class="title">
							{{item.course_name}}
							<!-- 拳击课程 -->
						</view>
						<view class="skill">
							{{item.desc}}
							<!-- 拳击课程修炼 -->
						</view>
						<view class="course_option">
							<view class="course_num">
								课程数量：{{item.course_number}}
							</view>
<!-- 							<view class="course_num">
								总计10课堂
							</view> -->
							<view class="remain_class">
								预约人数：{{item.reservation_number}}
							</view>
						</view>
						<view class="course_remain">
							<view class="remain_class">
								<!-- 预约人数：{{item.reservation_number}} -->
							</view>
							<view class="price">
								￥{{item.price_total}}
								<!-- ￥100 -->
							</view>
						</view>
					</view>
				</view>
				<view class="btn_title">
					<view class="title">
						上课地址：{{item.address}}
					</view>
					<view class="btn">
						<navigator :url="`/pagesA/course/reservation?orders_product_id=${item.orders_product_id}&course_id=${item.course_id}`">
							<view class="course_make_btn">
								预约上课
							</view>
						</navigator>
						<navigator url="/pagesA/course/usercourse">
							<view class="user_course_btn">
								我的预约
							</view>
						</navigator>
					</view>
				</view>
			</view>
		</view>
		<view class="to_bottom">---到底啦---</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//产品列表
				productList:[],
				// 请求参数
				requestParam:{
					name:"",
					page:1,
				},
				// 是否最后一页
				isLast:false,
				// 是否请求中
				isReqing:false,
			}
		},
		onShow() {
			// 没有数据的话，或者请求中，不允许刷新
			if( this.isReqing )		return ;
			// 请求参数
			this.requestParam.name	= "";
			// 请求参数
			this.requestParam.page	= 1;
			// 是否是最后一页
			this.isLast			 	= false;
			// 设置请求中
			this.isReqing			= true;
			this.$http.request('api/course/get_list',this.requestParam.page).then((re)=>{
				// 设置非请求中
				this.isReqing		= false;
				// 成功结果
				if( re.code == 'success' ){
					if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
					this.productList = re.data.data;
				}
			});
		},
		methods: {
			
		}
	}
</script>

<style lang="less">
.course_layout{
	width: 690rpx;
	margin: 30rpx auto;
	.course_list{
		display: block;
		width: 690rpx;
		.course_item{
			width:690rpx;
			display: block;
			background-color: #fafafa;
			padding: 1rpx 0rpx;
			margin: 20rpx 0rpx;
			.course_title{
				display: flex;
				width: 660rpx;
				margin: 20rpx auto;
				.left{
					width: 200rpx;
					// height: 200rpx;
					// background-color: aqua;
					// border: 2rpx solid;
					border-radius: 20rpx;
					image{
						width: 200rpx;
						height: 200rpx;
						border-radius: 20rpx;
						border: 2rpx solid;
					}
				}
				.right{
					font-size: 24rpx;
					margin-left: 20rpx;
					.title{
						font-size: 36rpx;
					}
					.skill{
						padding: 5rpx;
						margin: 10rpx 10rpx 10rpx 0rpx;
						color: #c9c9c9;
					}
					.course_option{
						display: flex;
						justify-content: space-between;
						flex-wrap: wrap;
						width: 420rpx;
						justify-content: ;
						.course_num{
							display: inline-flex;
							justify-content: center;
							width: 180rpx;
							border: 2rpx solid #3985ff;
							border-radius: 15rpx;
							margin: 5rpx;
							padding: 5rpx;
							color: #3985ff;
						}
						.remain_class{
							display: inline-flex;
							justify-content: center;
							width: 180rpx;
							margin: 5rpx;
							padding: 5rpx;
							background-color: #3985ff;
							border-radius: 15rpx;
							color: #ffffff;
						}
					}
					.course_remain{
							display: flex;
							justify-content: space-between;
							flex-wrap: wrap;
							width: 420rpx;
							margin-top: 30rpx;
						// .remain_class{
						// 	display: inline-flex;
						// 	justify-content: center;
						// 	width: 180rpx;
						// 	margin: 5rpx;
						// 	padding: 5rpx;
						// 	background-color: #3985ff;
						// 	border-radius: 15rpx;
						// 	color: #ffffff;
						// }
						.price{
							width: 180rpx;
							margin: 5rpx;
							padding: 5rpx;
							text-align: right;
							font-size: 30rpx;
						}
					}
				}
			}
			.btn_title{
				.title{
					margin-left: 20rpx;
				}
				.btn{
					
					display: flex;
					width: 690rpx;
					margin: 20rpx 0rpx;
					justify-content: space-between;
					.course_make_btn{
						width: 300rpx;
						height: 60rpx;
						line-height: 60rpx;
						text-align: center;
						padding: 10rpx;
						background-color: #1fbe7e;
						color: #ffffff;
						border-radius: 20rpx;
					}
					.user_course_btn{
						width: 300rpx;
						height: 60rpx;
						line-height: 60rpx;
						text-align: center;
						padding: 10rpx;
						background-color: #1fbe7e;
						color: #ffffff;
						border-radius: 20rpx;
					}
				}
				
			}
		}
	}
}
</style>
