<template>
    <div class="everyGetData">
      <div class="everyActiveDate">{{startTime}}-{{endTime}}</div>
      <div class="downTime" >
        <van-count-down :time="robTime - new Date().getTime()">
          <template #default="timeData" >
            <span class="colon">开奖倒计时：</span>
          <!--  <span class="block">{{ timeData.days >= 10 ? timeData.days : '0' + timeData.days }}</span>
            <span class="colon">天</span>-->
            <span class="block">{{ timeData.hours >= 10 ? timeData.hours : '0' + timeData.hours }}</span>
            <span class="colon">时</span>
            <span class="block">{{ timeData.minutes >= 10 ? timeData.minutes : '0' + timeData.minutes }}</span>
            <span class="colon">分</span>
            <span class="block">{{ timeData.seconds >= 10 ? timeData.seconds : '0' + timeData.seconds }}</span>
            <span class="colon">秒</span>
          </template>
        </van-count-down>
      </div>
      <div class="imgPrize">
        <img :src="prizeImg" alt="">
      </div>
      <div class="prizeNames">{{prizeName}}</div>
      <button  :class="{'noDraw':isDraw =='0'}" v-lz-click="'16'" @click="lingqu( prizeId,prizeType,position,prizeName, showImg)">111立即抢好礼</button>
    </div>
</template>

<script>
  import { Toast, CountDown } from 'vant';
  import apis1 from '../../../util/apis1.js';
  let {getDaily,getDailyLog,immediatelyDraw1} = apis1;
  // 中奖弹窗
  import { virtualWinningService, wishRealWinnersService,notWinPrizeService } from '../../../util/comCreate.js';
  import countDown from '../countdown/countdown.vue'; //倒计时
  export default {
    components:{
      countDown
    },
      name: "everyGetTime",
    data() {
      return {
        startTime:'',
        endTime:'',
        prizeId:'',
        prizeType:'',
        position:"",
        prizeName:'',
        showImg:'',

        hours:'10',
        minutes:'38',
        seconds:'45',
        robTime:'',
        prizeImg:'',
        isDraw:'',
      }
    },
    mounted(){
      this.initData();
    },
    methods:{
      initData(){
        console.log('1111@@@@@')
        var timeDiff = parseInt( this.robTime - new Date().getTime())
        if(timeDiff>=0){
          //没到抽奖时间或者已经是抽奖时间了
          var timeDiff1  = timeDiff;
        }else{
          //过了抽奖时间
        }


        getDaily(data =>{
          console.log(data.data,'数据数据数据');
          this.startTime = new Date(data.data.startTime).getFullYear() +'年'+( parseInt(new Date(data.data.startTime).getMonth()) + 1 )+'月'+new Date(data.data.startTime).getDate()+'日';
          this.endTime = new Date(data.data.endTime).getFullYear() +'年'+( parseInt(new Date(data.data.endTime).getMonth()) + 1 )+'月'+new Date(data.data.endTime).getDate()+'日';
          this.robTime = data.data.robTime;
          this.prizeImg = data.data.prizeImg;
          this.prizeName = data.data.prizeName;
          this.isDraw = data.data.isDraw;
        })
      },
      lingqu(prizeId, prizeType, position, prizeName, showImg, cardId){
        // if(this.isDraw == 0){
        //   console.log(this.isDraw)
        //   Toast('不可以抢');
        //   return;
        // }
        getDailyLog((data)=>{
          console.log(data,11111111111111111111)
          if(data.data.isDraw){
            if(data.data.prizeType == 3){
              wishRealWinnersService.create(position, prizeName, showImg, cardId, this.wishaddressId, this.wishid, submit => {

                wishRealWinnersService.close();
              });
            }else{
              virtualWinningService.create(position, prizeName, showImg, cardId, submit => {
                virtualWinningService.close();
              });
            }


          }else{
            notWinPrizeService.create(prizeId,submit => {
              notWinPrizeService.close();
            });
          }


        })












      }
    }
  }
</script>

<style lang="scss" scoped>
  .everyGetData{
    width: 7.5rem;
    height: 5.1rem;
    .everyActiveDate{
      height: 0.4rem;
      color: #fff;
      font-size: 0.2rem;
      line-height: 0.4rem;

    }
    .downTime{
      height: 0.5rem;
      color: #fff;
      font-size: 0.3rem;
      span{
        color: #fff;
        font-size: 0.2rem;
      }
      .block {
        display: inline-block;
        color: hotpink;
        width: 0.5rem;
        height: 0.4rem;
        background: white;
        line-height: 0.4rem;
        font-size: 0.3rem;
      }
    }
    .imgPrize{
      height: 2.6rem;
      img{
        height: 2.6rem;
      }
    }
    .prizeNames{
      color: #fff;
      font-size: 0.2rem;
      line-height: 0.3rem;
    }
    button{
      background-color: yellow;
      width:5.3rem;
      height: 1rem;
      border-radius: 0.2rem;
      font-size: 0.4rem;
      line-height: 1rem;
      color: red;
      margin-top: 0.1rem;

    }
    .canDraw{

    }
    .noDraw{
      background-color: #7f7f7f;
    }
  }

</style>
