<template>
	<view class="course-card">
		<view class="course-tips">
			<view class="">!</view>
			<view class="">全平台每种类型的运动课程只可免费试听一次</view>
		</view>
		<view class="select-btn">
			<view :class="sel_btn===index?'distance':'score'" v-for="(item,index) in selectList" :key="index"
				@click="select_btn(item,index)">{{item.name}}</view>
		</view>
		<view class="venue-card" v-for="item in listData" :key="item.id" @click="toCourseDetail(item)">
			<image :src="item.cover" mode=""></image>
			<view class="venue-info">
				<view class="info-title">
					<view class="title textHidden">{{item.name}}</view>
					<view class="sales">年售{{item.salesYear}}</view>
				</view>
				<view class="type">
					上课地点:{{item.address}} | {{item.km||'--'}}km
				</view>
				<view class="type">
					{{item.period||'0'}}课时 {{item.startTime}}-{{item.endTime}}
				</view>
				<view class="price">
					<view class="">￥{{item.sellingPrice}}</view>
					<view class="">￥{{item.originalPrice}}</view>
				</view>
				<view class="price-info">
					<view class="sale">
						已售{{item.sales}} {{item.goodRate}}%好评
					</view>
					<view class="price-btn">{{ item.hasDiscount?'免费试听':'立即购买' }}</view>
				</view>
			</view>
		</view>
		<view class="not-data" v-if="listData.length<1">暂无数据</view>
		<view class="more">查看更多</view>
	</view>
</template>

<script lang="ts" setup>
	import { ref } from 'vue';
	interface Props {
		listData ?: any;
		selectList?:any;
	}
	const props = withDefaults(defineProps<Props>(), {
		listData: [],
		selectList:[],
	});
	const emit = defineEmits(['change']);
	const sel_btn=ref(0);
	const select_btn=(e,i)=>{
		sel_btn.value=i
		emit('change', e, i);
	}
	
	const toCourseDetail=(e)=>{
		uni.navigateTo({
			url:`/pages/index/courseDetail/index?id=${e.id}&type=1`
		})
	}
</script>

<style lang="less" scoped>
	.course-card {
		padding: 20rpx;
		background: #FFFFFF;
		border-radius: 32rpx;
		margin-top: 20rpx;
		.course-tips {
			display: flex;
			align-items: center;
			gap: 10rpx;
			font-size: 24rpx;
			color: #999999;
		
			&>view:first-child {
				width: 32rpx;
				height: 32rpx;
				background:#FFA347;
				border-radius: 50%;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #FFFFFF;
			}
		}
		.select-btn {
			display: flex;
			align-items: center;
			gap: 20rpx;
			margin-top: 20rpx;
		
			.distance {
				width: 92rpx;
				height: 36rpx;
				background:#C8FF0C;
				border-radius: 8rpx;
				font-size: 24rpx;
				color: #222222;
				line-height:34rpx;
				text-align: center;
			}
		
			.score {
				width: 92rpx;
				height: 36rpx;
				background:#F5F5F5;
				border-radius: 8rpx;
				font-size: 24rpx;
				color:#AAAAAA;
				line-height:34rpx;
				text-align: center;
			}
		}
		.venue-card{
			display: flex;
			align-items: center;
			gap: 20rpx;
			margin-top: 20rpx;
			&>image{
				width: 200rpx;
				height: 200rpx;
				border-radius: 32rpx;
			}
			.venue-info{
				width: 430rpx;
				height: 260rpx;
				border-bottom: 1rpx solid #F0F0F0;
				.info-title{
					display: flex;
					align-items: center;
					justify-content: space-between;
					.title{
						width: 340rpx;
						font-weight: 800;
						font-size: 32rpx;
						color: #222222;
					}
					.sales{
						font-size: 22rpx;
						color: #AAAAAA;
					}
				}
				.type{
					margin-top: 16rpx;
					font-size: 24rpx;
					color: #AAAAAA;
				}
				.price{
					display: flex;
					align-items: center;
					gap: 20rpx;
					margin-top: 16rpx;
					&>view:nth-child(1){
						font-weight: bold;
						font-size: 28rpx;
						color: #FB5B5B;
					}
					&>view:nth-child(2){
						font-size: 22rpx;
						color: #AAAAAA;
						text-decoration: line-through;
					}
				}
				.price-info{
					display: flex;
					align-items: center;
					justify-content: space-between;
					.sale{
						font-size: 24rpx;
						color: #AAAAAA;
					}
					.price-btn{
						width: 152rpx;
						height: 48rpx;
						background: #C8FF0C;
						border-radius: 8rpx;
						font-weight: bold;
						font-size: 28rpx;
						color: #222222;
						text-align: center;
						line-height: 48rpx;
					}
				}
			}
		}
		.more{
			margin: auto;
			width:100rpx;
			margin-top: 20rpx;
			text-align: center;
			font-size: 24rpx;
			color: #CCCCCC;
			position: relative;
		}
		.more::after{
			position: absolute;
			bottom: -10rpx;
			left:25rpx;
			content: '';
			width: 38rpx;
			height: 4rpx;
			border-radius: 2rpx;
			background-color: #CCCCCC;
		}
	}
</style>