<template>
	<div :style="styleDataNew.prizePreviewNewAll">
		<div
		  :style="styleDataNew.prizePreviewNew"
		  v-if="isShow"
		  class="prizePreviewNew"
		  ref="prizePreviewNew"
		  @click="styleClick('click', 'prizePreviewNew')"
		  @mousemove="styleClick('mousemove', 'prizePreviewNew')"
		  @mouseout="styleClick('mouseout')"
		>
		  <img :style="styleData.shareTheImg" :src="styleData.shareTheImg.imageUrl" alt="" />
		
		  <div :style="styleData.listStyle">
		    <div :style="styleData.libox" v-for="(item, index) in prizeList" :key="index">
		      <div :style="styleData.imgbox">
		        <img :src="item.showImg" :style="styleData.imgdiv" alt="图片1加载失败" />
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '1'">京豆</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '2'">优惠券</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '3'">实物</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '4'">积分</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '5'">专享价</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '6'">红包</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '7'">礼品卡</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '8'">京东E卡</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '9'">plus会员卡</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '10'">爱奇艺会员卡</div>
		        <div :style="styleData.backName" class="back" v-if="item.prizeType == '11'">积分</div>
		      </div>
		      <div id="leftAll">
		        <div :style="styleDataNew.prizeName">{{ item.prizeName }}</div>
		
		        <div :style="styleDataNew.qiandaoDay">
		          {{ datas.prompt1 }}
		          <span :style="styleDataNew.qiandaoDayColor">{{ item.days }}位</span>
		          {{ datas.prompt2 }}
		        </div>
		        <div :style="styleDataNew.prizeSheng">奖品剩余：{{ item.leftNum }}份</div>
		        <div
		          style="
		            position: absolute;
		            bottom: 0.2rem;
		            right: 0.2rem;
		            display: flex;
		          "
		        >
		          <img :style="styleDataNew.nolingjiang" v-if="!item.canReceive && item.status == 0" @click="drawprize(index, item, 0)" :src="styleDataNew.nolingjiang.imageUrl" />
		          <img :style="styleDataNew.lingjiang" v-lz-click="'16'" @click="drawprize(index, item)" :src="styleDataNew.lingjiang.imageUrl" v-if="item.canReceive" />
		          <img
		            :style="styleDataNew.nolingjiang"
		            v-if="!item.canReceive && item.status == 2 && item.leftNum == 0"
		            @click="drawprize(index, item, 3)"
		            :src="styleDataNew.nolingjiang.imageUrl"
		          />
		          <img
		            :style="styleDataNew.nolingjiang"
		            v-if="!item.canReceive && item.status == 2 && item.leftNum != 0"
		            @click="drawprize(index, item, 1)"
		            :src="styleDataNew.nolingjiang.imageUrl"
		          />
		          <img :style="styleDataNew.nolingjiang" v-if="!item.canReceive && item.status == 3" :src="styleDataNew.nolingjiang.imageUrl" @click="drawprize(index, item, 3)" />
		        </div>
		      </div>
		      <img :style="styleDataNew.lingjiangSuss" v-if="!item.canReceive && item.status == 1" :src="styleDataNew.lingjiangSuss.imageUrl" />
		
		      <div :style="styleDataNew.bootomDiv"></div>
		    </div>
		  </div>
		</div>
	</div>
 
</template>
<script>
import dataJson from '../../../../src/data.json';
import dateUtil from '../../../util/dateUtil.js';
import { Toast, Notify } from 'vant';
import Vue from 'vue';
import { CountDown } from 'vant';
import store from '../../../store/store';
import { PrizeResultPopComService, NoPrizeResultPopComService } from '../../../util/comCreate.js';
import apis1 from '../../../util/apis1.js';
Vue.use(CountDown);
Vue.use(Toast, Notify);
let { immediatelyDraw, immediatelyDrawGray, getPrizeList, invitationList, inviteFollowShop } = apis1;

export default {
  props: ['isTemplate', 'datas', 'keyData', 'styleData', 'templateData', 'isWebClick', 'modifyContent', 'actType'],
  name: 'prizePreview',
  data() {
    return {
      isPlayType: false,
      JSONData: {
        notifyShow: false, //多少个奖励待领取是否显示
        titleShow: false,
        prizePreviewShow: true, //大奖提前看是否显示
        waitReceivePrizeShow: false, //等待领奖是否显示
        receivingPrizeShow: false, //领奖中是否显示

        receivePrizeShow: false, //领取奖励是否显示
        countDownShow: false, //倒计时是否显示
        isShowPrizeView: true //是否一直显示有礼组件
      },

      //标题图片
      titleImg: '//img10.360buyimg.com/imgzone/jfs/t1/163541/25/26/16298/5fec398dEdffb7eb6/53dd5715f16baa4e.png',
      nowTime: new Date().getTime(), //当前时间
      isShow: true, //整个组件是否显示
      receive: 1, // 领奖状态
      prizePreview: false, //大奖提前看
      waitReceivePrize: false, //等待领奖
      receivePrize: false, //领奖中

      year: 0,
      month: 0,
      day: 0,
      unclaimedNum: '', //待领取奖品数量
      prizeList: [],
      basic: {
        receivePrizeTimeStartTime: '', //领奖开始时间
        receivePrizeTimeEndTime: '' //领奖结束时间
      },
      isFinish: false, //是否显示组件
      jiekouChange: 0,
      styleDataOld: {}
    };
  },

  created() {
    //深拷贝重置需要
    this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));
    this.styleDataNew = this.styleData; //父组件传递过来的样式数据
    //如果父组件传递过来的样式数据则使用样式数据否则使用默认数据
    if (this.isWebClick) {
      this.publicData.$on('clickSwitchValue', (isCustomSwitching, refName) => {
        if (refName == 'prizePreview' || refName == 'winnersRecord') {
          console.log(123, isCustomSwitching);
          this.receive = isCustomSwitching;
          if (isCustomSwitching == '1') {
            //签到期
            this.nowTime = new Date().getTime(); //1613721651000; //2021-02-19 16:00:51
            this.basic[this.keyData.receivePrizeTimeStartTime] = this.nowTime + 2000; //1613960669000; //2021-02-23 15:03:56
            this.basic[this.keyData.receivePrizeTimeEndTime] = this.nowTime + 4000; //1614047069000; //2021-02-24 16:03:56 1609774412000 1609837728000

            this.prizePreview = true;
            this.waitReceivePrize = false;
            this.receivePrize = false;
            this.isShow = true;
            this.publicData.$emit('isNotyFiceWinnerReorrd', false, this.isTemplate);
          } else if (isCustomSwitching == '3') {
            //领奖期
            this.nowTime = 1613355869000; //2021-02-15 10:24:29
            this.basic[this.keyData.receivePrizeTimeStartTime] = 1611208276000; //2021-01-21 13:51:16
            this.basic[this.keyData.receivePrizeTimeEndTime] = 1613721651000; //2021-02-19 16:00:51 1609774412000 1609837728000
            this.prizePreview = false;
            this.waitReceivePrize = false;
            this.receivePrize = true;
            this.isShow = true;

            this.publicData.$emit('showMyPrize', true);
            this.publicData.$emit('isDrawRolled', true, this.isTemplate);
            this.publicData.$emit('isNotyFiceWinnerReorrd', false, this.isTemplate);
          } else if (isCustomSwitching == '5') {
            //公告期
            this.isFinish = true;
            this.nowTime = 1614219869000; //2021-02-19 16:00:51
            this.basic[this.keyData.receivePrizeTimeStartTime] = 1611208276000; //2021-01-21 13:51:16
            this.basic[this.keyData.receivePrizeTimeEndTime] = 1613960669000; //2021-02-22 10:24:29
            this.isShow = false;
            this.publicData.$emit('isDrawRolled', false, this.isTemplate);
            this.publicData.$emit('showMyPrize', true);
            this.publicData.$emit('isNotyFiceWinnerReorrd', true, this.isTemplate);
          } else {
            this.nowTime = 1613721651000; //2021-02-19 16:00:51
            this.basic[this.keyData.receivePrizeTimeStartTime] = 1613891036000; //2021-02-21 15:03:56
            this.basic[this.keyData.receivePrizeTimeEndTime] = 1613894636000; //2021-02-21 16:03:56 1609774412000 1609837728000
          }
        }
      });
    }
    this.activityType = this.actType ? this.actType : sessionStorage.getItem('activityType');

    this.JSONData.titleShow = true;
    this.receivingPrizeShow = true;
    this.receivePrize = true;
    this.jiekouChange = 2;
    this.isFinish = true;
    this.isShowPrizeView = true;
    this.receive = 4;

    this.publicData.$on('showPrizePreview', (datasAll, datas) => {
      console.log('是否显示组件', datas);
      if (datas == true) {
        //显示奖品展示组件
        this.isFinish = true;
        this.initData(datasAll);
      } else {
        this.isFinish = false;
      }
    });
    this.initData();
  },
  methods: {
    //点击可修改位置的方法
    styleClick(type, refName) {
      if (this.isWebClick) {
        //传值给B端
        let byValue = {
          modifyContent: this.modifyContent,
          refName: refName,
          styleData: this.styleDataNew,
          isCustomSwitching: this.receive,
          c_this: this,
          styleDataOld: this.styleDataOld
        };
        this.$emit('opertaionCom', type, byValue);
      }
    },
    // 获得今天的日期
    getCurrentDate() {
      const date = new Date();
      this.year = date.getFullYear();
      this.month = date.getMonth() + 1;
      this.day = date.getDate();
      // this.currentData = this.year + '年' + this.month + '月' + this.day + '号'
    },
    async initData(datasAll) {
      if (this.isTemplate == true) {
        console.log(datasAll, '领奖组件数据', this.templateData);
        var datasAll = this.templateData && this.templateData.followShop ? this.templateData.followShop : this.templateData;

        this.notifyShow = false;
        this.unclaimedNum = 5;
        if (datasAll) {
          var tabValue = store.state.tabValue; //模板预览时期
          // var initDataAll = datasAll.sign.receive
          //   ? datasAll.sign
          //   : datasAll.member;

          if (tabValue) {
            if (tabValue == '1') {
              //签到期
              this.nowTime = new Date().getTime(); //1613721651000; //2021-02-19 16:00:51
              this.basic[this.keyData.receivePrizeTimeStartTime] = datasAll.receive
                ? datasAll.receive[this.keyData.receivePrizeTimeStartTime]
                : datasAll.sign.receive[this.keyData.receivePrizeTimeStartTime]; //1613960669000; //2021-02-23 15:03:56
              this.basic[this.keyData.receivePrizeTimeEndTime] = datasAll.receive
                ? datasAll.receive[this.keyData.receivePrizeTimeEndTime]
                : datasAll.sign.receive[this.keyData.receivePrizeTimeEndTime]; //1614047069000; //2021-02-24 16:03:56 1609774412000 1609837728000

              this.prizePreview = true;
              this.waitReceivePrize = false;
              this.receivePrize = false;
            } else if (tabValue == '2') {
              //领奖期
              // this.nowTime = 1613355869000; //2021-02-15 10:24:29
              // this.basic[this.keyData.receivePrizeTimeStartTime] = 1611208276000; //2021-01-21 13:51:16
              // this.basic[this.keyData.receivePrizeTimeEndTime] = 1613721651000; //2021-02-19 16:00:51 1609774412000 1609837728000

              this.nowTime = new Date().getTime(); //1613721651000; //2021-02-19 16:00:51
              this.basic[this.keyData.receivePrizeTimeStartTime] = datasAll.receive
                ? datasAll.receive[this.keyData.receivePrizeTimeStartTime]
                : datasAll.sign.receive[this.keyData.receivePrizeTimeStartTime]; //1613960669000; //2021-02-23 15:03:56
              this.basic[this.keyData.receivePrizeTimeEndTime] = datasAll.receive
                ? datasAll.receive[this.keyData.receivePrizeTimeEndTime]
                : datasAll.sign.receive[this.keyData.receivePrizeTimeEndTime]; //1614047069000; //2021-02-24 16:03:56 1609774412000 1609837728000

              this.prizePreview = false;
              this.waitReceivePrize = false;
              this.receivePrize = true;
              // this.styleDataNew.prizeTitleImg.imageUrl =
              //   "//img10.360buyimg.com/imgzone/jfs/t1/152214/21/12744/14227/5fed342aE5dc69eaf/cb194184b588e7e8.png";
              this.publicData.$emit('showMyPrize', true);
              this.publicData.$emit('isDrawRolled', true, this.isTemplate);
            } else if (tabValue == '3') {
              //公告期
              this.isFinish = true;
              this.nowTime = 1614219869000; //2021-02-19 16:00:51
              this.basic[this.keyData.receivePrizeTimeStartTime] = 1611208276000; //2021-01-21 13:51:16
              this.basic[this.keyData.receivePrizeTimeEndTime] = 1613960669000; //2021-02-22 10:24:29
              this.isShow = false;
              this.publicData.$emit('isDrawRolled', false, this.isTemplate);
              this.publicData.$emit('showMyPrize', true);
              this.publicData.$emit('isNotyFiceWinnerReorrd', true, this.isTemplate);
            }
          } else {
            this.nowTime = 1613721651000; //2021-02-19 16:00:51
            this.basic[this.keyData.receivePrizeTimeStartTime] = 1613891036000; //2021-02-21 15:03:56
            this.basic[this.keyData.receivePrizeTimeEndTime] = 1613894636000; //2021-02-21 16:03:56 1609774412000 1609837728000
          }
          for (var i = 0; i < datasAll.draw.prizeList.length; i++) {
            datasAll.draw.prizeList[i].leftNum = datasAll.draw.prizeList[i].totalPrizeNum;
            datasAll.draw.prizeList[i].allNum = datasAll.draw.prizeList[i].totalPrizeNum;
            datasAll.draw.prizeList[i].days = datasAll.draw.prizeList[i].cotinueSignDay;
            datasAll.draw.prizeList[i].canReceive = false;
            datasAll.draw.prizeList[i].status = 2;
            datasAll.draw.prizeList[i].statueImg = '//img10.360buyimg.com/imgzone/jfs/t1/154713/4/12793/8489/5fec39ceE7bd9c63e/a64d5084bf34494d.png';
          }
          this.prizeList = datasAll.draw.prizeList;
        } else {
          this.nowTime = 1613721651000;
          this.basic[this.keyData.receivePrizeTimeStartTime] = 1613891036000;
          this.basic[this.keyData.receivePrizeTimeEndTime] = 1613894636000; // 1609774412000 1609837728000
          this.prizeList = [
            {
              showImg: '//img10.360buyimg.com/imgzone/jfs/t1/158835/9/878/32528/5fed6feeE1dea01a1/492a92753717c9c8.png',
              statueImg: '//img10.360buyimg.com/imgzone/jfs/t1/197485/37/18150/7911/619cec62Ee06d907f/e5f5555bc7d0bfb3.png',
              prizeName: '商品名称商品名称商品名称商品名称',
              leftNum: 0, //已领取奖品数量
              allNum: 100, //奖品总数量
              days: 3,
              canReceive: false,
              status: 2
            },
            {
              showImg: '//img10.360buyimg.com/imgzone/jfs/t1/158835/9/878/32528/5fed6feeE1dea01a1/492a92753717c9c8.png',
              statueImg: '//img10.360buyimg.com/imgzone/jfs/t1/197485/37/18150/7911/619cec62Ee06d907f/e5f5555bc7d0bfb3.png',
              prizeName: '商品名称商品名称商品名称商品名称',
              leftNum: 10,
              allNum: 100,
              days: 3,
              canReceive: false,
              status: 2
            }
          ];

          this.prizePreview = true;
          this.waitReceivePrize = false;
          this.receivePrize = false;
          console.log(this.basic[this.keyData.receivePrizeTimeStartTime] - this.nowTime, '111111111111111');
        }

        if (!this.JSONData.countDownShow) {
          //是否显示倒计时,不显示倒计时则不需要刷新页面
          console.log('不显示倒计时');
          this.prizePreview = false;
          this.waitReceivePrize = false;
          this.receivePrize = true;
          this.publicData.$emit('isDrawRolled', false, this.isTemplate);
          return;
        }
      } else {
        this.nowTime = new Date().getTime();
        //调用接口
        if (this.jiekouChange == 1) {
          await getPrizeList(prizesData => {
            this.publicData.$emit('prizeTime', prizesData.data);
            this.listArr = prizesData.data.prizeInfo;
            this.basic[this.keyData.receivePrizeTimeStartTime] = prizesData.data[this.keyData.receivePrizeTimeStartTime];
            this.basic[this.keyData.receivePrizeTimeEndTime] = prizesData.data[this.keyData.receivePrizeTimeEndTime];
            this.activityEndTime = prizesData.data.activityEndTime;
            if (this.nowTime > this.activityEndTime) {
              this.isShow = false;
              // console.log('活动已结束')
              this.publicData.$emit('isNotyFiceWinnerReorrd', true, this.isTemplate);
              this.publicData.$emit('isDrawRolled', false, this.isTemplate);
              return;
            }
          });
        } else if (this.jiekouChange == 2) {
          await invitationList(invitationData => {
            // console.log(444444444444433,invitationData);
            // this.publicData.$emit("prizeTime", invitationData.data);
            this.listArr = invitationData.data.prizeInfo;
            this.basic[this.keyData.receivePrizeTimeStartTime] = invitationData.data[this.keyData.receivePrizeTimeStartTime];
            this.basic[this.keyData.receivePrizeTimeEndTime] = invitationData.data[this.keyData.receivePrizeTimeEndTime];
          });
        } else if (this.jiekouChange == 4) {
          await inviteFollowShop(invitationData => {
            this.listArr = invitationData.data.prizeInfo;
          });
        }
        //领奖时间判断
        this.signStartTime = this.basic[this.keyData.receivePrizeTimeStartTime];
        this.signEndTime = this.basic[this.keyData.receivePrizeTimeEndTime]; //1609736010000 1614418856000;
        var timeDiff = parseInt(this.signStartTime - this.nowTime) + '';
        if (timeDiff.length >= 9) {
          var timeDiff1 = 24 * 60 * 60 * 1000;
        } else {
          var timeDiff1 = timeDiff;
        }
        if (timeDiff > 0) {
          //定时刷新判断签到时间是否结束
          var a = setInterval(() => {
            //重新请求
            this.initData();
            clearInterval(a);
          }, parseInt(timeDiff1));
        }

        //活动结束刷新页面 领奖结束即是活动结束
        if (this.nowTime > this.basic[this.keyData.receivePrizeTimeStartTime] && this.nowTime < this.basic[this.keyData.receivePrizeTimeEndTime]) {
          //当前领奖期内则当前时间到活动结束刷新页面
          var deadlineAcEndTime = parseInt(this.basic[this.keyData.receivePrizeTimeEndTime] - this.nowTime) + '';
          console.log(deadlineAcEndTime, '距离活动结束时间');
          if (deadlineAcEndTime.length >= 9) {
            var deadlineAcEndTime1 = 24 * 60 * 60 * 1000;
          } else {
            var deadlineAcEndTime1 = deadlineAcEndTime;
          }
          if (deadlineAcEndTime > 0) {
            //定时刷新判断签到时间是否结束
            var locationUrl = location.href;
            var a = setInterval(() => {
              //重新请求
              location.reload();
              clearInterval(a);
              // 2676401580
            }, parseInt(deadlineAcEndTime1));
          }
        }
        //判断显示那个标题
        if (this.isFinish == false) {
          console.log('签到期未结束');
          //签到期未结束
          this.JSONData.titleShow = true;
          this.prizePreview = true;
          this.waitReceivePrize = false;
          this.receivePrize = false;
          this.prizeList = this.listArr;
          return;
        } else if (this.nowTime < this.basic[this.keyData.receivePrizeTimeStartTime]) {
          console.log('签到期结束，领奖时间未开始');
          //签到期结束，领奖时间未开始
          this.JSONData.titleShow = true;
          this.prizePreview = false;
          this.waitReceivePrize = true;
          this.receivePrize = false;
          this.receive = 2;
          this.prizeList = this.listArr;
          return;
        } else if (this.nowTime >= this.basic[this.keyData.receivePrizeTimeStartTime] && this.nowTime <= this.basic[this.keyData.receivePrizeTimeEndTime]) {
          //领奖中 签到期结束，领奖期未结束
          console.log('签到期结束，领奖期未结束111');
          this.prizePreview = false;
          this.waitReceivePrize = false;
          this.receivePrize = true;
          this.JSONData.titleShow = true;
          this.publicData.$emit('showMyPrize', true);
          this.publicData.$emit('isDrawRolled', true, this.isTemplate);
          this.receive = 3;
          // this.styleDataNew.prizeTitleImg.imageUrl = '//img10.360buyimg.com/imgzone/jfs/t1/152214/21/12744/14227/5fed342aE5dc69eaf/cb194184b588e7e8.png';
        } else if (this.nowTime > this.basic[this.keyData.receivePrizeTimeEndTime]) {
          //领奖期结束
          console.log('领奖期结束');
          this.isShow = false;
          this.publicData.$emit('isNotyFiceWinnerReorrd', true, this.isTemplate);
          this.publicData.$emit('showMyPrize', true);
          this.publicData.$emit('isDrawRolled', false, this.isTemplate);
          return;
        }
        console.log(2211111111111111111111, this.receivingPrizeShow);
        if (this.receivingPrizeShow == true) {
          //奖品列表
          immediatelyDrawGray(receiveListData => {
            let data = receiveListData.data;
            this.unclaimedNum = data.receivePrizes.length; //待领取奖品个数

            let receivePrizesList = data.receivePrizes; //可领取奖品列表
            for (var i = 0; i < this.listArr.length; i++) {
              this.listArr[i].statueImg = '//img10.360buyimg.com/imgzone/jfs/t1/154713/4/12793/8489/5fec39ceE7bd9c63e/a64d5084bf34494d.png';
              this.listArr[i].canReceive = false; //可领取 (灰色的立即领取)
              this.listArr[i].status = 2;
              for (var j = 0; j < receivePrizesList.length; j++) {
                //判断达到条件奖品
                if (receivePrizesList[j].prizeInfoId == this.listArr[i].id) {
                  this.listArr[i].status = receivePrizesList[j].status;
                  console.log(122222222222222, this.listArr);
                  //判断奖品状态 （0 可领取 1 已经领取成功 2 领取失败）
                  if (this.listArr[i].leftNum > 0) {
                    //可领取 判断是否达到上限，达到上限 灰色立即领取 没有黄色立即领取
                    if (receivePrizesList[j].status == 0) {
                      this.listArr[i].canReceive = data.canReceive ? true : false;
                      if (!data.canReceive) {
                        this.listArr[i].statueImg = '//img10.360buyimg.com/imgzone/jfs/t1/197485/37/18150/7911/619cec62Ee06d907f/e5f5555bc7d0bfb3.png';
                      }
                    } else if (receivePrizesList[j].status == 1) {
                      //已经领取灰色已领取
                      this.listArr[i].canReceive = false;
                      this.listArr[i].statueImg = '//img10.360buyimg.com/imgzone/jfs/t1/154530/28/16203/7316/60111c2fE5d0fae64/062e58cb03541ce0.png';
                    } else if (receivePrizesList[j].status == 2) {
                      //领取失败 灰色立即领取
                      this.listArr[i].canReceive = false;
                      this.listArr[i].statueImg = '//img10.360buyimg.com/imgzone/jfs/t1/197485/37/18150/7911/619cec62Ee06d907f/e5f5555bc7d0bfb3.png';
                    }
                  } else {
                    if (receivePrizesList[j].status == 1) {
                      this.listArr[i].canReceive = false;
                      this.listArr[i].statueImg = '//img10.360buyimg.com/imgzone/jfs/t1/154530/28/16203/7316/60111c2fE5d0fae64/062e58cb03541ce0.png';
                    } else if (receivePrizesList[j].status == 2) {
                      this.listArr[i].canReceive = false;
                      this.listArr[i].statueImg = '//img10.360buyimg.com/imgzone/jfs/t1/197485/37/18150/7911/619cec62Ee06d907f/e5f5555bc7d0bfb3.png';
                    }
                  }
                }
              }
            }
            this.prizeList = this.listArr;
          });
        }
      }
    },
    //立即领取点击按钮
    drawprize(index, itemData, type) {
      let actStatus = sessionStorage.getItem('actStatus');
      if (actStatus == 2) {
        // Toast
        this.$toast('活动已结束');
        return;
      }
      if (actStatus == 1) {
        this.$toast('活动尚未开始');
        return;
      }
      if (type == 0) {
        Toast('很抱歉,奖品领取已达规定上限');
        return;
      } else if (type == 1) {
        Toast('您未达到领取条件~');
        return;
      } else if (type == 3) {
        Toast('奖品已发完~');
        return;
      }
      if (this.isPlayType) {
        return;
      }
      this.isPlayType = true;
      if (this.isTemplate) {
      } else if (!this.isTemplate) {
        let actStatus = sessionStorage.getItem('actStatus');
        if (actStatus == 1) {
          Toast('活动尚未开始');
          return;
        } else if (actStatus == 2) {
          Toast('活动已结束');
          return;
        }
        console.log(itemData.id, '领奖中');
        immediatelyDraw(itemData.id, receiveData => {
          console.log(receiveData, '领奖中');
          // console.log(itemData);
          if (receiveData.resp_code == 0) {
            this.isPlayType = false;
            if (receiveData.data.result == true) {
              this.initData();
              var obj = {
                datas: {},
                keyData: {
                  prizeUrl: 'showImg',
                  prizeName: 'prizeName',
                  prizeType: 'prizeType',
                  priceInfo: 'priceInfo',
                  discountType: 'discountType',
                  couponType: 'couponType'
                }
              };
              obj.datas = itemData;
              console.log(obj, 'obj');
              PrizeResultPopComService.create(obj, receiveData.data, submit => {
                console.log(submit);
                PrizeResultPopComService.close();
              });
            } else {
              NoPrizeResultPopComService.create(
                '抱歉您与奖品擦肩而过~',
                '//img10.360buyimg.com/imgzone/jfs/t1/152859/24/15591/14697/6008f58fE1744005f/765fe66b5a48aefc.png',
                submit => {
                  NoPrizeResultPopComService.close();
                }
              );
              this.initData();
            }
          } else {
            this.isPlayType = false;
            this.prizeList[index].status = 3;
            this.$toast('奖品已领完，下次早点哦');
          }
        });
      }
    }
  }
};
</script>
<style scoped>
/* .prizePreviewNew .libox:nth-of-type(1){
  margin-top: 0rem;
} */
#unclaimedPrize {
  background-image: url('//img10.360buyimg.com/imgzone/jfs/t1/159431/5/14938/5742/60598c88E883604f5/017b0087aef5ef83.png');
  background-repeat: no-repeat;
  background-size: 100%;
  line-height: 1.1rem;
  width: 7.25rem;
  color: red;
  font-size: 0.35rem;
  font-weight: bold;
  margin: 0 auto;
}
#allPrize {
  background-image: url('//img10.360buyimg.com/imgzone/jfs/t1/160479/25/14736/7489/60598c6aE34ff9cec/61a62ad51f5f818d.png');
  background-repeat: no-repeat;
  background-size: 100%;
  height: 9.7rem;
  width: 7.16rem;
  margin: 0 auto;
  margin-top: 1.15rem;
}
#allPrize .titleImg {
  /* height: 1.27rem;
  width: 4.46rem;
  margin-top: -0.8rem; */
}
#scroll {
  width: 6.9rem;
  border-radius: 0.2rem;
  background: turquoise;
}
#scroll::-webkit-scrollbar {
  display: none;
  /* background-color:transparent; */
}
.receivePrizeTime {
  font-size: 0.25rem;
  color: red;
  font-weight: bold;
}
#prizeList {
  margin-top: 0.25rem;
}
#prizeItem {
  background-color: red;
  /* height: 2rem; */
  width: 6.75rem;
  margin: auto;
  border-radius: 0.1rem;
  padding: 0.1rem;
  margin-bottom: -0.2rem;
  display: flex;
  align-items: center;
}
#prizePhoto {
  height: 1.8rem;
  width: 1.7rem;
  background-color: white;
  border-radius: 0.05rem;
  display: flex;
  justify-content: center;
  align-items: center;
  /* float: left; */
}
#prizePhoto img {
  height: 1.6rem;
  width: 1.4rem;
  /* margin-top: 0.1rem; */
}
#leftAll {
  /* width: 100%; */
}
#leftDiv {
  display: flex;
  flex-direction: column;
}
/* .prizeName {

} */

#clickdraw {
  margin-left: 2.3rem;
  /* margin-top: 0.83rem; */
  margin-bottom: 0.12rem;
  display: flex;
  justify-content: flex-end;
}
#clickdraw img {
  width: 2.4rem;
  height: 0.7rem;
}
#statistics0 {
  display: flex;
  justify-content: flex-end;
}
#statistics {
  line-height: 0.4rem;
  background-color: white;
  border-radius: 1rem;
  /* margin-left: 4rem; */
  margin-top: 0.5rem;
  margin-bottom: 0.2rem;
  display: flex;
  justify-content: center;
  width: 2.3rem;
}
#statistics1 {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-self: center;
  height: 100%;
  width: 0.23rem;
}
#statistics span {
  font-size: 0.3rem;
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
}
#statistics img {
  /* display: flex;
    align-items: center; */
  height: 0.24rem;
  width: 0.2rem;
  margin-top: 0;
  margin-right: 0.08rem;
}
#bottom {
  /* display: inline; */
  /* float: left; */
  display: flex;
  justify-content: space-between;
  padding-bottom: 0.12rem;
}
.surplus {
  color: white;
  display: inline;
  font-size: 0.24rem;
  /* padding-left: 0.4rem; */
}
</style>
