<template name="coupons">
  <div
    :style="styleData.bigbox"
    class="bigbox"
    :key="keyee"
    ref="coupons"
    @click.stop="styleClick('click', 'coupons')"
    @mousemove.stop="styleClick('mousemove', 'coupons')"
    @mouseout.stop="styleClick('mouseout')"
  >
    <div v-if="contboxshow != true && endShow">
      <!--============================ 抢券时间 ============================================-->
      <div id="couponstimediv" :style="styleData.couponstimediv">
        <!-- 抢券时间段---ul -->
        <!-- 时间段遍历---li -->
        <div
          v-for="(info, index) in list"
          :key="index"
          :style="info.active ? styleData.active : styleData.couponstimeli"
          @click="select(index)"
          v-if="index < 4"
        >
          <img
            src="https://img10.360buyimg.com/imgzone/jfs/t17803/340/1582599885/508/5fd18264/5acf26ceN9c73c1ec.png"
            alt="图片加载失败"
            v-if="list[index].active == true"
            class="coupinsttu"
          />
          <span>{{ info.startTime }}</span>
          <span v-if="list[index].active == true">
            <span>{{ info.titleText }}</span>
          </span>
        </div>
      </div>
      <!-- ============================== 时间倒计时 ============================================= -->
      <div v-if="!notstarted" :style="styleData.theme">
        {{ affairs }}&nbsp;:&nbsp;{{ counttime }}
      </div>
      <!-- <div :class="notstarted ? 'notheme' : 'theme'">
        <h1>{{ affairs }}&nbsp;:&nbsp;{{ counttime }}</h1>
      </div> -->
      <!--============================ 优惠券 ============================================-->
      <div id="couponsdiv" :style="styleData.couponsdiv">
        <div id="coupons" :style="styleData.couponsul">
          <!--优惠券 ul -->
          <div
            class="couponsmain"
            :style="styleData.couponsmainli"
            v-for="(item, index) in templatelist
              ? ticketlist[nowIndex]
              : ticketlist"
            :key="item.id"
          >
            <!-- li -->
            <div class="mainl" :style="styleData.mainl">
              <div class="nameber1" :style="styleData.nameber1">
                <span class="l" :style="styleData.nameber1span">￥</span>
                <span class="l" :style="styleData.nameber1h2">
                  {{ isTemplate ? item.priceInfo : item.priceNum }}
                </span>
              </div>
            </div>
            <div class="mainr" :style="styleData.mainr">
              <span class="mainsapn" :style="styleData.mainspan">{{
                item.prizeName
              }}</span>
              <span
                v-if="item.priceInfo"
                class="mainh2"
                :style="styleData.mainh2"
              >
                满{{ isTemplate ? item.fullPriceInfo : item.priceInfo }}元可使用
              </span>
              <button
                v-if="isWebClick"
                class="immediatelybtn1"
                :style="styleData.immediatelybtn1"
                :class="item.btnGray ? 'changebtngray' : ''"
              >
                {{ item.ticketTextList }}
              </button>
              <button
                v-else
                class="immediatelybtn1"
                :style="styleData.immediatelybtn1"
                v-lz-click="'12'"
                @click="handlestatus(index, item)"
                :class="item.btnGray ? 'changebtngray' : ''"
              >
                {{ item.ticketTextList }}
              </button>
            </div>
            <img
              :src="styleData.changeimg1.imageUrl"
              :style="
                item.imgGray ? styleData.changeimg1 : styleData.changeimg2
              "
            />
          </div>
        </div>
      </div>
    </div>
    <div id="contbox" v-if="contboxshow">
      <div>抱歉来晚了！</div>
      <div style="margin-top: 0.2rem">今天活动已结束！</div>
      <div style="margin-top: 0.2rem">欢迎明日继续参加活动！</div>
    </div>
    <div id="contbox" v-if="endShow == false">
      <div>抱歉您来晚了！</div>
      <div style="margin-top: 0.2rem">活动已结束！</div>
    </div>
  </div>
</template>
<script>
import apis1 from "../../../util/apis1.js";
import {
  // FollowShopFirstPopComService,
  voucherPopComService,
  eggPopComService,
} from "../../../util/comCreate.js";
import { Toast } from "vant";
import { PrizeResultPopComService } from "../../../util/comCreate.js";
let { robCoupons, robCouponsClick, followShop } = apis1;
export default {
  props: [
    "datas",
    "styleData",
    "keyData",
    "isTemplate",
    "templateData",
    "modifyContent",
    "isWebClick",
  ],
  data() {
    return {
      titleText: [], //span里文字
      titleTime: [], //转化后的小时分钟
      affairs: "", //距离结束/开始
      counttime: "", //倒计时标准
      setIntervalTime: "", // 计时器
      contboxshow: false, //券全部结束
      templatelist: true, //判断是不是手机
      guanzhu: 0, //是否关注店铺
      notstarted: false, //活动是否开始动态class定位
      keyee: 0,
      prizeResultData: {
        styleData: {},
        datas: {},
        keyData: {
          prizeUrl: "showImg",
          prizeName: "prizeName",
          prizeType: "prizeType",
          priceInfo: "priceInfo",
          discountType: "discountType",
          couponType: "couponType",
        },
      },
      list: [],
      ticketlist: [], //存优惠券数组
      ticketTextList: [], //优惠券文本
      btnGray: [], //控制按钮是否置灰
      imgGray: [], //控制盒子是否置灰
      nowIndex: 0,
      activeClick: [],
      endShow: true,
      styleDataOld: {},
    };
  },
  mounted() {
    //深拷贝重置需要
    this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));
    this.initDadas();
  },
  methods: {
    //点击可修改位置的方法
    styleClick(type, refName) {
      if (this.isWebClick) {
        //传值给B端
        let byValue = {
          modifyContent: this.modifyContent,
          refName: refName,
          styleData: this.styleData,
          styleDataOld: this.styleDataOld,
          c_this: this,
        };
        this.$emit("opertaionCom", type, byValue);
      }
    },
    //active初始默认false,点击改变true
    select(d) {
      if (this.isTemplate) {
        this.$toast("活动预览，仅供查看");
        return;
      }
      const self = this;
      let actStatus = sessionStorage.getItem("actStatus");
      if (actStatus == 2) {
        this.$toast("活动已结束");
        return;
      }
      if (actStatus == 1) {
        this.$toast("活动未开始");
        return;
      }
      this.ticketTextList = [];
      this.nowIndex = d; //默认0==active
      this.list.map((s) => (s.active = false));
      this.list[d].active = true;
      //转化标准时间显示在页面上
      var hour = new Date().getHours();
      var min = new Date().getMinutes();
      if (hour < 10) {
        hour = "0" + hour;
      }
      if (min < 10) {
        min = "0" + min;
      }
      var nowTime = hour + ":" + min;
      console.log(nowTime, this.list[d].endTime, this.list[d].startTime);
      if (nowTime > this.list[d].endTime) {
        this.affairs = "此时段已结束";
        this.list[d].titleText = "已结束";
        this.list[d].prizeVOs.forEach((m, d) => {
          this.ticketTextList.push("已结束");
          m.btnGray = true;
          m.imgGray = false;
        });
      } else if (nowTime < this.list[d].startTime) {
        this.affairs = "距离活动开始时间";
        this.list[d].titleText = "即将开始";
        this.list[d].prizeVOs.forEach((m, d) => {
          this.ticketTextList.push("即将开始");
          m.btnGray = true;
          m.imgGray = false;
        });
      } else if (
        nowTime >= this.list[d].startTime &&
        nowTime <= this.list[d].endTime
      ) {
        this.affairs = "距离活动结束时间";
        this.list[d].titleText = "疯抢中";
        this.list[d].prizeVOs.forEach((m, d) => {
          console.log(m);
          if (m.robStatus == 0) {
            m.btnGray = false;
            m.imgGray = false;
            m.ticketTextList = "立即抢券";
          } else if (m.robStatus == 1) {
            m.btnGray = true;
            m.imgGray = false;
            this.ticketTextList.push("此券已领");
          } else if (m.robStatus == 2) {
          } else if (m.robStatus == 3) {
            m.btnGray = true;
            m.imgGray = true;
            this.ticketTextList.push("已领完");
          }
        });
      }
      clearInterval(this.setIntervalTime);
      this.setIntervalTime = setInterval(() => {
        var start = this.list[this.nowIndex].startTime + ":00"; //券开始时间
        var end = this.list[this.nowIndex].endTime + ":00"; //券结束时间
        console.log(now, start, this.list[this.nowIndex], d, "suka");
        var resulttime = ""; //+距离结束时间  -已经结束
        var hour = "";
        var minute = "";
        var second = "";
        var hour = new Date().getHours();
        var min = new Date().getMinutes();
        var seco = new Date().getSeconds();
        if (min < 10) {
          min = "0" + min;
        }
        if (hour < 10) {
          hour = "0" + hour;
        }
        var now = hour + ":" + min + ":" + seco;
        if (now > end) {
          var isTime = this.timeDifference(now, end);
          if (isTime <= 1) {
            setTimeout(() => {
              this.initDadas();
            }, 1000);
          }
          resulttime = isTime;
          hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
          minute = Math.floor(((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60);
          second = Math.floor(((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60);
        } else if (now < start) {
          var isTime = this.timeDifference(now, start);
          if (isTime <= 1) {
            setTimeout(() => {
              this.initDadas();
            }, 1000);
          }
          resulttime = isTime;
          hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
          minute = Math.floor(((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60);
          second = Math.floor(((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60);
        } else if (now > start && now < end) {
          var isTime = this.timeDifference(now, end);
          if (isTime <= 1) {
            setTimeout(() => {
              this.initDadas();
            }, 1000);
          }
          resulttime = isTime;
          hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
          minute = Math.floor(((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60);
          second = Math.floor(((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60);
        }
        this.counttime = hour + "时" + minute + "分" + second + "秒";
      }, 1000);
    },
    timeDifference(startTime, endTime) {
      var start1 = startTime.split(":");
      var startAll =
        parseInt(start1[0] * 3600) +
        parseInt(start1[1] * 60) +
        parseInt(start1[2]);
      var end1 = endTime.split(":");
      var endAll =
        parseInt(end1[0] * 3600) + parseInt(end1[1] * 60) + parseInt(end1[2]);
      return endAll - startAll;
    },
    initDadas(data) {
      clearInterval(this.setIntervalTime);
      console.log("2333333333333333333333333333333333");
      if (this.isTemplate) {
        var daall = this.templateData;
        // console.log(this.list,"222333322223333222333222444")
        // B端预览
        console.log(daall, "dalllllllllllll");
        if (daall) {
          this.templatelist = false;
          daall.couponsData.endTimeList.forEach((v) => {
            var hour = new Date().getHours();
            var min = new Date().getMinutes();
            if (min < 10) {
              min = "0" + min;
            }
            if (hour < 10) {
              hour = "0" + hour;
            }
            var nowTime = hour + ":" + min;
            if (nowTime > v.endTime) {
            } else {
              this.list.push(v);
            }
          });
          console.log(daall.couponsData.endTimeList);
          this.ticketlist = daall.couponsData.endTimeList[0].draw.prizeList;
          if (this.list.length == 0) {
            this.contboxshow = true;
            return;
          }
          console.log(this.list, "affairs");
          //映射表取回优惠券数组
          this.list[0].active = true;
          //转化标准时间显示在页面上
          var hour = new Date().getHours();
          var min = new Date().getMinutes();
          if (min < 10) {
            min = "0" + min;
          }
          if (hour < 10) {
            hour = "0" + hour;
          }
          var nowTime = hour + ":" + min;
          if (nowTime > this.list[0].endTime) {
            this.affairs = "此时段已结束";
            this.list[0].titleText = "已结束";
            this.ticketlist.forEach((m, d) => {
              m.priceNum = m.beanNum;
              m.btnGray = true;
              m.imgGray = false;
              m.ticketTextList = "已结束";
            });
          } else if (nowTime < this.list[0].startTime) {
            this.affairs = "距离活动开始时间";
            this.list[0].titleText = "即将开始";
            this.ticketlist.forEach((m, d) => {
              m.priceNum = m.beanNum;
              m.btnGray = true;
              m.imgGray = false;
              m.ticketTextList = "即将开始";
            });
          } else if (
            nowTime > this.list[0].startTime &&
            nowTime < this.list[0].endTime
          ) {
            this.affairs = "距离活动结束时间";
            this.list[0].titleText = "疯抢中";
            this.ticketlist.forEach((m, d) => {
              m.priceNum = m.beanNum;
              m.btnGray = false;
              m.imgGray = false;
              m.ticketTextList = "立刻抢券";
            });
          }
          console.log(this.ticketlist);
          this.setIntervalTime = setInterval(() => {
            var start = this.list[0].startTime + ":00"; //券开始时间
            var end = this.list[0].endTime + ":00"; //券结束时间
            var resulttime = ""; //+距离结束时间  -已经结束
            var hour = "";
            var minute = "";
            var second = "";
            var hour = new Date().getHours();
            var min = new Date().getMinutes();
            var seco = new Date().getSeconds();
            if (hour < 10) {
              hour = "0" + hour;
            }
            if (min < 10) {
              min = "0" + minute;
            }
            if (seco < 10) {
              seco = "0" + second;
            }

            var now = hour + ":" + min + ":" + seco;
            console.log(start, "end");
            console.log(now, "now");
            var isTime = this.timeDifference(now, end);
            if (now > end) {
              resulttime = isTime;
              hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
              minute = Math.floor(
                ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
              );
              second = Math.floor(
                ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
              );
            } else if (now < start) {
              var isTime = this.timeDifference(now, start);
            
              resulttime = isTime;
              hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
              minute = Math.floor(
                ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
              );
              second = Math.floor(
                ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
              );
            } else if (now > start && now < end) {
              resulttime = isTime;
              hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
              minute = Math.floor(
                ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
              );
              second = Math.floor(
                ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
              );
            }
            if (hour < 10) {
              hour = "0" + hour;
            }
            if (minute < 10) {
              minute = "0" + minute;
            }
            if (second < 10) {
              second = "0" + second;
            }
            this.counttime = hour + "时" + minute + "分" + second + "秒";
          }, 1000);
          // B端前预览
        } else {
          if (this.isWebClick) {
            this.list = [
              {
                id: 1,
                startTime: "8:00",
                endTime: "10:00",
                active: true,
                titleText: "疯抢中",
                prizeVOs: [
                  {
                    id: 4,
                    ocean: "￥",
                    amount: "15",
                    tittle: "限时优惠券",
                    fullPriceInfo: "50",
                    ticketTextList: "立刻抢券",
                    priceInfo: 5,
                    prizeName: 5,
                    status: "", //优惠券抢券状态
                  },
                  {
                    id: 5,
                    ocean: "￥",
                    amount: "15",
                    tittle: "限时优惠券",
                    fullPriceInfo: "50",
                    ticketTextList: "立刻抢券",
                    priceInfo: 5,
                    prizeName: 5,
                    status: "", //优惠券抢券状态
                  },
                  {
                    id: 6,
                    ocean: "￥",
                    amount: "15",
                    tittle: "限时优惠券",
                    fullPriceInfo: "50",
                    ticketTextList: "立刻抢券",
                    priceInfo: 5,
                    prizeName: 5,
                    status: "1", //优惠券抢券状态
                    imgGray: true,
                  },
                ],
              },
              {
                id: 2,
                startTime: "11:00",
                endTime: "12:00",
                active: false,
                prizeVOs: [
                  {
                    id: 1,
                    ocean: "￥",
                    amount: "10",
                    tittle: "限时优惠券",
                    condition: "2",
                    number: 2,
                    status: "", //优惠券抢券状态
                  },
                ],
              },
              {
                id: 3,
                startTime: "14:00",
                endTime: "15:00",
                active: false,
                prizeVOs: [
                  {
                    id: 1,
                    ocean: "￥",
                    amount: "10",
                    tittle: "限时优惠券",
                    condition: "2",
                    number: 2,
                    status: "", //优惠券抢券状态
                  },
                ],
              },
            ];
          } else {
            this.list = [
              {
                id: 1,
                startTime: "8:00",
                endTime: "10:00",
                active: true,
                titleText: "疯抢中",
                prizeVOs: [
                  {
                    id: 5,
                    ocean: "￥",
                    amount: "15",
                    tittle: "限时优惠券",
                    fullPriceInfo: "50",
                    ticketTextList: "立刻抢券",
                    priceInfo: 5,
                    prizeName: 5,
                    status: "", //优惠券抢券状态
                  },
                  {
                    id: 6,
                    ocean: "￥",
                    amount: "15",
                    tittle: "限时优惠券",
                    fullPriceInfo: "50",
                    ticketTextList: "立刻抢券",
                    priceInfo: 5,
                    prizeName: 5,
                    status: "", //优惠券抢券状态
                  },
                ],
              },
              {
                id: 2,
                startTime: "11:00",
                endTime: "12:00",
                active: false,
                prizeVOs: [
                  {
                    id: 1,
                    ocean: "￥",
                    amount: "10",
                    tittle: "限时优惠券",
                    condition: "2",
                    number: 2,
                    status: "", //优惠券抢券状态
                  },
                ],
              },
              {
                id: 3,
                startTime: "14:00",
                endTime: "15:00",
                active: false,
                prizeVOs: [
                  {
                    id: 1,
                    ocean: "￥",
                    amount: "10",
                    tittle: "限时优惠券",
                    condition: "2",
                    number: 2,
                    status: "", //优惠券抢券状态
                  },
                ],
              },
            ];
          }
          this.list.forEach((v, i) => {
            //映射表取回优惠券数组
            this.ticketlist.push(v.prizeVOs);
            this.affairs = "距离活动结束时间";
            this.setIntervalTime = setInterval(() => {
              var start = this.list[0].startTime; //券开始时间
              var end = this.list[0].endTime + ":00"; //券结束时间
              var resulttime = ""; //+距离结束时间  -已经结束
              var hour = "";
              var minute = "";
              var second = "";
              var hour = new Date().getHours();
              var min = new Date().getMinutes();
              var seco = new Date().getSeconds();
              if (hour < 10) {
                hour = "0" + hour;
              }
              if (min < 10) {
                min = "0" + minute;
              }
              if (seco < 10) {
                seco = "0" + second;
              }
              var now = hour + ":" + min + ":" + seco;
              var isTime = this.timeDifference(now, end);
              if (now > end) {
                resulttime = isTime;
                hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
                minute = Math.floor(
                  ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
                );
                second = Math.floor(
                  ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
                );
              } else if (now < start) {
                var isTime = this.timeDifference(now, start);
                resulttime = isTime;
                hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
                minute = Math.floor(
                  ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
                );
                second = Math.floor(
                  ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
                );
              } else if (now > start && now < end) {
                resulttime = isTime;
                hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
                minute = Math.floor(
                  ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
                );
                second = Math.floor(
                  ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
                );
              }
              if (hour < 10) {
                hour = "0" + hour;
              }
              if (minute < 10) {
                minute = "0" + minute;
              }
              if (second < 10) {
                second = "0" + second;
              }
              this.counttime = hour + "时" + minute + "分" + second + "秒";
            }, 1000);
            console.log(
              this.list,
              this.ticketlist,
              "啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊"
            );
          });
          console.log(daall, this.ticketlist, "dahiwdnaidiadjiajdaidjiadj");
        }
        this.$toast("活动预览，仅供查看");
        return;
      }
      const self = this;
      var dataStartTime = null;
      var dataEndTime = null;
      robCoupons((data) => {
        if (new Date().getTime() > data.data.endTime) {
          this.endShow = false;
          return;
        }
        console.log(data.data, "rab1111111");
        this.guanzhu = data.data.involvementFlag;
        this.list = data.data.detailVOs;
        if (this.list.length == 0) {
          this.contboxshow = true;
          return;
        }
        this.list[0].active = true;
        this.list.forEach((v, i) => {
          //映射表取回优惠券数组
          this.ticketlist.splice(i, 1, v.prizeVOs);
          //转化标准时间显示在页面上

          var hour = new Date().getHours();
          var min = new Date().getMinutes();
          if (min < 10) {
            min = "0" + min;
          }
          if (hour < 10) {
            hour = "0" + hour;
          }
          var nowTime = hour + ":" + min;
          console.log(hour, min, nowTime, v.startTime, v.endTime, "hhhhhhhh");
          if (nowTime > v.endTime) {
            this.affairs = "此时段已结束";
            v.titleText = "已结束";
            v.prizeVOs.forEach((m, d) => {
              m.btnGray = true;
              m.imgGray = false;
              m.ticketTextList = "已结束";
            });
          } else if (nowTime < v.startTime) {
            this.affairs = "距离活动开始时间";
            v.titleText = "即将开始";
            v.prizeVOs.forEach((m, d) => {
              m.btnGray = true;
              m.imgGray = false;
              m.ticketTextList = "即将开始";
            });
          } else if (nowTime >= v.startTime && nowTime <= v.endTime) {
            this.affairs = "距离活动结束时间";
            v.titleText = "疯抢中";
            v.prizeVOs.forEach((m, d) => {
              console.log(m);
              if (m.robStatus == 0) {
                m.btnGray = false;
                m.imgGray = false;
                m.ticketTextList = "立刻抢券";
              } else if (m.robStatus == 1) {
                m.btnGray = true;
                m.imgGray = false;
                m.ticketTextList = "此券已领";
              } else if (m.robStatus == 2) {
                m.btnGray = true;
                m.imgGray = false;
                m.ticketTextList = "此券已领";
              } else if (m.robStatus == 3) {
                m.btnGray = true;
                m.imgGray = true;
                m.ticketTextList = "已领完";
              }
            });
          }
        });
        console.log(this.list, this.list[this.nowIndex].affairs, "affairs");
        let actStatus = sessionStorage.getItem("actStatus");
        if (actStatus == 2) {
          this.list[this.nowIndex].prizeVOs.forEach((m, d) => {
            m.btnGray = true;
            m.imgGray = false;
          });
        }
        console.log(
          this.ticketTextList,
          this.titleText,
          this.btnGray,
          this.imgGray
        );
        this.setIntervalTime = setInterval(() => {
          var start = this.list[0].startTime + ":00"; //券开始时间
          var end = this.list[0].endTime + ":00"; //券结束时间
          var resulttime = ""; //+距离结束时间  -已经结束
          var hour = "";
          var minute = "";
          var second = "";
          var hour = new Date().getHours();
          var min = new Date().getMinutes();
          var seco = new Date().getSeconds();
          if (hour < 10) {
            hour = "0" + hour;
          }
          if (min < 10) {
            min = "0" + min;
          }
          if (seco < 10) {
            seco = "0" + seco;
          }
          var now = hour + ":" + min + ":" + seco;
          if (now > end) {
            var isTime = this.timeDifference(end, now);
            if (isTime <= 1) {
              setTimeout(() => {
                this.initDadas();
              }, 1000);
            }
            resulttime = isTime;
            hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
            minute = Math.floor(
              ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
            );
            second = Math.floor(
              ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
            );
          } else if (now < start) {
            var isTime = this.timeDifference(now, start);
            if (isTime <= 1) {
              setTimeout(() => {
                this.initDadas();
              }, 1000);
              this.keyee++;
            }
            resulttime = isTime;
            hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
            minute = Math.floor(
              ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
            );
            second = Math.floor(
              ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
            );
          } else if (now > start && now < end) {
            //当现在时间大于开始时间且小于结束时间
            var isTime = this.timeDifference(now, end);
            if (isTime <= 1) {
              setTimeout(() => {
                this.initDadas();
              }, 1000);
              this.keyee++;
            }
            resulttime = isTime;
            hour = Math.floor((resulttime % (24 * 60 * 60)) / (60 * 60));
            minute = Math.floor(
              ((resulttime % (24 * 60 * 60)) % (60 * 60)) / 60
            );
            second = Math.floor(
              ((resulttime % (24 * 60 * 60)) % (60 * 60)) % 60
            );
          }
          if (hour < 10) {
            hour = "0" + hour;
          }
          if (minute < 10) {
            minute = "0" + minute;
          }
          if (second < 10) {
            second = "0" + second;
          }
          this.counttime = hour + "时" + minute + "分" + second + "秒";
        }, 1000);
        //
      });
    },
    handlestatus(index2, item) {
      if (this.isTemplate) {
        this.$toast("活动预览，仅供查看");
        return;
      }
      const self = this;
      let actStatus = sessionStorage.getItem("actStatus");
      if (actStatus == 2) {
        this.$toast("活动已结束");
        return;
      }
      if (actStatus == 1) {
        this.$toast("活动未开始");
        return;
      }
      console.log(item.prizeInfoId);
      if (item.btnGray || item.ticketTextList == "即将开始") {
        return;
      } else {
        if (this.guanzhu == 1) {
          // alert("关注,voucherPop")
          voucherPopComService.create(this.shopName, 0, (submit) => {
            voucherPopComService.close();
            if (submit == 1) {
              this.guanzhu = 0;
              robCouponsClick(item.prizeInfoId, (data) => {
                this.activeClick.push(item.prizeInfoId);
                console.log(data, this.activeClick);
                if (data.data != "") {
                  item.ticketTextList = "此券已领";
                  item.robStatus = 1;
                  item.btnGray = true;
                  Toast("优惠券已发放到账户中，可在京东-我的-优惠券中查看");
                } else {
                  Toast("奖项领取失败");
                }
              });
            }
          });
        } else {
          robCouponsClick(item.prizeInfoId, (data) => {
            this.activeClick.push(item.prizeInfoId);
            console.log(data, this.activeClick);
            if (data.data != "") {
              item.ticketTextList = "此券已领";
              item.robStatus = 1;
              item.btnGray = true;
              Toast("优惠券已发放到账户中，可在京东-我的-优惠券中查看");
            } else {
              Toast("奖项领取失败");
            }
          });
        }
      }
    },
  },
};
</script>
<style scoped>
.l {
  float: left;
}
.r {
  float: right;
}
.couponstimeli {
  height: 0.48rem;
  background-color: #959595;
  color: #fff;
  border: solid 2px #fff;
  font-size: 0.24rem;
  border-radius: 0.4rem;
  line-height: 0.48rem;
  margin-left: 0.1rem;
  cursor: pointer;
  padding: 0 0.2rem;
}
.active {
  background: #f46 !important;
}
.coupinsttu {
  width: 0.11rem;
  height: 0.15rem;
  margin-top: 0.12rem;
}
.theme {
  width: 4.2rem;
  height: 0.3rem;
  line-height: 0.3rem;
  text-align: center;
  position: absolute;
  top: -0.35rem;
  left: 1.5rem;
}

.theme h1 {
  font-size: 0.2rem;
  color: #fff;
  float: left;
  font-weight: 400;
}
.theme span {
  color: #f46;
  float: left;
  font-size: 0.2rem;
  display: block;
  margin: 0;
  padding: 0;
}
.changeimg1 {
  width: 6rem;
  height: 2rem;
  position: absolute;
  left: 0;
  top: 0;
}
.couponsmain {
  position: relative;
}
.changeimg2 {
  display: none;
}

.immediatelybtn1 {
  width: 1.3rem;
  height: 0.44rem;
  background: #f46;
  border-radius: 0.4rem;
  margin: 0 auto;
  font-size: 0.2rem;
  color: #fff6ee;
  border: 0;
  line-height: 0.44rem;
  text-align: center;
  display: block;
  margin-top: 0.24rem;
  cursor: pointer;
}
.changebtngray {
  background-color: rgb(204, 204, 204) !important;
}
#contbox {
  margin-top: 2.5rem;
  text-align: center;
  font-size: 0.5rem;
  color: rgb(255, 255, 255);
  /* margin-left: -1.5rem; */
}
#nobigbox {
  position: relative;
  top: -5.6rem;
}
#bigbox {
  position: absolute;
  top: 3.45rem;
}
.bigbox {
  position: relative;
}
#couponsdiv {
  margin-left: 0.75rem;
}
</style>