index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="parent-body">
  3. <!-- 热点 -->
  4. <hot />
  5. <!-- 热点弹出框 -->
  6. <popup />
  7. <!-- 加载初始页面 -->
  8. <div id="gui-thumb"></div>
  9. <!-- 主容器 -->
  10. <div id="player"></div>
  11. <div id="gui-parent">
  12. <!-- 进度条加载 -->
  13. <gui-loading v-show="false" />
  14. <div id="gui" class="disable">
  15. <!-- 退出VR模式按钮 -->
  16. <div id="vrOff">
  17. <img id="vrOffImg" src="images/vrOffImg.png" alt="" />
  18. </div>
  19. <!-- 热点列表 -->
  20. <hotspot-list />
  21. <!-- 标题 -->
  22. <v-title />
  23. <!-- 底部菜单 -->
  24. <v-menu class="disable" />
  25. <!-- 导览 -->
  26. <v-guide class="disable" />
  27. <!-- logo -->
  28. <div
  29. id="myCompany"
  30. style="width:100%;position:absolute;bottom:20px;text-align:center;font-size:14px;font-family: '微软雅黑';font-weight:580;color: rgba(255, 255, 255, 0.8);"
  31. >
  32. 四维时代提供技术支持
  33. </div>
  34. </div>
  35. <!-- vr -->
  36. <web-vr />
  37. <!-- loading -->
  38. <div id="gui-spinner" style="display: none;">
  39. <div class="gui-spinner-icon"></div>
  40. </div>
  41. <!-- guimsg -->
  42. <guimsg />
  43. <!-- 错误提示 -->
  44. <v-error />
  45. <vr-con />
  46. <v-other />
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import hot from "./views/hot";
  52. import popup from "./views/popup";
  53. import guiLoading from "./views/gui/loading";
  54. import hotspotList from "./views/gui/hotspotlist";
  55. import vTitle from "./views/gui/title";
  56. import vMenu from "./views/gui/menu";
  57. import vGuide from "./views/gui/guide";
  58. import webVr from "./views/gui/webvr";
  59. import guimsg from "./views/gui/guimsg";
  60. import vError from "./views/gui/error";
  61. import vrCon from "./views/gui/vrcon";
  62. import vOther from "./views/gui/other";
  63. export default {
  64. data() {
  65. return {
  66. hotspots: [],
  67. };
  68. },
  69. components: {
  70. hot,
  71. popup,
  72. guiLoading,
  73. hotspotList,
  74. vTitle,
  75. vMenu,
  76. vGuide,
  77. webVr,
  78. guimsg,
  79. vError,
  80. vrCon,
  81. vOther,
  82. },
  83. methods: {
  84. getHotSpotList() {
  85. $.ajax({
  86. url:
  87. window.g_Prefix +
  88. "data/" +
  89. window.number +
  90. "/hot/js/data.js" +
  91. "?" +
  92. Math.random(),
  93. type: "get",
  94. dataType: "json",
  95. contentType: "application/json",
  96. success: (result) => {
  97. this.hotspots = result;
  98. },
  99. });
  100. },
  101. start() {
  102. //加载完成页面展示
  103. window.parent.postMessage(
  104. {
  105. source: "showAll",
  106. data: true,
  107. },
  108. "*"
  109. );
  110. if (window.player) {
  111. this.getHotSpotList();
  112. //监听导览状态
  113. window.player.on("onplayStatus", (data) => {
  114. window.parent.postMessage(
  115. {
  116. source: "onplayStatus",
  117. data,
  118. },
  119. "*"
  120. );
  121. });
  122. window.player.on("flying.ended", (...data) => {
  123. window.parent.postMessage(
  124. {
  125. source: "flying.ended",
  126. data: data[2].id,
  127. },
  128. "*"
  129. );
  130. });
  131. window.player.on("openHotspot", (data) => {
  132. this.hotspot = this.hotspots[data];
  133. this.hotspot.contents = this.hotspot.content
  134. ? this.hotspot.content.split("(4dage)")
  135. : [];
  136. window.parent.postMessage(
  137. {
  138. source: "openHotspot",
  139. data: this.hotspot,
  140. },
  141. "*"
  142. );
  143. });
  144. }
  145. },
  146. },
  147. mounted() {
  148. this.$nextTick(() => {
  149. if (!window.evt) {
  150. window.evt = document.createEvent("HTMLEvents");
  151. }
  152. window.evt.initEvent("loadfinish", false, false);
  153. window.addEventListener("loadfinish", this.start, false);
  154. window.addEventListener("message", (res) => {
  155. if (Object.prototype.toString.call(res.data) == "[object Object]") {
  156. let data = res.data.data;
  157. if (res.data.source === "changeExhition") {
  158. window.player.flyToPano({
  159. pano: window.player.model.panos.index[data.index],
  160. quaternion: new THREE.Quaternion(...data.quat),
  161. });
  162. }
  163. if (res.data.source === "enterExhition") {
  164. window.firstView= data.firstView
  165. }
  166. }
  167. });
  168. });
  169. },
  170. beforeDestroy() {
  171. $(document).off(
  172. "fullscreenchange webkitfullscreenchange mozfullscreenchange MSFullscreenChange"
  173. );
  174. window.removeEventListener("loadfinish", this.start, false);
  175. },
  176. };
  177. </script>
  178. <style lang="less" scoped>
  179. .parent-body {
  180. width: 100%;
  181. height: 100%;
  182. position: relative;
  183. overflow: hidden;
  184. }
  185. </style>