<template>
  <div :style="styleData.distancePopStyle" v-show="distanceShadow">
    <!-- v-show控制弹窗 -->
    <div :style="styleData.box">
      <div :style="styleData.distancePopBoxStyle">
        <div class="builtinfo" :style="styleData.builtinfo">
          <div>开工时间：{{nowStartTime}}</div>
          <div>竣工时间：{{time}}</div>
          <div>竣工楼层：{{buildHigh}}</div>
          <div>施工人数：{{buildManNum}}</div>
          <div style="color: rgb(252, 60, 44);">中奖人数：{{long}}</div>
        </div>
        <div @click="PopButton()" class="btnimgbox"></div>
        <div>
          <div :style="styleData.distancePopButtonStyle" @click="PopButton()">
            <img
              src="https://img10.360buyimg.com/imgzone/jfs/t1/64190/37/4992/1258/5d317246E570a00cb/6f78d770d82b2580.png"
              alt
            />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import bus from "../../../util/bus.js";
export default {
  props: ["isTemplate", "datas", "styleData", "keyData", "templateData"],
  data() {
    return {
      starttime: 1626775200,
      endtime: 1626775200,
      distanceShadow: false,
      timeed: "",
      time: "",
      time1: null,
      nowStartTime:null,
      buildHigh: 0, //楼层
      buildManNum:0,
      long: null,
    };
  },
  created() {
    this.initDadas();
    bus.$on("prizelist", (content) => {
      // 输出兄弟组件传递的内容
      this.long = content;
    });
  },
  mounted() {},
  updated() {
    // 给bug绑定一个log事件,等待兄弟组件出发
    bus.$on("gertger", (content) => {
      // 输出兄弟组件传递的内容
      this.text = content;
      console.log(this.text, content, "99999999999999");
    });
  },
  methods: {
    PopButton(text) {
      this.distanceShadow = !this.distanceShadow;
      console.log(this.distanceShadow);
    },
    initDadas(data) {
      bus.$on("timeout", (content) => {
        this.distanceShadow = content;
      });
      bus.$on("data", (content) => {
        console.log(content, "data");
        // this.endtime = content.endTime
        this.buildHigh = content.bulidCount
        this.buildManNum = content.userCount
        console.log(this.nowTime(new Date(content.endTime)))
        this.time = this.nowTime(new Date(content.endTime))
        this.nowStartTime = this.nowTime(new Date(content.startTime))
      });
      bus.$on("winner", (content) => {
        if(content){
          this.long = content.data.length;
        }else{
          this.long = 0
        }
      });
    },
    nowTime(nowTime) {
      var year = nowTime.getFullYear();
      var month;
      var day;
      if (nowTime.getMonth() + 1 < 10) {
        month = "0" + (nowTime.getMonth() + 1);
      } else {
        month = nowTime.getMonth() + 1;
      }
      if (nowTime.getDate() < 10) {
        day = "0" + nowTime.getDate();
      } else {
        day = nowTime.getDate();
      }
      var time = year + "年" + month + "月" + day + "日";
      return time;
    },
  },
};
</script>
<style  scoped>
.btnimgbox {
  width: 100%;
  height: 0.9rem;
  position: absolute;
  bottom: 0;
}
</style>