app.vue 18 KB

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