<template>
  <div class="ifrcon">
    <Header :params="params" :title="'111'" />
    <iframe allowfullscreen="true" ref="iframe" id="showifr" :src="url" frameborder="0" @load="onIframLoad"></iframe>
  </div>
</template>

<script>
import Header from "./ui/Show.Header";

export default {
  props:['url'],
  components:{Header},
  data(){
    return {
      params:''
    }
  },
  methods:{
    onIframLoad(){
      window.onmessage = e =>{
        if (e.data.source != "4dage") {
            return
        }

        if (e.data.event == "guide-rooms") {
          this.$bus.emit('guideRoomsData',e.data.params)
        }

        // if (e.data.event == "guide-status") {
        // }

        if (e.data.event == "action") {
          this.$bus.emit('currentMode',e.data.params)
        }

        if (e.data.event == "loaded") {
          this.params = e.data.params
          this.$refs.iframe.contentWindow.postMessage({
              source: "mingyuan",
              event: 'guide-rooms'
          },"*")
        }

      }
    }
  }
}
</script>

<style lang="less" scoped>
.ifrcon{
  width: 100%;
  height: 100%;
  >iframe{
    width: 100%;
    height: 100%;
  }
}
</style>