index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <div :class="`theme${theme}`" id="scenebody" class="scene-body">
  3. <div class="scene-con">
  4. <scene :tourStatus="tourStatus" />
  5. <template v-if="!g_isLandscape">
  6. <div v-if="showViewMode && !tourStatus">
  7. <div :class="{ disabled: flying }" class="tab-layer">
  8. <div class="tabs">
  9. <div :class="{ active: mode === 'floorplan' }" @click="changeMode('floorplan', $event)">
  10. <img :src="require('@/assets/images/proj2022/icon/floor_active.png')" alt="" />
  11. <span>平面</span>
  12. </div>
  13. <div :class="{ active: mode === 'dollhouse' }" @click="changeMode('dollhouse', $event)">
  14. <img :src="require('@/assets/images/proj2022/icon/dollhouse.png')" alt="" />
  15. <span>三维</span>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. <div v-show="!showViewMode && !tourStatus">
  21. <!-- <vside :isShow="!tourStatus && showAside" @close="showAside = false" />
  22. <zhanxiang @showSearch="showSearch = true" v-if="isShowZL" @close="isShowZL = false" :tourStatus="tourStatus" />
  23. <rmenu :currentPanoid="currentPanoid" :isShowfunc="isShowfunc" :menuType="menuType" :tourStatus="tourStatus" @opencp="handlecp" />
  24. <vmenu :tourStatus="tourStatus" @play="startTour" /> -->
  25. <vsearch :currentPanoid="currentPanoid" @closeSearch="closeSearch" v-if="showSearch" />
  26. <div v-if="isClear" @click.stop="clicktoClear" class="isClear">
  27. <img :src="require('@/assets/images/proj2022/icon/clear_active.png')" alt="" />
  28. <span>恢复</span>
  29. </div>
  30. </div>
  31. <roundMenu
  32. @resetCurrentTheme="currentTheme = ''"
  33. @toggleBirdView="(data) => (showBirdview = data)"
  34. :currentZhanqu="currentZhanqu"
  35. :currentTheme="currentTheme"
  36. :class="!showViewMode && !tourStatus && !isClear ? 'ronundShow' : 'ronundHide'"
  37. @showSearch="showSearch = true"
  38. @play="startTour"
  39. />
  40. </template>
  41. </div>
  42. <birdview @close="showBirdview = false" v-if="showBirdview" />
  43. <template v-if="!g_isLandscape">
  44. <vpopup v-if="showpopup && cp" v-clickoutside="handleoutside">
  45. <div slot="vcon" class="popcon">
  46. <component :is="cp" :currentPano="currentPano" :currentZhanqu="currentZhanqu" :currentItem="currentItem"> </component>
  47. <img @click="(showpopup = false), (cp = '')" class="close" :src="require('@/assets/images/project/icon/close.png')" alt="" />
  48. </div>
  49. </vpopup>
  50. </template>
  51. <vhotspot v-if="hotspot" @close="hotspot = ''" :hotspot="hotspot" />
  52. </div>
  53. </template>
  54. <script>
  55. import birdview from "./birdview/index.vue";
  56. import vsearch from "./search";
  57. import scene from "./scene.vue";
  58. import vhotspot from "@/components/hotspot/index.vue";
  59. import roundMenu from "@/components/menu/index.vue";
  60. import content from "./components/content.vue";
  61. import qrcode from "./components/qrcode.vue";
  62. import popup from "./popup.vue";
  63. import { region } from "@/data/raw.js";
  64. import { Booth } from "@/data/booth.js";
  65. let all_booth = [];
  66. Booth.forEach((item) => {
  67. all_booth = all_booth.concat(item.company);
  68. });
  69. export default {
  70. components: {
  71. scene,
  72. vsearch,
  73. vhotspot,
  74. birdview,
  75. qrcode,
  76. vpopup: popup,
  77. vcontent: content,
  78. roundMenu,
  79. },
  80. computed: {
  81. currentItem() {
  82. return this.themes.find((item) => item.id == this.theme);
  83. },
  84. currentPano() {
  85. return all_booth.find((item) => item.panoId == this.currentPanoid) || {};
  86. },
  87. },
  88. data() {
  89. return {
  90. currentZhanqu: "",
  91. showBirdview: true,
  92. menuType: "func",
  93. isShowfunc: false,
  94. showpopup: false,
  95. showAside: false,
  96. showSearch: false,
  97. isShowZL: false,
  98. cp: "",
  99. tourStatus: false,
  100. showAll: false,
  101. currentPanoid: "",
  102. isFull: false,
  103. hotspots: [],
  104. hotspot: "",
  105. loginUrl: "",
  106. currentTheme: "",
  107. booth: Booth,
  108. showViewMode: false,
  109. flying: false,
  110. mode: "floorplan",
  111. isClear: false,
  112. };
  113. },
  114. watch: {
  115. showBirdview: {
  116. deep: true,
  117. immediate: true,
  118. handler: function(newVal) {
  119. this.$bus.$emit("noMode", newVal);
  120. },
  121. },
  122. g_isLandscape: {
  123. immediate: true,
  124. handler: function(newVal) {
  125. newVal ? this.$showOrientationtip({ isLandscape: false, isTip: true }) : this.$hideOrientationtip();
  126. },
  127. },
  128. currentTheme(newVal) {
  129. if (newVal) {
  130. let tt = this.currentPanoid;
  131. this.currentPanoid = "";
  132. this.$router.push({ params: { type: newVal.id, isjump: "none" } });
  133. setTimeout(() => {
  134. this.currentPanoid = tt;
  135. });
  136. }
  137. },
  138. isClear(newVal) {
  139. document.querySelector("#ifr").contentWindow.postMessage(
  140. {
  141. source: "toggleClear",
  142. data: newVal,
  143. },
  144. "*"
  145. );
  146. },
  147. },
  148. mounted() {
  149. this.$showLoading();
  150. this.$nextTick(() => {
  151. this.$bus.$on("resetCurrentTheme", () => {
  152. this.currentTheme = "";
  153. });
  154. $("#scenebody")
  155. .off("touchstart")
  156. .on("touchstart", () => {
  157. window.goldlog.record("/spec.1.1", "", "snsScene=m_page3&product=mobh5&pagename=中国网络文明建设成果展云展示", "");
  158. });
  159. this.$bus.$on("mblogin", (data) => {
  160. this.loginUrl = data;
  161. });
  162. this.$bus.$on("emitShowZX", (data) => {
  163. this.isShowZL = data;
  164. });
  165. this.$bus.$on("changeMenu", (data) => {
  166. this.menuType = data;
  167. });
  168. this.$bus.$on("changeShowfunc", (data) => {
  169. this.isShowfunc = data;
  170. });
  171. this.$bus.$on("opencp", (data) => {
  172. this.handlecp(data);
  173. this.isShowZL = false;
  174. });
  175. this.$bus.$on("toggleClear", (data) => {
  176. this.isClear = data;
  177. });
  178. window.addEventListener("message", (res) => {
  179. if (Object.prototype.toString.call(res.data) == "[object Object]") {
  180. let data = res.data.data;
  181. if (res.data.source === "showAll") {
  182. setTimeout(() => {
  183. this.$hideLoading();
  184. });
  185. }
  186. if (res.data.source === "onplayStatus") {
  187. // console.log("onplayStatus");
  188. this.tourStatus = data.tourIsPlaying;
  189. }
  190. if (res.data.source === "pano.chosen") {
  191. console.log("pano.chosen");
  192. window.g_lock = true;
  193. }
  194. if (res.data.source === "tour.end") {
  195. window.g_lock = false;
  196. }
  197. if (res.data.source === "warp.interrupted") {
  198. console.log("warp.interrupted");
  199. window.g_lock = false;
  200. }
  201. if (res.data.source === "mode.changed") {
  202. console.log("mode.changed", data);
  203. if (data == "floorplan" || data == "dollhouse") {
  204. this.showViewMode = true;
  205. this.flying = false;
  206. this.mode = data;
  207. document.querySelector("#ifr").contentWindow.postMessage(
  208. {
  209. source: "toggleClear",
  210. data: this.showViewMode,
  211. },
  212. "*"
  213. );
  214. } else if (data == "panorama") {
  215. this.showViewMode = false;
  216. this.flying = false;
  217. document.querySelector("#ifr").contentWindow.postMessage(
  218. {
  219. source: "toggleClear",
  220. data: this.showViewMode,
  221. },
  222. "*"
  223. );
  224. } else if (data == "transitioning") {
  225. this.flying = true;
  226. }
  227. }
  228. if (res.data.source === "flying.ended") {
  229. console.log("flying.ended");
  230. this.currentPanoid = data;
  231. this.currentTheme = region.find((item) => {
  232. if (item.spread.indexOf(Number(this.currentPanoid)) > -1) {
  233. return item;
  234. }
  235. });
  236. this.currentZhanqu = "";
  237. this.currentZhanqu = all_booth.find((item) => {
  238. if (item.containPanos.indexOf(this.currentPanoid) > -1) {
  239. return item;
  240. }
  241. });
  242. this.currentZhanqu &&
  243. window.goldlog.record(
  244. `/m_area${this.currentZhanqu.id}`,
  245. "",
  246. `snsScene=m_area${this.currentZhanqu.id}&product=mobh5&pagename=中国网络文明建设成果展云展示`,
  247. ""
  248. );
  249. }
  250. if (res.data.source === "openHotspot") {
  251. this.hotspot = data;
  252. this.$bus.$emit("isShowAside", false);
  253. }
  254. }
  255. });
  256. });
  257. },
  258. methods: {
  259. clicktoClear() {
  260. this.isClear = false;
  261. },
  262. startTour() {
  263. this.$bus.$emit("ifrMessage", {
  264. events: "toggleTour",
  265. data: "startAndPlay",
  266. });
  267. },
  268. changeMode(data) {
  269. this.mode = data;
  270. document.querySelector("#ifr").contentWindow.player.director.changeMode(data);
  271. },
  272. closeSearch(data) {
  273. if (data == "closeAll") {
  274. this.isShowZL = false;
  275. }
  276. this.showSearch = false;
  277. },
  278. handlecp(data) {
  279. this.cp = data;
  280. console.log(data,'opencp')
  281. this.showpopup = true;
  282. },
  283. handleoutside() {
  284. this.cp = "";
  285. this.showpopup = false;
  286. },
  287. },
  288. };
  289. </script>
  290. <style lang="less" scoped>
  291. .scene-body {
  292. background-repeat: no-repeat;
  293. .tab-layer {
  294. width: 100%;
  295. text-align: center;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. z-index: 10;
  300. position: fixed;
  301. left: 50%;
  302. transform: translateX(-50%);
  303. top: 30px;
  304. pointer-events: none;
  305. .tabs {
  306. pointer-events: auto;
  307. position: relative;
  308. display: flex;
  309. background: rgba(0, 0, 0, 0.5);
  310. padding: 2px;
  311. justify-content: center;
  312. align-items: center;
  313. border: 1px solid rgba(255, 255, 255, 0.1);
  314. border-radius: 6px;
  315. padding: 0px 2px;
  316. backdrop-filter: blur(20px);
  317. > div {
  318. color: #fff;
  319. border-radius: 6px;
  320. font-size: 16px;
  321. transition: all 0.3s ease;
  322. display: flex;
  323. align-items: center;
  324. z-index: 1;
  325. margin: 4px;
  326. padding: 2px 6px 2px 0;
  327. img {
  328. width: 30px;
  329. }
  330. > span {
  331. font-size: 14px;
  332. }
  333. &.active {
  334. background: rgba(127, 127, 127, 0.57);
  335. border-radius: 4px;
  336. }
  337. }
  338. }
  339. }
  340. .disabled {
  341. opacity: 0.5;
  342. pointer-events: none;
  343. }
  344. .scene-con {
  345. width: 100%;
  346. height: 100%;
  347. .isClear {
  348. position: absolute;
  349. left: 20px;
  350. bottom: 20px;
  351. z-index: 99;
  352. width: 50px;
  353. cursor: pointer;
  354. display: flex;
  355. flex-direction: column;
  356. justify-content: center;
  357. text-align: center;
  358. > img {
  359. width: 50px;
  360. height: 50px;
  361. }
  362. }
  363. }
  364. .logo {
  365. position: absolute;
  366. left: 10px;
  367. top: 8px;
  368. z-index: 999;
  369. display: flex;
  370. align-items: center;
  371. > img {
  372. width: 48px;
  373. }
  374. }
  375. .popcon {
  376. z-index: 9999;
  377. width: 100%;
  378. height: 100%;
  379. .close {
  380. position: absolute;
  381. top: 20px;
  382. right: 20px;
  383. width: 16px;
  384. cursor: pointer;
  385. z-index: 1000;
  386. }
  387. }
  388. .logincon {
  389. position: fixed;
  390. z-index: 99999;
  391. width: 100%;
  392. height: 100%;
  393. top: 0;
  394. left: 0;
  395. > iframe {
  396. width: 100%;
  397. height: 100%;
  398. position: relative;
  399. z-index: 999900;
  400. }
  401. .close {
  402. display: inline-block;
  403. position: absolute;
  404. right: 16px;
  405. top: 16px;
  406. z-index: 999999;
  407. width: 16px;
  408. }
  409. }
  410. .btn-tips {
  411. position: fixed;
  412. z-index: 999999;
  413. width: 100%;
  414. height: 100%;
  415. top: 0;
  416. left: 0;
  417. background-color: rgba(0, 0, 0, 0.5);
  418. > img {
  419. position: absolute;
  420. width: 34%;
  421. bottom: 175px;
  422. right: 40px;
  423. max-width: 120px;
  424. }
  425. }
  426. }
  427. .ronundShow {
  428. opacity: 1;
  429. pointer-events: auto;
  430. transition: ease all 0.5s;
  431. }
  432. .ronundHide {
  433. transition: ease all 0.5s;
  434. opacity: 0;
  435. pointer-events: none !important;
  436. }
  437. </style>