<template>
  <div v-sd-watermark="waterMark" class="search">
    <div id="temp" class="search"> </div>
  </div>
</template>

<script>
import systemManage from '@/system-manage/system-manage'

export default {
  name: 'SuperSearch',
  metaInfo: {
    title: '超级审搜',
  },
  data() {
    return { iframe: null, waterMark: systemManage.getFormWaterMark() }
  },
  mounted() {
    this.postIframe()
  },
  methods: {
    postIframe() {
      const iframe = document.createElement('iframe')
      const bodyDom = document.getElementById('temp')
      iframe.id = 'iframe'
      iframe.classList.add('iframe')
      iframe.src = 'http://10.104.32.31:9999/#/'
      // iframe.src = 'http://127.0.0.1:8888/#/'
      // <!-- todo生产地址 10.104.1.174 -->
      // iframe.src = 'http://10.104.1.174/#/'

      this.iframe = iframe
      bodyDom.insertBefore(iframe, bodyDom.lastChild)
      const token = this.$store.state.sd.login.tokens.access_token
      iframe.onload = function() {
        iframe.contentWindow.postMessage(JSON.stringify(token), 'http://10.104.32.31:9999/')
        // iframe.contentWindow.postMessage(JSON.stringify(token), 'http://127.0.0.1:8888')
        // <!-- todo生产地址 10.104.1.174 -->
        // iframe.contentWindow.postMessage(JSON.stringify(token), 'http://10.104.1.174/')
      }
    },
  },
}
</script>

<style lang="scss">
.search {
  width: 100%;
  height: 100%;
  #iframe {
    width: 100%;
    height: 100%;
  }
}
</style>
