<template>
    <view 
        class="record-item c-gap-top"
        :class="{
            'record-item--disable': data.status !== 1,
        }"
    >
        <view class="record-item__cont c-font-normal">
            <view class="record-item__cont__title c-font-medium c-text-gap-cancel">{{ data.vipName }}</view>
            <view v-if="data.exchangeDate" class="record-item__cont__date c-text-gap-cancel">{{ data.exchangeDate }}</view>
            <view v-if="data.validityTime" class="record-item__cont__validity c-text-gap-cancel">{{ data.validityTime }}</view>
        </view>
        <view 
            v-if="data.statusText" 
            class="record-item__btn c-font-normal"
            @tap="onBtnTap(data)"
        >
            <text class="record-item__btn__text">{{ data.statusText }}</text>
        </view>
    </view>
</template>

<script>
/**
 * @file 兑换记录Item
 * @author jiaxiangju
 * @categories 业务组件
 * @tags [component]
 */
import {navigate} from '@utils/navigate';
export default {
    config: {
        component: true
    },
    options: {
        addGlobalClass: true
    },
    data() {
        return {};
    },
    props: {
        /**
         * 数据
         */
        data: {
            type: Object,
            default: () => {
                return {};
            }
        }
    },
    methods: {
        onBtnTap(data) {
            if (data.status !== 1) {
                this.$api.showToast({title: '您兑换的会员已到期', icon: 'none'});
            } else if (data.url) {
                navigate({
                    url: data.url
                });
            }
        }
    }
};
</script>
<style lang="less" scoped>
.record-item {
    position: relative;
    background: #fff3dd;
    height: 1.02rem;
    border-radius: 0.09rem;
    padding: 0 0.13rem;
    display: flex;
    align-items: center;
    &__cont {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        color: #2c1800;
        &__title {
            font-weight: bold;
            margin-bottom: .11rem;
        }
        &__date {
            margin-bottom: .09rem;
        }
    }
    &__btn {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
        width: 0.74rem;
        height: 0.3rem;
        border-radius: 0.15rem;
        background-image: linear-gradient(137deg, #F5DEB7 0%, #E9B966 100%);
        color: #402200;
        font-weight: bold;
    }
    &--disable {
        background: #FAFAFA;
        color: #858585;
        .record-item__cont {
            color: #858585;
        }
        .record-item__btn {
            background-image: linear-gradient(-45deg, #B5B5B5 0%, #E0E0E0 100%);
            color: #fff;
        }
    }
    
}
</style>
