<template>
  <div class="records">
    <div class="records__layouts">
      <div class="records__entry" @click="openRecord">
        <div class="records__entry-wrap">
          <p>抽奖</p>
          <p>记录</p>
        </div>
      </div>
      <div v-if="isShowWinnersList" class="records__entry records__entry--winners" @click="openRecordPopup('winners')">
        <div class="records__entry-wrap">
          <p>中奖</p>
          <p>名单</p>
        </div>
      </div>
    </div>
    <RecordsPupup v-model="isShowRecordsPopup" :active-tab="activeTab" :is-show-winners-list="isShowWinnersList"></RecordsPupup>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
import RecordsPupup from '@/components/Lottery/Instant/RecordsPupup'

export default {
  name: 'Records',
  components: {
    RecordsPupup
  },
  data() {
    return {
      isShowRecordsPopup: false,
      activeTab: 'personal'
    }
  },
  computed: {
    ...mapGetters({ isLogin: 'users/isLogin', lotteryInfo: 'lottery/lotteryInfo' }),
    isShowWinnersList() {
      const { lotteryInfo } = this
      return !!lotteryInfo.showResult
    }
  },
  methods: {
    ...mapActions({ jumpToLogin: 'users/jumpToLogin' }),
    openRecord() {
      if (!this.isLogin) {
        this.$toast({
          message: '请先登录，正在为您转跳',
          duration: 1500,
          onClose: () => {
            this.jumpToLogin()
          }
        })
      } else {
        this.openRecordPopup('personal')
      }
    },
    openRecordPopup(type){
      this.activeTab = type
      this.isShowRecordsPopup = true
    }
  }
}
</script>

<style lang="less" scoped>
.records {
  &__layouts {
    position: fixed;
    z-index: 5;
    right: 10px;
    bottom: 75px;
  }
  &__entry {
    width: 47px;
    height: 47px;
    background-color: #fff;
    box-shadow: 0px 1px 3px 0px rgba(170, 80, 40, 0.35);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    &--winners {
      margin-top: 18px;
    }
  }
  &__entry-wrap {
    > p {
      font-size: 13px;
      font-weight: 500;
      color: #804e26;
    }
  }
}
</style>
