bonus-ui/src/views/iframe/rentManage.vue

41 lines
1.1 KiB
Vue
Raw Normal View History

2025-11-18 14:09:29 +08:00
<template>
<iframe ref="rentFrame" :src="iframeSrc" style="width: 100%; height: 100vh; border: none"></iframe>
2025-11-18 14:09:29 +08:00
</template>
<script>
import { getToken } from '@/utils/auth'
2025-11-18 14:09:29 +08:00
export default {
name: 'RentManage',
data() {
return {
iframeSrc: '',
}
},
mounted() {
console.log('🚀 ~ mounted:', window.location)
this.iframeSrc =
process.env.NODE_ENV === 'production'
2025-11-25 11:17:46 +08:00
? 'http://36.33.26.201:21999/iws/mall-view/home?redirect=rent-manage'
2025-11-18 14:09:29 +08:00
: '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
)
}
}
2025-11-18 14:09:29 +08:00
},
}
</script>