<template>
  <div class="page" :class="{'mobile':_isMobile,'pc':!_isMobile}">
    <div class="main_content" :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="info" :style="{'marginTop':cT,'marginLeft':cL, 'marginRight':cL, 'marginBottom':cT}">
          <div class="title" :style="{'margin-bottom':cTb}">{{$t('strings.homeText4')}}</div>
        </div>
        <div class="bottomBtn">
          <light-button @click="clickAuthCamera" :text="$t('strings.homeButtonText')"></light-button>
          <div class="bottom-tips">{{$t('strings.completeText2')}}</div>
        </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";

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秒后开始识别",
          slogan: "疼痛少一分，自在喂养多一分"
        },
        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.请放松肩膀，用垫子或枕头支撑抱宝宝的手，腰部和脚。",
          suggestText5: "5.全程请保持放松，愉悦的状态，直到宝宝主动吐出乳头。",
          suggestConfirmText: "知道了",
          suggestText6:
            "1.在哺乳过程中，请时刻避免乳房闷到宝宝，不要挤压胸部释放空间，应使宝宝臀部紧贴妈妈腹部，自然留有空隙。",
          suggestText7:
            "2.妈妈可在头部下方垫上垫子用以支撑，但位置不宜过高。在背部放上靠垫支撑腰部，保持腿部放松，自然屈曲，也可在两膝关节间放置垫子缓解压力。",
          discardReasonTitle: "放弃的原因是...",
          discardReason1: "不知道怎么用",
          discardReason2: "担心我的个人隐私",
          discardReason3: "觉得没有用处",
          literature:
            "[1]Fernandez L, Cardenas N, Arroyo R, et al. Prevention of infectious mastitis by oral administration of Lactobacillus salivarius PS2 during late pregnancy [J]. Clinical Infectious Diseases, 2016, 62 (5): 568-73.",
          mainTipsText:
            "请在安全环境安全设备使用本功能。在使用过程中，我们不会存储您的图像。",
          guidance: "指导",
          recordText: '正在进行哺乳计时，当喂养结束后请点击"结束哺乳"按钮',
          noCameraText1: "您已关闭摄像头",
          noCameraText2: "哺乳计时将会继续",
          noCameraEndText: "结束哺乳",
          briefSummaryTitleFront: "恭喜您在",
          briefSummaryTitleAfter: "秒内完成了本次姿势矫正",
          briefSummaryText1: "您在AI的帮助下掌握了",
          briefSummaryText2: "摇篮式姿势要点",
          sitMainPointsText1: "婴儿头高臀低，妈妈能看到婴儿的表情",
          sitMainPointsText2: "妈妈和婴儿应该腹胸相贴",
          sitMainPointsText3: "婴儿的头枕于妈妈手肘处，不要用手固定婴儿头部",
          sitMainPointsText4: "婴儿的耳、肩、臀成一条直线",
          sitMainPointsConfirmText: "好 的",
          momLeft: "当未检测到您,将自动停止计时后续流程,停留5s后跳转至结束页面"
        }
      };
      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:
            "When actually breastfeeding, please pay attention to supporting the baby's neck with elbow joint",
          nobabysittingBabystright:
            "When actually breastfeeding, please keep your baby's ears, shoulders and hips in a straight line",

          /// 坐姿建议
          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: "Less pain, more free feeding"
        },
        sittingMsg: {
          babyneckloc: "Please support your baby's neck with your elbow",
          babyhead: "Do not hold the baby's head with your palm",
          babybackloc: "Please put your forearm along your baby's back",
          upleft: "Please raise your left arm",
          upright: "Please raise your right arm",
          downleft: "Please lower your left arm",
          downright: "Please lower your right arm",
          headupassdown: "Keep your baby's head above your hips",
          babystright:
            "Please keep your baby's ears, shoulders and hips in the same line",
          babyheadloc:
            "Please make sure the baby's head is facing the mother's breast and should not be too high"
        },
        sittingMsgPart: {
          babyneckloc: "Please support your baby's neck with your elbow",
          babyhead: "Do not hold the baby's head with your palm",
          babybackloc: "Please put your forearm along your baby's back",
          headupassdown: "Keep your baby's head above your hips",
          babystright:
            "Please keep your baby's ears, shoulders and hips in the same line",
          babyheadloc:
            "Please make sure the baby's head is facing the mother's breast and should not be too high"
        },
        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: "It can be maintained at the beginning of lactation:",
          suggestText1:
            "1During breast-feeding, both mother and baby should be in a comfortable position to ensure that they are always close to the chest and abdomen of the baby.",
          suggestText2:
            "2.Please let the baby's mouth wrap around the areola as much as possible, keep the chin close to the breast, and open the mouth at an angle greater than 100 degrees.",
          suggestText3:
            "3.If you feel nipple pain, please click the upper right corner to know / explain the adjustment in detail.",
          suggestText4:
            "4.Please relax your shoulders and support your baby's hands, waist and feet with cushions or pillows.",
          suggestText5:
            "5.Please stay relaxed and happy until the baby spits out his nipples.",
          suggestConfirmText: "got it",
          suggestText6:
            "1.During lactation, please always avoid breast tightness to the baby, do not squeeze the chest to release space, and make the baby's hips close to the mother's abdomen, leaving a gap naturally.",
          suggestText7:
            "2.Mother can put a cushion under her head for support, but the position should not be too high. Put a cushion on your back to support your waist, keep your legs relaxed and flex naturally, or place a cushion between your knees to relieve pressure.",
          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",
          literature:
            "[1]Fernandez L, Cardenas N, Arroyo R, et al. Prevention of infectious mastitis by oral administration of Lactobacillus salivarius PS2 during late pregnancy [J]. Clinical Infectious Diseases, 2016, 62 (5): 568-73.",
          mainTipsText:
            "Please use this function in a safe environment and safe equipment. We will not store your images during use.",
          guidance: "guide",
          recordText:
            'Lactation timing is in progress. Please click the "end lactation" button after feeding',
          noCameraText1: "You have turned off the camera",
          noCameraText2: "Lactation timing will continue",
          noCameraEndText: "End lactation",
          briefSummaryTitleFront:
            "Congratulations! You have completed the session in ",
          briefSummaryTitleAfter: " seconds",
          briefSummaryText1: "You have learned the",
          briefSummaryText2: "key points of cradle hold breastfeeding",
          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:
            "When you are not detected, the follow-up process of timing will be automatically stopped, and after 5S, jump to the end page"
        }
      };
      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:
            "Vous pouvez commencer à allaiter maintenant ! La minuterie démarre dans 3 secondes…",
          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…",
          slogan: "Moins de douleur, plus de liberté d'alimentation"
        },
        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:
            "Au début de l’allaitement, il est possible de maintenir:",
          suggestText1:
            "1.Pendant l'allaitement, assurez - vous d'utiliser une position confortable pour la mère et le bébé, en veillant à ce qu'il soit toujours attaché à la poitrine et à l'abdomen du bébé.",
          suggestText2:
            "2.S'il vous plaît laissez la bouche du bébé couvrir l'aréole autant que possible, le menton près du sein, l'angle d'ouverture de la bouche est supérieur à 100 degrés.",
          suggestText3:
            "3.Si vous ressentez une douleur au mamelon, cliquez sur le coin supérieur droit pour connaître / détailler le réglage.",
          suggestText4:
            "4.Détendez vos épaules et utilisez un coussin ou un oreiller pour soutenir vos mains, votre taille et vos pieds.",
          suggestText5:
            "5.Restez détendu et heureux jusqu'à ce que le bébé vomisse ses mamelons.",
          suggestConfirmText: "J'ai compris.",
          suggestText6:
            "1.Dans le processus d'allaitement, s'il vous plaît toujours éviter l'oppression mammaire au bébé, ne pas presser la poitrine pour libérer de l'espace, devrait faire les fesses du bébé près de l'abdomen de la mère, laisser l'espace naturel.",
          suggestText7:
            "2.Maman peut mettre un coussin sous la tête pour soutenir, mais pas trop haut. Placez des coussins sur le dos pour soutenir la taille, garder les jambes détendues et fléchies naturellement, ou placez des coussins entre les genoux pour soulager la pression.",
          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",
          literature:
            "[1]Fernandez L, Cardenas N, Arroyo R, et al. Prevention of infectious mastitis by oral administration of Lactobacillus salivarius PS2 during late pregnancy [J]. Clinical Infectious Diseases, 2016, 62 (5): 568-73.",
          mainTipsText:
            "Veuillez utiliser cette fonction dans l'équipement de sécurité de l'environnement de sécurité.Vos images et vidéos ne seront utilisées que pour la reconnaissance des coachs IA. Elles ne seront pas stockés.",
          guidance: "Orientation",
          recordText:
            "'Le timing de l'allaitement est en cours. Cliquez sur le bouton « terminer l'allaitement » lorsque l'allaitement est terminé.'",
          noCameraText1: "Vous avez éteint la caméra",
          noCameraText2: "Le temps d'allaitement se poursuivra",
          noCameraEndText: "Mettre fin à l'allaitement",
          briefSummaryTitleFront: "Toutes nos félicitations!",
          briefSummaryTitleAfter: " Vous avez terminé la session !",
          briefSummaryText1: "Vous l'avez maîtrisé avec l'aide de l'IA",
          briefSummaryText2: "Points clés de la posture du berceau",
          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 le cou de bébé sur votre coude et ne limitez pas la tête de bébé avec votre main",
          sitMainPointsConfirmText: "OK",
          momLeft:
            "Si vous n'êtes pas détecté, le processus de suivi du timing s'arrêtera automatiquement et passera à la page de fin après 5S."
        }
      };
      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:
            "¡Puede comenzar a darle el pecho ahora! El temporizador comienza en 3 segundos...",
          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...",
          slogan: "Un punto menos de dolor, un punto más de alimentación libre"
        },
        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: "Al comienzo de la lactancia se puede mantener:",
          suggestText1:
            "1.Durante la lactancia, la madre y el bebé deben adoptar una postura cómoda para asegurarse de que siempre se adhieren al pecho y el abdomen del bebé.",
          suggestText2:
            "2.Por favor, deje que la boca del bebé envuelva la areola en la medida de lo posible, la barbilla se aferra al pecho, el ángulo de la boca abierta es superior a 100 grados.",
          suggestText3:
            "3.Si siente dolor en el pezón, por favor haga clic en la esquina superior derecha para saber / explicar el ajuste de la imagen.",
          suggestText4:
            "4.Por favor, afloje los hombros y sostenga las manos, la cintura y los pies del bebé con almohadillas o almohadas.",
          suggestText5:
            "5.Por favor, manténgase relajado y alegre hasta que el bebé vomite sus pezones.",
          suggestConfirmText: "Lo tengo.",
          suggestText6:
            "1.En el proceso de lactancia, por favor, evite siempre la opresión de los pechos al bebé, no apriete el pecho para liberar el espacio, debe hacer que las caderas del bebé se aferren al abdomen de la madre, la naturaleza deja espacio.",
          suggestText7:
            "2.Mamá puede estar debajo de la almohadilla de la cabeza para apoyar, pero la posición no debe ser demasiado alta. Coloque almohadillas en la espalda para apoyar la cintura, mantenga las piernas relajadas, flexiones naturales, o coloque almohadillas entre las rodillas para aliviar la presión.",
          discardReasonTitle: "Razones para rendirse...",
          discardReason1: "No estoy segura de cómo usarlo",
          discardReason2: "Preocupación por mi privacidad",
          discardReason3: "No creo que sea útil",
          literature:
            "[1]Fernandez L, Cardenas N, Arroyo R, et al. Prevention of infectious mastitis by oral administration of Lactobacillus salivarius PS2 during late pregnancy [J]. Clinical Infectious Diseases, 2016, 62 (5): 568-73.",
          mainTipsText:
            "Por favor, utilice esta función en un dispositivo seguro.Sus imágenes y videos solo se utilizarán para el reconocimiento del asistente de IA. No se almacenarán.",
          guidance: "Guía",
          recordText:
            'El tiempo de lactancia está en curso, por favor haga clic en el botón "terminar la lactancia" después de la alimentación.',
          noCameraText1: "Has apagado la Cámara",
          noCameraText2: "El tiempo de lactancia continuará",
          noCameraEndText: "Fin de la lactancia",
          briefSummaryTitleFront: "¡Felicidades! Has completado la sesión en ",
          briefSummaryTitleAfter: " segundos",
          briefSummaryText1: "Lo tienes con la ayuda de AI.",
          briefSummaryText2: "Postura de cuna",
          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:
            "Cuando no se detecta, el proceso de seguimiento de la sincronización se detiene automáticamente, se detiene durante 5 segundos y se salta a la página final"
        }
      };
      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(camera);
      if (camera) {
        let openDev = this.$route.query.openDev;
        localStorage.setItem(
          "backUrl",
          "https://bfai-service-uat.d-lab-services.danone.com/demo/#/complete"
        );
        localStorage.setItem("enterUrl", document.URL);
        let url =
          "https://bfai-service-uat.d-lab-services.danone.com/sdk/#/?camera=1&lying=0";
        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() {
    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: 31px;
      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: 26.5px;
        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;
          font-weight: bold;
          white-space: pre-line;
          &.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;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      position: relative;
      .info {
        align-self: flex-start;
        color: #999;
        font-size: 14.8px;
        .title {
          color: #fb7c76;
          font-size: 16px;
          line-height: 1.2;
          font-weight: bold;
        }
        .item {
          min-height: 22.25px;
          line-height: 22.3px;
        }
      }
      .bottomBtn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: absolute;
        bottom: 15px;
        left: 50%;
        transform: translateX(-50%);
        .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.8267rem;
      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.7067rem;
        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;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      position: relative;
      min-height: 3.8rem;
      max-height: 4.2rem;
      .info {
        align-self: flex-start;
        color: #999;
        font-size: 0.3947rem;
        .title {
          color: #fb7c76;
          font-size: 0.4267rem;
          line-height: 1.2;
          font-weight: bold;
        }
        .item {
          min-height: 0.5933rem;
          line-height: 0.5947rem;
        }
      }
      .bottomBtn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: absolute;
        bottom: 0.4rem;
        left: 50%;
        transform: translateX(-50%);
        .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>