<template>
	<view class="message-container">
		<!-- 固定背景的容器 -->
		<view class="background-container"></view>

		<!-- 可滚动的内容区域 -->
		<view class="content-container" :style="'height:'+height+'px'">

			<u-swiper class="u-m-t-60" :list="list" name="url" height="324"></u-swiper>

			<view class="menu-list">
				<swiper class="swiper" @change="changeMenu">
					<swiper-item>
						<u-grid :col="4" :border="false">
							<u-grid-item bg-color="transparent">
								<u-icon name="/static/home/1.png" :size="120"></u-icon>
								<view class="grid-text">精选直播</view>
							</u-grid-item>
							<u-grid-item bg-color="transparent">
								<u-icon name="/static/home/2.png" :size="120"></u-icon>
								<view class="grid-text">订单数据</view>
							</u-grid-item>
							<u-grid-item bg-color="transparent" @click="openMall">
								<u-icon name="/static/home/3.png" :size="120"></u-icon>
								<view class="grid-text">商城好物</view>
							</u-grid-item>
							<u-grid-item bg-color="transparent">
								<u-icon name="/static/home/4.png" :size="120"></u-icon>
								<view class="grid-text">获得积分</view>
							</u-grid-item>
						</u-grid>
					</swiper-item>
					<swiper-item>
						<u-grid :col="4" :border="false">
							<u-grid-item bg-color="transparent">
								<u-icon name="/static/home/5.png" :size="120"></u-icon>
								<view class="grid-text">微信读书</view>
							</u-grid-item>
						</u-grid>
					</swiper-item>
				</swiper>

				<view class="indicator-dots">
					<view class="indicator-dots-item" :class="current==0?'indicator-dots-active':''">
					</view>
					<view class="indicator-dots-item" :class="current==1?'indicator-dots-active':''">
					</view>
				</view>
			</view>
		</view>

		<Tabbar id="tabbarId"></Tabbar>
	</view>
</template>

<script setup lang="ts">
	import { ref, computed, getCurrentInstance } from 'vue';
	import {
		onReady
	} from '@dcloudio/uni-app';
	import { onReady as onUniReady } from '@dcloudio/uni-app';
	const instance = getCurrentInstance();

	const height = ref(0)

	const loadHeight = () => {
		uni.getSystemInfo({
			success(res) {
				let screenHeight = res.screenHeight
				uni.createSelectorQuery().in(instance.proxy).select("#tabbarId").boundingClientRect((data : any) => {
					height.value = screenHeight - data.height
				}).exec()
			}
		})
	}

	const list = [
		{ url: '/static/banner/1.png' },
		{ url: '/static/banner/2.png' },
		{ url: '/static/banner/3.png' },
	]

	const current = ref(0)
	const changeMenu = (val : any) => {
		current.value = val.detail.current
	}

	const openMall = () => {
		uni.navigateTo({
			url: '/pages/mall/mall'
		})
	}

	onUniReady(() => {
		loadHeight()
	})
</script>

<style lang="scss" scoped>
	.message-container {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		height: 100%;
		overflow: hidden;
		/* 防止容器本身滚动 */

		/* 固定背景 */
		.background-container {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			background: linear-gradient(180deg, #2F75F9 0%, #F0F3FF 34.13%);
			z-index: 1;
			/* 确保背景在内容下方 */
		}

		/* 内容滚动区域 */
		.content-container {
			position: relative;
			z-index: 2;
			/* 确保内容在背景上方 */
			width: 100%;
			overflow-y: scroll;
			height: 100%;
			// padding: 32rpx;

			.menu-list {
				border-top-left-radius: 32rpx;
				border-top-right-radius: 32rpx;
				box-shadow: 0rpx -8rpx 20rpx 0rpx #628AC080;
				padding-bottom: 20rpx;

				.swiper {
					height: 200rpx;

					.grid-text {
						font-family: Work Sans;
						font-weight: 400;
						font-style: Regular;
						font-size: 28rpx;
						leading-trim: NONE;
						line-height: 32rpx;
						letter-spacing: -2%;
						text-align: center;
					}
				}


				.indicator-dots {
					// margin-top: 40rpx;
					display: flex;
					justify-content: center;
					align-items: center;
				}

				.indicator-dots-item {
					background-color: $u-tips-color;
					height: 6px;
					width: 6px;
					border-radius: 10px;
					margin: 0 3px;
				}

				.indicator-dots-active {
					background-color: $u-type-primary;
				}
			}
		}
	}
</style>