<template>
  <div class="panocon">
    <div id="pano"></div>
  </div>
</template>

<script>
import * as krfn from "@/core/index.js";
import { getSceneInfo } from "@/api";
import config from "@/config";


let __krfn = krfn.default;
window.__krfn = __krfn

window.screenshot = function () {
  let canvas = $("#krpanoSWFObject canvas")[0];
  

  let krpano = document.getElementById('krpanoSWFObject');
  let data = __krfn.utils.setInitView(krpano, canvas);
  return data
}

export default {
  data(){
    return {
      activeItem:'',
      someData:'',
    }
  },
  methods:{
    onFullScreen() {
        let element = document.documentElement;
        if (this.isFullscreen) {
            if (document.exitFullscreen) {
                document.exitFullscreen();
            } else if (document.webkitCancelFullScreen) {
                document.webkitCancelFullScreen();
            } else if (document.mozCancelFullScreen) {
                document.mozCancelFullScreen();
            } else if (document.msExitFullscreen) {
                document.msExitFullscreen();
            }
        } else {
            if (element.requestFullscreen) {
                element.requestFullscreen();
            } else if (element.webkitRequestFullScreen) {
                element.webkitRequestFullScreen();
            } else if (element.mozRequestFullScreen) {
                element.mozRequestFullScreen();
            } else if (element.msRequestFullscreen) {
                element.msRequestFullscreen();
            }
        }
          // 改变当前全屏状态
        // this.isFullscreen = !this.isFullscreen;
      },
    onclick(){
      let canvas = $("#krpanoSWFObject canvas")[0];
      let krpano = document.getElementById('krpanoSWFObject');
      __krfn.utils.setInitView(krpano, canvas);
    },
    getSceneInfo(){
      getSceneInfo({},data=>{
        this.activeItem = data.data
      })
    }
  },
 
  mounted(){
    window.addEventListener('message',data=>{
      if (data.data.event=="onfull") {
        this.onFullScreen()
      }
      // this.onFullScreen()

    })
 
    // this.getSceneInfo()
        $('#pano').empty();
        removepano('#pano')
            embedpano({
              // xml: "%HTMLPATH%/static/template/tour.xml",
              xml: `${this.$cdn}/720yun_fd_manage/${config.sceneNum}/vtour/tour.xml`,
              swf: "%HTMLPATH%/static/template/tour.swf",
              target: "pano",
              html5: "auto",
              mobilescale: 0.7,
              webglsettings: { preserveDrawingBuffer: true },
              passQueryParameters: true,
            });

  }
}
</script>

<style lang="less" scoped>
.panocon{
  width: 100%;
  height: 100%;
  #pano{
    width: 100%;
    height: 100%;
  }
}
</style>
