<template>
  <iframe ref="iframe" width="100%" height="100%" :src="src" />
</template>
<script>
export default {
  data() {
    return {
      activeName: '',
      bustype: '',
      src: '',
      url: ''
    }
  },
  created() {
    if (Object.keys(this.$route.query)) {
      this.activeName = this.$route.query.activeName || ''
      this.bustype = this.$route.query.bustype || ''
    }
    if (!this.$route.query.activeName && !this.$route.query.bustype) {
      this.url = '/aiccs/#/todo/list'
    } else {
      if (this.$route.query.activeName === 'fraudCheck') {
        this.url = '/aiccs/#/cancel/fraudCheckList'
      } else {
        this.url = '/aiccs/#/todo/list' + '?activeName=' + this.activeName + '&bustype=' + this.bustype + '&activeNamet=' + (this.$route.query.activeNamet || '')
      }
    }
    this.src = this.url
  },
  mounted() {
    window.addEventListener('message', this.iframeMessage, false)
  },
  destroyed() {
    window.removeEventListener('message', this.iframeMessage, false)
  },
  methods: {
    iframeMessage(event) {
      const { data } = event
      if (typeof data === 'string' && !data.startsWith('webpack')) {
        // 这里获取data参数，就是子系统给过来的参数，你就可以进行判断跳转做操作了
        this.src = data
        console.log('子系统传来的' + data)
      }
    }
  }
}
</script>
