<template>
            <div v-if='isShow' class="map_right"> 
              <iframe :src="src" ref="iframe"></iframe>
            </div>
</template>

<script>
import { mapState, mapGetters, mapActions } from 'vuex'

    export default {
        data() {
            return {
                code:'',
                src: window.CONFIG.bimPath,
                
            }
        },
        computed: {
            ...mapState('d2admin/bjCode', ['resourceCode']),
            ...mapState('d2admin/bim', ['isShow'])
        },
        watch: {
            resourceCode(val) {
            console.log('resourceCode:', val)
            if (this.transformationSta == 2) {
                this.sendBjMessage(val.substring(0, val.indexOf('+')))
            }
            }
  },
        mounted() {
            this.code = this.resourceCode
            console.log(this.isShow,'111111111111')

        //   this.sendMessage()
        },
        methods: {
                sendMessage(code) {
                    console.log(111)
                    setTimeout(() => {
                        if (!this.$refs.iframe) {
                        return
                        }
                        this.$refs.iframe.contentWindow.postMessage(
                        {
                            func: 'locateByCode',
                            data: {
                                code: code
                            }
                        },
                        this.src
                        )
                    }, 1000)
                    },
                    sendBjMessage(code) {
                        console.log('********' + code)
                        setTimeout(() => {
                            if (!this.$refs.iframe) {
                            return
                            }
                            this.$refs.iframe.contentWindow.postMessage({
                            func: 'alarm',
                            data: {
                                code: code
                                }
                            }, this.src)
                        }, 1000)
                    },
        },  
    }
</script>

<style lang="scss" scoped>

    iframe {
      width: 1580px;
      height: 770px;
      position:absolute;
      top:50px;
      right:0;
      z-index:99;
    }
</style>