<template>
	<view class="container" :style="vuex_skin">
		<!-- #ifdef MP-WEIXIN -->
		<view class="navbar">
			<u-navbar title-color="#000000" :is-back="true" title="我的兑换"></u-navbar>
		</view>
		<!-- #endif -->
		<view class="tabs flex flex-direction" :style="'top:'+navbarHeight">
			<scroll-view scroll-x class="bg-white nav">
				<view class="flex text-center">
					<view class="cu-item flex-sub" :class="index==current?'text-base cur text-xl text-bold ':'text-lg'"
						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 @showOpinion="showOpinion" ref="mescrollItem" :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 {
				navbarHeight:'',
				current: 0,
				swiperCurrent: 0,
				tabs: [{
						name: '全部',
						value: '全部'
					}, {
						name: '待付款',
						value: '待付款'
					},
					{
						name: '待发货',
						value: '待发货'
					},
					{
						name: '待收货',
						value: '待收货'
					},
					{
						name: '已完成',
						value: '已完成'
					}
				],
			}
		},
		onReady() {
			// #ifdef MP-WEIXIN
			this.getElInfo()
			// #endif
			
			// #ifdef H5
			this.navbarHeight= '-10rpx'
			// #endif
		},
		methods: {
			getElInfo() {
				this.$u.getRect('.navbar').then(res => {
					this.navbarHeight= res.height - 4 + 'px'
				})
			},
			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: 80rpx 0rpx 0rpx;

		.tabs {
			position: fixed;
			left: 0;
			width: 100%;
			background-color: #FFFFFF;
			box-sizing: border-box;
			z-index: 3;
		}
	}
</style>
