<template>
	<view class="tab_page" :style="{'height':h+'px', 'padding-top':mt+'px'}">
		<up-navbar title=" " bgColor="transparent">
            <template #left>
				<view class="u-nav-slot" slot="left" style="display: flex;background-color: transparent;">
					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/a5ad7f10-d625-4c9a-89f3-59f98c56dee8.png" style="width: 370rpx;height: 40rpx;"></image>
				</view>
			</template>
		</up-navbar>
		<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/a7f990ec-1bff-4bd6-8b7f-fa61c0170d3b.png" class="top_bg_img" mode="widthFix"></image>
		<div class="c-box adffc">
			<div class="c-box-lunbo">
				<up-swiper
					:list="bannarList"
					@change="e => current = e.current"
					:autoplay="false"
					height="326rpx"
				>
					<template #indicator>
						<view class="indicator adf">
							<view class="indicator__dot" v-for="(item, index) in bannarList" :key="index"
								:class="[index === current && 'indicator__dot--active']">
							</view>
						</view>
					</template>
				</up-swiper>
			</div>
			<div class="c-box-title adfacjb">
				<div class="c-box-title-left">公益活动</div>
				<div class="c-box-title-right adfac">更多 <up-icon name="arrow-right" size="30rpx" style="margin-left: 10rpx;"></up-icon></div>
			</div>
			<div class="c-box-type">
				<scroll-view class="scroll-view_H" scroll-x="true" scroll-with-animation="true" :scroll-left="scrollLeft">
					<view class="scroll-view-item_H" :id="'svih_'+index" v-for="(item,index) in typeList" :key="index" @tap="changeType(item,index)">
						<view class="cl_item" :class="{'active':tlIndex===index}">
							<text>{{item.name}}</text>
						</view>
					</view>
				</scroll-view>
			</div>
			<div class="c-box-list">
				<NonprofitActivety></NonprofitActivety>
				<NonprofitActivety></NonprofitActivety>
			</div>
		</div>
		<CusTabbar :tabbarIndex="0"></CusTabbar>
	</view>
</template>

<script setup name="">
	import CusTabbar from '@/components/CusTabbar/index.vue'
	import NonprofitActivety from '@/components/pages/nonprofitActivety/index.vue'
	import { ref, getCurrentInstance, onMounted } from 'vue'
	const { proxy } = getCurrentInstance()
	
	const bannarList = ref([
		'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/337c22f0-2583-4556-84b6-eb21fdde6e82.png',
		'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/337c22f0-2583-4556-84b6-eb21fdde6e82.png',
		'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/337c22f0-2583-4556-84b6-eb21fdde6e82.png'
	])
	const current = ref(0)
	const typeList = ref([
		{id:'',name:'全部'},
		{id:1,name:'儿童关爱'},
		{id:2,name:'老人关爱'},
		{id:3,name:'社区发展'},
		{id:4,name:'社会服务'},
		{id:5,name:'健康行动'},
		{id:6,name:'减肥运动'}
	])
	const tlIndex = ref(0)
	const scrollLeft = ref(0)
	
	const changeType = (item,index) => {
		tlIndex.value = index;
		if(typeList.value.length>4){
			if(index<3) scrollLeft.value = 0
			else{
				scrollLeft.value = (index-2)*172/2;
			}
		}
	}
</script>

<style scoped lang="scss">
	::v-deep .indicator__dot{
		width: 48rpx;
		height: 4rpx;
		background: #E2E5E9;
		border-radius: 2rpx;
		margin: 0 8rpx;
	}
	::v-deep .indicator__dot--active{
		width: 48rpx;
		height: 4rpx;
		background: #00AE57;
		border-radius: 2rpx;
	}
	
	.scroll-view_H {
		white-space: nowrap;
		width: 100%;
	}
	
	.scroll-view-item_H {
		display: inline-block;
		width: 152rpx;
		height: 100%;
		margin-left: 20rpx;
		&:first-child{
			margin-left: 0;
		}
	}
	
	.tab_page{
		.c-box{
			width: 100%;
			height: 100%;
			overflow-y: auto;
			position: relative;
			&-lunbo{
				width: 100%;
				height: 326rpx;
				margin-top: 20rpx;
			}
			&-title{
				margin-top: 58rpx;
				&-left{
					width: 170rpx;
					height: 44rpx;
					padding-left: 2rpx;
					font-family: PingFang-SC, PingFang-SC;
					font-weight: 800;
					font-size: 36rpx;
					color: #151B29;
					line-height: 36rpx;
					background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/6ec1f999-fcbb-4a0b-a1a5-d0b5e1374bb1.png');
					background-size: 170rpx 31rpx;
					background-position: 0 20rpx;
					background-repeat: no-repeat;
				}
				&-right{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #676775;
					line-height: 33rpx;
				}
			}
			&-type{
				width: 100%;
				height: 68rpx;
				margin-top: 31rpx;
				.cl_item{
					width: 152rpx;
					height: 68rpx;
					background: #FFFFFF;
					border-radius: 34rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #676775;
					line-height: 68rpx;
					text-align: center;
					&.active{
						background: #B7F358;
						font-weight: bold;
						font-size: 30rpx;
						color: #151B29;
					}
				}
			}
			&-list{
				width: 100%;
				flex: 1;
				overflow-y: auto;
			}
		}
	}
</style>