<template>
  <div v-if="show">
    <basicPop :pop="pop" @closeClick="closeClick">
      <div v-if="awardList.length" class="award-list">
        <span class="tips">活动奖励将于活动结束后进行发放。</span>
        <div class="award-item" v-for="award in awardList" :key="award.awardId">
          <img alt="奖品" :src="award.prizeImg" />
          <div class="prize-info">
            <div class="prize-name">奖品名称：{{ award.prizeName }}</div>
            <div class="award-time">领取时间：{{ formatTime(award.prizeTime) }}</div>
          </div>
        </div>
      </div>
      <div v-else class="award-list">
        <div class="no-data">—— 暂无数据 ——</div>
      </div>
    </basicPop>
  </div>
</template>

<script>
import basicPop from "./hdzxtbasicPop.vue";
import apis1 from "../../../util/apis1.js";
import moment from 'moment';

const { breakThroughPrizeList } = apis1;
export default {
  props: [],
  components: {
    basicPop
  },
  data() {
    return {
      pop: {
        title: "领奖记录"
      },
      awardList: []
    };
  },
  created() {
    // 自定义样式初始化
    if (this.styleData) {
      const { rightLineDiv, leftLineDiv, titlepop } = this.styleData;

      this.pop = {
        ...this.pop,
        rightLineDiv: rightLineDiv || {},
        leftLineDiv: leftLineDiv || {},
        titlepop: titlepop || {
          backgroundImage:
            "url(//img10.360buyimg.com/imgzone/jfs/t1/141588/29/18217/44025/5fd571b9Ef55329ec/42dba91b188b9dce.png)"
        }
      };
    }

    this.initData();
  },
  methods: {
    initData() {
      breakThroughPrizeList((res) => {
        this.awardList = res.data;
      })
    },
    closeClick() {
      this.handleClose();
    },
    formatTime(time) {
      return moment(time).format('YYYY-MM-DD hh:mm:ss');
    }
  }
};
</script>

<style lang="scss">
.award-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.3rem;
  min-height: 40vh;
  .tips {
    color: rgb(180, 180, 180);
    font-size: 0.24rem;
  }
  .award-item {
    padding: 0.15rem;
    display: flex;
    flex-direction: row;
    gap: 0.1rem;
    align-items: center;
    background-color: #fff;
    border-radius: 0.1rem;
    img {
      height: 1rem;
      width: 1rem;
    }
    .prize-info {
      .prize-name {
        font-size: 0.24rem;
      }
      .award-time {
        font-size: 0.24rem;
      }
    }
  }
  .no-data {
    text-align: center;
    line-height: 40vh;
    font-size: 0.32rem;
    color: rgb(180, 180, 180);
  }
}
</style>
