123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- <template>
- <LoadingLogo v-if="workEnable" />
- <template v-if="workEnable">
- <Opening :coverData="coverInfo" v-if="coverInfo.isShowCover && !hasPasswordLock" />
- <Password @pass="handlePass" />
- <Share />
- <div class="ui-view-layout" :class="{ show: show }">
- <Pano />
- <Tags />
- <UiGather />
- <TitieSlide />
- </div>
- </template>
- <Error v-else />
- </template>
- <script setup>
- import Pano from "@/components/Pano";
- import Tags from "@/components/assembly/MobileTags";
- import Password from "@/components/assembly/Password";
- import Share from "@/components/assembly/Share";
- import Error from "@/components/assembly/Error";
- import UiGather from "@/components/UIGather/mobile";
- import TitieSlide from "@/components/assembly/titieSlide";
- import Opening from "@/components/assembly/OpeningMobile";
- import LoadingLogo from "@/components/assembly/Loading";
- import { createApp } from "@/app";
- import { ref, onMounted, computed, unref, onBeforeMount, watch, nextTick } from "vue";
- import { getPanoInfo, checkWork, exchangeId, getWorkInfo } from "@/apis";
- import { useStore } from "vuex";
- import config from "@/utils/config";
- import browser from "@/utils/browser";
- import { useApp } from "@/app";
- import { useWxShared } from "@/hooks/useWxshared";
- import { useAudio } from "@/hooks/useAudio";
- import { useI18n, getLocale } from "@/i18n";
- import { Dialog } from "@/global_components";
- import { debounce } from "lodash";
- const _ = window.ResizeObserver;
- window.ResizeObserver = class ResizeObserver extends _ {
- constructor(callback) {
- callback = debounce(callback, 100);
- super(callback);
- }
- };
- const { t } = useI18n({ useScope: "global" });
- const { initWxShare } = useWxShared();
- const coverInfo = ref({});
- const store = useStore();
- const show = ref(false);
- const workEnable = ref(true);
- const lang = getLocale();
- const hasPasswordLock = ref(false);
- const currentScene = computed(() => store.getters["scene/currentScene"]);
- const currentCatalogRoot = computed(() => store.getters["scene/currentCatalogRoot"]);
- const isAutoRotate = computed(() => store.getters["functions/isAutoRotate"]);
- const hotspots = computed(() => store.getters["tags/hotspots"]);
- const earthMask = computed(() => store.getters["scene/earthMask"]);
- const skyMask = computed(() => store.getters["scene/skyMask"]);
- const isShowOpeningAnimation = ref(0);
- onBeforeMount(() => {
- const vlog = browser.getURLParam("vlog");
- // if (vlog) {
- var vConsole = new window.VConsole();
- // }
- });
- onMounted(async () => {
- if (!browser.isMobile()) {
- window.location.href = window.location.href.replace("showMobile.html", "show.html");
- return;
- }
- const idRes = await exchangeId({
- id: config.projectNum,
- });
- const { id, num, calcStatus } = idRes.data;
- config.projectNum = id;
- if (calcStatus === 0) {
- Dialog.alert({
- title: t("common.tips"),
- content: t("common.calcing"),
- okText: t("common.confirm"),
- });
- return;
- }
- let res = await checkWork();
- if (!res.data) {
- workEnable.value = res.data;
- return;
- }
- // getPanoInfo().then(async (data) => {
- getWorkInfo().then(async (res) => {
- let data = res.data;
- let { workOpeningAnimation, work, navigationTrees, workVisualAngleList, workCustomMaskList, workHotList } = data;
- store.commit("tags/setData", { hotspots: workHotList });
- isShowOpeningAnimation.value = workOpeningAnimation.isShowOpeningAnimation ? Number(workOpeningAnimation.isShowOpeningAnimation) : 0;
- //TODO 兼容1.2.0或以下数据
- if (!("isShowOpeningAnimation" in workOpeningAnimation) && "openingAnimationType" in workOpeningAnimation && workOpeningAnimation.openingAnimationType.length > 0) {
- console.log("小行星没有开关,但有openingAnimationType强制开启");
- isShowOpeningAnimation.value = 1;
- }
- let scenes = [];
- navigationTrees.forEach((item) => {
- item.children.forEach((s_item) => {
- if (s_item.type != "group") {
- scenes.push(s_item);
- }
- s_item.children.forEach((t_item) => {
- if (t_item.type != "group") {
- scenes.push(t_item);
- }
- });
- });
- });
- store.commit("scene/setScenes", scenes);
- store.commit("scene/setPassword", work.password === "" ? false : work.password);
- if (work.password.length > 0) {
- hasPasswordLock.value = true;
- }
- store.commit("scene/setMetaData", data);
- // document.title = data.name || t("common.no_title");
- let firstScene = "";
- if (config.sceneNum) {
- firstScene = scenes.find((item) => item.sceneCode == config.sceneNum);
- } else if (data.firstScene) {
- firstScene = scenes.find((item) => item.sceneCode == data.firstScene.sceneCode);
- }
- // 所有audio入口
- const currentSceneData = firstScene || scenes[0];
- // debugger;
- store.dispatch("audio/initNormalBGM", data.workBackgroundMusic ? data.workBackgroundMusic.ossPath : "");
- store.commit("scene/setCurrentScene", currentSceneData);
- let activeScene = null;
- navigationTrees.forEach((item, index) => {
- activeScene = item.children.find((pano) => pano.id == currentSceneData.id);
- if (activeScene) {
- store.commit("scene/setCurrentScenesList", item.children);
- store.commit("scene/setData", { currentSecondId: null, currentRootId: item.id });
- // throw new Error("LoopTerminated");
- }
- item = item.children.forEach((s_item, s_index) => {
- activeScene = s_item.children.find((pano) => pano.id == currentSceneData.id);
- if (activeScene) {
- store.commit("scene/setCurrentScenesList", s_item.children);
- store.commit("scene/setData", { currentSecondId: s_item.id, currentRootId: item.id });
- // throw new Error("LoopTerminated");
- }
- s_item = s_item.children.forEach((t_item, t_index) => {
- activeScene = t_item.children.find((pano) => pano.id == currentSceneData.id);
- if (activeScene) {
- store.commit("scene/setCurrentScenesList", s_item.children);
- store.commit("scene/setData", { currentSecondId: s_item.id, currentRootId: item.id });
- // throw new Error("LoopTerminated");
- }
- });
- });
- });
- // // 过滤空分组
- // let ttt = data.catalogRoot.filter((item) => {
- // let flag = "";
- // if (item.children) {
- // item.children.some((sub) => {
- // flag = data.scenes.some((son) => {
- // // console.log(String(son.category).toLowerCase(), String(sub).toLowerCase());
- // return String(son.category).toLowerCase() == String(sub).toLowerCase();
- // });
- // return flag;
- // });
- // }
- // return flag;
- // });
- // data.catalogRoot = ttt;
- // let catalog = data.catalogs.find((item) => item.id == currentScene.value.category);
- // // 查询初始场景的所在1级分组
- // data.catalogRoot.forEach((item) => {
- // let temp = item.children && item.children.find((sub) => sub == catalog.id);
- // if (temp) {
- // store.commit("scene/setCurrentCatalogRoot", item);
- // return;
- // }
- // });
- // // 查询初始场景的所在2级分组
- // store.commit("scene/setCurrentSecondary", catalog);
- store.commit("functions/setAutoRotate", !!work.isAuto);
- show.value = true;
- let isHavePano = scenes.some((item) => item.type == "pano");
- let currnetVisual = workVisualAngleList.find((item) => item.navigationId == currentScene.value.id);
- document.body.setAttribute("is-mobile", true);
- const app = createApp({
- // xml: "%HTMLPATH%/static/template/tour.xml",
- xml: `${process.env.VUE_APP_CDN}/720yun_fd_manage/${config.projectNum}/tour.xml?rnd=${Math.random()}`,
- swf: "%HTMLPATH%/showviewer/lib/krpano/tour.swf",
- target: "pano",
- html5: "auto",
- mobilescale: 1,
- isHavePano,
- vars: {
- startscene: "scene_" + currentScene.value.sceneCode,
- "view.org_vlookat": currnetVisual ? currnetVisual.vlookat : 0,
- "view.org_hlookat": currnetVisual ? currnetVisual.hlookat : 0,
- "autorotate.enabled": !!work.isAuto,
- "skin_settings.littleplanetintro": typeof workOpeningAnimation.openingAnimationType === "number" ? workOpeningAnimation.openingAnimationType : 1,
- "skin_settings.lptswitch": unref(isShowOpeningAnimation),
- },
- passQueryParameters: true,
- });
- if (app) {
- coverInfo.value = data.workCoverType || {};
- app.Scene.lock();
- //如果不需要开场封面就直接渲染
- if (!coverInfo.value?.isShowCover) {
- app.render();
- }
- if (isHavePano) {
- app.Scene.on("sceneReady", () => {
- if (app.krpanoDom) {
- // const { sky, earth } = currentScene.value.customMask;
- let customMask = workCustomMaskList.find((item) => item.navigationId == currentScene.value.id);
- const { sky, earth } = customMask.data;
- handleMasksUpdate(sky, earth, app);
- app.krpanoDom.set(`layer[webvr_exitbutton].html`, t("common.exit_vr"));
- }
- console.error("sceneReady");
- // let hotspots = [];
- // if (currentScene.value.someData) {
- // hotspots = typeof currentScene.value.someData == "string" ? JSON.parse(currentScene.value.someData).hotspots : currentScene.value.someData.hotspots;
- // }
- let currentHotspots = hotspots.value.filter((item) => item.navigationId == currentScene.value.id);
- console.error("currentHotspots", currentHotspots);
- if (currentHotspots.length) {
- app.Tags.initHotspot(currentHotspots, false);
- }
- handleVisualLimit(app, currentScene.value);
- });
- }
- initWxShare(lang);
- // debugger
- console.log("初始化微信分享");
- const { initDefaultAudio } = useAudio();
- initDefaultAudio();
- }
- });
- });
- const handlePass = () => {
- hasPasswordLock.value = false;
- };
- const handleVisualLimit = (app, currentScene) => {
- // const { vlookatmax, vlookatmin } = currentScene.initVisual;
- // console.log('initVisual',currentScene.initVisual)
- let currnetVisual = workVisualAngleList.forEach((item) => item.navigationId == currentScene.value.id);
- app.krpanoDom.set(`view.limitview`, "lookat");
- app.krpanoDom.set(`view.vlookatmin`, currnetVisual.vlookatmin || -90);
- app.krpanoDom.set(`view.vlookatmax`, currnetVisual.vlookatmax || 90);
- };
- const handleMasksUpdate = (skyMask, earthMask, app) => {
- const lang = getLocale();
- let defaultMask = `%SWFPATH%/skin/masking_${lang}.png`;
- if (skyMask) {
- if ("isShow" in skyMask) {
- app.krpanoDom.set(`hotspot[peaklogo].visible`, Boolean(skyMask.isShow));
- }
- if (skyMask.icon) {
- app.krpanoDom.set(`hotspot[peaklogo].url`, skyMask.icon + "?x-oss-process=image/resize,w_1000");
- } else {
- app.krpanoDom.set(`hotspot[peaklogo].url`, defaultMask);
- }
- if ("scale" in skyMask) {
- app.krpanoDom.set(`hotspot[peaklogo].scale`, skyMask.scale);
- }
- if ("antidistorted" in skyMask) {
- app.krpanoDom.set(`hotspot[peaklogo].distorted`, skyMask.antidistorted);
- if (!skyMask.antidistorted) {
- app.krpanoDom.set(`hotspot[peaklogo].scale`, skyMask.scale * 1.5);
- }
- }
- }
- if (earthMask) {
- if ("isShow" in earthMask) {
- app.krpanoDom.set(`hotspot[nadirlogo].visible`, Boolean(earthMask.isShow));
- }
- if (earthMask.icon) {
- app.krpanoDom.set(`hotspot[nadirlogo].url`, earthMask.icon + "?x-oss-process=image/resize,w_1000");
- }
- if ("scale" in earthMask) {
- app.krpanoDom.set(`hotspot[nadirlogo].scale`, earthMask.scale);
- }
- if ("antidistorted" in earthMask) {
- app.krpanoDom.set(`hotspot[nadirlogo].distorted`, earthMask.antidistorted);
- if (!earthMask.antidistorted) {
- app.krpanoDom.set(`hotspot[nadirlogo].scale`, earthMask.scale * 1.5);
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .ui-view-layout {
- position: relative;
- z-index: 0;
- }
- </style>
|