Browse Source

修复ticket失效的问题

feature
duanliangtao 11 months ago
parent
commit
cacb91dff4
  1. 71
      src/views/modules/volunteer/mall/category.vue
  2. 71
      src/views/modules/volunteer/mall/index.vue

71
src/views/modules/volunteer/mall/category.vue

@ -26,46 +26,53 @@ export default {
created() { created() {
// ,ticket // ,ticket
http.get("/auth/sso/getTicket") http.get("/auth/sso/getTicket")
.then(({data: res}) => { .then(({ data: res }) => {
let ticket = res.data let ticket = res.data;
console.log('ticket:', ticket) console.log('ticket:', ticket);
this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/productCategory?target=_blank&ticket=" + ticket this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/productCategory?ticket=" + ticket;
}) });
}, },
methods: { methods: {
// iframe // iframe
onIframeLoad() { onIframeLoad() {
// iframe
const iframe = this.$refs.childIframe; if(this.iframeSrc==''){
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; return;
}
if (iframeDocument) { const iframe = this.$refs.childIframe;
const styleElement = iframeDocument.createElement('style');
styleElement.type = 'text/css'; if (this.iframeSrc.indexOf("ticket")!== -1) {
// iframeSrc URL ticket
const newStyles = ` this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/productCategory";
#app .main-container { }else{
margin-left: 0px !important; const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
}
#app .sidebar-container {
display: none !important;
}
.navbar {
display: none !important;
}
`;
styleElement.appendChild(iframeDocument.createTextNode(newStyles));
iframeDocument.head.appendChild(styleElement);
// iframe if (iframeDocument) {
iframe.style.display = 'block'; const styleElement = iframeDocument.createElement('style');
styleElement.type = 'text/css';
const newStyles = `
#app .main-container {
margin-left: 0px !important;
}
#app .sidebar-container {
display: none !important;
}
.navbar {
display: none !important;
}
`;
styleElement.appendChild(iframeDocument.createTextNode(newStyles));
iframeDocument.head.appendChild(styleElement);
// iframe
iframe.style.display = 'block';
}
} }
} }
} }
}; };
</script> </script>
<style scoped>
</style>

71
src/views/modules/volunteer/mall/index.vue

@ -26,46 +26,53 @@ export default {
created() { created() {
// ,ticket // ,ticket
http.get("/auth/sso/getTicket") http.get("/auth/sso/getTicket")
.then(({data: res}) => { .then(({ data: res }) => {
let ticket = res.data let ticket = res.data;
console.log('ticket:', ticket) console.log('ticket:', ticket);
this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/product?target=_blank&ticket=" + ticket this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/product?ticket=" + ticket;
}) });
}, },
methods: { methods: {
// iframe // iframe
onIframeLoad() { onIframeLoad() {
// iframe
const iframe = this.$refs.childIframe; if(this.iframeSrc==''){
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; return;
}
if (iframeDocument) { const iframe = this.$refs.childIframe;
const styleElement = iframeDocument.createElement('style');
styleElement.type = 'text/css'; if (this.iframeSrc.indexOf("ticket")!== -1) {
// iframeSrc URL ticket
const newStyles = ` this.iframeSrc = "../../../epmet-voluntary-mall-admin/pms/product";
#app .main-container { }else{
margin-left: 0px !important; const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
}
#app .sidebar-container {
display: none !important;
}
.navbar {
display: none !important;
}
`;
styleElement.appendChild(iframeDocument.createTextNode(newStyles));
iframeDocument.head.appendChild(styleElement);
// iframe if (iframeDocument) {
iframe.style.display = 'block'; const styleElement = iframeDocument.createElement('style');
styleElement.type = 'text/css';
const newStyles = `
#app .main-container {
margin-left: 0px !important;
}
#app .sidebar-container {
display: none !important;
}
.navbar {
display: none !important;
}
`;
styleElement.appendChild(iframeDocument.createTextNode(newStyles));
iframeDocument.head.appendChild(styleElement);
// iframe
iframe.style.display = 'block';
}
} }
} }
} }
}; };
</script> </script>
<style scoped>
</style>

Loading…
Cancel
Save