<template>
  <div class="page" :class="{'mobile':_isMobile,'pc':!_isMobile}">
    <div class="main_content" id="main" :class="{'small':_isMobile && isSmall,'big':_isMobile && isBig}">
      <div class="top" :class="{'small':_isMobile && isSmall,'big':_isMobile && isBig}" :style="{'height':topHeiht}">
        <div class="page_title">{{$t('strings.homeTitle')}}</div>
        <div class="picture-box" :style="{'transform': scale>0?'scale('+scale+')':''}">
          <img class="page_bg2" src="../assets/images/gesture/swiper1big_new.png" alt srcset />
          <div class="page_tips_1 page_tips">{{$t('strings.homeText1')}}</div>
          <div class="page_tips_2 page_tips">{{$t('strings.homeText2')}}</div>
          <div class="page_tips_3 page_tips">{{$t('strings.homeText3')}}</div>
        </div>
      </div>
      <div class="global_box">
        <img class="global_img" @click="clickGlobalPopup" src="../assets/images/gesture/icon_global.png" alt srcset />
        <div class="popup-box" v-if="showPopup">
          <img class="popup_bg" src="../assets/images/gesture/popup.png" alt srcset />
          <div class="poup-item" :class="{'active':currentLanguage === index}" v-for="(item,index) in languageList" :key="item" @click="clickLanguage(index)">
            <img v-if="currentLanguage === index" class="icon" src="../assets/images/gesture/select.png" alt srcset />
            <div v-else></div>
            <span>{{item}}</span>
          </div>
        </div>
      </div>
      <div class="bottom">
        <div class="bottomBtn">
          <light-button @click="clickAuthCamera" :text="$t('strings.homeButtonText')"></light-button>
        </div>
      </div>
      <div class="no_camera_dialog" v-if="showNoCameraDialog">
        <div class="no_camera_dialog_mask"></div>
        <div class="no_camera_dialog_content">
          <div class="no_camera_dialog_title">{{$t('strings.cameraText')}}</div>
          <div class="no_camera_dialog_text_content">{{$t('strings.cameraText1')}}</div>
          <div class="no_camera_dialog_button" @click="clickConfirm">
            <img class="no_camera_dialog_button_bg" src="../assets/images/gesture/light-btn-bg.png" alt srcset />
            <div class="no_camera_dialog_button_text">{{$t('strings.cameraButtonText')}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  calcAdapt,
  isBigScreen,
  isSmallScreen,
  authCamera,
  isMobile,
  getSystemInfo
} 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 {
      showNoCameraDialog: false,
      topHeiht: 0,
      isBig: isBigScreen(),
      isSmall: isSmallScreen(),
      scale: scale,
      currentLanguage: 0,
      showPopup: false,
      languageList: ["English", "Français", "Español"],
      cL: calcCoord({ minTop: 23.5, maxTop: 15.5 }).top + "px",
      cT: calcCoord({ minTop: 23.5, maxTop: 33.5 }).top + "px",
      cB: calcCoord({ minTop: 20, maxTop: 40 }).top + "px",
      cTs: calcCoord({ minTop: 20, maxTop: 30 }).top + "px", // title fontsize
      cTb: calcCoord({ minTop: 15, maxTop: 15 }).top + "px", // title bottom
      cCs: calcCoord({ minTop: 10, maxTop: 20 }).top + "px", // content
      pageHeight: "",
      _isMobile: false,
      scale: 0
    };
  },
  components: {
    lightButton
  },
  methods: {
    clickGlobalPopup() {
      this.showPopup = !this.showPopup;
    },
    setLanguagePack() {
      let lang = "en";
      if (this.currentLanguage === 0) {
        lang = "en";
      } else if (this.currentLanguage === 1) {
        lang = "fr";
      } else if (this.currentLanguage === 2) {
        lang = "es";
      }
      localStorage.setItem("lang", lang);
      let _languagePack = {
        tipsString: {
          initInitial: "请调整姿势",
          sittingUnrecognition: "未识别到宝宝，请根据屏幕上的宝宝贴纸模拟动作",
          sittingBabyneckloc: "请用肘关节支撑宝宝颈部",
          sittingBabyhead: "请勿用手掌固定宝宝头部",
          sittingBabybackloc: "请将前臂顺着宝宝背部",
          sittingUpleft: "请抬高左手臂",
          sittingUpright: "请抬高右手臂",
          sittingDownleft: "请放低左手臂",
          sittingDownright: "请放低右手臂",
          sittingHeadupassdown: "请保持宝宝头部高于臀部",
          sittingBabystright: "请保持宝宝耳肩臀在同一直线",
          sittingBabyheadloc: "请确保宝宝头部正对妈妈乳房，不宜过高",
          nobabysittingBabyneckloc: "实际哺乳时，请注意用肘关节支撑宝宝颈部",
          nobabysittingHeadupassdown: "实际哺乳时，请保持宝宝头部高于臀部",
          nobabysittingBabystright: "实际哺乳时，请保持宝宝耳肩臀一条直线",

          /// 坐姿建议
          sittingSuggest: [
            "请采用舒适姿势，确保与宝宝始终胸腹相贴",
            "宝宝嘴巴尽量包裹住乳晕",
            "使宝宝下巴紧贴乳房，张嘴角度大于100度",
            "随时点击右上角指导图示调整含乳姿势",
            "放松肩膀",
            "妈妈抱宝宝的手，腰部和脚有支撑",
            "保持放松，直到哺乳结束"
          ]
        },
        commonmemsg: {
          initialMassage:
            "请与屏幕保持1米左右距离使身体进入轮廓线，5秒后开始识别"
        },
        sittingMsg: {
          babyneckloc: "请用肘关节支撑宝宝颈部",
          babyhead: "请勿用手掌固定宝宝头部",
          babybackloc: "请将前臂顺着宝宝背部",
          upleft: "请抬高左手臂",
          upright: "请抬高右手臂",
          downleft: "请放低左手臂",
          downright: "请放低右手臂",
          headupassdown: "请保持宝宝头部高于臀部",
          babystright: "请保持宝宝耳肩臀在同一直线",
          babyheadloc: "请确保宝宝头部正对妈妈乳房，不宜过高"
        },
        sittingMsgPart: {
          babyneckloc: "请用肘关节支撑宝宝颈部",
          babyhead: "请勿用手掌固定宝宝头部",
          babybackloc: "请将前臂顺着宝宝背部",
          headupassdown: "请保持宝宝头部高于臀部",
          babystright: "请保持宝宝耳肩臀在同一直线",
          babyheadloc: "请确保宝宝头部正对妈妈乳房，不宜过高"
        },
        successmsg: {
          recordMessage: "现在可以开始哺乳了！3秒后将自动开始计时",
          nobabyRecord: "您已掌握喂养姿势，期待您和宝宝一起来体验哺乳计时功能",
          suggest: "请及时点击右上角指导图示调整",
          posSuccess: "您的姿势正确，请继续保持"
        },
        strings: {
          suggestTitle: "在开始哺乳的时候可以保持:",
          suggestText1:
            "1.在哺乳过程中，应采用妈妈和宝宝都舒适的姿势，确保与宝宝始终胸腹相贴。",
          suggestText2:
            "2.请让宝宝嘴巴尽量包裹住乳晕，下巴紧贴乳房，张嘴角度大于100度。",
          suggestText3: "3.请放松肩膀，用垫子或枕头支撑抱宝宝的手，腰部和脚。",
          suggestText4: "4.全程请保持放松，愉悦的状态，直到宝宝主动吐出乳头。",
          suggestConfirmText: "知道了",
          discardReasonTitle: "放弃的原因是...",
          discardReason1: "不知道怎么用",
          discardReason2: "担心我的个人隐私",
          discardReason3: "觉得没有用处",
          mainTipsText:
            "请在安全环境安全设备使用本功能。在使用过程中，我们不会存储您的图像。",
          guidance: "指导",
          briefSummaryTitleFront: "恭喜您在",
          briefSummaryTitleAfter: "秒内完成了本次姿势矫正",
          sitMainPointsText1: "婴儿头高臀低，妈妈能看到婴儿的表情",
          sitMainPointsText2: "妈妈和婴儿应该腹胸相贴",
          sitMainPointsText3: "婴儿的头枕于妈妈手肘处，不要用手固定婴儿头部",
          sitMainPointsText4: "婴儿的耳、肩、臀成一条直线",
          sitMainPointsConfirmText: "好 的",
          momLeft: "当未检测到您,将自动停止计时后续流程,停留5s后跳转至结束页面",
          successStatusTips: "您的姿势正确，请继续保持大约20秒",
          errorTitle: "Error message",
          keyErrorText: "Forbidden",
          originErrorText: "Not allowed by CORS"
        }
      };
      let _englishLanguagePack = {
        tipsString: {
          initInitial: "Please adjust your posture",
          sittingUnrecognition:
            "No baby detected. Please follow the on-screen instructions",
          sittingBabyneckloc: "Make sure baby's neck is on your elbow",
          sittingBabyhead: "Do not restrict baby's head with your hands",
          sittingBabybackloc:
            "Make sure your forearm is supporting baby's back",
          sittingUpleft: "Raise your left arm",
          sittingUpright: "Raise your right arm",
          sittingDownleft: "Lower your left arm",
          sittingDownright: "Lower your right arm",
          sittingHeadupassdown:
            "Keep baby's head in higher position than the rest of the body",
          sittingBabystright:
            "Keep baby's ear, shoulder and butt at the same level",
          sittingBabyheadloc:
            "Make sure baby is facing the breast at proper height",
          nobabysittingBabyneckloc:
            "During actual breastfeeding, make sure baby's neck is on your elbow",
          nobabysittingHeadupassdown:
            "During actual breastfeeding, keep baby's head in higher position than the rest of the body",
          nobabysittingBabystright:
            "During actual breastfeeding, keep baby's ear, shoulder and butt at the same level",

          /// 坐姿建议
          sittingSuggest: [
            "Adjust to a comfortable posture, and keep baby very close to you at all times",
            "Make sure baby is latched properly (mouth should fully cover the nipple and areola)",
            "Keep baby's chin close to your breast, and mouth fully covering the nipple and areola",
            "Tap top right icon to view more info",
            "Relax your shoulder",
            "There should be support to your hand, waist and feet when holding baby",
            "Keep relaxed until the end of session"
          ]
        },
        commonmemsg: {
          initialMassage:
            "Keep one meter away from the camera, and fit your body into the guide line. Session starts in 5 seconds…",
          slogan: ""
        },
        sittingMsg: {
          babyneckloc: "Make sure baby's neck is on your elbow",
          babyhead: "Do not restrict baby's head with your hands",
          babybackloc: "Make sure your forearm is supporting baby's back",
          upleft: "Raise your left arm",
          upright: "Raise your right arm",
          downleft: "Lower your left arm",
          downright: "Lower your right arm",
          headupassdown:
            "Keep baby's head in higher position than the rest of the body",
          babystright: "Keep baby's ear, shoulder and butt at the same level",
          babyheadloc: "Make sure baby is facing the breast at proper height"
        },
        sittingMsgPart: {
          babyneckloc: "Make sure baby's neck is on your elbow",
          babyhead: "Do not restrict baby's head with your hands",
          babybackloc: "Make sure your forearm is supporting baby's back",
          headupassdown:
            "Keep baby's head in higher position than the rest of the body",
          babystright: "Keep baby's ear, shoulder and butt at the same level",
          babyheadloc: "Make sure baby is facing the breast at proper height"
        },
        successmsg: {
          recordMessage:
            "You may start breastfeeding now! Timer starts in 3 seconds…",
          nobabyRecord:
            "You have learned the correct posture. You may try this AI coach with your baby next time",
          suggest: "Tap top right icon to view more info",
          posSuccess: "Your posture is correct. Please keep it going"
        },
        strings: {
          suggestTitle: "During actual breastfeeding:",
          suggestText1:
            "Adjust to a comfortable posture, and keep baby very close to you at all times",
          suggestText2:
            "Make sure baby is latched properly (mouth should fully cover the nipple and areola); keep baby's chin close to your breast, and mouth fully covering the nipple and areola",
          suggestText3:
            "There should be support to your hand, waist and feet when holding baby",
          suggestText4: "Keep relaxed until the end of session",
          suggestConfirmText: "OK",
          discardReasonTitle: "Reasons to give up?",
          discardReason1: "Not sure how to use it",
          discardReason2: "Concern about my personal privacy",
          discardReason3: "Do not think it is helpful",
          mainTipsText:
            "Your images and videos will only be used for AI coach recognition. They will not be stored.",
          guidance: "Tips",
          briefSummaryTitleFront:
            "Congratulations! You have completed the session in ",
          briefSummaryTitleAfter: " seconds",
          sitMainPointsText1:
            "Keep baby's head in higher position so you can see baby's face",
          sitMainPointsText2: "Keep baby very close to you",
          sitMainPointsText3:
            "Keep baby's neck on your elbow, and do not restrict baby's head with your hand",
          sitMainPointsText4:
            "Keep baby's ear, shoulder and butt at the same level",
          sitMainPointsConfirmText: "OK",
          momLeft:
            "No person detected. The finish page will be shown after 5 seconds",
          successStatusTips:
            "Correct! Please keep the posture for about 20 seconds",
          errorTitle: "Error message",
          keyErrorText: "Forbidden",
          originErrorText: "Not allowed by CORS"
        }
      };
      let _frenchLanguagePack = {
        tipsString: {
          initInitial: "Veuillez ajuster votre posture",
          sittingUnrecognition:
            "Aucun bébé détecté. Veuillez suivre les instructions à l'écran",
          sittingBabyneckloc:
            "Assurez-vous que le cou de bébé est sur votre coude",
          sittingBabyhead: "Ne limitez pas la tête de bébé avec vos mains",
          sittingBabybackloc:
            "Assurez-vous que votre avant-bras soutient le dos de bébé",
          sittingUpleft: "Levez votre bras gauche",
          sittingUpright: "Levez votre bras droit",
          sittingDownleft: "Abaissez votre bras gauche",
          sittingDownright: "Abaissez votre bras droit",
          sittingHeadupassdown:
            "Gardez la tête de bébé en position plus haute que le reste du corps",
          sittingBabystright:
            "Gardez l'oreille, l'épaule et les fesses de bébé au même niveau",
          sittingBabyheadloc:
            "Assurez-vous que bébé est face au sein à la bonne hauteur",
          nobabysittingBabyneckloc:
            "Pendant l'allaitement, assurez-vous que le cou du bébé est sur votre coude",
          nobabysittingHeadupassdown:
            "Pendant l'allaitement, gardez la tête de bébé en position plus haute que le reste du corps",
          nobabysittingBabystright:
            "Pendant l'allaitement, gardez l'oreille, l'épaule et les fesses de bébé au même niveau",

          /// 坐姿建议
          sittingSuggest: [
            "Ajustez-vous à une posture confortable et gardez bébé très près de vous à tout moment",
            "Assurez-vous que le bébé prend correctement le sein (la bouche doit couvrir entièrement le mamelon et l'aréole)",
            "Gardez le menton de bébé près de votre sein, sa bouche couvrant entièrement le mamelon et l'aréole",
            "Appuyez sur l'icône en haut à droite pour afficher plus d'informations",
            "Détendez votre épaule",
            "Votre main, votre taille et vos pieds doivent être soutenus lorsque vous tenez bébé",
            "Restez détendu jusqu'à la fin de la séance"
          ]
        },
        commonmemsg: {
          initialMassage:
            "Tenez-vous à un mètre de la caméra et placez votre corps dans la ligne de guidage. La session démarre dans 5 secondes…"
        },
        sittingMsg: {
          babyneckloc: "Assurez-vous que le cou de bébé est sur votre coude",
          babyhead: "Ne limitez pas la tête de bébé avec vos mains",
          babybackloc:
            "Assurez-vous que votre avant-bras soutient le dos de bébé",
          upleft: "Levez votre bras gauche",
          upright: "Levez votre bras droit",
          downleft: "Abaissez votre bras gauche",
          downright: "Abaissez votre bras droit",
          headupassdown:
            "Gardez la tête de bébé en position plus haute que le reste du corps",
          babystright:
            "Gardez l'oreille, l'épaule et les fesses de bébé au même niveau",
          babyheadloc:
            "Assurez-vous que bébé est face au sein à la bonne hauteur"
        },
        sittingMsgPart: {
          babyneckloc: "Assurez-vous que le cou de bébé est sur votre coude",
          babyhead: "Ne limitez pas la tête de bébé avec vos mains",
          babybackloc:
            "Assurez-vous que votre avant-bras soutient le dos de bébé",
          headupassdown:
            "Gardez la tête de bébé en position plus haute que le reste du corps",
          babystright:
            "Gardez l'oreille, l'épaule et les fesses de bébé au même niveau",
          babyheadloc:
            "Assurez-vous que bébé est face au sein à la bonne hauteur"
        },
        successmsg: {
          recordMessage:
            "Vous pouvez commencer à allaiter maintenant ! La minuterie démarre dans 3 secondes…",
          nobabyRecord:
            "Vous avez appris la bonne posture. Vous pouvez essayer cet entraîneur AI avec votre bébé la prochaine fois",
          suggest:
            "Appuyez sur l'icône en haut à droite pour afficher plus d'informations",
          posSuccess: "Votre posture est correcte. Vous pouvez continuer"
        },
        strings: {
          suggestTitle: "Pendant l'allaitement:",
          suggestText1:
            "Ajustez-vous à une posture confortable et gardez bébé très près de vous à tout moment",
          suggestText2:
            "Assurez-vous que le bébé prend correctement le sein (la bouche doit couvrir entièrement le mamelon et l'aréole); gardez le menton de bébé près de votre sein, sa bouche couvrant entièrement le mamelon et l'aréole",
          suggestText3:
            "Votre main, votre taille et vos pieds doivent être soutenus lorsque vous tenez bébé",
          suggestText4: "Restez détendu jusqu'à la fin de la séance",
          suggestConfirmText: "OK.",
          discardReasonTitle: "Raisons d'abandonner?",
          discardReason1: "Je ne sais pas comment l'utiliser",
          discardReason2: "Inquiétude pour ma vie privée",
          discardReason3: "Je ne pense pas que c'est utile",
          mainTipsText:
            "Vos images et vidéos ne seront utilisées que pour la reconnaissance des coachs IA. Elles ne seront pas stockés.",
          guidance: "des astuces",
          briefSummaryTitleFront:
            "Toutes nos félicitations! Vous avez terminé la session en ",
          briefSummaryTitleAfter: " secondes",
          sitMainPointsText1:
            "Gardez la tête de bébé en position haute pour que vous puissiez voir le visage de bébé",
          sitMainPointsText2: "Gardez bébé très près de vous",
          sitMainPointsText3:
            "Gardez le cou de bébé sur votre coude et ne limitez pas la tête de bébé avec votre main",
          sitMainPointsText4:
            "Gardez l'oreille, l'épaule et les fesses de bébé au même niveau",
          sitMainPointsConfirmText: "OK",
          momLeft:
            "Aucune personne détectée. La page d'arrivée s'affichera après 5 secondes",
          successStatusTips:
            "Corriger! Veuillez garder la posture pendant environ 20 secondes",
          errorTitle: "Message d'erreur",
          keyErrorText: "Forbidden",
          originErrorText: "Not allowed by CORS"
        }
      };
      let _spanishLanguagePack = {
        tipsString: {
          initInitial: "Por favor, ajuste su postura",
          sittingUnrecognition:
            "Ningún bebé detectado. Siga las instrucciones mostradas en pantalla",
          sittingBabyneckloc:
            "Asegúrese de que el cuello del bebé esté sobre su codo",
          sittingBabyhead: "No restrinja la cabeza del bebé con las manos",
          sittingBabybackloc:
            "Asegúrese de que su antebrazo esté sosteniendo la espalda del bebé",
          sittingUpleft: "Levante su brazo izquierdo",
          sittingUpright: "Levante su brazo derecho",
          sittingDownleft: "Baje su brazo izquierdo",
          sittingDownright: "Baje su brazo derecho",
          sittingHeadupassdown:
            "Mantenga la cabeza del bebé en una posición más alta que el resto del cuerpo",
          sittingBabystright:
            "Mantenga la oreja, el hombro y el trasero del bebé al mismo nivel",
          sittingBabyheadloc:
            "Asegúrese de que el bebé esté frente al pecho a la altura adecuada",
          nobabysittingBabyneckloc:
            "Durante la lactancia real, asegúrese de que el cuello del bebé esté sobre su codo.",
          nobabysittingHeadupassdown:
            "Durante la lactancia real, mantenga la cabeza del bebé en una posición más alta que el resto del cuerpo",
          nobabysittingBabystright:
            "Durante la lactancia real, mantenga la oreja, el hombro y el trasero del bebé al mismo nivel",

          /// 坐姿建议
          sittingSuggest: [
            "Tome una postura cómoda y mantén al bebé muy cerca de usted en todo momento",
            "Asegúrese de que el bebé esté bien sujeto (la boca debe cubrir completamente el pezón y la areola)",
            "Mantenga la barbilla del bebé cerca de su seno y la boca cubriendo completamente el pezón y la areola",
            "Toque el icono superior derecho para ver más información",
            "Relaje su hombro",
            "Debe haber apoyo en su mano, su cintura y sus pies al sostener al bebé",
            "Manténgase relajada hasta el final de la sesión"
          ]
        },
        commonmemsg: {
          initialMassage:
            "Manténgase a un metro de distancia de la cámara y coloque su cuerpo en la línea. La sesión comienza en 5 segundos..."
        },
        sittingMsg: {
          babyneckloc: "Asegúrese de que el cuello del bebé esté sobre su codo",
          babyhead: "No restrinja la cabeza del bebé con las manos",
          babybackloc:
            "Asegúrese de que su antebrazo esté sosteniendo la espalda del bebé",
          upleft: "Levante su brazo izquierdo",
          upright: "Levante su brazo derecho",
          downleft: "Baje su brazo izquierdo",
          downright: "Baje su brazo derecho",
          headupassdown:
            "Mantenga la cabeza del bebé en una posición más alta que el resto del cuerpo",
          babystright:
            "Mantenga la oreja, el hombro y el trasero del bebé al mismo nivel",
          babyheadloc:
            "Asegúrese de que el bebé esté frente al pecho a la altura adecuada"
        },
        sittingMsgPart: {
          babyneckloc: "Asegúrese de que el cuello del bebé esté sobre su codo",
          babyhead: "No restrinja la cabeza del bebé con las manos.",
          babybackloc:
            "Asegúrese de que su antebrazo esté sosteniendo la espalda del bebé",
          headupassdown:
            "Mantenga la cabeza del bebé en una posición más alta que el resto del cuerpo",
          babystright:
            "Mantenga la oreja, el hombro y el trasero del bebé al mismo nivel",
          babyheadloc:
            "Asegúrese de que el bebé esté frente al pecho a la altura adecuada"
        },
        successmsg: {
          recordMessage:
            "¡Puede comenzar a darle el pecho ahora! El temporizador comienza en 3 segundos...",
          nobabyRecord:
            "Ha aprendido la postura correcta. Puede probar este asistente de IA con su bebé la próxima vez",
          suggest: "Toque el icono superior derecho para ver más información",
          posSuccess: "Su postura es correcta. Por favor, sigua así"
        },
        strings: {
          suggestTitle: "Durante la lactancia real:",
          suggestText1:
            "Tome una postura cómoda y mantén al bebé muy cerca de usted en todo momento",
          suggestText2:
            "Asegúrese de que el bebé esté bien sujeto (la boca debe cubrir completamente el pezón y la areola); mantenga la barbilla del bebé cerca de su seno y la boca cubriendo completamente el pezón y la areola",
          suggestText3:
            "Debe haber apoyo en su mano, su cintura y sus pies al sostener al bebé",
          suggestText4: "Manténgase relajada hasta el final de la sesión",
          suggestConfirmText: "DE ACUERDO",
          discardReasonTitle: "Razones para rendirse?",
          discardReason1: "No estoy segura de cómo usarlo",
          discardReason2: "Preocupación por mi privacidad",
          discardReason3: "No creo que sea útil",
          mainTipsText:
            "Sus imágenes y videos solo se utilizarán para el reconocimiento del asistente de IA. No se almacenarán.",
          guidance: "consejos",
          briefSummaryTitleFront: "¡Felicidades! Has completado la sesión en ",
          briefSummaryTitleAfter: " segundos",
          sitMainPointsText1:
            "Mantenga la cabeza del bebé en una posición más alta para que pueda ver la cara del bebé",
          sitMainPointsText2: "Mantenga al bebé muy cerca de usted",
          sitMainPointsText3:
            "Mantenga el cuello del bebé sobre su codo y no restrinja la cabeza del bebé con su mano",
          sitMainPointsText4:
            "Mantenga la oreja, el hombro y el trasero del bebé al mismo nivel",
          sitMainPointsConfirmText: "DE ACUERDO",
          momLeft:
            "No se detectó ninguna persona. La página de finalización se mostrará después de 5 segundos",
          successStatusTips:
            "¡Correcto! Mantenga la postura durante unos 20 segundos",
          errorTitle: "Mensaje de error",
          keyErrorText: "Forbidden",
          originErrorText: "Not allowed by CORS"
        }
      };
      switch (this.currentLanguage) {
        case 0:
          localStorage.setItem(
            "languagePack",
            JSON.stringify(_englishLanguagePack)
          );
          break;
        case 1:
          localStorage.setItem(
            "languagePack",
            JSON.stringify(_frenchLanguagePack)
          );
          break;
        case 2:
          localStorage.setItem(
            "languagePack",
            JSON.stringify(_spanishLanguagePack)
          );
          break;
        // case 3:
        //   _prefs.setString("languagePack", json.encode(_spanishLanguagePack));
        //   break;
        default:
      }
    },
    clickLanguage(index) {
      this.showPopup = false;
      this.currentLanguage = index;
      let lang = "zh";
      if (index === 0) {
        lang = "en";
      } else if (index === 1) {
        lang = "fr";
      } else if (index === 2) {
        lang = "es";
      }
      this.$i18n.locale = lang;
      localStorage.setItem("lang", lang);
    },
    clickConfirm() {
      this.showNoCameraDialog = false;
    },
    async clickAuthCamera() {
      this.setLanguagePack();
      if (this.showNoCameraDialog) {
        this.showNoCameraDialog = false;
      }
      let { camera } = await authCamera(0);
      console.log(import.meta.env);

      if (camera) {
        let apiKey = "DLAB-customername-12345687";
        let env = import.meta.env.VITE_TRACKING_ENV;
        console.log(env);
        let aiParams = {
          env: env,
          apiKey: apiKey,
          region: "apac"
        };
        localStorage.setItem("aiParams", JSON.stringify(aiParams));
        let openDev = this.$route.query.openDev;
        localStorage.setItem(
          "completeUrl",
          "https://bfai-service-apac-uat.d-lab-services.danone.com/demo/#/complete"
        );
        localStorage.setItem("incompleteUrl", document.URL);
        let url =
          "https://bfai-service-apac-uat.d-lab-services.danone.com/sdk/#/";
        if (openDev) {
          url = url + "&openDev=true";
        }
        window.location.href = url;
      } else {
        this.showNoCameraDialog = true;
      }
    }
  },
  created() {
    document.body.addEventListener(
      "touchmove",
      function (e) {
        e.preventDefault(); //阻止默认的处理方式(阻止下拉滑动的效果)
      },
      { passive: false }
    ); //passive 参数不能省略，用来兼容ios和android
    let { scale } = getSystemInfo();
    if (scale > 1 && scale < 2) {
      this.scale = 1 - (scale - 1) / 100;
      console.log(this.scale);
    }
    this.$i18n.locale = "en";
    this._isMobile = isMobile();
    if (!isMobile()) {
      document.getElementsByTagName("body")[0].style.minWidth = "750px";
      this.topHeiht = calcCoord({ minTop: 459, maxTop: 571.3 }).top;
      this.topHeiht = 521.3;
    } else {
      this.topHeiht = calcCoord({ minTop: 918, maxTop: 1142.6 }).top;
    }

    if (!this._isMobile) {
      this.topHeiht = this.topHeiht + "px";
      this.cL = calcCoord({ minTop: 23.5, maxTop: 25.5 }).top + "px";
      this.cT = calcCoord({ minTop: 23.5, maxTop: 33.5 }).top + "px";
      this.cB = calcCoord({ minTop: 20, maxTop: 40 }).top + "px";
      this.cTs = calcCoord({ minTop: 20, maxTop: 30 }).top + "px"; // title fontsize
      this.cTb = calcCoord({ minTop: 15, maxTop: 15 }).top + "px"; // title bottom
      this.cCs = calcCoord({ minTop: 10, maxTop: 20 }).top + "px"; // content
    } else {
      this.topHeiht = this.topHeiht / 75 + "rem";
      this.cL = calcCoord({ minTop: 47, maxTop: 51 }).top / 75 + "rem";
      this.cT = calcCoord({ minTop: 47, maxTop: 67 }).top / 75 + "rem";
      this.cB = calcCoord({ minTop: 40, maxTop: 80 }).top / 75 + "rem";
      this.cTs = calcCoord({ minTop: 40, maxTop: 60 }).top / 75 + "rem"; // title fontsize
      this.cTb = calcCoord({ minTop: 30, maxTop: 30 }).top / 75 + "rem"; // title bottom
      this.cCs = calcCoord({ minTop: 20, maxTop: 40 }).top / 75 + "rem"; // content
    }
  },
  mounted() {
    this.$nextTick(() => {
      new DevicePixelRatio().init();
    });
    window.onresize = () => {
      return (() => {})();
    };
  }
};
</script>

<style lang="scss" scoped>
.page {
  background: #000;
  display: flex;
  justify-content: center;
  height: 100%;
}
.pc {
  height: 100vh;
  align-items: center;
  .main_content {
    width: 375px;
    height: 667px;
    background: #ffffff;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    .global_box {
      width: 31px;
      position: absolute;
      right: 9px;
      top: 10px;
      z-index: 10;
      .global_img {
        width: 100%;
      }

      .popup-box {
        width: 70px;
        height: 75px;
        position: absolute;
        right: -4.5px;
        top: 36px;
        padding-top: 6px;
        box-sizing: border-box;
        overflow: hidden;
        border-radius: 6px;
        .popup_bg {
          position: absolute;
          left: 0;
          top: 0;
          width: 70px;
        }
        .poup-item {
          position: relative;
          height: 22.5px;
          font-size: 10px;
          font-family: Source Han Sans SC;
          font-weight: 500;
          color: #303030;
          line-height: 22.5px;
          display: flex;
          align-items: center;
          justify-content: start;
          cursor: pointer;
          img {
            width: 7px;
            margin-left: 9.5px;
            margin-right: 5.5px;
          }
          div {
            width: 7px;
            margin-left: 9.5px;
            margin-right: 5.5px;
          }
          &.active {
            color: #f68682;
          }
        }
      }
    }
    .top {
      position: relative;
      width: 100%;
      background: url("../assets/images/gesture/introduceBg.png") no-repeat top
        center;
      overflow: hidden;
      .page_bg {
        width: 100%;
        position: absolute;
        left: 0;
        top: 0;
      }

      .page_title {
        font-size: 21px;
        font-family: Source Han Sans SC;
        font-weight: bold;
        color: #f68682;
        line-height: 30px;
        // -webkit-text-stroke: 1px #fff9fb;
        // text-stroke: 1px #fff9fb;
        width: 100%;
        position: absolute;
        left: 0;
        top: 58px;
        z-index: 2;
      }
      .picture-box {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        .page_bg2 {
          width: 100%;
          position: absolute;
          left: 0;
          top: 50px;
        }

        .page_tips {
          font-size: 12px;
          color: #7d7c7a;
          text-align: left;
          word-wrap: break-word;
          hyphens: auto;
          &.page_tips_1 {
            position: absolute;
            top: 165px;
            left: 50px;
            width: 130px;
          }
          &.page_tips_2 {
            position: absolute;
            width: 215px;
            left: 155px;
            top: 356px;
          }
          &.page_tips_3 {
            position: absolute;
            width: 265px;
            left: 55px;
            top: 445px;
          }
        }
      }
      &.small {
        .page_title {
          top: 20px;
        }
        .page_bg2 {
          width: 60%;
          position: absolute;
          left: 20%;
          top: 30px;
        }
        .page_tips {
          font-size: 10px;
          &.page_tips_1 {
            position: absolute;
            top: 96px;
            left: calc(20% + 27.4987px);
            width: 130.0012px;
          }
          &.page_tips_2 {
            position: absolute;
            width: 215px;
            left: calc(20% + 92px);
            top: 212px;
          }
          &.page_tips_3 {
            position: absolute;
            width: 265px;
            left: calc(20% + 30px);
            top: 264px;
          }
        }
      }
    }
    .bottom {
      flex: 1;
      width: 375px;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      .bottomBtn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: absolute;
        .bottom-tips {
          margin-top: 10px;
          font-size: 12px;
          color: #999999;
        }
      }
    }
    .no_camera_dialog {
      position: fixed;
      left: 0;
      top: 0;
      width: 100vw;
      height: calc(var(--vh, 1vh) * 100);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 99;
      &_mask {
        position: absolute;
        left: 0;
        top: 0;
        width: 100vw;
        height: calc(var(--vh, 1vh) * 100);
        background: rgba(0, 0, 0, 0.5);
        z-index: 0;
      }
      &_content {
        width: 296.5px;
        min-height: 248px;
        background: #ffffff;
        border-radius: 8px;
        z-index: 1;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        box-sizing: border-box;
        padding: 22px 0 32px 0;
      }
      &_title {
        font-size: 23px;
        line-height: 1.2;
        font-family: Source Han Sans SC;
        font-weight: 500;
        color: #000000;
        width: 228px;
        text-align: center;
        margin-bottom: 26px;
      }
      &_text_content {
        width: 250px;
        text-align: left;
        font-size: 20px;
        font-family: Source Han Sans SC;
        font-weight: 400;
        color: #010101;
        line-height: 33px;
        margin-bottom: 41.5px;
      }
      &_button {
        width: 215.5px;
        height: 34.5px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        &_bg {
          width: 100%;
          height: 100%;
          position: absolute;
          left: 0;
          top: 0;
        }
        &_text {
          font-size: 16.5px;
          font-family: Source Han Sans SC;
          font-weight: 500;
          color: #ffffff;
          z-index: 1;
        }
      }
    }
  }
}
.mobile {
  .main_content {
    width: 10rem;
    height: calc(var(--vh, 1vh) * 100);
    background: #ffffff;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;

    .global_box {
      width: 0.8267rem;
      position: absolute;
      right: 0.24rem;
      top: 0.1333rem;
      z-index: 10;
      .global_img {
        width: 100%;
      }

      .popup-box {
        width: 1.8667rem;
        height: 2rem;
        position: absolute;
        right: -0.12rem;
        top: 0.96rem;
        padding-top: 0.16rem;
        box-sizing: border-box;
        overflow: hidden;
        border-radius: 0.16rem;
        .popup_bg {
          position: absolute;
          left: 0;
          top: 0;
          width: 1.8667rem;
        }
        .poup-item {
          position: relative;
          height: 0.6rem;
          font-size: 0.2667rem;
          font-family: Source Han Sans SC;
          font-weight: 500;
          color: #303030;
          line-height: 0.6rem;
          display: flex;
          align-items: center;
          justify-content: start;
          cursor: pointer;
          img {
            width: 0.1867rem;
            margin-left: 0.2533rem;
            margin-right: 0.1467rem;
          }
          div {
            width: 0.1867rem;
            margin-left: 0.2533rem;
            margin-right: 0.1467rem;
          }
          &.active {
            color: #f68682;
          }
        }
      }
    }
    .top {
      position: relative;
      width: 100%;
      background: url("../assets/images/gesture/introduceBg.png") no-repeat top
        center;
      overflow: hidden;
      flex: 1;
      .page_bg {
        width: 100%;
        position: absolute;
        left: 0;
        top: 0;
      }

      .page_title {
        font-size: 0.28rem;
        font-family: Source Han Sans SC;
        font-weight: bold;
        color: #f68682;
        line-height: 0.8rem;
        // -webkit-text-stroke: 0.0267rem #fff9fb;
        // text-stroke: 0.0267rem #fff9fb;
        width: 100%;
        position: absolute;
        left: 0;
        top: 1.5467rem;
        z-index: 2;
      }
      .picture-box {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        .page_bg2 {
          width: 100%;
          position: absolute;
          left: 0;
          top: 1.3333rem;
        }

        .page_tips {
          font-size: 0.2933rem;
          color: #7d7c7a;
          text-align: left;
          font-weight: bold;
          white-space: pre-line;
          &.page_tips_1 {
            position: absolute;
            top: 4.4rem;
            left: 1.3333rem;
            width: 3.4667rem;
          }
          &.page_tips_2 {
            position: absolute;
            width: 5.7333rem;
            left: 4.1333rem;
            top: 9.4933rem;
          }
          &.page_tips_3 {
            position: absolute;
            width: 7.0667rem;
            left: 1.4667rem;
            top: 11.8667rem;
          }
        }
      }
      &.small {
        .page_bg2 {
          width: 80%;
          position: absolute;
          left: 10%;
          top: 0.8rem;
        }
        .page_tips {
          font-size: 0.2667rem;
          &.page_tips_1 {
            position: absolute;
            top: 3.3067rem;
            left: calc(10% + 1.0667rem);
            width: 3.4667rem;
          }
          &.page_tips_2 {
            position: absolute;
            width: 5.7333rem;
            left: calc(10% + 3.2rem);
            top: 7.36rem;
          }
          &.page_tips_3 {
            position: absolute;
            width: 7.0667rem;
            left: calc(10% + 1.0667rem);
            top: 9.28rem;
          }
        }
      }
    }
    .bottom {
      flex: 1;
      width: 10rem;
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      min-height: 3rem;
      max-height: 3.4rem;
      .bottomBtn {
        display: flex;
        justify-content: center;
        align-items: center;
        .bottom-tips {
          margin-top: 0.2667rem;
          font-size: 0.32rem;
          color: #999999;
        }
      }
    }
    .no_camera_dialog {
      position: fixed;
      left: 0;
      top: 0;
      width: 100vw;
      height: calc(var(--vh, 1vh) * 100);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 99;
      &_mask {
        position: absolute;
        left: 0;
        top: 0;
        width: 100vw;
        height: calc(var(--vh, 1vh) * 100);
        background: rgba(0, 0, 0, 0.5);
        z-index: 0;
      }
      &_content {
        width: 7.9067rem;
        min-height: 6.6133rem;
        background: #ffffff;
        border-radius: 0.2133rem;
        z-index: 1;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        box-sizing: border-box;
        padding: 0.5867rem 0 0.8533rem 0;
      }
      &_title {
        font-size: 0.6133rem;
        line-height: 1.2;
        font-family: Source Han Sans SC;
        font-weight: 500;
        color: #000000;
        width: 6.08rem;
        text-align: center;
        margin-bottom: 0.6933rem;
      }
      &_text_content {
        width: 6.6667rem;
        text-align: left;
        font-size: 0.5333rem;
        font-family: Source Han Sans SC;
        font-weight: 400;
        color: #010101;
        line-height: 0.88rem;
        margin-bottom: 1.1067rem;
      }
      &_button {
        width: 5.7467rem;
        height: 0.92rem;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        &_bg {
          width: 100%;
          height: 100%;
          position: absolute;
          left: 0;
          top: 0;
        }
        &_text {
          font-size: 0.44rem;
          font-family: Source Han Sans SC;
          font-weight: 500;
          color: #ffffff;
          z-index: 1;
        }
      }
    }

    &.big {
      .top {
        flex: none;
      }
      .bottom {
        max-height: none;
      }
    }
  }
}
</style>