Commit 1766b46d authored by yht15023815643's avatar yht15023815643

跳转插件详情

parent b50b5bba
...@@ -25,7 +25,7 @@ service.interceptors.request.use(config => { ...@@ -25,7 +25,7 @@ service.interceptors.request.use(config => {
// 是否需要设置 token // 是否需要设置 token
const isToken = (config.headers || {}).isToken === false const isToken = (config.headers || {}).isToken === false
// 是否需要防止数据重复提交 // 是否需要防止数据重复提交
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false||config.url.indexOf('getUipIdByCid')!=-1 const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
if (getToken() && !isToken) { if (getToken() && !isToken) {
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
config.headers['tenantid'] = getTenantid() //携带租户id config.headers['tenantid'] = getTenantid() //携带租户id
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
<script> <script>
import { steerScroll } from '@/assets/js/jskplug'; import { steerScroll } from '@/assets/js/jskplug';
import { dskAccessToken } from '@/api/common'; import { dskAccessToken } from '@/api/common';
import {encodeStr} from "@/assets/js/common.js"
import { getUipIdByCid } from '@/api/macro/macro'
export default { export default {
name: 'Enterprise', name: 'Enterprise',
components: { components: {
...@@ -16,6 +17,7 @@ export default { ...@@ -16,6 +17,7 @@ export default {
}, },
data() { data() {
return { return {
encodeStr,
loading: false, // 是否加载完成-当前页控制 loading: false, // 是否加载完成-当前页控制
iframeTimer: '', // 是否加载中定时器-当前页控制 iframeTimer: '', // 是否加载中定时器-当前页控制
footHeight: 0, //底部高度,若为0(页面内部嵌套或者没有底部板块) footHeight: 0, //底部高度,若为0(页面内部嵌套或者没有底部板块)
...@@ -41,22 +43,39 @@ export default { ...@@ -41,22 +43,39 @@ export default {
}, },
mounted() { mounted() {
this.iframeLoading(); // 判断iframe页面是否加载完成-当前页控制 this.iframeLoading(); // 判断iframe页面是否加载完成-当前页控制
let that = this window.addEventListener('message', this.linkListener, false);
window.addEventListener('message', function (event) {
if(!event.data.id && event.data.url){
that.$tab.openPage(event.data.title, event.data.url).then(() => {
// 执行结束的逻辑
})
}
}, false);
steerScroll('companyIframe', this.navigation, this.footHeight, true); // iframeId: iframe的id;navigation:页面排除iframe后剩下的顶部高度;footHeight: 页面排除iframe后剩下的底部高度;state:监听or移除监听;parentId: 父级id[不带默认就是铺满整个页面]];_this:指向当前实例(可忽略) steerScroll('companyIframe', this.navigation, this.footHeight, true); // iframeId: iframe的id;navigation:页面排除iframe后剩下的顶部高度;footHeight: 页面排除iframe后剩下的底部高度;state:监听or移除监听;parentId: 父级id[不带默认就是铺满整个页面]];_this:指向当前实例(可忽略)
}, },
beforeDestroy() { beforeDestroy() {
clearInterval(this.iframeTimer); // -当前页控制 clearInterval(this.iframeTimer); // -当前页控制
window.removeEventListener("message", this.linkListener);
steerScroll('companyIframe', this.navigation, this.footHeight); // iframeId: iframe的id;navigation:页面排除iframe后剩下的顶部高度;footHeight: 页面排除iframe后剩下的底部高度;state:监听or移除监听;parentId: 父级id[不带默认就是铺满整个页面]];_this:指向当前实例(可忽略) steerScroll('companyIframe', this.navigation, this.footHeight); // iframeId: iframe的id;navigation:页面排除iframe后剩下的顶部高度;footHeight: 页面排除iframe后剩下的底部高度;state:监听or移除监听;parentId: 父级id[不带默认就是铺满整个页面]];_this:指向当前实例(可忽略)
clearInterval(this.tokentimer); clearInterval(this.tokentimer);
}, },
methods: { methods: {
linkListener(event){
let {data} = event
if(data.id){
getUipIdByCid([data.id]).then(res=>{
if (res.code==200) {
if(res.data&&res.data.length>0&&res.data[0].uipId){
this.$router.push({path: '/enterprise/'+this.encodeStr(data.id)})
}else{
this.$tab.openPage(data.title, '/company/'+this.encodeStr(data.id))
}
}
}).catch(error=>{
});
}else{
if(data.url){
this.$tab.openPage(data.title, data.url).then(() => {
// 执行结束的逻辑
})
}
}
},
gettokens() { gettokens() {
dskAccessToken().then(res => { dskAccessToken().then(res => {
if (res.code == 200) { if (res.code == 200) {
......
...@@ -50,14 +50,31 @@ export default { ...@@ -50,14 +50,31 @@ export default {
this.iframeObserver(); this.iframeObserver();
let that = this let that = this
window.addEventListener("message", this.pagecapListener, { passive: true }); window.addEventListener("message", this.pagecapListener, { passive: true });
window.addEventListener('message', function (event) { window.addEventListener('message', this.linkListener, false);
if(event.data.id){ },
getUipIdByCid([event.data.id]).then(res=>{ mounted() {
this.iframeLoading(); // 判断iframe页面是否加载完成-当前页控制
// steerScroll('companyIframe', this.navigation, this.footHeight, true); // iframeId: iframe的id;navigation:页面排除iframe后剩下的顶部高度;footHeight: 页面排除iframe后剩下的底部高度;state:监听or移除监听;parentId: 父级id[不带默认就是铺满整个页面]];_this:指向当前实例(可忽略)
},
beforeDestroy() {
clearInterval(this.iframeTimer); // -当前页控制
steerScroll('companyIframe', this.navigation, this.footHeight); // iframeId: iframe的id;navigation:页面排除iframe后剩下的顶部高度;footHeight: 页面排除iframe后剩下的底部高度;state:监听or移除监听;parentId: 父级id[不带默认就是铺满整个页面]];_this:指向当前实例(可忽略)
clearInterval(this.tokentimer);
window.removeEventListener("message", this.pagecapListener, { passive: true });
window.removeEventListener("message", this.linkListener);
// 移除layout样式
this.iframeIns.contentWindow.postMessage("removeHtmlLayoutStyle", { targetOrigin: this.domain, });
},
methods: {
linkListener(event){
let {data} = event
if(data.id){
getUipIdByCid([data.id]).then(res=>{
if (res.code==200) { if (res.code==200) {
if(res.data&&res.data.length>0&&res.data[0].uipId){ if(res.data&&res.data.length>0&&res.data[0].uipId){
that.$router.push({path: '/enterprise/'+that.encodeStr(event.data.id)}) this.$router.push({path: '/enterprise/'+this.encodeStr(data.id)})
}else{ }else{
that.$tab.openPage(event.data.title, '/company/'+that.encodeStr(event.data.id)) this.$tab.openPage(data.title, '/company/'+this.encodeStr(data.id))
} }
} }
...@@ -65,28 +82,13 @@ export default { ...@@ -65,28 +82,13 @@ export default {
}); });
}else{ }else{
if(event.data.url){ if(data.url){
that.$tab.openPage(event.data.title, event.data.url).then(() => { this.$tab.openPage(data.title, data.url).then(() => {
// 执行结束的逻辑 // 执行结束的逻辑
}) })
} }
} }
}, false);
},
mounted() {
this.iframeLoading(); // 判断iframe页面是否加载完成-当前页控制
// steerScroll('companyIframe', this.navigation, this.footHeight, true); // iframeId: iframe的id;navigation:页面排除iframe后剩下的顶部高度;footHeight: 页面排除iframe后剩下的底部高度;state:监听or移除监听;parentId: 父级id[不带默认就是铺满整个页面]];_this:指向当前实例(可忽略)
},
beforeDestroy() {
clearInterval(this.iframeTimer); // -当前页控制
steerScroll('companyIframe', this.navigation, this.footHeight); // iframeId: iframe的id;navigation:页面排除iframe后剩下的顶部高度;footHeight: 页面排除iframe后剩下的底部高度;state:监听or移除监听;parentId: 父级id[不带默认就是铺满整个页面]];_this:指向当前实例(可忽略)
clearInterval(this.tokentimer);
window.removeEventListener("message", this.pagecapListener, { passive: true });
// 移除layout样式
this.iframeIns.contentWindow.postMessage("removeHtmlLayoutStyle", { targetOrigin: this.domain, });
}, },
methods: {
async iframeObserver() { async iframeObserver() {
try { try {
await this.$nextTick(); await this.$nextTick();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment