<template>
  <div class="mainPage">
    <swiper :options="swiperOption" ref="mySwiper" class="inner" v-if="detail.length > 0">
      <swiper-slide class="swiper-slide" v-for="(item,index) in detail" :key="index">
        <div class="vip-box">
          <div class="vip-header">
            <img :src='vipBg' width="100%" height="100%">
            <div>
              <span class="balance">￥ <span>{{item.Balance}}</span></span>
              <span class="date">vip有效日期：{{toolClass.dateFormat(item.BeginDate, 'yyyy-MM-dd')}} ~ {{toolClass.dateFormat(item.EndDate, 'yyyy-MM-dd')}}</span>
            </div>
          </div>
          <div class="vip-detail-list">
            <div class="title">账单明细</div>
            <div class="list-box">
              <div class="list" v-for="(items,indexs) in item.Changes" :key="indexs">
                <span>{{items.SourceName}}</span>
                <span>{{items.FloatType}}{{items.Amount}}</span>
                <span class="date">{{toolClass.dateFormat(items.CreateDate)}}</span>
              </div>
            </div>
          </div>
        </div>
      </swiper-slide>
    </swiper>
    <div class="swiper-pagination" v-if="detail.length > 0"></div>
    <noMore v-if='detail.length <= 0'></noMore>
  </div>
</template>

<script>
import vipBg from '../../../common/icon/vipBg.jpg'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
import noMore from '../../../components/noMore/noMore'
import { createNamespacedHelpers } from 'vuex'
const { mapState: mapVipState, mapActions: mapVipActions } = createNamespacedHelpers('vip')
export default {
  data () {
    return {
      vipBg,
      swiperOption: {
        observer: true,
        pagination: {
          el: '.swiper-pagination',
          type: 'bullets',
          //type: 'fraction',
          //type : 'progressbar',
          //type : 'custom',
          clickable: true, //此参数设置为true时，点击分页器的指示点分页器会控制Swiper切换。
        },
      }
    }
  },
  components: {
    swiper,
    swiperSlide,
    noMore
  },
  created () {
    this.getVipDetail().then((res) => {
      console.log(this.detail)
    })
  },
  computed: {
    MySwiper () {
      return this.$refs.mySwiper.swiper
    },
    ...mapVipState({
      detail: item => item.vipDetails
    })
  },
  methods: {
    ...mapVipActions(['getVipDetail'])
  }
}
</script>

<style lang="scss" scoped>
@import 'page.scss';
</style>

<style>
.swiper-pagination > span {
  margin: 0 0.025rem;
}
</style>
