<template>
  <x-prompt :visible="visible">
    <div class="sign2-box">
      <div class="title">签到成功</div>
      <template v-if="is_old">
        <div class="sign2-list__box">
          <p class="change-notice">
            <span>亲爱的读者们：</span>
            为了确保更好的奖励体验，签到活动即将改版哦，敬请关注！
          </p>
          <p class="notice"
             v-html="getNoticeText()"></p>
          <div class="sign2-list">
            <div class="sign2-item"
                 :class="{
                  'nmr': (i + 1) % 5 === 0,
                  'signed': (i + 1) < days,
                  'is_today': (i + 1) === days}"
                 v-for="(sign,i) in signList"
                 :key="i">
              <template v-if="(i + 1) === 7">
                <!-- 7天 -->
                <img :src="days >= 7 ? sign2Today : sign2_7"
                     alt="">
              </template>
              <template v-else-if="(i + 1) === 15">
                <!-- 15天 -->
                <img :src="days === 15 ? sign2Today : sign2_15"
                     alt="">
              </template>
              <template v-else>
                <img :src="(i + 1) <= days ? sign2Today : sign2Coin"
                     alt="">
              </template>
              <span>{{i + 1 === days ? '今天' : '第' + (i + 1) + '天'}}</span>
            </div>
          </div>
        </div>
      </template>
      <template v-else>
        <div class="sign-info">
          <p class="user-get">获得<i>{{sign_reard}}</i>书币</p>
          <p class="user-sign">您已经连续签到<i>{{signDays}}</i>天，明天签到获得<i>{{items[newDays]}}</i>书币</p>
        </div>
        <div class="activity-week__list">
          <div class="week-list__one">
            <template v-for="(week, i) in items.slice(0, 4)">
              <div :class="['week-item', { 'week-item__active': i < newDays }]"
                   :key="i">
                <div class="week-wrap">
                  <img :src="i < newDays ? newSigned : i === 2 ? newSign_3 : newSignCoin"
                       alt="">
                  <span class="day-get">{{week}}书币</span>
                </div>
                <span class="day-key">第{{i + 1}}天</span>
              </div>
            </template>
          </div>
          <div class="week-list__two">
            <template v-for="(week, i) in items.slice(4)">
              <div :class="['week-item', { 'week-item__active': (i + 4) < newDays }]"
                   :key="i">
                <div class="week-wrap">
                  <img :src="(i + 4) < newDays ? newSigned : (i + 4) === 6 ? newSign_7 : newSignCoin"
                       alt="">
                  <span class="day-get">{{week}}书币</span>
                </div>
                <span class="day-key">第{{i + 5}}天</span>
              </div>
            </template>
          </div>
        </div>
      </template>
    </div>
  </x-prompt>
</template>

<script>
import prompt from "../prompt.vue";

export default {
  components: { "x-prompt": prompt },
  data() {
    return {
      sign2Coin: require("../../../assets/sign2_coin.png"),
      sign2_7: require("../../../assets/sign2_7.png"),
      sign2_15: require("../../../assets/sign2_15.png"),
      sign2Today: require("../../../assets/sign2.png"),
      newSignCoin: require("../../../assets/gold-bi.png"),
      newSign_3: require("../../../assets/red-he.png"),
      newSign_7: require("../../../assets/big-red-he.png"),
      newSigned: require("../../../assets/signed_2.png"),
      signList: new Array(15),
      newSignList: new Array(7),
      newDays: 1,
      days: 1
      // signDays: 3
    };
  },
  methods: {
    getNoticeText() {
      let days = this.days;
      let html = "";
      switch (days) {
        case 1:
        case 2:
          html = `今日签到赠送<i>${
            this.sign_reard
          }</i>书币，连续签到每日可领<i>50</i>书币，最高月送<i>2000</i>书币`;
          break;
        case 6:
          html = `今天签到赠送<i>${
            this.sign_reard
          }</i>书币，明日签到可以领取小礼包哦~`;
          break;
        case 7:
          html = `今天签到赠送<i>${
            this.sign_reard
          }</i>书币，签到已满7日，额外送您<i>100</i>书币大礼包~`;
          break;
        case 14:
          html = `今天签到赠送<i>${
            this.sign_reard
          }</i>书币，明日签到可以领取大礼包哦~`;
          break;
        case 15:
          html = `今天签到赠送<i>${
            this.sign_reard
          }</i>书币，签到已满15日，额外送您<i>150</i>书币大礼包~`;
          break;
        default:
          html = `今日签到赠送<i>${
            this.sign_reard
          }</i>书币，连续签到最高月送<i>2000</i>书币`;
      }
      return html;
    }
  },
  created() {
    this.days = this.signDays % 15 === 0 ? 15 : this.signDays % 15;
    this.newDays = this.signDays % 7 === 0 ? 7 : this.signDays % 7;
  }
};
</script>

<style lang="scss">
.sign2-box {
  .title {
    font-size: 0.4rem;
    font-weight: bold;
    padding: 0.3rem 0;
    border-bottom: 1px solid #f7f7f7;
  }
}

.sign2-list__box {
  padding: 0.3rem 0.2rem;

  .notice {
    font-size: 0.3rem;

    i {
      font-style: normal;
      color: #f26d32;
      font-weight: bold;
    }
  }

  .change-notice {
    text-align: left;
    background: #ffede7;
    color: #f26d32;
    padding: .15rem;
    margin-bottom: 0.2rem;

    span {
      display: block;
      font-weight: bold;
    }
  }
}

.sign2-list {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-flow: row wrap;
  margin-top: 0.4rem;
  padding: 0 0.2rem;

  .sign2-item {
    width: 15%;
    margin-right: 0.3rem;
    margin-bottom: 0.2rem;
    padding: 0.2rem 0;

    img {
      width: 70%;
    }

    span {
      font-size: 0.24rem;
    }

    &.nmr {
      margin-right: 0;
    }

    &.signed {
      color: #f26d32;
    }

    &.is_today {
      color: #f26d32;
      background: #ffede7;
      font-weight: bold;
    }
  }
}

.activity-week__list {
  padding: 0.3rem 0.2rem;

  .week-list__one,
  .week-list__two {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .week-wrap {
      height: 1.4rem;
      border: 0.5px solid #f7f7f7;
      background: #f7f7f7;
      margin-bottom: 0.1rem;
      border-radius: 2px;
      position: relative;
    }

    .week-item {
      font-size: 0;
      text-align: center;
      width: 1.2rem;

      img {
        width: 0.5rem;
        margin: 0.2rem auto;
        display: block;
      }

      .day-get {
        font-size: 0.24rem;
        color: #666;
      }

      .day-key {
        font-size: 0.24rem;
      }

      .coin-expire {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        margin: 0;
      }
    }

    .week-item__active {
      .week-wrap {
        border-color: #4895ff;
        background: #fff;
      }

      .day-get {
        background: #4895ff;
        color: #fff;
        width: 85%;
        margin: 0 auto;
        font-weight: bold;
        border-radius: 2px;
        padding: 0 0.05rem;
      }

      .day-key {
        color: #4895ff;
      }
    }
  }

  .week-list__one {
    margin-bottom: 0.3rem;
  }

  .week-list__two {
    width: 74%;
    margin: 0 auto;
    padding-bottom: 0.3rem;
  }
}

.sign-info {
  margin-top: 0.3rem;

  .user-get {
    color: #4895ff;
    font-size: 0.4rem;
    line-height: 1;

    i {
      font-style: normal;
      font-weight: bold;
    }
  }

  .user-sign {
    font-size: 0.3rem;
    color: #333;

    i {
      font-style: normal;
      color: #4895ff;
      font-weight: bold;
      font-size: 0.36rem;
    }
  }
}
</style>

