app.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. scene: {
  216. markerOpacity: 1,
  217. markerURL: "https://eurs3.4dkankan.com/cdf/file/43aa29799bfd472298a47cc6370b10cc.png",
  218. pathEndColor: "#FF4641",
  219. },
  220. });
  221. app.use("MinMap", { theme: { camera_fillStyle: "#ED5D18" } });
  222. app.use("Tag");
  223. app
  224. .use("TagView", {
  225. render(data) {
  226. if (data.type == "waterfall") {
  227. return `<span class="tag-icon waterfall animate" style="background-image:url({{icon}})"></span>`;
  228. } else if (data.type == "coupon") {
  229. return `<span class="tag-icon coupon animate" style="background-image:url({{icon}})"></span>`;
  230. } else if (data.type == "applet_link") {
  231. try {
  232. data.hotContent = JSON.parse(data.hotContent);
  233. } catch (error) {}
  234. return `<span class="tag-icon applet_link animate" style="background-image:url(${
  235. data.hotContent.liveIcon.src ? common.changeUrl(data.hotContent.liveIcon.src) : "{{icon}}"
  236. })"></span>`;
  237. } else if (data.type == "link_scene") {
  238. return `<span class="tag-icon animate" style="background-image:url({{icon}})"></span>
  239. <div class="tag-body">
  240. <div data-id="${data.sid}" class="tag-commodity tag-link_scene">
  241. <p class="tag-title">點擊前往下一個區域</p>
  242. </div>
  243. </div>
  244. `;
  245. } else if (data.type == "commodity") {
  246. let arr = data.products.map((item) => item.price);
  247. let priceMin = isFinite(Math.min.apply(null, arr)) ? Math.min.apply(null, arr) : 0;
  248. let priceMax = isFinite(Math.max.apply(null, arr)) ? Math.max.apply(null, arr) : 0;
  249. let price = priceMin == priceMax ? priceMax : `${priceMin}-${priceMax}`;
  250. let range = `${data.products[0] ? data.products[0].symbol : "MOP$"} ${price}`;
  251. return `<span class="tag-icon animate" style="background-image:url({{icon}})"></span>
  252. <div class="tag-body">
  253. <div data-id="${data.sid}" class="tag-commodity">
  254. <div style="background-image:url(${data.products[0] ? data.products[0].pic : ""})" class='tag-avatar'>
  255. </div>
  256. <p class="tag-title">${data.title}</p>
  257. <p class="tag-info">${range} | 查看 ></p>
  258. </div>
  259. </div>
  260. `;
  261. } else {
  262. return `<span class="tag-icon animate" style="background-image:url({{icon}})"></span>`;
  263. }
  264. },
  265. })
  266. .then((view) => {
  267. view.on("click", (e) => {
  268. var tag = e.data;
  269. // 聚焦當前點擊的熱點
  270. view.focus(tag.sid).then(() => {
  271. if (tag.type == "coupon") {
  272. try {
  273. document.querySelector(`[data-tag-id="${tag.sid}"] .tag-icon`).style.display = 'none'
  274. let hotcontent = JSON.parse(tag.hotContent);
  275. browser.openLink(
  276. "/subPackage/pages/activity/activity?pageId=" + hotcontent.couponLink,
  277. `https://m.cdfmembers.com/shop/600667208/showactivity?pageId=${hotcontent.couponLink}`,
  278. `/pages/showactivity/showactivity?pageId=${hotcontent.couponLink}`
  279. );
  280. apis.burying_point({ type: 2 });
  281. } catch (error) {}
  282. } else if (tag.type == "waterfall") {
  283. store.commit("tag/setTagClickType", {
  284. type: "waterfall",
  285. data: tag,
  286. });
  287. } else if (tag.type == "applet_link") {
  288. browser.openLink(tag.hotContent.liveLink);
  289. } else if (tag.type == "link_scene") {
  290. let sceneFirstView = tag.hotContent.sceneFirstView;
  291. window.location.href = jumpNewScene(sceneFirstView);
  292. }
  293. });
  294. });
  295. view.on("focus", (e) => {
  296. document.querySelectorAll("[xui_tags_view] >div").forEach((el) => {
  297. if (el.getAttribute("data-tag-type") == "link_scene" || el.getAttribute("data-tag-type") == "commodity") {
  298. el.querySelector(".tag-body").classList.remove("show");
  299. el.style.zIndex = "auto";
  300. }
  301. });
  302. if (e.data.type == "commodity" || e.data.type == "link_scene") {
  303. e.target.style.zIndex = "999";
  304. e.target.querySelector(".tag-body").classList.add("show");
  305. e.target.querySelector(".tag-commodity").removeEventListener("click", onClickTagInfo);
  306. e.target.querySelector(".tag-commodity").addEventListener("click", onClickTagInfo);
  307. if (tagid) {
  308. document.querySelector(`[data-id="${tagid}"]`) && document.querySelector(`[data-id="${tagid}"]`).click();
  309. tagid = null;
  310. }
  311. }
  312. });
  313. view.on("rendered", (e) => {
  314. tagid && view.focus(tagid);
  315. }); //dom渲染完成
  316. });
  317. app.use("TourPlayer");
  318. // if (!hadVideo.value) {
  319. // app.Scene.lock();
  320. // }
  321. app.Scene.on("ready", () => {
  322. show.value = true;
  323. });
  324. app.Scene.on("loaded", (pano) => {
  325. refMiniMap.value = "[xui_min_map]";
  326. store.commit("setFloorId", pano.floorIndex);
  327. app.resource.tags(`${process.env.VUE_APP_RESOURCE_URL}cdf/hot/${browser.getURLParam("m")}/hot.json?rnd=${Math.random()}`);
  328. useMusicPlayer();
  329. });
  330. app.Scene.on("panorama.videorenderer.resumerender", () => {
  331. musicPlayer.pause(true);
  332. });
  333. app.Scene.on("panorama.videorenderer.suspendrender", async () => {
  334. let player = await getApp().TourManager.player;
  335. if (!player.isPlaying) {
  336. musicPlayer.resume();
  337. }
  338. });
  339. app.store.on("metadata", (metadata) => {
  340. store.commit("scene/load", metadata);
  341. if (!metadata.controls.showMap) {
  342. app.MinMap.hide(true);
  343. }
  344. dataLoaded.value = true;
  345. });
  346. app.store.on("tags", (tags) => {
  347. store.commit("tag/load", tags);
  348. });
  349. app.Camera.on("mode.beforeChange", ({ fromMode, toMode, floorIndex }) => {
  350. if (fromMode) {
  351. store.commit("setFlying", true);
  352. }
  353. });
  354. app.Camera.on("mode.afterChange", ({ toMode, floorIndex }) => {
  355. store.commit("setFlying", false);
  356. });
  357. app.Camera.on("flying.started", (pano) => {
  358. store.commit("setFlying", true);
  359. });
  360. app.Camera.on("flying.ended", ({ targetPano }) => {
  361. store.commit("setFlying", false);
  362. store.commit("setPanoId", targetPano.id);
  363. if (app.Scene.isCurrentPanoHasVideo) {
  364. apis.burying_point({ type: 5 });
  365. }
  366. });
  367. app.Camera.on("pano.chosen", (pano) => {
  368. apis.burying_point({ type: 4 });
  369. });
  370. app.store.on("tour", async (tour) => {
  371. app.TourManager.load(tour);
  372. store.commit("tour/setData", {
  373. tours: JSON.parse(
  374. JSON.stringify(app.TourManager.tours, (key, val) => {
  375. if (key === "audio") {
  376. return null;
  377. } else {
  378. return val;
  379. }
  380. })
  381. ),
  382. });
  383. store.commit("tour/setBackUp", {
  384. tours: JSON.parse(
  385. JSON.stringify(app.TourManager.tours, (key, val) => {
  386. if (key === "audio") {
  387. return null;
  388. } else {
  389. return val;
  390. }
  391. })
  392. ),
  393. });
  394. });
  395. app.store.on("floorcad", (floor) => store.commit("scene/loadFloorData", floor));
  396. app.render();
  397. document.removeEventListener("visibilitychange", visibilitychangeFn);
  398. document.addEventListener("visibilitychange", visibilitychangeFn);
  399. if (browser.detectWeixin()) {
  400. //ios的ua中无miniProgram,但都有MicroMessenger(表示是微信浏览器)
  401. wx.miniProgram.getEnv((res) => {
  402. if (res.miniprogram) {
  403. window.removeEventListener("hashchange", hashchangefn);
  404. window.addEventListener("hashchange", hashchangefn);
  405. }
  406. });
  407. }
  408. });
  409. </script>
  410. <style lang="scss">
  411. .tab-layer {
  412. width: 100%;
  413. text-align: center;
  414. display: flex;
  415. justify-content: center;
  416. align-items: center;
  417. z-index: 10;
  418. position: fixed;
  419. left: 50%;
  420. transform: translateX(-50%);
  421. top: 2.3rem;
  422. pointer-events: none;
  423. }
  424. .tabs {
  425. pointer-events: auto;
  426. position: relative;
  427. display: flex;
  428. background: #222222;
  429. border-radius: 6px;
  430. padding: 2px;
  431. justify-content: center;
  432. align-items: center;
  433. border: 1px solid rgba(255, 255, 255, 0.1);
  434. box-shadow: inset 0px 0px 6px 0px rgba(0, 0, 0, 0.5);
  435. .background {
  436. position: absolute;
  437. left: 2px;
  438. top: 2px;
  439. bottom: 2px;
  440. width: 50%;
  441. border-radius: 4px;
  442. background: #444444;
  443. box-shadow: 2px 0px 4px 0px rgba(0, 0, 0, 0.3);
  444. z-index: 0;
  445. transition: left 0.3s;
  446. }
  447. span {
  448. flex: 1;
  449. color: #fff;
  450. opacity: 0.5;
  451. border-radius: 6px;
  452. height: 0.94737rem;
  453. font-size: 0.36842rem;
  454. transition: all 0.3s ease;
  455. display: flex;
  456. align-items: center;
  457. justify-content: center;
  458. padding-left: 10px;
  459. padding-right: 10px;
  460. white-space: nowrap;
  461. z-index: 1;
  462. i {
  463. font-size: 0.47368rem;
  464. margin-right: 4px;
  465. pointer-events: none;
  466. }
  467. }
  468. span.active {
  469. opacity: 1;
  470. }
  471. }
  472. [xui_tags_view] {
  473. .tag-body {
  474. /* display: none; */
  475. position: absolute;
  476. left: 50%;
  477. bottom: 50px;
  478. transform: translateX(-50%) scale(0);
  479. transform-origin: bottom;
  480. transition: all 0.3s cubic-bezier(0.35, 0.32, 0.65, 0.63);
  481. // pointer-events: none;
  482. .tag-commodity,
  483. .tag-link_scene {
  484. min-width: 230px;
  485. height: 76px;
  486. background: rgba(255, 255, 255, 0.8);
  487. box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.16);
  488. border-radius: 2px;
  489. position: relative;
  490. margin-bottom: 30px;
  491. &::before {
  492. content: "";
  493. display: inline-block;
  494. left: 50%;
  495. transform: translateX(-50%);
  496. width: 2px;
  497. height: 28px;
  498. bottom: -30px;
  499. background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0));
  500. position: absolute;
  501. }
  502. .tag-avatar {
  503. position: absolute;
  504. z-index: 99;
  505. width: 80px;
  506. height: 80px;
  507. background: #ffffff;
  508. box-shadow: 0px 3px 6px 0px rgb(0 0 0 / 16%);
  509. border-radius: 2px;
  510. top: -14px;
  511. left: -12px;
  512. background-size: cover;
  513. pointer-events: none;
  514. }
  515. > p {
  516. color: #131d34;
  517. font-size: 16px;
  518. pointer-events: none;
  519. }
  520. .tag-title {
  521. padding: 10px 10px 10px 76px;
  522. overflow: hidden;
  523. text-overflow: ellipsis;
  524. white-space: nowrap;
  525. width: 240px;
  526. }
  527. .tag-info {
  528. padding: 0 20px 0 76px;
  529. font-size: 12px;
  530. overflow: hidden;
  531. text-overflow: ellipsis;
  532. white-space: nowrap;
  533. }
  534. }
  535. &.show {
  536. transform: translateX(-50%) scale(1);
  537. }
  538. .tag-link_scene {
  539. height: auto;
  540. min-width: unset;
  541. .tag-title {
  542. padding: 10px;
  543. width: auto;
  544. text-align: center;
  545. }
  546. }
  547. }
  548. .coupon {
  549. width: 84px !important;
  550. height: 84px !important;
  551. &::after {
  552. content: "發現好禮";
  553. width: 100%;
  554. color: #ed5d18;
  555. position: absolute;
  556. bottom: -24px;
  557. text-align: center;
  558. font-size: 14px;
  559. }
  560. }
  561. .waterfall {
  562. width: 90px !important;
  563. height: 90px !important;
  564. }
  565. .applet_link {
  566. width: 64px !important;
  567. height: 64px !important;
  568. border-radius: 50%;
  569. background-color: #fff;
  570. border: 1px solid #ed5d18;
  571. position: relative;
  572. overflow: hidden;
  573. &::after {
  574. content: "直播中";
  575. width: 100%;
  576. height: 20px;
  577. background: #ed5d18;
  578. position: absolute;
  579. bottom: 0;
  580. text-align: center;
  581. line-height: 1.2;
  582. font-size: 12px;
  583. border-radius: 26%;
  584. }
  585. }
  586. }
  587. @media (orientation: landscape) {
  588. .tab-layer {
  589. top: 1.2rem;
  590. .tabs {
  591. height: 0.7rem;
  592. > span {
  593. height: 0.7rem;
  594. font-size: 0.25rem;
  595. }
  596. }
  597. }
  598. }
  599. </style>