<template>
  <view class="page">
		<navbar title="代金券" leftClick @leftClick="$utils.navigateBack" color="#fff" />

		<view class="tabs">
			<uv-tabs 
				:list="tabs" 
				@click="onTabChange" 
				:customStyle="{
					backgroundColor: '#FFFFFF',
				}"
				:activeStyle="{
					color: '#84A73F',
					fontSize: '28rpx',
					whiteSpace: 'nowrap',
					paddingTop: '29rpx',
					paddingBottom: '21rpx',
				}"
				:inactiveStyle="{
					color: '#000000',
					fontSize: '28rpx',
					whiteSpace: 'nowrap',
					paddingTop: '29rpx',
					paddingBottom: '21rpx',
				}"
				lineHeight="5rpx" 
				lineWidth="92rpx" 
				lineColor="linear-gradient(to right, #84A73F, #D8FF8F)"
				:scrollable="false"
			></uv-tabs>
		</view>

    <template v-if="current == 0" >
      <view class="list voucher">
        <voucherCard class="list-item"
          v-for="item in list"
          :key="item.id"
          :data="data"
        ></voucherCard>
      </view>
    </template>
    <template v-else-if="current == 1" >
      <view class="list store">
        <storeCard class="list-item"
          v-for="item in list"
          :key="item.id"
          :data="data"
        ></storeCard>
      </view>
    </template>
  </view>
</template>

<script>
	import mixinsList from '@/mixins/list.js'
  import voucherCard from '../components/voucher/voucherCard.vue'
  import storeCard from '../components/voucher/storeCard.vue'

  const TAB_AND_API_FIELDS_MAPPING = {
    // todo: 接口对接
    0: 'fetchVoucher',
    1: 'fetchStore',
  }

  export default {
		mixins : [mixinsList],
    components: {
      voucherCard,
      storeCard,
    },
    data() {
      return {
        tabs: [{
          name: "代金券"
        }, {
          name: "可使用门店"
        }],
        current: 0
      };
    },
    computed: {
      mixinsListApi() {
        // todo
        return TAB_AND_API_FIELDS_MAPPING[this.current]
      }
    },
    methods: {
      onTabChange(e) {
        this.current = e.index
      }
    },
  }
</script>


<style scoped lang="scss">
	.page {
		background-color: $uni-bg-color;
		min-height: 100vh;
				
		/deep/ .nav-bar__view {
			background-image: linear-gradient(#84A73F, #D8FF8F);
		}
	}
	

	.tabs {
		/deep/ .uv-tabs__wrapper__nav__line {
			bottom: 0;
		}
	}

  .list {
    &-item {
      & + & {
        margin-top: 20rpx;
      }
    }

    &.voucher {
      padding: 30rpx 28rpx;
    }

    &.store {
      padding: 29rpx 13rpx;
    }
  }
	
</style>