<template>
	<view class="nav-title"
		:style="{height:navBarHeight+'px',opacity: navOpacity,transition: 'opacity 0.3s ease-in-out',background: backgroundColor }">
		<view class="back-icon" :style="{paddingTop:statusBarHeight+'px'}">
			<zzx-icon name="location" size="13"></zzx-icon>
			<view class="location-text">富力中心A7</view>
			<zzx-icon name="right" size="10"></zzx-icon>
		</view>
	</view>
	<view class="index-header">
		<image class="header-bg" src="@/static/index_bg.png" mode="widthFix"></image>
		<view class="back-icon" :style="{paddingTop:(statusBarHeight+10)+'px'}" v-if="navOpacity==0">
			<zzx-icon name="location" size="13"></zzx-icon>
			<view class="location-text">富力中心A7</view>
			<zzx-icon name="right" size="10"></zzx-icon>
		</view>
		<view class="content" style="padding-top:180rpx;" @click="gotoPage('/pages/index/search/index')">
			<view class="header-search">
				<zzx-icon name="search" size="16"></zzx-icon>
				<input type="text" placeholder="搜索俱乐部名称" />
				<view class="search-btn">
					搜索
				</view>
			</view>
		</view>
		<view class="header-banner">
			<swiper class="header-swiper" :autoplay="true" :current="currentIndex" :circular="true" previous-margin="80rpx"
				next-margin="80rpx" :interval="4000" :duration="500" @change="swierChange">
				<swiper-item v-for="(item,i) in bannerList" :key="i">
					<image :src="item.img" class="slide-image" :class="currentIndex === i?'active':''"></image>
				</swiper-item>
			</swiper>
		</view>
	</view>
	<view class="content">
		<view class="announcement" @click="gotoPage('/pages/index/messageNotice/index')">
			<image src="/src/static/gg-icon.png" mode="heightFix"></image>
			<view class="">
				<swiper class="announcement-swiper" :vertical="true" :circular="true" :autoplay="true" :interval="3000" :duration="1000">
					<swiper-item v-for="item in 3">
						<view class="swiper-item textHidden">学校为公益场地，请严格遵守相关规范！</view>
					</swiper-item>
				</swiper>
			</view>
			<zzx-icon name="ashRight" size="10"></zzx-icon>
		</view>
		<view class="grid-card">
			<view class="grid-item" @click="gotoPage('/pages/index/venue/index')">
				<view class="item-icon">
					<image src="/src/static/cd-icon.png" mode=""></image>
				</view>
				<view class="item-text">场地</view>
			</view>
			<view class="grid-item" @click="gotoPage('/pages/index/training/index')">
				<view class="item-icon">
					<image src="/src/static/px-icon.png" mode=""></image>
				</view>
				<view class="item-text">培训</view>
			</view>
			<view class="grid-item" @click="gotoPage('/pages/index/events/index')">
				<view class="item-icon">
					<image src="/src/static/ss-icon.png" mode=""></image>
				</view>
				<view class="item-text">赛事</view>
			</view>
		</view>
		<view class="course-card">
			<view class="commonweal" @click="gotoPage('/pages/index/training/index')">
				<view class="commonweal-title">
					<view class="title-left">
						<image src="/src/static/gy-icon.png" mode=""></image>
						<view class="">公益课</view>
					</view>
					<zzx-icon name="right" size="14"></zzx-icon>
				</view>
				<view class="commonweal-detail">
					<view class="detail-list" v-for="item in 3">
						<image
							src="https://bpic.588ku.com/element_origin_min_pic/23/07/11/d32dabe266d10da8b21bd640a2e9b611.jpg!r650">
						</image>
						<view class="detail-text">免费</view>
					</view>
				</view>
			</view>
			<view class="audition" @click="gotoPage('/pages/index/training/index')">
				<view class="audition-title">
					<view class="title-left">
						<image src="/src/static/st-icon.png" mode=""></image>
						<view class="">试听课</view>
					</view>
					<zzx-icon name="whiteRight" size="14"></zzx-icon>
				</view>
				<view class="audition-detail">
					<view class="detail-list" v-for="item in 3">
						<image src="@/static/index_bg.png"></image>
						<view class="detail-text">￥25</view>
					</view>
				</view>
			</view>
		</view>
		<view class="hot-instructor">
			<view class="i-title">
				<view class="i-hot">
					<view class="i-text">
						<text>热门教练</text>
					</view>
					<image src="/src/static/hot-icon1.png" mode="widthFix"></image>
				</view>
				<view class="i-more" @click="gotoPage('/pages/index/allInstructor/index')">
					<view class="">全部教练</view>
					<zzx-icon name="ashRight" size="10"></zzx-icon>
				</view>
			</view>
			<view class="i-info-card">
				<view class="i-card-list" :style="{background:index % 2=== 0?'linear-gradient(179deg, #FFD5FB 0%, #FFFFFF 40%)':'linear-gradient( 179deg, #F2FFBE 0%, #FFFFFF 40%)'}" v-for="(item,index) in 6">
					<view class="i-info" @click="gotoPage('/pages/index/instructorDetail/index')">
						<view class="header" :style="{background:index % 2=== 0?'#FFB8F9':'#C8FF0C'}">
							<image class="head-img" src="https://img.keaitupian.cn/newupload/08/1629449018344288.jpg"
								mode=""></image>
							<image class="head-tag" src="/src/static/badge.png" mode=""></image>
						</view>
						<view class="i-name-tag">
							<view class="name-tag">
								<view class="name">
									<view class="">
										<text>张慕斯</text>
									</view>
									<image v-if="index % 2=== 0" src="/src/static/name_bg.png" mode=""></image>
									<image v-else src="/src/static/name_bg1.png" mode=""></image>
								</view>
								<view class="tag">篮球</view>
							</view>
							<view class="ascription">贵州成人篮球俱乐部</view>
							<view class="sign">教育就是看到美并将其无限放大</view>
						</view>
						<view class="type-icon">
							<image src="/src/static/hot-icon2.png" mode=""></image>
						</view>
					</view>
					<view class="i-data">
						<view class="acclaim">
							<zzx-icon name="acclaim"></zzx-icon>
							<view style="color: #FFCC00;">好评 99%</view>
						</view>
						<view class="acclaim">
							<zzx-icon name="order"></zzx-icon>
							<view style="color: #4DDF96;">订单数 5577</view>
						</view>
						<view class="acclaim">
							<zzx-icon name="number"></zzx-icon>
							<view style="color: #AB7BFF;">授课人数 8659</view>
						</view>
					</view>
					<view class="i-skill">
						擅长：体能、篮球、其他运动培训。体能、篮球、其他运
						动培训。体能、篮球、其他运动培训。
					</view>
					<view class="i-course" v-for="item in 2">
						<view class="course-name">
							<view class="price">￥296</view>
							<view class="name textHidden">室内小班篮球培训课时室内小班篮球培训课时</view>
						</view>
						<view class="num">已售9999</view>
					</view>
					<view class="more">更多课程</view>
				</view>
			</view>
		</view>
				<view class="login-tips">
			<view class="">终于等到你！快去登录吧~</view>
			<view class="">马上登录</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import zzxNavbar from '@/components/zzx-navbar/zzx-navbar.vue';
	import { ref, onMounted } from 'vue'
	import { onLoad, onPageScroll } from '@dcloudio/uni-app';
	const navBarHeight = ref(0);
	const statusBarHeight = ref(0);
	const titleBarHeight = ref(0);
	const navOpacity = ref(0);
	const backgroundColor = ref('#D2FD73');
	onMounted(() => {
		get_navheight()
	})
	onPageScroll((e) => {
		navOpacity.value = Math.min(Math.max(e.scrollTop / navBarHeight.value, 0), 1);
	})
	const get_navheight = () => {
		const systemInfo = uni.getSystemInfoSync();
		statusBarHeight.value = systemInfo.statusBarHeight || 0;
		const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
		const titleBarHeightCalc = (menuButtonInfo.top - statusBarHeight.value) * 2 + menuButtonInfo.height;
		titleBarHeight.value = titleBarHeightCalc;
		navBarHeight.value = statusBarHeight.value + titleBarHeight.value;
	}

	const currentIndex = ref(0);
	const bannerList = ref([{
		img: 'https://bpic.588ku.com/element_origin_min_pic/23/07/11/d32dabe266d10da8b21bd640a2e9b611.jpg!r650'
	}, {
		img: 'https://ts1.tc.mm.bing.net/th/id/R-C.6f18e58bf3bacbcee226cb76dfc089a3?rik=61%2bMLnhOzFiZOg&riu=http%3a%2f%2fimages.shejidaren.com%2fwp-content%2fuploads%2f2014%2f07%2f085628m6c.jpg&ehk=v1vDvzVgPRc3irw6n%2bs5gF%2b5SEc1uCstErDhRaxqlgE%3d&risl=&pid=ImgRaw&r=0'
	}, {
		img: 'https://ts1.tc.mm.bing.net/th/id/R-C.a8553f142638e741396e386b43c2bca7?rik=dzSGk6XRsxAAsQ&riu=http%3a%2f%2fseopic.699pic.com%2fphoto%2f50062%2f5890.jpg_wh1200.jpg&ehk=BgxiqxvzoNQd0pZHWV4VPOMbYgqM76WDMt8RDzCjoYY%3d&risl=&pid=ImgRaw&r=0'
	}])
	const swierChange = (e) => {
		currentIndex.value = e.detail.current
	}

	const gotoPage = (path : string) => {
		uni.navigateTo({
			url: path
		})
	}
</script>

<style lang="less" scoped>
	.nav-title {
		position: fixed;
		width: 100%;
		text-align: center;
		font-size: 28rpx;
		z-index: 9999;
		display: flex;
		justify-content: center;
		align-items: center;

		.back-icon {
			position: absolute;
			left: 20rpx;
			z-index: 9999;
			display: flex;
			align-items: center;
			gap: 10rpx;
			font-weight: 800;
			font-size: 28rpx;
			color: #222222;
		}
	}

	.index-header {
		position: relative;
		height: 580rpx;

		.header-bg {
			position: absolute;
			width: 100%;
		}

		.back-icon {
			position: absolute;
			left: 20rpx;
			z-index: 9999;
			display: flex;
			align-items: center;
			gap: 10rpx;
			font-weight: 800;
			font-size: 28rpx;
			color: #222222;
		}

		.header-search {
			position: absolute;
			display: flex;
			align-items: center;
			gap: 10rpx;
			background: #fff;
			width: 685rpx;
			padding: 8rpx;
			border-radius: 40rpx;
			&>input {
				width: 670rpx;
				font-weight: bold;
				font-size: 24rpx;
				color: #CCCCCC;
			}

			.search-btn {
				width: 144rpx;
				height: 52rpx;
				background: #222222;
				border-radius: 28rpx;
				font-weight: bold;
				font-size: 28rpx;
				color: #C8FF0C;
				line-height: 52rpx;
				text-align: center;
			}
		}

		.header-banner {
			position: absolute;
			top: 240rpx;
			left: 0;
			width: 100%;
			height: 340rpx;
			.header-swiper{
				height: 340rpx;
			}
			.slide-image {
				position: absolute;
				height: 200rpx;
				width: 570rpx;
				border-radius: 15rpx;
				z-index: 5;
				opacity: 0.7;
				top: 18%;
				margin: 0 20rpx;
			}

			swiper {
				height: 430rpx;
			}

			.active {
				opacity: 1;
				z-index: 10;
				height: 316rpx;
				width: 572rpx;
				top: 7%;
				transition: all 0.2s ease-in 0s;
			}
		}
	}

	.announcement {
		margin-top: 20rpx;
		padding: 20rpx;
		background: #FFFFFF;
		border-radius: 32rpx;
		display: flex;
		justify-content: space-around;
		z-index: 9999;
		&>image {
			height: 32rpx;
		}

		&>view {
			font-size: 28rpx;
			color: #222222;
			width: 440rpx;
			.announcement-swiper{
				height: 40rpx;
			}
		}

	}

	.grid-card {
		padding: 20rpx;
		background: #FFFFFF;
		border-radius: 32rpx;
		display: flex;
		justify-content: space-around;
		margin-top: 20rpx;

		.grid-item {
			display: flex;
			flex-direction: column;
			align-items: center;

			.item-icon {
				width: 80rpx;
				height: 80rpx;

				&>image {
					width: 80rpx;
					height: 80rpx;
				}
			}

			.item-text {
				font-size: 24rpx;
				color: #222222;
				margin-top: 20rpx;
			}
		}
	}

	.course-card {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 20rpx;

		.commonweal {
			background: #C8FF0C;
			border-radius: 32rpx;
			padding: 30rpx;

			.commonweal-title {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.title-left {
					font-weight: 800;
					font-size: 32rpx;
					color: #222222;
					display: flex;
					gap: 10rpx;

					&>image {
						width: 40rpx;
						height: 40rpx;
					}
				}
			}

			.commonweal-detail {
				display: flex;
				justify-content: space-around;
				gap: 20rpx;
				margin-top: 20rpx;

				.detail-list {
					display: flex;
					flex-direction: column;
					align-items: center;

					&>image {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
					}

					.detail-text {
						margin-top: 16rpx;
						font-size: 24rpx;
						color: #222222;
					}
				}
			}
		}

		.audition {
			background: #AB7BFF;
			border-radius: 32rpx;
			padding: 30rpx;

			.audition-title {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.title-left {
					font-weight: 800;
					font-size: 32rpx;
					color: #FFFFFF;
					display: flex;
					gap: 10rpx;

					&>image {
						width: 40rpx;
						height: 40rpx;
					}
				}
			}

			.audition-detail {
				display: flex;
				justify-content: space-around;
				gap: 20rpx;
				margin-top: 20rpx;

				.detail-list {
					display: flex;
					flex-direction: column;
					align-items: center;

					&>image {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
					}

					.detail-text {
						margin-top: 16rpx;
						font-size: 24rpx;
						color: #fff;
					}
				}
			}
		}
	}

	.hot-instructor {
		margin-top: 20rpx;
		position: relative;

		.i-title {
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: #fff;
			padding: 0 20rpx 0 20rpx;
			border-radius: 32rpx 32rpx 0 0;

			.i-hot {
				display: flex;
				align-items: center;
				font-weight: bold;
				font-size: 32rpx;
				color: #222222;
				position: relative;
				height: 100rpx;

				.i-text {
					position: relative;
					width: 130rpx;
					margin-top: 30rpx;

					&>text {
						position: absolute;
						bottom: 0;
						z-index: 1;
					}
				}

				.i-text::after {
					position: absolute;
					content: '';
					bottom: -6rpx;
					left: 20rpx;
					width: 80rpx;
					height: 20rpx;
					background-color: #D3FD76;
					border-radius: 4rpx;
				}

				&>image {
					position: absolute;
					width: 300rpx;
					top: 0;
					left: 140rpx;
				}
			}

			.i-more {
				font-size: 24rpx;
				color: #AAAAAA;
				display: flex;
				align-items: center;
				gap: 10rpx;
			}
		}

		.i-info-card {
			position: absolute;

			.i-card-list {
				margin-bottom:24rpx;
				border-radius: 32rpx;
				padding: 20rpx;
				width: 670rpx;
				height: 480rpx;
			}

			.i-info {
				display: flex;
				align-items: center;
				justify-content: space-around;

				.header {
					width: 150rpx;
					height: 150rpx;
					border-radius: 32rpx;
					// background: #FFB8F9;
					padding: 4rpx;
					position: relative;

					.head-img {
						width: 150rpx;
						height: 150rpx;
						border-radius: 32rpx;
					}

					.head-tag {
						position: absolute;
						bottom: 0;
						right: -14rpx;
						width: 36rpx;
						height: 36rpx;
					}
				}

				.i-name-tag {
					.name-tag {
						display: flex;
						align-items: center;
						gap: 8rpx;

						.name {
							width: 134rpx;
							height: 60rpx;
							font-weight: 800;
							font-size: 36rpx;
							color: #222222;
							position: relative;

							&>view {
								&>text {
									position: absolute;
									z-index: 1;
								}
							}

							&>image {
								top: 0;
								left: 0;
								position: absolute;
								width: 133rpx;
								height: 48rpx;
							}
						}

						.tag {
							font-size: 24rpx;
							color: #AAAAAA;
						}
					}

					.ascription {
						font-size: 24rpx;
						color: #222222;
					}

					.sign {
						margin-top: 20rpx;
						font-weight: bold;
						font-size: 24rpx;
						color: #222222;
					}
				}

				.type-icon {
					&>image {
						width: 106rpx;
						height: 100rpx;
					}
				}
			}

			.i-data {
				display: flex;
				align-items: center;
				gap: 28rpx;
				margin-top: 20rpx;

				.acclaim {
					display: flex;
					align-items: center;
					gap: 10rpx;
					font-size: 24rpx;
				}
			}

			.i-skill {
				width: 700rpx;
				margin-top: 20rpx;
				font-size: 24rpx;
				color: #AAAAAA;
			}

			.i-course {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 20rpx;

				.course-name {
					display: flex;
					align-items: center;
					gap: 20rpx;

					.price {
						font-weight: bold;
						font-size: 28rpx;
						color: #FB5B5B;
					}

					.name {
						width: 440rpx;
						font-weight: bold;
						font-size: 28rpx;
						color: #222222;
					}
				}

				.num {
					font-size: 24rpx;
					color: #AAAAAA;
				}
			}

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

	.login-tips {
		position: fixed;
		bottom: 22rpx;
		width: 686rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 10rpx;
		background: rgba(0, 0, 0, 0.6);
		border-radius: 8rpx;
		z-index: 9999;
		&>view:first-child {
			font-size: 28rpx;
			color: #FFFFFF;
		}

		&>view:last-child {
			width: 160rpx;
			height: 60rpx;
			background: #C8FF0C;
			border-radius: 8rpx;
			font-size: 28rpx;
			color: #222222;
			text-align: center;
			line-height: 60rpx;
		}
	}
</style>