<template>
  <van-popup v-model="visible" class="introduction-popup">
    <div class="introduction-popup__main">
      <div class="introduction-popup__sec-title">活动介绍</div>
      <div class="introduction-popup__wrap">
        <div class="introduction-popup__content">
          <p class="introduction-popup__intro">{{ lotteryInfo.intro }}</p>
          <template v-if="!!lotteryInfo.isShowPrize">
            <div class="introduction-popup__title">本场活动奖品：</div>
            <div class="introduction-popup__prize">
              <ul
                class="introduction-popup__list"
                :class="{ 'introduction-popup__list--center': lotteryInfo.prizeConfigs.length < 3 }"
              >
                <li v-for="(item, index) in lotteryInfo.prizeConfigs" :key="index">
                  <img v-lazy="item.icon || img" class="introduction-popup__item-img" alt />
                  <p v-if="item.prizeAlias" class="introduction-popup__item-level">{{ item.prizeAlias }}</p>
                  <p class="introduction-popup__item-name">{{ item.name }}</p>
                </li>
              </ul>
            </div>
          </template>
        </div>
      </div>
      <div class="introduction-popup__back" @click="visible = false">返回活动</div>
    </div>
  </van-popup>
</template>

<script>
import { mapGetters } from 'vuex'
import img from '@/assets/images/lottery/gift.png'

export default {
  name: 'Introduction',
  props: {
    value: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      img
    }
  },
  computed: {
    ...mapGetters({ lotteryInfo: 'lottery/lotteryInfo' }),
    visible: {
      get() {
        return this.value
      },
      set(val) {
        this.$emit('input', val)
      }
    }
  }
}
</script>

<style lang="less" scoped>
.introduction-popup {
  width: 100%;
  height: 100%;
  background-image: url('~@/assets/images/lottery/index_bg.png');
  background-size: 100% 100%;
  background-position: top center;
  background-repeat: no-repeat;
  &__main {
    width: 100%;
    border-radius: 6px;
    padding: 13px;
    position: relative;
    padding-top: 44px;
  }
  &__back {
    position: absolute;
    top: 10px;
    right: 5px;
    background-color: #ffd440;
    border: 2px solid #e28a00;
    color: #9c5c00;
    font-size: 12px;
    writing-mode: vertical-lr;
    padding: 5px 3px;
    border-radius: 6px;
  }
  &__sec-title {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 72px;
    padding-top: 22px;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
  }
  &__wrap {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background-color: #f6d2b6;
    padding: 6px;
  }
  &__content {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background-color: #f8e0cb;
    font-size: 12px;
    padding: 20px 14px 14px;
    color: #79420c;
  }
  &__intro {
    font-size: 12px;
    line-height: 18px;
    white-space: pre-line;
  }
  &__title {
    margin: 14px 0 10px;
  }
  &__prize {
    width: 100%;
  }
  &__list {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    &--center {
      justify-content: center;
    }
    > li {
      text-align: center;
      width: 33.3333%;
      padding: 6px;
    }
  }
  &__item-img {
    display: block;
    width: 68px;
    height: 68px;
    margin: 0 auto;
  }
  &__item-level {
    font-size: 14px;
    height: 18px;
    line-height: 18px;
    margin: 5px 0 0;
  }
  &__item-name {
    font-size: 12px;
    margin: 5px 0 0;
    line-height: 14px;
  }
}
</style>
