<template>
    <!-- TODO -->
    <view class="coupon-find-list">
        <!-- tabs -->
        <tui-tabs
            :tabs="tabs"
            :currentTab="currentTab"
            @change="tabChange"
            :sliderWidth="118"
            color="#333333"
            selectedColor="#FF457B"
            sliderBgColor="#FF457B"
        ></tui-tabs>
        <!-- 优惠券列表 -->
        <swiper
            :indicator-dots="false"
            :autoplay="false"
            class="swiper"
            :style="{ height: swiperHeight + 'px' }"
            :current="currentTab"
            @change="swiperChange"
        >
            <swiper-item class="coupon-list"> <cm-coupon :key="i" v-for="i in 15"></cm-coupon> </swiper-item>
            <swiper-item class="coupon-list"> <cm-coupon :key="i" v-for="i in 3"></cm-coupon> </swiper-item>
            <swiper-item class="coupon-list"> 
                <cm-empty message="暂无任何优惠券~" :image="baseUrl + 'icon-coupon-empty.png'" :offset="-12"></cm-empty>
            </swiper-item>
        </swiper>
        <!-- 跳转领券中心 -->
        <view class="footer"> <view class="btn">领券中心</view> </view>
    </view>
</template>

<script>
import CmCoupon from '@/components/cm-module/cm-coupon/cm-coupon.vue'
import CmEmpty from '@/components/cm-module/cm-empty/cm-empty.vue'
import { mapGetters } from 'vuex'
export default {
    components: {
        CmCoupon,
        CmEmpty
    },
    data() {
        return {
            baseUrl: this.$Static,
            tabs: [
                {
                    name: '未使用10'
                },
                {
                    name: '已使用10'
                },
                {
                    name: '已失效10'
                }
            ],
            currentTab: 0
        }
    },
    computed: {
        ...mapGetters(['windowHeight', 'isIphoneX']),
        swiperHeight() {
            if (this.isIphoneX) {
                return this.windowHeight - 120
            }
            return this.windowHeight - 80
        }
    },
    onLoad() {},
    methods: {
        tabChange(e) {
            this.currentTab = e.index
        },
        swiperChange(e){
            this.currentTab = e.detail.current
        }
    }
}
</script>

<style lang="scss" scoped>
page{
    width: 100%;
    height: 100%;
    background: #f7f7f7;
}
.swiper {
    height: 800rpx;
    background: #f7f7f7;
    .coupon-list{
        height: 100%;
        overflow-y: scroll;
    }
}
.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f7f7f7;
    padding-top: 20rpx;
    .btn {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 600rpx;
        height: 90rpx;
        background: linear-gradient(90deg, #fc32b4 0%, #f83c6c 100%);
        border-radius: 45rpx;
        font-size: 30rpx;
        color: #ffffff;
    }
}
</style>
