<template>
  <div class="page" :class="{'mobile':_isMobile,'pc':!_isMobile}">
    <div class="main_content" id="main">
      <img class="page-bg" src="../assets/images/gesture/massage-entry-fullbg.png" alt srcset />
      <div class="massage-complete-modal noBaby">
        <div class="title">
          <!-- <image src="{{images.title}}"></image> -->
          <img class="icon" src="../assets/images/gesture/massage-complete-title-icon.png" />
          {{$t('strings.completeText')}}
        </div>
        <!-- <div class="record" v-if="finalBabyStatus != 3 && finalBabyStatus != -1">
          <div>{{$t('strings.completeText2')}}: {{time}}s</div>
        </div>-->
        <div class="bottom">
          <light-button @click="goHome" :text="$t('strings.completeButtonText')"></light-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { calcAdapt, isMobile } from "../common/util";
import lightButton from "../components/lightButton.vue";
import DevicePixelRatio from "../utils/evicePixelRatio.js";

let calcs = calcAdapt();
let scale;
const calcCoord = function () {
  let width = 0;
  let height = 0;
  if (!isMobile()) {
    width = 375;
    height =
      document.body.clientHeight > 667 ? document.body.clientHeight : 667;
  } else {
    width = document.body.clientWidth;
    height = document.body.clientHeight;
  }
  if (height === 0) {
    height = window.innerHeight;
    if (!isMobile()) {
      height = window.innerHeight > 667 ? window.innerHeight : 667;
    }
  }
  scale = height / width;
  let k = +scale.toFixed(2);
  if (k >= 2.16) {
    k = 2.16;
  } else if (k <= 1.78) {
    k = 1.78;
  }
  return calcs.calcCoord.call(null, ...arguments, k);
};
export default {
  data() {
    return {
      nikeName: "William",
      finalBabyStatus: 0,
      lying: 0,
      time: 0,
      total: 0,
      modalCalc: {
        top: ""
      },
      _isMobile: false
    };
  },
  components: {
    lightButton
  },
  methods: {
    goHome() {
      this.$router.push({
        path: "/"
      });
    }
  },
  created() {
    this.$i18n.locale = "en";
    let lang = localStorage.getItem("lang");
    if (lang) {
      this.$i18n.locale = lang;
    }
    this._isMobile = isMobile();
    let lying = this.$route.query.lying;
    let time = this.$route.query.totalDuration;
    let total = this.$route.query.totalDuration;
    this.lying = lying;
    this.time = time || 0;
    this.total = total || 0;
  },
  mounted() {
    this.$nextTick(() => {
      new DevicePixelRatio().init();
    });
  }
};
</script>

<style lang="scss" scoped>
.page {
  background: #000;
  display: flex;
  justify-content: center;
  height: 100%;
}
.pc {
  height: calc(var(--vh, 1vh) * 100);
  align-items: center;
  .main_content {
    width: 375px;
    height: 667px;
    background: #ffffff;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    .page-bg {
      position: absolute;
      left: 0;
      top: 0;
      width: 375px;
      z-index: 0;
    }
  }
  .massage-complete-modal {
    box-sizing: border-box;
    width: 330px;
    min-height: 210px;
    padding: 40px 0 62.5px;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 7px 7px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    &.noBaby {
      height: 210px;
      .bottom {
        margin-top: 50px;
      }
    }
    .nickname {
      font-size: 23px;
      color: #fb7c76;
      font-family: "Gotham-Book";
      text-shadow: 1px 1px 2px #ffffff;
      span {
        font-size: 30px;
      }
    }
    .title {
      margin-top: 20.5px;
      color: #fb7c76;
      font-size: 23px;
      line-height: 26.5012px;
      font-weight: bolder;
      .icon {
        width: 34.5px;
        height: 22.5px;
      }
    }
    .subTitle {
      width: 100%;
      text-align: center;
      color: #fb7c76;
      font-size: 13px;
      margin-top: 10px;
      font-weight: bolder;
      &.underline {
        text-decoration: underline;
      }
    }
    .record {
      margin-top: 50px;
      margin-bottom: 50px;
      width: 280px;
      height: 48px;
      line-height: 48px;
      border-radius: 24px 24px;
      font-size: 17.3362px;
      color: #999999;
      background-color: #f5f5f5;
      text-align: center;
      text-shadow: 1px 1px 2px #ffffff;
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
    }
  }
}

.mobile {
  .main_content {
    width: 10rem;
    height: calc(var(--vh, 1vh) * 100);
    background: #ffffff;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    .page-bg {
      position: absolute;
      left: 0;
      top: 0;
      width: 10rem;
      z-index: 0;
    }
  }
  .massage-complete-modal {
    box-sizing: border-box;
    width: 8.8rem;
    min-height: 5.6rem;
    padding: 1.0667rem 0 1.6667rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 0.1867rem 0.1867rem;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    &.noBaby {
      height: 5.6rem;
      .bottom {
        margin-top: 1.3333rem;
      }
    }
    .nickname {
      font-size: 0.6133rem;
      color: #fb7c76;
      font-family: "Gotham-Book";
      text-shadow: 0.0267rem 0.0267rem 0.0533rem #ffffff;
      span {
        font-size: 0.8rem;
      }
    }
    .title {
      margin-top: 0.5467rem;
      color: #fb7c76;
      font-size: 0.6133rem;
      line-height: 0.7067rem;
      font-weight: bolder;
      .icon {
        width: 0.92rem;
        height: 0.6rem;
      }
    }
    .subTitle {
      width: 100%;
      text-align: center;
      color: #fb7c76;
      font-size: 0.3467rem;
      margin-top: 0.2667rem;
      font-weight: bolder;
      &.underline {
        text-decoration: underline;
      }
    }
    .record {
      margin-top: 1.3333rem;
      margin-bottom: 1.3333rem;
      width: 7.4533rem;
      height: 1.28rem;
      line-height: 1.28rem;
      border-radius: 0.64rem 0.64rem;
      font-size: 0.4623rem;
      color: #999999;
      background-color: #f5f5f5;
      text-align: center;
      text-shadow: 0.0267rem 0.0267rem 0.0533rem #ffffff;
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
    }
  }
}
</style>