<template>
  <div class="content">
    <!-- open -->
    <div v-if="data.status == 'opened'" class="opened">
      <div class="header">
        <div class="title">Awesome! You Will Get</div>
        <div class="money">
          <img :src="require('../assets/svg/icon-dollar.svg')" alt />
          <span class="big">1.23</span>
          <span class="small">USD</span>
        </div>
      </div>

      <div class="list">
        <div class="item" v-for="item, i in data.list" v-bind:key="i">
          <img :src="item.url" alt />
          <div class="item-content">
            <div class="item-title">{{ item.title }}</div>
            <span>@shasid \!@asd</span>
          </div>
          <div class="btn">{{ item.title }}</div>
        </div>
      </div>
      <div class="people">
        <div class="txt">Total $100 USD，173/1000 People Got</div>
        <div class="right" @click="clickRoad">
          <img :src="require('../assets/svg/icon-dollar.svg')" alt />
          <img :src="require('../assets/svg/icon-dollar.svg')" alt />
          <img :src="require('../assets/svg/icon-dollar.svg')" alt />
          <img :src="require('../assets/svg/icon-right.svg')" alt class="road" />
        </div>
      </div>
      <div class="footer">
        <div class="first">
          <div class="validity">Validity</div>
          <div class="time">23:57:32</div>
        </div>
        <div class="btn" @click="clickGetGiveways">Get Giveaways</div>
      </div>
    </div>
    <!-- success -->
    <div v-if="data.status == 'success'" class="success">
      <div class="header">
        <div class="money">
          <img :src="require('../assets/svg/icon-dollar.svg')" alt />
          <span class="big">1.23</span>
          <span class="small">USD</span>
        </div>
      </div>
      <div class="luck-list-title">
        <div>173/1000 People Got</div>
        <div>Total $100 USD</div>
      </div>
      <div class="luck-list">
        <div class="luck-item" v-for="item,index in data.luck_list" v-bind:key="index">
          <img :src="require('../assets/svg/icon-dollar.svg')" alt />
          <div class="luck-content">
            <div class="luck-title">{{item.title}}</div>
            <div class="luck-time">刚刚</div>
          </div>
          <div class="luck-money">
            <img :src="require('../assets/svg/icon-dollar.svg')" alt />
            <div class="luck-money-txt">123</div>
          </div>
          <div class="luck-king">
            <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
            <span>Luckiest Draw</span>
          </div>
        </div>
      </div>
    </div>
    <!-- no-open -->
    <div v-if="data.status == 'not-open'" class="not-open">
      <img :src="require('../assets/img/up.png')" alt class="up" />
      <img :src="require('../assets/img/down.png')" alt class="down" />
      <div class="open" @click="clickOpenRedPacket">OPEN</div>
    </div>
    <!-- 领取列表 -->
    <div v-if="data.status == 'luck-peopel-list'" class="luck-peopel-list">
      <div class="head">
        <img :src="require('../assets/svg/icon-back.svg')" alt @click="clickBack" />
      </div>
      <div class="luck-list-title">
        <div>173/1000 People Got</div>
        <div>Total $100 USD</div>
      </div>
      <div class="luck-list">
        <div class="luck-item" v-for="item,i in data.luck_list" v-bind:key="i">
          <img :src="require('../assets/svg/icon-dollar.svg')" alt />
          <div class="luck-content">
            <div class="luck-title">{{item}}</div>
            <div class="luck-time">刚刚</div>
          </div>
          <div class="luck-money">
            <img :src="require('../assets/svg/icon-dollar.svg')" alt />
            <div class="luck-money-txt">123</div>
          </div>
          <div class="luck-king">
            <img :src="require('../assets/svg/icon-king-hat.svg')" alt />
            <span>Luckiest Draw</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'redPacket',
}
</script>
<script setup>
import { onMounted, reactive } from "vue";
import { getPostDetail,getRedPacket} from '../server/redPacket.js'

let data = reactive({
  status: '',
  list: [
    {
      title: 'Follow',
      url: require('../assets/svg/icon-follow.svg')
    },
    {
      title: 'Like',
      url: require('../assets/svg/icon-like.svg')
    }, {
      title: 'Retweet',
      url: require('../assets/svg/icon-retweet.svg')
    }
  ],
  luck_list: [
    {
      title: 'Retweet',
      url: require('../assets/svg/icon-retweet.svg')
    },
    {
      title: 'Retweet',
      url: require('../assets/svg/icon-retweet.svg')
    }
  ]
})

onMounted(()=>{
  getPostDetail().then((res)=>{
    if(res.data.myReceived){
      // 领取了红包
      data.status = 'opened'    
    }else{
      data.status = 'not-open'
    }
    
    
    console.log(JSON.parse(res.data.postBizData))
    
  })
})

function clickOpenRedPacket() {
  data.status = 'opened'
  getRedPacket().then((res)=>{
    
  })
}
function clickGetGiveways() {
  data.status = 'success'
}
function clickBack() {
  data.status = 'opened'
}
function clickRoad(){
  data.status = 'luck-peopel-list'
}
</script>
 
<style  lang="scss">
html,
body {
  margin: 0;
  padding: 0;
}
.content {
  width: 375px;
  height: 500px;
  background: #fafafa;
  border-radius: 11px;
  font-family: "SF Pro Display";
  font-style: normal;
  .success,
  .luck-peopel-list {
    filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
    width: 100%;
    height: 100%;
    border-radius: 11px;
    background: #fff;
    .head {
      padding: 14px 16px;
      img {
        cursor: pointer;
        width: 24px;
        height: 24px;
      }
    }
    .header {
      text-align: center;
      height: 120px;
      width: 100%;
      background: #ef4545;
      padding-top: 30px;

      .title {
        color: #fff7e4;
        opacity: 0.6;

        font-weight: 700;
        font-size: 18px;
        line-height: 21px;
        letter-spacing: -0.3px;
      }
      .money {
        img {
          width: 40px;
          height: 40px;
        }
        .big {
          font-weight: 700;
          font-size: 46px;
          line-height: 55px;
          /* identical to box height */

          letter-spacing: 0.3px;

          color: #fff8e6;
        }
        .small {
          font-weight: 700;
          font-size: 13px;
          line-height: 16px;
          /* identical to box height */

          letter-spacing: 0.5px;

          color: #fff8e6;
        }
      }
    }
    .luck-list-title {
      padding: 0 16px;
      background: #fff;
      color: #9b9b9b;
      display: flex;
      justify-content: space-between;
    }
    .luck-list {
      background: #fff;
      .luck-item {
        display: flex;
        padding: 12px 16px;
        border-top: 1px solid #d1d1d1;
        justify-content: space-between;
        position: relative;
        .luck-king {
          position: absolute;
          top: 36px;
          right: 16px;
          display: flex;
          align-items: center;
          img {
            width: 22px;
            height: 19px;
            margin: 0;
          }
          span {
            font-weight: 500;
            font-size: 12px;
            line-height: 14px;
            letter-spacing: 0.3px;
            color: #f5b945;
          }
        }
        img {
          width: 42px;
          height: 42px;
          margin-right: 12px;
        }
        .luck-content {
          flex: auto;
          .luck-title {
            font-weight: 500;
            font-size: 16px;
            letter-spacing: 0.3px;
            color: #444444;
          }
          .luck-time {
            font-weight: 400;
            font-size: 12px;
            line-height: 14px;

            color: #9b9b9b;
          }
        }
        .luck-money {
          display: flex;
          height: 17px;
          align-items: center;
          img {
            width: 14px;
            height: 14px;
            margin-right: 6px;
          }
          .luck-money-txt {
            font-weight: 500;
            font-size: 14px;
            /* identical to box height */

            text-align: right;
            letter-spacing: 0.3px;

            color: #444444;
          }
        }
      }
    }
  }
  .opened {
    filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
    width: 100%;
    height: 100%;
    .header {
      text-align: center;
      height: 120px;
      width: 100%;
      background: #ef4545;
      padding-top: 30px;
      .title {
        color: #fff7e4;
        opacity: 0.6;

        font-weight: 700;
        font-size: 18px;
        line-height: 21px;
        letter-spacing: -0.3px;
      }
      .money {
        img {
          width: 40px;
          height: 40px;
        }
        .big {
          font-weight: 700;
          font-size: 46px;
          line-height: 55px;
          /* identical to box height */

          letter-spacing: 0.3px;

          color: #fff8e6;
        }
        .small {
          font-weight: 700;
          font-size: 13px;
          line-height: 16px;
          /* identical to box height */

          letter-spacing: 0.5px;

          color: #fff8e6;
        }
      }
    }
    .list {
      padding: 0 16px 0 16px;
      background: #ffffff;

      .item {
        display: flex;
        align-items: center;
        min-height: 50px;
        border-bottom: 1px solid #f0f0f0;
        img {
          width: 24px;
          height: 24px;
        }
        .item-content {
          flex: 1;

          .item-title {
            font-weight: 500;
            font-size: 16px;
            letter-spacing: 0.3px;
            color: #000000;
          }
          span {
            font-weight: 400;
            font-size: 11px;
            line-height: 13px;
            letter-spacing: 0.3px;

            color: #000000;

            opacity: 0.4;
          }
        }
        .btn {
          width: 72px;
          height: 29px;
          line-height: 29px;
          background: #389aff;
          border-radius: 500px;
          text-align: center;
          letter-spacing: 0.3px;
          color: #ffffff;
          cursor: pointer;
        }
      }

      .item:last-child {
        border: 0;
      }
    }
    .people {
      padding-left: 16px;
      height: 44px;
      line-height: 44px;
      background: #faf9f8;
      box-shadow: 0px 1px 0px #f2f2f2;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .txt {
        font-weight: 400;
        font-size: 12px;
        line-height: 14px;
        letter-spacing: 0.3px;
        color: #000000;
        opacity: 0.4;
      }
      .right {
        cursor: pointer;
        margin-right: 22px;
        display: flex;
        align-items: center;
        img {
          width: 22px;
          height: 22px;
        }
      }
    }
    .footer {
      background: #ffffff;
      display: flex;
      padding: 20px 22px 20px 17px;
      .first {
        flex: 1;

        .validity {
          font-weight: 400;
          font-size: 12px;
          line-height: 14px;
          letter-spacing: 0.3px;
          color: #000000;
          opacity: 0.4;
          margin: 2px 0 8px 0;
        }
        .time {
          font-weight: 500;
          font-size: 13px;
          line-height: 16px;
          /* identical to box height */

          color: #000000;
        }
      }
      .btn {
        background: #ef4545;
        border-radius: 100px;
        color: #fff;
        width: 258px;
        height: 52px;
        font-weight: 600;
        font-size: 18px;
        line-height: 52px;
        text-align: center;
        cursor: pointer;
      }
    }
  }
  .not-open {
    filter: drop-shadow(0px 4px 94px rgba(0, 0, 0, 0.3));
    position: relative;
    img {
      width: 100%;
    }
    .up {
      position: absolute;
      top: 0;
      box-shadow: 0px 4px 44px rgba(0, 0, 0, 0.1);
      z-index: 1;
    }
    .down {
      position: absolute;
      top: 253px;
    }

    .open {
      width: 110px;
      height: 110px;
      text-align: center;
      font-size: 26px;
      font-weight: 600;
      background: #ffe9b5;
      color: #ef4545;
      cursor: pointer;
      border-radius: 50%;
      line-height: 110px;
      position: absolute;
      top: 235px;
      left: 50%;
      margin-left: -55px;
      z-index: 2;
    }
  }
}
</style>
