<template>
	<view class="coupon-swiper">
		<u-tabs-swiper ref="coupon" :list="couponGroupList" :is-scroll="true" active-color="#FF780F" :current="couponCurrent" font-size="24" :show-bar="false" @change="couponTabsChange" height="88" ></u-tabs-swiper>
		<swiper :current="swiperCouponCurrent" @animationfinish="couponAnimationFinish" :style="{ height: swiperHeight }">
			<swiper-item class="swiper-coupon-item" v-for="(_, i) in couponGroupList" :key="i">
				<scroll-view scroll-y style="height: 100%;">
					<view v-for="(coupon, index) in couponList" :key="index" class="coupon-item">
						<!-- <img src="../static/mine/23.png" />
						<view class="coupon-main">
							<view class="coupon-title">萌店十元优惠券</view>
							<view class="coupon-date">
								<img src="../static/mine/26.png" />
								<view>2020.05.17-2020.06.17</view>
							</view>
							<view class="coupon-integral">299积分</view>
						</view>
						<view class="coupon-btn">兑换</view> -->
						<Coupon :couponInfo="coupon" :status='0' :type="0" @exchange="exchangeCoupon($event)"></Coupon>
					</view>
					<u-empty text="暂无优惠券" mode="coupon" color="#000" v-if="!couponList.length"></u-empty>
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>
<script>
import Coupon from "@/components/mine/coupon/index";
export default {
	data() {
		return {
			swiperHeight: '',
			couponCurrent: 0,
			swiperCouponCurrent: 0,
			couponGroupList: [
				{
					name: '平台'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}, {
					name: '分类名称'
				}
			],
			couponList: [
				{
					index: 0
				},
				{
					index: 1
				},
			],
		}
	},
	components: {
		Coupon
	},
	created() {
		this.setViewHeight();
	},
	methods: {
		exchangeCoupon(id) {
			console.log(id);
			
		},
		couponTabsChange(index) {
			this.couponCurrent = index;
		},
		couponAnimationFinish(e) {
			const current = e.detail.current;
			this.swiperCouponCurrent = current;
			this.couponCurrent = current;
		},
		setViewHeight() {
			const res = uni.getSystemInfoSync();
			this.swiperHeight = res.windowHeight - ((88 + 10 + 88) / 2) + 'px';
		},
	},
};
</script>
<style lang="scss" scoped>
.coupon-swiper {
	.swiper-coupon-item {
		box-sizing: border-box;
		background-color: #ffffff;
		padding: 30rpx {
			top: 0;
		};
		.coupon-item {
			margin-bottom: 20rpx;
		}
		// .coupon-item {
		// 	padding: 30rpx;
		// 	background-color: #ffffff;
		// 	display: flex;
		// 	align-items: flex-end;
		// 	// margin-bottom: 2rpx;
		// 	> img {
		// 		width: 180rpx;
		// 		height: 160rpx;
		// 		border-radius: 10rpx;
		// 		margin-right: 30rpx;
		// 	}
		// 	.coupon-main {
		// 		.coupon-title {
		// 			font-size: 30rpx;
		// 			color: rgba(51,51,51,1);
		// 		}
		// 		.coupon-date {
		// 			display: flex;
		// 			align-items: center;
		// 			margin: 29rpx 0 20rpx;
		// 			> img {
		// 				width: 24rpx;
		// 				height: 24rpx;
		// 				margin-right: 15rpx;
		// 			}
		// 			> view {
		// 				font-size: 24rpx;
		// 				color: rgba(153,153,153,1);
		// 			}
		// 		}
		// 		.coupon-integral {
		// 			font-size: 30rpx;
		// 			font-weight: 500;
		// 			color: rgba(255,120,15,1);
		// 		}
		// 	}
		// 	.coupon-btn {
		// 		margin-left: auto;
		// 		width: 85rpx;
		// 		// height: 42rpx;
		// 		border: 2rpx solid rgba(255,120,15,1);
		// 		border-radius: 10rpx;
		// 		font-size: 26rpx;
		// 		color: rgba(255,120,15,1);
		// 		line-height: 42rpx;
		// 		text-align: center;
		// 	}
		// }
	}
}
</style>