市北互联平台前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.9 KiB

4 years ago
<template>
<main :class="['aui-content']">
<!-- 其他方式, 展示内容 -->
<template>
<keep-alive>
<router-view />
</keep-alive>
</template>
</main>
</template>
<script>
import { isURL } from '@/utils/validate'
import Cookie from 'js-cookie'
export default {
data () {
return {
iframeUrl: '',
token: '',
customerId: ''
}
},
created () {
// this.$nextTick(() => {
// this.sendMessage()
// })
this.token = Cookie.get('token')
this.customerId = localStorage.getItem('customerId')
},
methods: {
changeCustomerName (customerName) {
this.$emit('changeCustomerName', customerName)
},
// tabs, 是否通过iframe展示
tabIsIframe (url) {
// this.appendIframe(url)
this.iframeUrl = url + '?token=' + Cookie.get('token') + '&customerId=' + localStorage.getItem('customerId')
return isURL(url)
},
// tabs, 选中tab
tabSelectedHandle (tab) {
tab = this.$store.state.contentTabs.filter(item => item.name === tab.name)[0]
if (tab) {
this.$router.push({
'name': tab.name,
'params': { ...tab.params },
'query': { ...tab.query }
})
}
},
// tabs, 删除tab
tabRemoveHandle (tabName) {
if (tabName === 'home') {
return false
}
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName)
if (this.$store.state.contentTabs.length <= 0) {
this.$store.state.sidebarMenuActiveName = this.$store.state.contentTabsActiveName = 'home'
return false
}
// 当前选中tab被删除
if (tabName === this.$store.state.contentTabsActiveName) {
let tab = this.$store.state.contentTabs[this.$store.state.contentTabs.length - 1]
this.$router.push({
name: tab.name,
params: { ...tab.params },
query: { ...tab.query }
})
}
},
// tabs, 关闭其它
tabsCloseOtherHandle () {
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => {
return item.name === 'home' || item.name === this.$store.state.contentTabsActiveName
})
},
// tabs, 关闭全部
tabsCloseAllHandle () {
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => item.name === 'home')
this.$router.push({ name: 'home' })
},
sendMessage () {
// const iframe = this.$refs.iframes.contentWindow
const iframe = document.getElementsByClassName('iframes')[0].contentWindow
console.log('iframe', iframe)
// iframe.postMessage({
// token: Cookie.get('token'),
// customerId: localStorage.getItem('customerId')
// }, '*')
iframe.postMessage({ name: 'lalalal' }, '*')
},
}
}
</script>
4 years ago
<style lang="scss" src="@/assets/scss/main-shuju.scss" scoped></style>