<template>
  <div class='analysis-report-production-spec-card flex flex-(row items-center)' :class='{ "is-pack": spec.pack }' @click='$emit("select", spec.id)'>
    <div class='buy-tip--price flex flex-(col items-center)'>
      <span class="spec-i-text active-price"><span class='active-price-unit'>￥</span>{{ (spec.now) }}</span>
      <span class="spec-i-text del" v-if='spec.origin > spec.now'>￥{{ (spec.origin) }}</span>
    </div>
    <div class='flex flex-(1 row items-center justify-between)'>
      <div>
        <div class='spec-c-label flex flex-(row items-center)'>
          <span class='spec-name'>{{spec.label}}</span>
          <span class='vip-label' :class='{ [spec.packLevel]: true }' v-if='spec.pack'>
            <i class='iconfont icon-vip'></i>
          </span>
          <div class="activity-badge" :class='{"is-huo": spec.badge !== "权益特价"}' v-if="spec.badge">
            <span v-if='spec?.badge === "权益特价"' class="j-icon icon-crown"></span>
            <span v-else class="j-icon icon-huo-badge"></span>
            &nbsp;{{spec.badge}}
          </div>
        </div>

        <div>
          <div class='spec-card-tip flex flex-(row items-center)' v-if='spec.pack'>
            <span class='spec-card-tip--day flex-shrink-0'>{{spec._extend.day}}天</span>
            <span class='spec-line'></span>
            <div class='flex-shrink-0'>免费下载：<span>{{spec._extend.number}}{{spec._extend.specsUnit}}</span> /月</div>
          </div>
          <div v-else>
            <span class='spec-i-text'>{{spec.desc}}</span>
          </div>
        </div>

      </div>
      <div>
        <div class="check--actions">
          <span class="check-icon iconfont icon-choose1" v-if='active === spec.id'></span>
          <span class="check-icon iconfont icon-unchoose1" v-else></span>
        </div>
      </div>
    </div>
    <div class='spec-card-tip--fixed' v-if='spec.pack'>
      <div class='spec-card-tip--desc'  :class='{ [spec.packLevel]: true }'>若本月报告下载超出额度，时效内享特价：<span>{{spec._extend.first}}元/{{spec._extend.specsUnit}}</span></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'AnalysisReportProductionSpecCard',
  props: {
    spec: {
      type: Object,
      default: () => {}
    },
    active: {
      type: Number,
      default: -1
    }
  }
}
</script>

<style scoped lang='scss'>
.analysis-report-production-spec-card {
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0px 4px 16px 0px rgba(8, 31, 38, 0.08);
  background: #fff;
  width: 100%;
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px;
  padding-left: 23px;
  &.is-pack {
    padding-bottom: 29px;
  }

  .spec-i-text {
    font-size: 11px;
    color: #5f5e64;
    line-height: 16px;

    &.del {
      font-size: 10px;
      line-height: 14px;
      color: #9B9CA3;
      text-decoration: line-through;
    }
  }

  .buy-tip--price {
    margin-right: 23px;
    .active-price-unit {
      font-size: 14px;
    }
    .active-price {
      font-size: 22px;
      line-height: 32px;
      color: #FB483D;
    }
  }
  .activity-badge {
    display: flex;
    align-items: center;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 11px;
    line-height: 14px;
    background: linear-gradient(98deg, #ff7c32 0%, #f33838 100%);
    border-radius: 9px 0px;
    text-align: center;
    color: #fff;
    &.is-huo {
      padding: 2px 4px;
      background: rgba(255, 243, 239, 1);
      border: 1px solid rgba(255, 98, 107, 1);
      border-radius: 4px;
      color: #FB483D;
    }
  }
  .vip-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    height: 18px;
    background: #2abed1;
    border-radius: 8px 2px 8px 2px;
    color: #fff;

    &.monthly-theme {}
    &.seasonal-theme {
      background: #F1D090;
      color: #1D1D1D;
    }
    &.year-theme {
      background: #171826;
      color: #FAE7CA;
    }

    .icon-vip {
      display: inline-block;
      color: inherit;
      font-size: 18px;
      transform: scale(0.5);
    }
  }
  .spec-card-tip {
    margin-top: 10px;
    .spec-line {
      width: 1px;
      height: 12px;
      background: #E0E0E0;
      margin: 0 6px;
      display: inline-block;
      vertical-align: middle;
    }

    &--day {
      color: #1d1d1d;
    }

    &--fixed {
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
    }
    &--desc {
      color: #2ABED1;
      font-size: 10px;
      line-height: 21px;
      text-align: center;
      width: 299px;
      height: 21px;
      margin: 0 auto;
      background: url(@/assets/image/order/report/bg-monthly.png) no-repeat center;
      background-size: contain;

      &.seasonal-theme {
        background-image: url(@/assets/image/order/report/bg-seasonal.png);
        color: rgba(194, 111, 51, 1);
      }
      &.year-theme {
        background-image: url(@/assets/image/order/report/bg-year.png);
        color: #5F5E64;
      }
    }
  }

  .spec-c-label {
    .spec-name {
      font-size: 16px;
      line-height: 24px;
      color: #171826;
    }
  }
  .check--actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    color: #2abed1;
    .check-icon {
      font-size: 24px;

      &.icon-choose1 {
        color: #2abed1;
      }

      &.icon-unchoose1 {
        color: #c0c4cc;
      }
    }
  }

}
</style>
