index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <div :class="`theme${theme}`" id="scenebody" class="scene-body">
  3. <div class="logo" @click="$router.push({ path: '/' })">
  4. <img :src="require(`@/assets/images/proj2022/pc/logo.png`)" alt="" />
  5. </div>
  6. <div class="scene-con" :class="{ showscene: showAll }">
  7. <div v-show="!showViewMode && !tourStatus">
  8. <vmenu :currentPanoid="currentPanoid" v-show="!tourStatus && !isClear" :tourStatus="tourStatus" @opencp="handlecp" />
  9. <!-- <zhanxiang :currentPanoid="currentPanoid" v-show="!tourStatus && !isClear" :zxdata="zhanxiangData" :class="{ zxshow: isShowZX }" /> -->
  10. <div v-if="isClear" @click.stop="clicktoClear" class="isClear">
  11. <img :src="require('@/assets/images/proj2022/icon/clear_active.png')" alt="" />
  12. <span>恢复</span>
  13. </div>
  14. </div>
  15. <roundMenu
  16. @resetCurrentTheme="currentTheme = ''"
  17. :currentZhanqu="currentZhanqu"
  18. :currentTheme="currentTheme"
  19. :class="`${!tourStatus && !isClear ? 'ronundShow' : 'ronundHide'}`"
  20. />
  21. <scene v-if="showScene" />
  22. </div>
  23. <vhotspot v-if="hotspot" @close="hotspot = ''" :hotspot="hotspot" />
  24. <vpopup v-if="showpopup && cp" v-clickoutside="handleoutside">
  25. <div slot="vcon" class="popcon" :class="{ pad_notlandscape: isiPad && !g_isLandscape }">
  26. <component :is="cp" :currentPano="currentPano" :currentZhanqu="currentZhanqu" :currentItem="currentItem"> </component>
  27. <div class="close">
  28. <img @click="(showpopup = false), (cp = ''), $bus.$emit('resetMenuActive')" :src="require('@/assets/images/proj2022/pc/cancel_btn.png')" alt="" />
  29. </div>
  30. </div>
  31. </vpopup>
  32. </div>
  33. </template>
  34. <script>
  35. import aside from "./aside.vue";
  36. import menu from "./menu.vue";
  37. import popup from "./popup.vue";
  38. import vsearch from "./search";
  39. import zhanxiang from "./zhanxiang";
  40. import daka from "./components/daka.vue";
  41. import content from "./components/content.vue";
  42. import qrcode from "./components/qrcode.vue";
  43. import scene from "./scene.vue";
  44. import vhotspot from "@/components/hotspot/index.vue";
  45. import roundMenu from "@/components/menu/index.vue";
  46. import { region } from "@/data/raw.js";
  47. import { Booth } from "@/data/booth.js";
  48. let all_booth = [];
  49. Booth.forEach((item) => {
  50. all_booth = all_booth.concat(item.company);
  51. });
  52. let exitFullscreen = function() {
  53. document.exitFullscreen
  54. ? document.exitFullscreen()
  55. : document.msExitFullscreen
  56. ? document.msExitFullscreen()
  57. : document.mozCancelFullScreen
  58. ? document.mozCancelFullScreen()
  59. : document.webkitExitFullscreen && document.webkitExitFullscreen();
  60. };
  61. let requestFullscreen = function(e) {
  62. e.requestFullscreen
  63. ? e.requestFullscreen()
  64. : e.mozRequestFullScreen
  65. ? e.mozRequestFullScreen()
  66. : e.webkitRequestFullscreen
  67. ? e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)
  68. : e.msRequestFullscreen && e.msRequestFullscreen();
  69. };
  70. export default {
  71. components: {
  72. zhanxiang,
  73. vside: aside,
  74. vmenu: menu,
  75. vpopup: popup,
  76. daka,
  77. qrcode,
  78. vcontent: content,
  79. scene,
  80. vsearch,
  81. vhotspot,
  82. roundMenu,
  83. },
  84. data() {
  85. return {
  86. showpopup: false,
  87. cp: "",
  88. tourStatus: false,
  89. isClear: false,
  90. showAll: false,
  91. showScene: true,
  92. currentPanoid: "",
  93. isFull: false,
  94. hotspots: [],
  95. hotspot: "",
  96. currentTheme: "",
  97. currentZhanqu: "",
  98. isShowZX: true,
  99. showViewMode: false,
  100. };
  101. },
  102. computed: {
  103. currentItem() {
  104. return this.themes.find((item) => item.id == this.theme);
  105. },
  106. zhanxiangData() {
  107. return Booth.find((item) => item.id == this.theme);
  108. },
  109. currentPano() {
  110. return all_booth.find((item) => item.panoId == this.currentPanoid) || {};
  111. },
  112. },
  113. watch: {
  114. currentTheme(newVal) {
  115. if (newVal) {
  116. let tt = this.currentPanoid;
  117. this.currentPanoid = "";
  118. this.$router.push({ params: { type: newVal.id, isjump: "none" } });
  119. setTimeout(() => {
  120. this.currentPanoid = tt;
  121. });
  122. }
  123. },
  124. cp(newVal) {
  125. if (newVal) {
  126. this.$bus.$emit("toggleShowZX", false);
  127. }
  128. },
  129. isClear(newVal) {
  130. document.querySelector("#ifr").contentWindow.postMessage(
  131. {
  132. source: "toggleClear",
  133. data: newVal,
  134. },
  135. "*"
  136. );
  137. },
  138. },
  139. mounted() {
  140. this.$showLoading();
  141. this.$nextTick(() => {
  142. $("#scenebody")
  143. .off("click")
  144. .on("click", () => {
  145. window.goldlog.record("/spec.1.1", "", "snsScene=p_page3&product=pcweb&pagename=中国网络文明建设成果展云展示", "");
  146. });
  147. this.$bus.$on("toggleClear", (data) => {
  148. this.isClear = data;
  149. });
  150. this.$bus.$on("resetCurrentTheme", () => {
  151. this.currentTheme = "";
  152. });
  153. window.addEventListener("message", (res) => {
  154. if (Object.prototype.toString.call(res.data) == "[object Object]") {
  155. let data = res.data.data;
  156. if (res.data.source === "showAll") {
  157. this.showAll = true;
  158. this.$hideLoading();
  159. document.querySelector("#ifr").contentWindow.postMessage(
  160. {
  161. source: "changeTheme",
  162. data: this.theme,
  163. },
  164. "*"
  165. );
  166. }
  167. if (res.data.source === "mode.changed") {
  168. console.log("mode.changed", data);
  169. if (data == "floorplan" || data == "dollhouse") {
  170. this.showViewMode = true;
  171. this.cp = "";
  172. } else if (data == "panorama") {
  173. this.showViewMode = false;
  174. this.isShowZX = true;
  175. } else if (data == "transitioning") {
  176. this.flying = true;
  177. }
  178. }
  179. if (res.data.source === "onplayStatus") {
  180. this.tourStatus = data.tourIsPlaying;
  181. // document.querySelector("#ifr").contentWindow.postMessage(
  182. // {
  183. // source: "toggleClear",
  184. // data: this.tourStatus,
  185. // },
  186. // "*"
  187. // );
  188. }
  189. if (res.data.source === "pano.chosen") {
  190. console.log("pano.chosen");
  191. }
  192. if (res.data.source === "tour.end") {
  193. console.log("tour.end");
  194. }
  195. if (res.data.source === "warp.interrupted") {
  196. console.log("warp.interrupted");
  197. }
  198. if (res.data.source === "flying.ended") {
  199. console.log("flying.ended");
  200. this.currentPanoid = data;
  201. this.currentTheme = region.find((item) => {
  202. if (item.spread.indexOf(Number(this.currentPanoid)) > -1) {
  203. return item;
  204. }
  205. });
  206. console.log(this.currentPanoid,'currentPanoid');
  207. this.currentZhanqu = "";
  208. this.currentZhanqu = all_booth.find((item) => {
  209. if (item.containPanos.indexOf(String(this.currentPanoid)) > -1) {
  210. return item;
  211. }
  212. });
  213. console.log(this.currentZhanqu,'currentZhanqu');
  214. this.currentZhanqu &&
  215. window.goldlog.record(
  216. `/p_area${this.currentZhanqu.id}`,
  217. "",
  218. `snsScene=p_area${this.currentZhanqu.id}&product=pcweb&pagename=中国网络文明建设成果展云展示`,
  219. ""
  220. );
  221. }
  222. if (res.data.source === "openHotspot") {
  223. this.hotspot = data;
  224. console.log(data, "openHotspot");
  225. this.$bus.$emit("isShowAside", false);
  226. }
  227. }
  228. });
  229. $(document).on("fullscreenchange webkitfullscreenchange mozfullscreenchange MSFullscreenChange", () => {
  230. this.isFull = !!(
  231. document.fullscreenElement ||
  232. document.mozFullscreenElement ||
  233. document.mozFullScreenElement ||
  234. document.webkitFullscreenElement ||
  235. document.msFullscreenElement
  236. );
  237. });
  238. });
  239. },
  240. beforeDestroy() {
  241. $(document).on("fullscreenchange webkitfullscreenchange mozfullscreenchange MSFullscreenChange");
  242. },
  243. methods: {
  244. clicktoClear() {
  245. this.isClear = false;
  246. },
  247. handleFull() {
  248. if (this.isFull) {
  249. exitFullscreen();
  250. } else {
  251. requestFullscreen($("html")[0]);
  252. }
  253. },
  254. handlecp(data) {
  255. this.cp = data;
  256. this.showpopup = true;
  257. this.$bus.$emit("isShowAside", false);
  258. },
  259. handleoutside() {
  260. this.cp = "";
  261. this.showpopup = false;
  262. this.$bus.$emit("resetMenuActive");
  263. },
  264. },
  265. };
  266. </script>
  267. <style lang="less" scoped>
  268. .scene-body {
  269. background-repeat: no-repeat;
  270. position: relative;
  271. .logo {
  272. position: absolute;
  273. left: 18px;
  274. top: 8px;
  275. z-index: 999;
  276. display: flex;
  277. align-items: center;
  278. cursor: pointer;
  279. > img {
  280. width: 600px;
  281. margin-right: 10px;
  282. }
  283. }
  284. .scene-con {
  285. width: 100%;
  286. height: 100%;
  287. .isClear {
  288. position: absolute;
  289. right: 20px;
  290. bottom: 20px;
  291. z-index: 99;
  292. width: 50px;
  293. cursor: pointer;
  294. display: flex;
  295. flex-direction: column;
  296. justify-content: center;
  297. text-align: center;
  298. > img {
  299. width: 50px;
  300. height: 50px;
  301. }
  302. }
  303. .vright {
  304. position: absolute;
  305. right: 10px;
  306. top: 10px;
  307. display: flex;
  308. align-items: flex-start;
  309. z-index: 990;
  310. .vfull {
  311. width: 35px;
  312. height: 35px;
  313. background: rgba(0, 0, 0, 0.5);
  314. border-radius: 50%;
  315. position: relative;
  316. margin-left: 20px;
  317. cursor: pointer;
  318. > img {
  319. position: absolute;
  320. top: 50%;
  321. left: 50%;
  322. transform: translate(-50%, -50%);
  323. width: 46%;
  324. }
  325. }
  326. }
  327. .zxshow {
  328. left: 0 !important;
  329. opacity: 1 !important;
  330. }
  331. }
  332. .popcon {
  333. position: fixed;
  334. top: 50%;
  335. left: 50%;
  336. transform: translate(-50%, -50%);
  337. z-index: 9999;
  338. .close {
  339. position: absolute;
  340. width: 100px;
  341. height: 100px;
  342. top: 50px;
  343. right: 60px;
  344. border-radius: 4px;
  345. > img {
  346. position: absolute;
  347. top: 14px;
  348. right: 14px;
  349. width: 20px;
  350. cursor: pointer;
  351. }
  352. }
  353. }
  354. .pad_notlandscape {
  355. transform: scale(0.7) translate(-50%, -50%);
  356. transform-origin: top left;
  357. }
  358. .mascot {
  359. position: fixed;
  360. bottom: 0;
  361. right: 0;
  362. z-index: 899;
  363. width: 330px;
  364. pointer-events: none;
  365. > img {
  366. width: 100%;
  367. }
  368. }
  369. .showscene {
  370. opacity: 1;
  371. }
  372. }
  373. .ronundShow {
  374. opacity: 1;
  375. pointer-events: auto;
  376. transition: ease all 0.5s;
  377. }
  378. .ronundHide {
  379. transition: ease all 0.5s;
  380. opacity: 0;
  381. pointer-events: none;
  382. }
  383. </style>