app.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <Password />
  3. <LoadingLogo :thumb="true" />
  4. <Guide />
  5. <div class="ui-view-layout" :class="{ show: show }" is-mobile="true">
  6. <div class="scene" ref="scene$"></div>
  7. <template v-if="dataLoaded">
  8. <Information />
  9. <Control />
  10. <teleport v-if="refMiniMap && player.showWidgets" :to="refMiniMap">
  11. <span class="button-switch" @click.stop="toggleMap">
  12. <ui-icon type="show_map_collect"></ui-icon>
  13. </span>
  14. <p class="change" v-if="controls.showDollhouse" @click="changeMode('dollhouse')">
  15. <ui-icon type="show_3d_normal"></ui-icon>
  16. 3D模型
  17. </p>
  18. </teleport>
  19. <template v-if="refMiniMap">
  20. <div :class="{ disabled: flying }" v-show="mode != 'panorama'" v-if="controls.showFloorplan && controls.showDollhouse" class="tab-layer">
  21. <div class="tabs" v-if="controls.showMap">
  22. <span :class="{ active: mode === 'floorplan' }" ref="floorplan_ref" @click="changeMode('floorplan', $event)">
  23. <ui-icon :type="mode == 'floorplan' ? 'show_plane_selected' : 'show_plane_normal'"></ui-icon>
  24. 二维
  25. </span>
  26. <span :class="{ active: mode === 'dollhouse' }" ref="dollhouse_ref" @click="changeMode('dollhouse', $event)">
  27. <ui-icon :type="mode == 'dollhouse' ? 'show_3d_selected' : 'show_3d_normal'"></ui-icon>
  28. 三维
  29. </span>
  30. <div class="background" ref="background"></div>
  31. </div>
  32. </div>
  33. </template>
  34. </template>
  35. <UiTags />
  36. </div>
  37. </template>
  38. <script setup>
  39. import { useMusicPlayer } from "@/utils/sound";
  40. import UiTags from "@/components/Tags";
  41. import Information from "@/components/Information";
  42. import Control from "@/components/Controls/Control.Mobile.vue";
  43. import LoadingLogo from "@/components/shared/Loading.vue";
  44. import OpenVideo from "@/components/openVideo/";
  45. import Guide from "@/components/shared/Guide.vue";
  46. import Password from "@/components/shared/Password.vue";
  47. import { createApp } from "@/app";
  48. import { ref, onMounted, computed, nextTick, watch } from "vue";
  49. import { useStore } from "vuex";
  50. import browser from "@/utils/browser";
  51. import { useApp, getApp } from "@/app";
  52. const musicPlayer = useMusicPlayer();
  53. let app = null;
  54. const closetagtype = () => {
  55. store.commit("tag/setTagClickType", {
  56. type: "",
  57. data: {},
  58. });
  59. };
  60. const store = useStore();
  61. const tags = computed(() => {
  62. return store.getters["tag/tags"] || [];
  63. });
  64. const player = computed(() => store.getters["player"]);
  65. const flying = computed(() => store.getters["flying"]);
  66. const metadata = computed(() => store.getters["scene/metadata"]);
  67. const controls = computed(() => {
  68. return metadata.value.controls;
  69. });
  70. const mode = computed(() => store.getters["mode"]);
  71. const showNavigations = computed(() => store.getters["showNavigations"]);
  72. const scene$ = ref(null);
  73. const show = ref(false);
  74. const dataLoaded = ref(false);
  75. const refMiniMap = ref(null);
  76. const isCollapse = ref(false);
  77. const background = ref(null);
  78. const resize = () => {
  79. if (this.$refs.background && (this.mode == "floorplan" || this.mode == "dollhouse")) {
  80. this.$nextTick(() => {
  81. let $active = $(this.$el).find(".tabs .active");
  82. background.value.style.width = $active[0].getBoundingClientRect().width + "px";
  83. background.value.style.left = $active.position().left + "px";
  84. });
  85. }
  86. };
  87. watch(
  88. () => player.value.showMap,
  89. (val, old) => {
  90. if (!isCollapse.value) {
  91. let $minmap = document.querySelector("[xui_min_map]");
  92. if ($minmap) {
  93. if (val) {
  94. $minmap.classList.remove("collapse");
  95. } else {
  96. $minmap.classList.add("collapse");
  97. }
  98. }
  99. }
  100. },
  101. {
  102. deep: true,
  103. }
  104. );
  105. watch(
  106. () => player.value.showWidgets,
  107. (val, old) => {
  108. let $minmap = document.querySelector("[xui_min_map]");
  109. if ($minmap) {
  110. if (val) {
  111. $minmap.classList.remove("collapse");
  112. } else {
  113. $minmap.classList.add("collapse");
  114. }
  115. }
  116. },
  117. {
  118. deep: true,
  119. }
  120. );
  121. watch(
  122. () => mode.value,
  123. (val, old) => {
  124. console.log(val);
  125. let timer = setTimeout(() => {
  126. clearTimeout(timer);
  127. if (val == "floorplan") {
  128. if (floorplan_ref.value && floorplan_ref.value) {
  129. background.value.style.width = floorplan_ref.value.getBoundingClientRect().width + "px";
  130. background.value.style.left = floorplan_ref.value.offsetLeft + "px";
  131. }
  132. } else if (val == "dollhouse") {
  133. if (dollhouse_ref.value && dollhouse_ref.value) {
  134. background.value.style.width = dollhouse_ref.value.getBoundingClientRect().width + "px";
  135. background.value.style.left = dollhouse_ref.value.offsetLeft + "px";
  136. }
  137. }
  138. }, 0);
  139. },
  140. {
  141. deep: true,
  142. }
  143. );
  144. const floorplan_ref = ref(null);
  145. const dollhouse_ref = ref(null);
  146. const changeMode = (name, e) => {
  147. if (e) {
  148. if (!flying.value) {
  149. // background.value.style.width = e.srcElement.getBoundingClientRect().width + 'px'
  150. // background.value.style.left = e.srcElement.offsetLeft + 'px'
  151. store.commit("setMode", name);
  152. }
  153. } else {
  154. // let t = setTimeout(() => {
  155. // background.value.style.width = dollhouse_ref.value.getBoundingClientRect().width + 'px'
  156. // background.value.style.left = dollhouse_ref.value.offsetLeft + 'px'
  157. store.commit("setMode", name);
  158. // }, 0)
  159. }
  160. };
  161. // console.dir(document.querySelector(".tabs>span:last-of-type"));
  162. const toggleMap = () => {
  163. isCollapse.value = !isCollapse.value;
  164. let $minmap = document.querySelector("[xui_min_map]");
  165. if ($minmap) {
  166. if (!isCollapse.value) {
  167. $minmap.classList.remove("collapse");
  168. } else {
  169. $minmap.classList.add("collapse");
  170. }
  171. }
  172. };
  173. const onClickTagInfo = (el) => {
  174. el.stopPropagation();
  175. let item = tags.value.find((item) => item.sid == el.target.dataset.id);
  176. if (item.type == "commodity") {
  177. store.commit("tag/setTagClickType", {
  178. type: "goodlist",
  179. data: item,
  180. });
  181. }
  182. };
  183. onMounted(() => {
  184. const app = createApp({
  185. num: browser.getURLParam("m"),
  186. dom: scene$.value,
  187. mobile: true,
  188. });
  189. app.Scene.lock();
  190. app.use("MinMap", { theme: { camera_fillStyle: "#0076f6" } });
  191. app.use("Tag");
  192. app.use("TourPlayer");
  193. app.Scene.on("ready", () => {
  194. show.value = true;
  195. });
  196. app.Scene.on("error", (data) => {
  197. console.error(data);
  198. switch (data.code) {
  199. case 5033:
  200. window.location.replace(`/5033.html?m=` + browser.getURLParam("m"));
  201. break;
  202. case 5034:
  203. window.location.replace(`/5034.html?m=` + browser.getURLParam("m"));
  204. break;
  205. case 5009:
  206. window.location.replace(`/5034.html?m=` + browser.getURLParam("m"));
  207. break;
  208. case 5005:
  209. window.location.replace(`/#/404.html?m=` + browser.getURLParam("m"));
  210. break;
  211. }
  212. });
  213. app.Scene.on("loaded", (pano) => {
  214. refMiniMap.value = "[xui_min_map]";
  215. store.commit("setFloorId", pano.floorIndex);
  216. useMusicPlayer();
  217. });
  218. app.Scene.on("panorama.videorenderer.resumerender", () => {
  219. musicPlayer.pause(true);
  220. });
  221. app.Scene.on("panorama.videorenderer.suspendrender", async () => {
  222. let player = await getApp().TourManager.player;
  223. if (!player.isPlaying) {
  224. musicPlayer.resume();
  225. }
  226. });
  227. app.store.on("metadata", (metadata) => {
  228. let div = document.createElement("div");
  229. div.innerHTML = metadata.description;
  230. store.commit("scene/load", metadata);
  231. if (!metadata.controls.showMap) {
  232. app.MinMap.hide(true);
  233. }
  234. dataLoaded.value = true;
  235. });
  236. app.store.on("tags", (tags) => {
  237. store.commit("tag/load", tags);
  238. });
  239. app.Camera.on("mode.beforeChange", ({ fromMode, toMode, floorIndex }) => {
  240. if (fromMode) {
  241. store.commit("setFlying", true);
  242. }
  243. });
  244. app.Camera.on("mode.afterChange", ({ toMode, floorIndex }) => {
  245. store.commit("setFlying", false);
  246. });
  247. app.Camera.on("flying.started", (pano) => {
  248. store.commit("setFlying", true);
  249. });
  250. app.Camera.on("flying.ended", ({ targetPano }) => {
  251. store.commit("setFlying", false);
  252. store.commit("setPanoId", targetPano.id);
  253. });
  254. app.store.on("tour", async (tour) => {
  255. app.TourManager.load(tour);
  256. store.commit("tour/setData", {
  257. tours: JSON.parse(
  258. JSON.stringify(app.TourManager.tours, (key, val) => {
  259. if (key === "audio") {
  260. return null;
  261. } else {
  262. return val;
  263. }
  264. })
  265. ),
  266. });
  267. store.commit("tour/setBackUp", {
  268. tours: JSON.parse(
  269. JSON.stringify(app.TourManager.tours, (key, val) => {
  270. if (key === "audio") {
  271. return null;
  272. } else {
  273. return val;
  274. }
  275. })
  276. ),
  277. });
  278. });
  279. app.store.on("floorcad", (floor) => store.commit("scene/loadFloorData", floor));
  280. app.render();
  281. });
  282. </script>
  283. <style lang="scss">
  284. .tab-layer {
  285. width: 100%;
  286. text-align: center;
  287. display: flex;
  288. justify-content: center;
  289. align-items: center;
  290. z-index: 10;
  291. position: fixed;
  292. left: 50%;
  293. transform: translateX(-50%);
  294. top: 2.3rem;
  295. pointer-events: none;
  296. }
  297. .tabs {
  298. pointer-events: auto;
  299. position: relative;
  300. display: flex;
  301. background: #222222;
  302. border-radius: 6px;
  303. padding: 2px;
  304. justify-content: center;
  305. align-items: center;
  306. border: 1px solid rgba(255, 255, 255, 0.1);
  307. box-shadow: inset 0px 0px 6px 0px rgba(0, 0, 0, 0.5);
  308. .background {
  309. position: absolute;
  310. left: 2px;
  311. top: 2px;
  312. bottom: 2px;
  313. width: 50%;
  314. border-radius: 4px;
  315. background: #444444;
  316. box-shadow: 2px 0px 4px 0px rgba(0, 0, 0, 0.3);
  317. z-index: 0;
  318. transition: left 0.3s;
  319. }
  320. span {
  321. flex: 1;
  322. color: #fff;
  323. opacity: 0.5;
  324. border-radius: 6px;
  325. height: 0.94737rem;
  326. font-size: 0.36842rem;
  327. transition: all 0.3s ease;
  328. display: flex;
  329. align-items: center;
  330. justify-content: center;
  331. padding-left: 10px;
  332. padding-right: 10px;
  333. white-space: nowrap;
  334. z-index: 1;
  335. i {
  336. font-size: 0.47368rem;
  337. margin-right: 4px;
  338. pointer-events: none;
  339. }
  340. }
  341. span.active {
  342. opacity: 1;
  343. }
  344. }
  345. [xui_tags_view] {
  346. .tag-body {
  347. /* display: none; */
  348. position: absolute;
  349. left: 50%;
  350. bottom: 50px;
  351. transform: translateX(-50%) scale(0);
  352. transform-origin: bottom;
  353. transition: all 0.3s cubic-bezier(0.35, 0.32, 0.65, 0.63);
  354. // pointer-events: none;
  355. .tag-commodity {
  356. min-width: 230px;
  357. height: 76px;
  358. background: rgba(255, 255, 255, 0.8);
  359. box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.16);
  360. border-radius: 2px;
  361. position: relative;
  362. margin-bottom: 30px;
  363. &::before {
  364. content: "";
  365. display: inline-block;
  366. left: 50%;
  367. transform: translateX(-50%);
  368. width: 2px;
  369. height: 28px;
  370. bottom: -30px;
  371. background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0));
  372. position: absolute;
  373. }
  374. .tag-avatar {
  375. position: absolute;
  376. z-index: 99;
  377. width: 80px;
  378. height: 80px;
  379. background: #ffffff;
  380. box-shadow: 0px 3px 6px 0px rgb(0 0 0 / 16%);
  381. border-radius: 2px;
  382. top: -14px;
  383. left: -12px;
  384. background-size: cover;
  385. pointer-events: none;
  386. }
  387. > p {
  388. color: #131d34;
  389. font-size: 16px;
  390. pointer-events: none;
  391. }
  392. .tag-title {
  393. padding: 10px 10px 10px 76px;
  394. overflow: hidden;
  395. text-overflow: ellipsis;
  396. white-space: nowrap;
  397. width: 240px;
  398. }
  399. .tag-info {
  400. padding: 0 20px 0 76px;
  401. font-size: 12px;
  402. overflow: hidden;
  403. text-overflow: ellipsis;
  404. white-space: nowrap;
  405. }
  406. }
  407. &.show {
  408. transform: translateX(-50%) scale(1);
  409. }
  410. }
  411. .coupon {
  412. width: 64px !important;
  413. height: 64px !important;
  414. &::after {
  415. content: "發現好禮";
  416. width: 100%;
  417. color: #ed5d18;
  418. position: absolute;
  419. bottom: -24px;
  420. text-align: center;
  421. font-size: 14px;
  422. }
  423. }
  424. .waterfall {
  425. width: 70px !important;
  426. height: 70px !important;
  427. }
  428. .applet_link {
  429. width: 64px !important;
  430. height: 64px !important;
  431. border-radius: 50%;
  432. background-color: #fff;
  433. border: 1px solid #ed5d18;
  434. position: relative;
  435. overflow: hidden;
  436. &::after {
  437. content: "直播中";
  438. width: 100%;
  439. height: 20px;
  440. background: #ed5d18;
  441. position: absolute;
  442. bottom: 0;
  443. text-align: center;
  444. line-height: 1.2;
  445. font-size: 12px;
  446. border-radius: 26%;
  447. }
  448. }
  449. }
  450. @media (orientation: landscape) {
  451. .tab-layer {
  452. top: 1.2rem;
  453. .tabs {
  454. height: 0.7rem;
  455. > span {
  456. height: 0.7rem;
  457. font-size: 0.25rem;
  458. }
  459. }
  460. }
  461. }
  462. </style>