index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="parent-body " :class="`theme${themescene}`">
  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">
  15. <!-- 退出VR模式按钮 -->
  16. <div id="vrOff" class="disable">
  17. <img id="vrOffImg" src="static/images/vrOffImg.png" alt="" />
  18. </div>
  19. <!-- 热点列表 -->
  20. <hotspot-list class="disable" />
  21. <!-- 标题 -->
  22. <v-title class="disable" />
  23. <!-- 底部菜单 -->
  24. <v-menu class="disable" />
  25. <!-- 导览 -->
  26. <v-guide :themescene="themescene" :isTour="isTour" :class="{ showGuide: isTour }" />
  27. <!-- logo -->
  28. <div
  29. class="disable"
  30. id="myCompany"
  31. 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);"
  32. >
  33. 四维时代提供技术支持
  34. </div>
  35. </div>
  36. <!-- vr -->
  37. <web-vr />
  38. <!-- loading -->
  39. <div id="gui-spinner" style="display: none;">
  40. <div class="gui-spinner-icon"></div>
  41. </div>
  42. <!-- guimsg -->
  43. <guimsg />
  44. <!-- 错误提示 -->
  45. <v-error />
  46. <vr-con />
  47. <v-other />
  48. </div>
  49. <vmap v-show="!toggleClear" :flying="flying" :themescene="themescene" />
  50. </div>
  51. </template>
  52. <script>
  53. import hot from "./views/hot";
  54. import popup from "./views/popup";
  55. import guiLoading from "./views/gui/loading";
  56. import hotspotList from "./views/gui/hotspotlist";
  57. import vTitle from "./views/gui/title";
  58. import vMenu from "./views/gui/menu";
  59. import vGuide from "./views/gui/guide";
  60. import webVr from "./views/gui/webvr";
  61. import guimsg from "./views/gui/guimsg";
  62. import vError from "./views/gui/error";
  63. import vrCon from "./views/gui/vrcon";
  64. import vOther from "./views/gui/other";
  65. import vmap from "../scene/raside/map.vue";
  66. import vmbmap from "../mobilescene/map.vue";
  67. import browser from "@/utils/browser";
  68. let tongjiurl = "https://shuangchuang-api.kczg.org.cn/Web/jt/";
  69. export default {
  70. data() {
  71. return {
  72. hotspots: [],
  73. themescene: "xuting",
  74. toggleClear: false,
  75. isTour: false,
  76. flying: false,
  77. };
  78. },
  79. components: {
  80. hot,
  81. popup,
  82. guiLoading,
  83. hotspotList,
  84. vTitle,
  85. vMenu,
  86. vGuide,
  87. webVr,
  88. guimsg,
  89. vError,
  90. vrCon,
  91. vOther,
  92. vmap: browser.mobile ? vmbmap : vmap,
  93. },
  94. methods: {
  95. tongji(event) {
  96. if (event) {
  97. $.ajax({
  98. url: tongjiurl + `?Area=yunzhanlan&incident=${event}&rnd=` + Math.random(),
  99. type: "get",
  100. dataType: "json",
  101. contentType: "application/json",
  102. success: () => {},
  103. });
  104. }
  105. },
  106. getHotSpotList() {
  107. $.ajax({
  108. url: window.g_Prefix + "data/" + window.number + "/hot/js/data.js" + "?" + Math.random(),
  109. type: "get",
  110. dataType: "json",
  111. contentType: "application/json",
  112. success: (result) => {
  113. this.hotspots = result;
  114. },
  115. });
  116. },
  117. start() {
  118. //加载完成页面展示
  119. window.parent.postMessage(
  120. {
  121. source: "showAll",
  122. data: true,
  123. },
  124. "*"
  125. );
  126. if (window.player) {
  127. this.getHotSpotList();
  128. //监听导览状态
  129. window.parent.postMessage(
  130. {
  131. source: "flying.ended",
  132. data: window.player.currentPano.id,
  133. },
  134. "*"
  135. );
  136. window.player.on("onplayStatus", (data) => {
  137. console.log(data.tourIsPlaying);
  138. this.isTour = data.tourIsPlaying;
  139. window.parent.postMessage(
  140. {
  141. source: "onplayStatus",
  142. data,
  143. },
  144. "*"
  145. );
  146. });
  147. window.player.on("flying.ended", (...data) => {
  148. window.parent.postMessage(
  149. {
  150. source: "flying.ended",
  151. data: data[2].id,
  152. },
  153. "*"
  154. );
  155. });
  156. window.player.on("mode.changed", (...data) => {
  157. if (data[1] == "floorplan" || data[1] == "dollhouse") {
  158. this.flying = false;
  159. } else if (data[1] == "panorama") {
  160. this.flying = false;
  161. } else if (data[1] == "transitioning") {
  162. this.flying = true;
  163. }
  164. window.parent.postMessage(
  165. {
  166. source: "mode.changed",
  167. data: data[1],
  168. },
  169. "*"
  170. );
  171. });
  172. window.player.on("pano.chosen", () => {
  173. window.parent.postMessage(
  174. {
  175. source: "pano.chosen",
  176. data: true,
  177. },
  178. "*"
  179. );
  180. });
  181. window.player.on("warp.interrupted", () => {
  182. window.parent.postMessage(
  183. {
  184. source: "warp.interrupted",
  185. data: true,
  186. },
  187. "*"
  188. );
  189. });
  190. window.player.on("input.start", () => {
  191. window.parent.postMessage(
  192. {
  193. source: "input.start",
  194. data: true,
  195. },
  196. "*"
  197. );
  198. });
  199. window.player.director.on("tour.end", () => {
  200. window.parent.postMessage(
  201. {
  202. source: "tour.end",
  203. data: true,
  204. },
  205. "*"
  206. );
  207. });
  208. window.player.on("openHotspot", (data) => {
  209. this.hotspot = this.hotspots[data];
  210. this.hotspot.contents = this.hotspot.content ? this.hotspot.content.split("(4dage)") : [];
  211. window.parent.postMessage(
  212. {
  213. source: "openHotspot",
  214. data: this.hotspot,
  215. },
  216. "*"
  217. );
  218. });
  219. }
  220. },
  221. },
  222. mounted() {
  223. this.$nextTick(() => {
  224. if (!window.evt) {
  225. window.evt = document.createEvent("HTMLEvents");
  226. }
  227. window.evt.initEvent("loadfinish", false, false);
  228. window.addEventListener("loadfinish", this.start, false);
  229. window.addEventListener("message", (res) => {
  230. if (Object.prototype.toString.call(res.data) == "[object Object]") {
  231. let data = res.data.data;
  232. if (res.data.source === "toggleClear") {
  233. this.toggleClear = data;
  234. // this.$store.dispatch("changeTheme", data.data);
  235. }
  236. if (res.data.source === "changeTheme") {
  237. this.themescene = data;
  238. // this.$store.dispatch("changeTheme", data.data);
  239. }
  240. if (res.data.source === "changeExhition") {
  241. let { x, y, z, w } = data.quat;
  242. let fnname = "flyToPano";
  243. if (window.player.mode == "panorama") {
  244. fnname = "blackToPano";
  245. }
  246. window.player[fnname]({
  247. pano: window.player.model.panos.index[data.index],
  248. quaternion: new window.THREE.Quaternion(x, y, z, w),
  249. });
  250. }
  251. if (res.data.source === "enterExhition") {
  252. window.firstView = data.firstView;
  253. }
  254. }
  255. });
  256. $(document)
  257. .off("click touchstart")
  258. .on("click touchstart", () => {
  259. this.tongji("click");
  260. });
  261. $(document)
  262. .off("keydown")
  263. .on("keydown", () => {
  264. this.tongji("keydown");
  265. });
  266. });
  267. },
  268. beforeDestroy() {
  269. $(document).off("fullscreenchange webkitfullscreenchange mozfullscreenchange MSFullscreenChange click touchstart keydown");
  270. window.removeEventListener("loadfinish", this.start, false);
  271. },
  272. };
  273. </script>
  274. <style lang="less" scoped>
  275. .parent-body {
  276. width: 100%;
  277. height: 100%;
  278. position: relative;
  279. overflow: hidden;
  280. }
  281. </style>
  282. <style lang="less">
  283. .showGuide {
  284. bottom: 0 !important;
  285. }
  286. .hiddenzhangxiang{
  287. bottom: -160px!important;
  288. }
  289. </style>