<template>
	<view class="container">
		<view class="tabs" style="width: 420rpx;margin: 0rpx  auto;padding-top: 20rpx;">
			<scroll-view scroll-x class="nav">
				<view class="flex text-center">
					<view style="border: 1rpx solid #5064eb;padding:15rpx 20rpx;" class="flex-sub"
						:class="index==current?'nav-checked':'nav-unchecked'" v-for="(item,index) in tabs" :key="index"
						@tap="tabChange(index)">
						{{item.name}}
					</view>
				</view>
			</scroll-view>
		</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 @showDetail="showDetail" :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 {
				scrollLeft: 0,
				current: 0,
				swiperCurrent: 0,
				tabs: [{
						name: '全部记录',
						value: ''
					},
					{
						name: '异常记录',
						value: 1
					}
				],
			}
		},
		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;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		height: calc(100vh);
		background-color: #F6F6F6;
		padding: 100rpx 0rpx 0rpx;

		.tabs {
			height: 100rpx;
			position: fixed;
			top: 0rpx;
			left: 0;
			right: 0;
			width: 100%;
			z-index: 3;
		}
	}

	.nav-checked {
		background-color: $base-color;
		color: #FFFFFF;
		font-weight: 800;
	}

	.nav-unchecked {
		background-color: #FFFFFF;
		color: $base-color;
	}
</style>
