41 lines
1.1 KiB
Vue
41 lines
1.1 KiB
Vue
<template>
|
|
<iframe ref="rentFrame" :src="iframeSrc" style="width: 100%; height: 100vh; border: none"></iframe>
|
|
</template>
|
|
|
|
<script>
|
|
import { getToken } from '@/utils/auth'
|
|
|
|
export default {
|
|
name: 'RentManage',
|
|
data() {
|
|
return {
|
|
iframeSrc: '',
|
|
}
|
|
},
|
|
mounted() {
|
|
console.log('🚀 ~ mounted:', window.location)
|
|
this.iframeSrc =
|
|
process.env.NODE_ENV === 'production'
|
|
? 'http://36.33.26.201:21999/iws/mall-view/home?redirect=rent-manage'
|
|
: 'http://localhost:8102/iws/mall-view/home?redirect=rent-manage'
|
|
console.log('🚀 ~ this.iframeSrc:', this.iframeSrc)
|
|
|
|
// 等 iframe 加载完成再传 token
|
|
this.$refs.rentFrame.onload = () => {
|
|
const token = getToken() // 从 Cookie 中获取正确的 token
|
|
console.log('A项目token:' + token)
|
|
if (token) {
|
|
// 使用 postMessage 发送给 B
|
|
this.$refs.rentFrame.contentWindow.postMessage(
|
|
{
|
|
type: 'SET_TOKEN',
|
|
token: token,
|
|
},
|
|
window.location.origin
|
|
)
|
|
}
|
|
}
|
|
},
|
|
}
|
|
</script>
|