<template>
  <div>
    <div v-if="snapdragon" class="snapdragonDiv" @click='clickEmpty()'>
      <div class="basicPopDiv" @click='stopClickEmpty'>
        <div class="titleDiv">
          <div class="titleDiv1">
            <div class="leftLineDiv"></div>
            <span>成功抽取</span>
            <div class="RightLineDiv"></div>
          </div>
          <div class="closeDiv" @click="closeClick()"></div>
        </div>
        <div class="content-body">
          <slot></slot>
        </div>
      </div>
    </div>
    <div v-else class="basicbackground" @click='clickEmpty()'>
      <div class="basicbackgroundClass" :style="styleData.backgroundimg" @click='stopClickEmpty'>
        <!-- <div class="colorbarimg">中奖啦！</div> -->
        <div class="closeimg" :style="styleData.closeimg" @click="closeClick()"></div>
        <slot></slot>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ["colorTitle","styleData"],
  name: "basicbackground",
  data() {
    return {
      titleImg:
        "//img10.360buyimg.com/imgzone/jfs/t1/135404/32/20175/13069/5fd996feE9cfa65b2/0fcd54f513291325.png",
    };
  },
  computed: {
    snapdragon() {
      const at = sessionStorage.getItem("activityType");
      const snapdragon = ["10011", "10012", "10013", "10014"];
      return snapdragon.some((o) => at === o);
    },
  },
  mounted() {
    document
      .querySelector("body")
      .setAttribute(
        "style",
        "position:#fixed;top:0;height:100%;overflow:hidden"
      );
  },
  created() {
    console.log(this.styleData,"kkkkkkkk");
    console.log(this.colorTitle);
    if (this.colorTitle) {
      this.titleImg = this.colorTitle;
    }
  },
  methods: {
    closeClick() {
      this.$emit("closeClick");
    },
    //点击空白处关闭弹框
    clickEmpty(){
      this.$emit("closeClick");
    },
    //阻止冒泡
    stopClickEmpty(event){
      event.stopPropagation();
    },
  },
};
</script>
<style lang="scss" scoped>
.basicbackground {
  .basicbackgroundClass{
    height:6.9rem;
    width:6rem;
    background-image:url('//img10.360buyimg.com/imgzone/jfs/t1/102050/20/27655/237782/6268e9b4E40cf6e02/1ed0ccada5088734.png');
    background-repeat:no-repeat;
    background-size:100%;
    position:relative;
  }
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;

  .colorbarimg {
    font-size: 0.42rem;
    color: #fff;
    margin-top: 0.37rem;
    text-align: center;
  }

  .closeimg {
    height: 0.24rem;
    width: 0.24rem;
    position: absolute;
    right: 0.34rem;
    top: 0.34rem;
    background-image: url("//img10.360buyimg.com/imgzone/jfs/t1/212853/26/18084/464/626a4812E26295ade/62d9d070d6de83b8.png");
    background-repeat: no-repeat;
    background-size: 100%;
  }

  .backgroundimg {
    height: 6.9rem;
    width: 6rem;
    background-image: url("//img10.360buyimg.com/imgzone/jfs/t1/222294/18/2922/260686/6194a878E076b5c8a/74933463999a3c52.png");
    background-repeat: no-repeat;
    background-size: 100%;
    position: relative;
  }
}

.snapdragonDiv {
  position: fixed;
  width: 100%;
  height: 100%;
  background: rgba($color: #000000, $alpha: 0.7);
  top: 0;
  bottom: 0;
  z-index: 200;

  .basicPopDiv {
    position: fixed;
    width: 6.48rem;
    min-height: 7rem;
    max-height: 100vh;
    background-color: #eaebf0;
    border-radius: 0.2rem;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;

    .titleDiv {
      width: 100%;
      height: 1.14rem;
      position: relative;
      flex-grow: 0;
      flex-shrink: 0;

      .titleDiv1 {
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        color: #333333;
        font-size: 0.46rem;
      }

      .leftLineDiv {
        width: 34px;
        height: 4px;
        background: linear-gradient(to right, #4f5f7a, #e9eaef);
        border-radius: 4px;
        margin-right: 0.1rem;
      }

      .RightLineDiv {
        width: 34px;
        height: 4px;
        background: linear-gradient(to left, #4f5f7a, #e9eaef);
        border-radius: 4px;
        margin-left: 0.1rem;
      }

      .closeDiv {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 48px;
        height: 48px;

        img {
          display: none;
        }

        &:before,
        &:after {
          position: absolute;
          left: 50%;
          top: 50%;
          display: block;
          content: "";
          width: 0.4rem;
          height: 0.04rem;
          border-radius: 1px;
          background-color: #8293ab;
        }

        &:before {
          transform: translate(-50%, -50%) rotate(45deg);
        }

        &:after {
          transform: translate(-50%, -50%) rotate(-45deg);
        }
      }
    }

    .content-body {
      margin: 0.25rem;
      background-color: white;
      padding: 0.34rem;
      box-shadow: 0rem 0.05rem 0.16rem 0rem rgba(177, 177, 177, 0.18);
      border-radius: 0.1rem;
      color: #495975;
      flex-direction: column;
      font-size: 0.44rem;
    }
  }
}
</style>
