app.vue 19 KB

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