<template>
  <div class="download-box" ref="pronbit">
    <div class="title">
      <span>下载软件地址</span>
    </div>

    <div
      class="download-bg"
      :style="'background:url(' + mod.bgImage + ')'"
      v-show="isShow"
    >
      <div class="mainImg-box" style="float: right">
        <img :src="mod.mainImage" style="width: 100%" alt="" />
      </div>

      <div class="mainRight-box" style="float: left">
        <div class="modLogo-text">
          <img class="modLogo" :src="mod.applyLogo" alt="" />
          <span>{{ mod.mainText }}</span>
        </div>
        <div class="subText">{{ mod.subText }}</div>
        <div class="download-code">
          <div class="downloadImg">
            <div
              class="downloadImg-box"
              :style="getHoversColor"
              @click="downloadLink(linkData.iosLink)"
            >
              <img
                :src="mod.iosDownloadBtn"
                style="width: 42px; height: 42px"
                alt=""
              />
              <div style="margin-left: 10px">IPhone下载</div>
            </div>

            <div
              class="downloadImg-box"
              :style="getHoversColor"
              @click="downloadLink(linkData.androidLink)"
            >
              <img
                :src="mod.androidDownloadBtn"
                style="width: 42px; height: 42px"
                alt=""
              />
              <div style="margin-left: 10px">Android下载</div>
            </div>
          </div>

          <div class="download-content-code">
            <img class="modQrCde" :src="mod.qrcode" alt="" />
            <div>扫一扫轻松下载</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>


<script>
export default {
  computed: {
    getHoversColor: function () {
      return {
        "--text-color": this.mod.unSelectTextColor,
        "--text-color-hover": this.mod.selectTextColor,
        "--background-color": this.mod.unSelectBgColor,
        "--background-color-hover": this.mod.selectBgColor,
        "--box-shadow-color-hover": this.mod.selectBgColor + "4D",
      };
    },
  },
  data() {
    return {
      winHeight: 0,
      isShow: false,
    };
  },

  props: {
    mod: {
      type: Object,
      default: () => {},
    },
    linkData: {
      tpye: Object,
      default: () => {},
    },
  },
  created() {

    console.log(this.linkData)
    window.addEventListener("scroll", this.handleScrollx, true);
    this.winHeight =
      document.documentElement.clientHeight / 2 ||
      document.body.clientHeight / 2;
  },
  methods: {
    downloadLink: function (link) {
      window.open(link);
    },
    handleScrollx() {
      if (this.winHeight > this.$refs.pronbit.getBoundingClientRect().top) {
        this.isShow = true;

        window.removeEventListener("scroll", this);
      }
    },
  },
};
</script>


<style scoped>
.download-box {
  width: 1200px;
  height: 610px;
  margin: 0 auto;
  display: flex;
  flex-flow: column;
}
.title {
  color: #0f0f0f;
  font-size: 26px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 55px;
  letter-spacing: 5px;
}

.title::after {
  content: "";
  width: 12px;
  height: 12px;
  background: #ff4242;
  border-radius: 50%;
  margin-left: 5px;
}

.download-bg {
  width: 100%;
  height: 520px;
  background-size: 100% 100% !important;
  background-repeat: no-repeat;
  box-sizing: border-box;
  overflow: hidden;
  padding: 94px 110px 0;
  opacity: 0;
  animation: aniamtionDownload 1.2s ease-in-out forwards;
}

@keyframes aniamtionDownload {
  100% {
    opacity: 1;
  }
}

.mainImg-box {
  width: 344px;
  position: relative;
  animation: aniamtionMainImg 1.2s forwards;
  transform: translateY(600px);
}

@keyframes aniamtionMainImg {
  100% {
    transform: translateX(0);
  }
}

.mainImg-box::after {
  content: "";
  height: 100px;
  background: linear-gradient(
    rgba(255, 255, 255, 0) 0%,
    rgb(255, 255, 255) 100%
  );
  width: 100%;
  top: 326px;
  z-index: 99;
  position: absolute;
  left: 0px;
}

.mainRight-box {
  display: flex;
  flex-flow: column;
  transform: translateX(-220px);
  animation: aniamtionMainRight 1.2s ease-in-out forwards;
}

@keyframes aniamtionMainRight {
  100% {
    transform: translateX(0px);
  }
}

.modLogo-text {
  display: flex;
  color: #333333;
  font-size: 40px;
  font-weight: bold;
  align-items: center;
  margin-top: 14px;
}

.modLogo {
  margin-right: 18px;
  width: 60px;
  height: 60px;
  border-radius: 5px;
}

.subText {
  margin-top: 12px;
  font-size: 20px;
  color: #999999;
  white-space: pre-line;
}

.download-code {
  display: flex;
  margin-top: 26px;
}

.downloadImg {
  display: flex;
  flex-flow: column;
  margin-right: 20px;
  width: 222px;
  justify-content: space-between;
}

.download-content-code {
  width: 135px;
  height: 170px;
  background: #ffffff;
  border-radius: 10px;
  box-sizing: border-box;
  padding: 10px;
  color: #333333;
  font-size: 14px;
  display: flex;
  flex-flow: column;
  align-items: center;
}

.modQrCde {
  width: 100%;
  margin-bottom: 12px;
  border-radius: 3px;
}

.downloadImg-box {
  width: 222px;
  height: 72px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding-left: 15px;
  border-radius: 10px;
  color: var(--text-color);
  background: var(--background-color);
  box-shadow: 0px;
  transition: color 0.25s, background-color 0.25s, box-shadow 0.25s;
  cursor: pointer;
}

.downloadImg-box:hover {
  color: var(--text-color-hover);
  background: var(--background-color-hover);
  box-shadow: 0px 2px 30px 0px var(--box-shadow-color-hover);
  transition: color 0.35s, background-color 0.35s, box-shadow 0.35s;
}

@media screen and (max-width: 1500px) {
  .mainImg-box {
    width: 300px;
  }
}
</style>