<template>
	<view class="container">
		<view class="tabs">
			<u-tabs-swiper ref="uTabs"
				name="label"
				:active-item-style="activeItemStyle"
			    bg-color="#DE2910"
				active-color="#fff"
				inactive-color="#fff"
				:show-bar="false"
				:list="tabs" :current="current"
				 @change="tabChange" :is-scroll="true"
				 swiperWidth="750"></u-tabs-swiper>
		</view>
		<view style="height: 100%;">
			<swiper style="height: 100%;" :current="current"  @change="swiperChange"
				@animationfinish="animationfinish">
				<swiper-item  v-for="(item, index) in tabs" :key="index">
					<scroll-view scroll-y style="height: 100%;">
						<item  :i="index" :item="item" :type="current"></item>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>
<script>
	import item from "./comps/item.vue"
	export default {
		components: {
			item
		},
		data() {
			return {
				activeItemStyle:{
					fontSize:'38rpx'
				},
				
				current: 0,
				swiperCurrent:0,
				tabs: [],
			}
		},
		onLoad() {
			this.getDict()
		},
		methods:{
			tabChange(index) {
				this.current = index
			},
			swiperChange(e) {
			  uni.pageScrollTo({
			      scrollTop: 0,
			      duration: 0
			  });
			  this.current = e.detail.current
			},
			animationfinish({detail: { current }}) {
				this.swiperCurrent = current;
				this.current = current;
			},
			getDict(){
				this.tabs=[{label: '全部',value:-1}]
				let dict=this.$cache.get('dict')
				if (dict&&!this.$isEmpty(dict.partyMeetingClass)) {
					//缓存中有字典值
					this.tabs=this.tabs.concat(dict.partyMeetingClass)
					return
				}
				this.$api.dict({code:'party_meeting_class'}).then(res=>{
					res.data.forEach((item)=>{
						let tmp={
							value:item.dictKey,
							label:item.dictValue
						}
						this.tabs.push(tmp)
					})
				})
			}
		}
	}
</script>



<style lang="scss" >
	.text-checked{
		font-size: 34rpx;
		font-weight: 800;
		color: #FFFFFF;
	}
	.container {
	  height: calc(100vh);
	  background-color: #F6F6F6;
	  padding: 70rpx 0rpx 0rpx;
	 .tabs {
	    position: fixed;
	    top: -10rpx;
		left: 0;
		width: 100%;
		background-color: #FFFFFF;
		box-sizing: border-box;
		z-index: 3;
	  }
}
</style>