fullPageIns.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div class="contan">
  3. <iframe
  4. v-if="isShow"
  5. ref="iframe"
  6. :src="url"
  7. :width="iframeWidth"
  8. :height="iframeHeight"
  9. frameborder="0"
  10. allowfullscreen="true"
  11. ></iframe>
  12. <div class="iframeDiv" v-show="isResizing"></div>
  13. <videoView
  14. v-if="showVideo"
  15. @closeVideo="showVideo = false"
  16. :docY="docY"
  17. :videoSrc="videoSrc"
  18. @isResizing="
  19. (val) => {
  20. this.isResizing = val;
  21. }
  22. "
  23. ></videoView>
  24. </div>
  25. </template>
  26. <script>
  27. import videoView from "./insVideo";
  28. export default {
  29. components: {
  30. videoView,
  31. },
  32. data() {
  33. return {
  34. url: "",
  35. h: "",
  36. w: "",
  37. y: 130,
  38. docY: "",
  39. isShow: false,
  40. showVideo: false,
  41. isResizing:false,
  42. src:""
  43. };
  44. },
  45. mounted() {
  46. this.initSize();
  47. // this.y = 130;
  48. window.addEventListener("resize", this.resizeWindow);
  49. this.url = this.$route.query.url;
  50. this.isShow = true;
  51. },
  52. methods: {
  53. initSize() {
  54. this.docY =
  55. document.documentElement.clientHeight || document.body.clientHeight;
  56. this.h = this.docY - this.y;
  57. this.w = document.documentElement.clientWidth - 40;
  58. this.x = 210;
  59. },
  60. resizeWindow() {
  61. if (this.isShow) {
  62. this.isShow = false;
  63. this.initSize();
  64. this.$nextTick((res) => {
  65. this.isShow = true;
  66. });
  67. }
  68. },
  69. },
  70. computed: {
  71. // key() {
  72. // console.log(this.$route);
  73. // this.isShow = false;
  74. // return this.$route.path;
  75. // },
  76. iframeWidth() {
  77. return this.w + "px";
  78. },
  79. iframeHeight() {
  80. return this.h - 30 + "px";
  81. },
  82. videoSrc(){
  83. return this.src
  84. }
  85. },
  86. watch: {
  87. isShow(val) {
  88. if (val) {
  89. this.$nextTick((res) => {
  90. let outFrame = this.$refs.iframe;
  91. let outFrameWindow = this.$refs.iframe.contentWindow;
  92. console.log(outFrame)
  93. setTimeout((res) => {
  94. let rightFrame = outFrameWindow.document.querySelector(
  95. "#mainFrame"
  96. );
  97. rightFrame.contentWindow.document.addEventListener(
  98. "click",
  99. (e) => {
  100. let path = (e.composedPath && e.composedPath()) || e.path || [];
  101. if (path.length > 0) {
  102. for (let i in path) {
  103. if (
  104. path[i]?.getAttribute &&
  105. path[i]?.getAttribute("title")
  106. ) {
  107. console.log(
  108. "打开视频链接",
  109. e.path[i].getAttribute("title")
  110. );
  111. this.src = e.path[i].getAttribute("title");
  112. this.showVideo = true;
  113. // this.isShow = false;
  114. break;
  115. }
  116. }
  117. } else {
  118. this.$message.error(
  119. "该浏览器不支持,请更换或升级chrome浏览器"
  120. );
  121. }
  122. console.log("点击了");
  123. this.showVideo = true;
  124. // let document
  125. },
  126. true
  127. );
  128. }, 500);
  129. });
  130. }
  131. },
  132. },
  133. };
  134. </script>
  135. <style lang="scss" scoped>
  136. .contan {
  137. z-index: 2000;
  138. position: relative;
  139. }
  140. .iframeDiv {
  141. width: 100%;
  142. height: 100%;
  143. position: absolute;
  144. z-index: 2000;
  145. filter: alpha(opacity=0);
  146. opacity: 0;
  147. background: transparent;
  148. top: 0;
  149. left: 0;
  150. /*display: none;*/
  151. }
  152. </style>