<template>
  <div class="page-body">
    <iframe ref="mainIframe" :src="url" class="coffee" frameborder="0"></iframe>
  </div>
</template>
<script>
  export default {
    meta: {
      title: "商品管理"
    },
    data() {
      return {
        // url: `http://127.0.0.1:8080/#/coffeeManage/order`
        url:'http://mall.oytour.com/#/coffeeManage/order'
      }
    },
    created(){
       if(this.$route.query.id){
        this.url=`http://mall.oytour.com/#/coffeeManage/order?orderId=`+this.$route.query.id
      }
    },
    mounted() {
      let userinfo = JSON.parse(localStorage.getItem('loginUserInfo')).data
      let obj={
          token:userinfo.MallToken,
          Id:userinfo.Id,
          GroupId:userinfo.Group_Id,
          TenantId:userinfo.JHTenantId,  
      }
      let jsonData=JSON.stringify(obj)
      const mapFrame = this.$refs.mainIframe
      if (mapFrame.attachEvent) { // 兼容浏览器判断
        mapFrame.attachEvent('onload', function () {
          const iframeWin = mapFrame.contentWindow
          iframeWin.postMessage(jsonData, '*')
        })
      } else {
        mapFrame.onload = function () {
          const iframeWin = mapFrame.contentWindow
          iframeWin.postMessage(jsonData, '*')
        }
      }
    }
  }

</script>
<style>
  .coffee {
    width: 100%;
    height: calc(100vh - 120px);
  }
</style>
