app.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <template>
  2. <LoadingLogo v-if="hadVideo" :thumb="true" />
  3. <OpenVideo v-else @close="hadVideo = 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 v-if="!isshoppingguide" />
  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" @click="changeMode('dollhouse', $event, 'focus3d')">
  15. <ui-icon type="show_3d_normal"></ui-icon>
  16. 3D模型
  17. </p>
  18. </teleport>
  19. <template v-if="refMiniMap && player.showWidgets">
  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' }" @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' }" @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. <GoodsList @close="closetagtype" />
  38. <Treasure @close="closetagtype" />
  39. <Waterfall @close="closetagtype" />
  40. </template>
  41. <script setup>
  42. import { useMusicPlayer } from "@/utils/sound";
  43. // import UiTags from "@/components/Tags";
  44. import GoodsList from "@/components/Tags/goods-list.vue";
  45. import Treasure from "@/components/Tags/treasure.vue";
  46. import Waterfall from "@/components/Tags/waterfall.vue";
  47. import Information from "@/components/Information";
  48. import Control from "@/components/Controls/Control.Mobile.vue";
  49. import LoadingLogo from "@/components/shared/Loading.vue";
  50. import OpenVideo from "@/components/openVideo/";
  51. import Guide from "@/components/shared/Guide.vue";
  52. import { createApp } from "@/app";
  53. import { ref, onMounted, computed, nextTick, watch } from "vue";
  54. import { useStore } from "vuex";
  55. import browser from "@/utils/browser";
  56. import { useApp, getApp } from "@/app";
  57. import common from "@/utils/common";
  58. import { Cache } from "@/utils/index";
  59. import * as apis from "@/apis/index.js";
  60. const store = useStore();
  61. let jumpNewScene = (sceneFirstView) => {
  62. let url = window.location.href;
  63. if (!browser.hasURLParam("pose")) {
  64. url += `&${sceneFirstView.sceneview}`;
  65. } else {
  66. url = browser.replaceQueryString(url, "pose", sceneFirstView.sceneview.replace("pose=", ""));
  67. }
  68. url = browser.replaceQueryString(url, "m", sceneFirstView.num);
  69. return url;
  70. };
  71. let visibilitychangeFn = () => {
  72. if (browser.isTabHidden()) {
  73. apis.burying_point({ type: 1 });
  74. }
  75. };
  76. let hashchangefn = () => {
  77. if (window.location.hash.indexOf("#showpage") >= 0) {
  78. window.history.go(-1);
  79. }
  80. };
  81. const musicPlayer = useMusicPlayer();
  82. let app = null;
  83. let tagid = browser.getURLParam("tagid");
  84. const closetagtype = () => {
  85. store.commit("tag/setTagClickType", {
  86. type: "",
  87. data: {},
  88. });
  89. };
  90. const tags = computed(() => {
  91. return store.getters["tag/tags"] || [];
  92. });
  93. const isshoppingguide = computed(() => store.getters["shoppingguide"]);
  94. const player = computed(() => store.getters["player"]);
  95. const flying = computed(() => store.getters["flying"]);
  96. const metadata = computed(() => store.getters["scene/metadata"]);
  97. const controls = computed(() => {
  98. return metadata.value.controls;
  99. });
  100. const mode = computed(() => store.getters["mode"]);
  101. const showNavigations = computed(() => store.getters["showNavigations"]);
  102. const scene$ = ref(null);
  103. const hadVideo = ref(true);
  104. if (!Cache.get("HIDENVIDEOEXPIRES")) {
  105. if (browser.getURLParam("m") == "eur-KJ-z5ZEV22AeU" && browser.getURLParam("pose") == "pano:408,qua:-0.006,0.6299,0.0049,0.7766") {
  106. Cache.set("HIDENVIDEOEXPIRES", "yes", 60 * 8 * 60);
  107. hadVideo.value = false;
  108. } else {
  109. hadVideo.value = true;
  110. }
  111. }
  112. const show = ref(false);
  113. const dataLoaded = ref(false);
  114. const refMiniMap = ref(null);
  115. const isCollapse = ref(false);
  116. const background = ref(null);
  117. const resize = () => {
  118. if (this.$refs.background && (this.mode == "floorplan" || this.mode == "dollhouse")) {
  119. this.$nextTick(() => {
  120. let $active = $(this.$el).find(".tabs .active");
  121. background.value.style.width = $active[0].getBoundingClientRect().width + "px";
  122. background.value.style.left = $active.position().left + "px";
  123. });
  124. }
  125. };
  126. // watch(
  127. // () => hadVideo.value,
  128. // (val, old) => {
  129. // if (val) {
  130. // app.Scene.unlock();
  131. // }
  132. // }
  133. // );
  134. watch(
  135. () => player.value.showMap,
  136. (val, old) => {
  137. if (!isCollapse.value) {
  138. let $minmap = document.querySelector("[xui_min_map]");
  139. if ($minmap) {
  140. if (val) {
  141. $minmap.classList.remove("collapse");
  142. } else {
  143. $minmap.classList.add("collapse");
  144. }
  145. }
  146. }
  147. },
  148. {
  149. deep: true,
  150. }
  151. );
  152. watch(
  153. () => player.value.showWidgets,
  154. (val, old) => {
  155. let $minmap = document.querySelector("[xui_min_map]");
  156. if ($minmap) {
  157. if (val) {
  158. $minmap.classList.remove("collapse");
  159. } else {
  160. $minmap.classList.add("collapse");
  161. }
  162. }
  163. },
  164. {
  165. deep: true,
  166. }
  167. );
  168. const changeMode = (name, e, focus3d = false) => {
  169. if (!flying.value) {
  170. let width, left;
  171. store.commit("setMode", name);
  172. nextTick(() => {
  173. if (focus3d) {
  174. let $active = document.querySelector(".tabs>span:last-of-type");
  175. background.value.style.width = $active.getBoundingClientRect().width + "px";
  176. background.value.style.left = $active.offsetLeft + "px";
  177. } else {
  178. background.value.style.width = width || e.srcElement.getBoundingClientRect().width + "px";
  179. background.value.style.left = left || e.srcElement.offsetLeft + "px";
  180. }
  181. });
  182. }
  183. // console.dir(document.querySelector(".tabs>span:last-of-type"));
  184. };
  185. const toggleMap = () => {
  186. isCollapse.value = !isCollapse.value;
  187. let $minmap = document.querySelector("[xui_min_map]");
  188. if ($minmap) {
  189. if (!isCollapse.value) {
  190. $minmap.classList.remove("collapse");
  191. } else {
  192. $minmap.classList.add("collapse");
  193. }
  194. }
  195. };
  196. const onClickTagInfo = (el) => {
  197. el.stopPropagation();
  198. let item = tags.value.find((item) => item.sid == el.target.dataset.id);
  199. if (item.type == "commodity") {
  200. store.commit("tag/setTagClickType", {
  201. type: "goodlist",
  202. data: item,
  203. });
  204. } else if (item.type == "link_scene") {
  205. let sceneFirstView = item.hotContent.sceneFirstView;
  206. window.location.href = jumpNewScene(sceneFirstView);
  207. }
  208. };
  209. onMounted(async () => {
  210. apis.burying_point({ type: 0 });
  211. app = createApp({
  212. num: browser.getURLParam("m"),
  213. dom: scene$.value,
  214. mobile: true,
  215. isLoadTags: false,
  216. scene: {
  217. markerOpacity: 1,
  218. markerURL: "https://eurs3.4dkankan.com/cdf/file/43aa29799bfd472298a47cc6370b10cc.png",
  219. pathEndColor: "#FF4641",
  220. },
  221. });
  222. app.use("MinMap", { theme: { camera_fillStyle: "#ED5D18" } });
  223. app.use("Tag");
  224. app
  225. .use("TagView", {
  226. render(data) {
  227. if (data.type == "waterfall") {
  228. return `<span class="tag-icon waterfall animate" style="background-image:url({{icon}})"></span>`;
  229. } else if (data.type == "coupon") {
  230. return `<span class="tag-icon coupon animate" style="background-image:url({{icon}})"></span>`;
  231. } else if (data.type == "applet_link") {
  232. try {
  233. data.hotContent = JSON.parse(data.hotContent);
  234. } catch (error) {}
  235. return `<span class="tag-icon applet_link animate" style="background-image:url(${
  236. data.hotContent.liveIcon.src ? common.changeUrl(data.hotContent.liveIcon.src) : "{{icon}}"
  237. })"></span>`;
  238. } else if (data.type == "link_scene") {
  239. return `<span class="tag-icon animate" style="background-image:url({{icon}})"></span>
  240. <div class="tag-body">
  241. <div data-id="${data.sid}" class="tag-commodity tag-link_scene">
  242. <p class="tag-title">點擊前往下一個區域</p>
  243. </div>
  244. </div>
  245. `;
  246. } else if (data.type == "commodity") {
  247. let arr = data.products.map((item) => item.price);
  248. let priceMin = isFinite(Math.min.apply(null, arr)) ? Math.min.apply(null, arr) : 0;
  249. let priceMax = isFinite(Math.max.apply(null, arr)) ? Math.max.apply(null, arr) : 0;
  250. let price = priceMin == priceMax ? priceMax : `${priceMin}-${priceMax}`;
  251. let range = `${data.products[0] ? data.products[0].symbol : "MOP$"} ${price}`;
  252. return `<span class="tag-icon animate" style="background-image:url({{icon}})"></span>
  253. <div class="tag-body">
  254. <div data-id="${data.sid}" class="tag-commodity">
  255. <div style="background-image:url(${data.products[0] ? data.products[0].pic : ""})" class='tag-avatar'>
  256. </div>
  257. <p class="tag-title">${data.title}</p>
  258. <p class="tag-info">${range} | 查看 ></p>
  259. </div>
  260. </div>
  261. `;
  262. } else {
  263. return `<span class="tag-icon animate" style="background-image:url({{icon}})"></span>`;
  264. }
  265. },
  266. })
  267. .then((view) => {
  268. view.on("click", (e) => {
  269. var tag = e.data;
  270. // 聚焦當前點擊的熱點
  271. view.focus(tag.sid).then(() => {
  272. if (tag.type == "coupon") {
  273. try {
  274. document.querySelector(`[data-tag-id="${tag.sid}"] .tag-icon`).style.display = "none";
  275. let hotcontent = JSON.parse(tag.hotContent);
  276. browser.openLink(
  277. "/subPackage/pages/activity/activity?pageId=" + hotcontent.couponLink,
  278. `https://m.cdfmembers.com/shop/600667208/showactivity?pageId=${hotcontent.couponLink}`,
  279. `/pages/showactivity/showactivity?pageId=${hotcontent.couponLink}`
  280. );
  281. apis.burying_point({ type: 2 });
  282. } catch (error) {}
  283. } else if (tag.type == "waterfall") {
  284. store.commit("tag/setTagClickType", {
  285. type: "waterfall",
  286. data: tag,
  287. });
  288. } else if (tag.type == "applet_link") {
  289. browser.openLink(tag.hotContent.liveLink);
  290. } else if (tag.type == "link_scene") {
  291. let sceneFirstView = tag.hotContent.sceneFirstView;
  292. window.location.href = jumpNewScene(sceneFirstView);
  293. }
  294. });
  295. });
  296. view.on("focus", (e) => {
  297. document.querySelectorAll("[xui_tags_view] >div").forEach((el) => {
  298. if (el.getAttribute("data-tag-type") == "link_scene" || el.getAttribute("data-tag-type") == "commodity") {
  299. el.querySelector(".tag-body").classList.remove("show");
  300. el.style.zIndex = "auto";
  301. }
  302. });
  303. if (e.data.type == "commodity" || e.data.type == "link_scene") {
  304. e.target.style.zIndex = "999";
  305. e.target.querySelector(".tag-body").classList.add("show");
  306. e.target.querySelector(".tag-commodity").removeEventListener("click", onClickTagInfo);
  307. e.target.querySelector(".tag-commodity").addEventListener("click", onClickTagInfo);
  308. if (tagid) {
  309. document.querySelector(`[data-id="${tagid}"]`) && document.querySelector(`[data-id="${tagid}"]`).click();
  310. tagid = null;
  311. }
  312. }
  313. });
  314. view.on("rendered", (e) => {
  315. tagid && view.focus(tagid);
  316. }); //dom渲染完成
  317. });
  318. app.use("TourPlayer");
  319. // if (!hadVideo.value) {
  320. // app.Scene.lock();
  321. // }
  322. app.Scene.on("ready", () => {
  323. show.value = true;
  324. });
  325. app.Scene.on("loaded", (pano) => {
  326. refMiniMap.value = "[xui_min_map]";
  327. store.commit("setFloorId", pano.floorIndex);
  328. store.commit("rtc/setShowdaogou", true);
  329. if (browser.getURLParam("roomId")) {
  330. store.commit("showShoppingguide", true);
  331. }
  332. app.resource.tags(`${process.env.VUE_APP_RESOURCE_URL}cdf/hot/${browser.getURLParam("m")}/hot.json?rnd=${Math.random()}`);
  333. useMusicPlayer();
  334. });
  335. app.Scene.on("panorama.videorenderer.resumerender", () => {
  336. musicPlayer.pause(true);
  337. });
  338. app.Scene.on("panorama.videorenderer.suspendrender", async () => {
  339. let player = await getApp().TourManager.player;
  340. if (!player.isPlaying) {
  341. musicPlayer.resume();
  342. }
  343. });
  344. app.store.on("metadata", (metadata) => {
  345. store.commit("scene/load", metadata);
  346. if (!metadata.controls.showMap) {
  347. app.MinMap.hide(true);
  348. }
  349. dataLoaded.value = true;
  350. });
  351. app.store.on("tags", (tags) => {
  352. store.commit("tag/load", tags);
  353. });
  354. app.Camera.on("mode.beforeChange", ({ fromMode, toMode, floorIndex }) => {
  355. if (fromMode) {
  356. store.commit("setFlying", true);
  357. }
  358. });
  359. app.Camera.on("mode.afterChange", ({ toMode, floorIndex }) => {
  360. store.commit("setFlying", false);
  361. });
  362. app.Camera.on("flying.started", (pano) => {
  363. store.commit("setFlying", true);
  364. });
  365. app.Camera.on("flying.ended", ({ targetPano }) => {
  366. store.commit("setFlying", false);
  367. store.commit("setPanoId", targetPano.id);
  368. if (app.Scene.isCurrentPanoHasVideo) {
  369. apis.burying_point({ type: 5 });
  370. }
  371. });
  372. app.Camera.on("pano.chosen", (pano) => {
  373. apis.burying_point({ type: 4 });
  374. });
  375. app.store.on("tour", async (tour) => {
  376. app.TourManager.load(tour);
  377. store.commit("tour/setData", {
  378. tours: JSON.parse(
  379. JSON.stringify(app.TourManager.tours, (key, val) => {
  380. if (key === "audio") {
  381. return null;
  382. } else {
  383. return val;
  384. }
  385. })
  386. ),
  387. });
  388. store.commit("tour/setBackUp", {
  389. tours: JSON.parse(
  390. JSON.stringify(app.TourManager.tours, (key, val) => {
  391. if (key === "audio") {
  392. return null;
  393. } else {
  394. return val;
  395. }
  396. })
  397. ),
  398. });
  399. });
  400. app.store.on("floorcad", (floor) => store.commit("scene/loadFloorData", floor));
  401. app.render();
  402. document.removeEventListener("visibilitychange", visibilitychangeFn);
  403. document.addEventListener("visibilitychange", visibilitychangeFn);
  404. if (browser.detectWeixin()) {
  405. //ios的ua中无miniProgram,但都有MicroMessenger(表示是微信浏览器)
  406. wx.miniProgram.getEnv((res) => {
  407. if (res.miniprogram) {
  408. window.removeEventListener("hashchange", hashchangefn);
  409. window.addEventListener("hashchange", hashchangefn);
  410. }
  411. });
  412. }
  413. });
  414. </script>
  415. <style lang="scss">
  416. .tab-layer {
  417. width: 100%;
  418. text-align: center;
  419. display: flex;
  420. justify-content: center;
  421. align-items: center;
  422. z-index: 10;
  423. position: fixed;
  424. left: 50%;
  425. transform: translateX(-50%);
  426. top: 2.3rem;
  427. pointer-events: none;
  428. }
  429. .tabs {
  430. pointer-events: auto;
  431. position: relative;
  432. display: flex;
  433. background: #222222;
  434. border-radius: 6px;
  435. padding: 2px;
  436. justify-content: center;
  437. align-items: center;
  438. border: 1px solid rgba(255, 255, 255, 0.1);
  439. box-shadow: inset 0px 0px 6px 0px rgba(0, 0, 0, 0.5);
  440. .background {
  441. position: absolute;
  442. left: 2px;
  443. top: 2px;
  444. bottom: 2px;
  445. width: 50%;
  446. border-radius: 4px;
  447. background: #444444;
  448. box-shadow: 2px 0px 4px 0px rgba(0, 0, 0, 0.3);
  449. z-index: 0;
  450. transition: left 0.3s;
  451. }
  452. span {
  453. flex: 1;
  454. color: #fff;
  455. opacity: 0.5;
  456. border-radius: 6px;
  457. height: 0.94737rem;
  458. font-size: 0.36842rem;
  459. transition: all 0.3s ease;
  460. display: flex;
  461. align-items: center;
  462. justify-content: center;
  463. padding-left: 10px;
  464. padding-right: 10px;
  465. white-space: nowrap;
  466. z-index: 1;
  467. i {
  468. font-size: 0.47368rem;
  469. margin-right: 4px;
  470. pointer-events: none;
  471. }
  472. }
  473. span.active {
  474. opacity: 1;
  475. }
  476. }
  477. [xui_tags_view] {
  478. .tag-body {
  479. /* display: none; */
  480. position: absolute;
  481. left: 50%;
  482. bottom: 50px;
  483. transform: translateX(-50%) scale(0);
  484. transform-origin: bottom;
  485. transition: all 0.3s cubic-bezier(0.35, 0.32, 0.65, 0.63);
  486. // pointer-events: none;
  487. .tag-commodity,
  488. .tag-link_scene {
  489. min-width: 230px;
  490. height: 76px;
  491. background: rgba(255, 255, 255, 0.8);
  492. box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.16);
  493. border-radius: 2px;
  494. position: relative;
  495. margin-bottom: 30px;
  496. &::before {
  497. content: "";
  498. display: inline-block;
  499. left: 50%;
  500. transform: translateX(-50%);
  501. width: 2px;
  502. height: 28px;
  503. bottom: -30px;
  504. background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0));
  505. position: absolute;
  506. }
  507. .tag-avatar {
  508. position: absolute;
  509. z-index: 99;
  510. width: 80px;
  511. height: 80px;
  512. background: #ffffff;
  513. box-shadow: 0px 3px 6px 0px rgb(0 0 0 / 16%);
  514. border-radius: 2px;
  515. top: -14px;
  516. left: -12px;
  517. background-size: cover;
  518. pointer-events: none;
  519. }
  520. > p {
  521. color: #131d34;
  522. font-size: 16px;
  523. pointer-events: none;
  524. }
  525. .tag-title {
  526. padding: 10px 10px 10px 76px;
  527. overflow: hidden;
  528. text-overflow: ellipsis;
  529. white-space: nowrap;
  530. width: 240px;
  531. }
  532. .tag-info {
  533. padding: 0 20px 0 76px;
  534. font-size: 12px;
  535. overflow: hidden;
  536. text-overflow: ellipsis;
  537. white-space: nowrap;
  538. }
  539. }
  540. &.show {
  541. transform: translateX(-50%) scale(1);
  542. }
  543. .tag-link_scene {
  544. height: auto;
  545. min-width: unset;
  546. .tag-title {
  547. padding: 10px;
  548. width: auto;
  549. text-align: center;
  550. }
  551. }
  552. }
  553. .coupon {
  554. width: 84px !important;
  555. height: 84px !important;
  556. &::after {
  557. content: "發現好禮";
  558. width: 100%;
  559. color: #ed5d18;
  560. position: absolute;
  561. bottom: -24px;
  562. text-align: center;
  563. font-size: 14px;
  564. }
  565. }
  566. .waterfall {
  567. width: 90px !important;
  568. height: 90px !important;
  569. }
  570. .applet_link {
  571. width: 64px !important;
  572. height: 64px !important;
  573. border-radius: 50%;
  574. background-color: #fff;
  575. border: 1px solid #ed5d18;
  576. position: relative;
  577. overflow: hidden;
  578. &::after {
  579. content: "直播中";
  580. width: 100%;
  581. height: 20px;
  582. background: #ed5d18;
  583. position: absolute;
  584. bottom: 0;
  585. text-align: center;
  586. line-height: 1.2;
  587. font-size: 12px;
  588. border-radius: 26%;
  589. }
  590. }
  591. }
  592. @media (orientation: landscape) {
  593. .tab-layer {
  594. top: 1.2rem;
  595. .tabs {
  596. height: 0.7rem;
  597. > span {
  598. height: 0.7rem;
  599. font-size: 0.25rem;
  600. }
  601. }
  602. }
  603. }
  604. </style>