show.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <template v-if="workEnable">
  3. <LoadingLogo />
  4. <Opening
  5. :coverData="coverInfo"
  6. v-if="coverInfo.isShowCover && !hasPasswordLock"
  7. />
  8. <Password @pass="handlePass" />
  9. <Share />
  10. <div class="ui-view-layout" :class="{ show: show }">
  11. <Pano />
  12. <Tags />
  13. <UiGather />
  14. <TitieSlide />
  15. </div>
  16. </template>
  17. <Error v-else />
  18. </template>
  19. <script setup>
  20. import Pano from "@/components/Pano";
  21. import Tags from "@/components/assembly/Tags";
  22. import Password from "@/components/assembly/Password";
  23. import Share from "@/components/assembly/Share";
  24. import Error from "@/components/assembly/Error";
  25. import TitieSlide from "@/components/assembly/titieSlide";
  26. import UiGather from "@/components/UIGather/";
  27. import LoadingLogo from "@/components/assembly/Loading";
  28. import Opening from "@/components/assembly/Opening";
  29. import { createApp } from "@/app";
  30. import { ref, onMounted, computed, watch, nextTick, unref } from "vue";
  31. import { getPanoInfo, checkWork } from "@/apis";
  32. import { useStore } from "vuex";
  33. import config from "@/utils/config";
  34. import browser from "@/utils/browser";
  35. import { useApp } from "@/app";
  36. import { useI18n, getLocale } from "@/i18n";
  37. const { t } = useI18n({ useScope: "global" });
  38. const fixOpening = {
  39. 小行星开场: 1,
  40. 水平巡游开场: 2,
  41. 小行星巡游开场: 3,
  42. 水晶球开场: 4,
  43. 小行星缩放开场: 5,
  44. };
  45. const store = useStore();
  46. const show = ref(false);
  47. const workEnable = ref(true);
  48. const coverInfo = ref({});
  49. const hasPasswordLock = ref(false);
  50. const lang = getLocale();
  51. const currentScene = computed(() => store.getters["scene/currentScene"]);
  52. const currentCatalogRoot = computed(
  53. () => store.getters["scene/currentCatalogRoot"]
  54. );
  55. const isAutoRotate = computed(() => store.getters["functions/isAutoRotate"]);
  56. const earthMask = computed(() => store.getters["scene/earthMask"]);
  57. const skyMask = computed(() => store.getters["scene/skyMask"]);
  58. const isShowOpeningAnimation = ref(0);
  59. onMounted(async () => {
  60. if (browser.isMobile()) {
  61. window.location.href = window.location.href.replace(
  62. "show.html",
  63. "showMobile.html"
  64. );
  65. return;
  66. }
  67. let res = await checkWork();
  68. if (!res.data) {
  69. workEnable.value = res.data;
  70. return;
  71. }
  72. getPanoInfo().then(async (data) => {
  73. isShowOpeningAnimation.value = Number(data.isShowOpeningAnimation);
  74. store.commit("scene/setScenes", data.scenes);
  75. store.commit(
  76. "scene/setPassword",
  77. data.password === "" ? false : data.password
  78. );
  79. if (data.password.length > 0) {
  80. hasPasswordLock.value = true;
  81. }
  82. store.commit("scene/setMetaData", data);
  83. document.title = data.name || t("common.no_title");
  84. let firstScene = "";
  85. if (config.sceneNum) {
  86. firstScene = data.scenes.find(
  87. (item) => item.sceneCode == config.sceneNum
  88. );
  89. } else if (data.firstScene) {
  90. firstScene = data.scenes.find(
  91. (item) => item.sceneCode == data.firstScene.sceneCode
  92. );
  93. }
  94. store.commit("scene/setCurrentScene", firstScene || data.scenes[0]);
  95. // 过滤空分组
  96. let ttt = data.catalogRoot.filter((item) => {
  97. let flag = "";
  98. if (item.children) {
  99. item.children.some((sub) => {
  100. flag = data.scenes.some((son) => {
  101. // console.log(String(son.category).toLowerCase(), String(sub).toLowerCase());
  102. return (
  103. String(son.category).toLowerCase() == String(sub).toLowerCase()
  104. );
  105. });
  106. return flag;
  107. });
  108. }
  109. return flag;
  110. });
  111. data.catalogRoot = ttt;
  112. let catalog = data.catalogs.find(
  113. (item) => item.id == currentScene.value.category
  114. );
  115. // 查询初始场景的所在1级分组
  116. data.catalogRoot.forEach((item) => {
  117. let temp =
  118. item.children && item.children.find((sub) => sub == catalog.id);
  119. if (temp) {
  120. store.commit("scene/setCurrentCatalogRoot", item);
  121. return;
  122. }
  123. });
  124. // 查询初始场景的所在2级分组
  125. store.commit("scene/setCurrentSecondary", catalog);
  126. store.commit("functions/setAutoRotate", !!data.isAuto);
  127. show.value = true;
  128. let isHavePano = data.scenes.some((item) => item.type == "pano");
  129. const app = createApp({
  130. // xml: "%HTMLPATH%/static/template/tour.xml",
  131. xml: `${process.env.VUE_APP_CDN}/720yun_fd_manage/${
  132. config.projectNum
  133. }/tour.xml?rnd=${Math.random()}`,
  134. swf: "%HTMLPATH%/showviewer/lib/krpano/tour.swf",
  135. target: "pano",
  136. html5: "auto",
  137. mobilescale: 1,
  138. isHavePano,
  139. vars: {
  140. startscene: "scene_" + currentScene.value.sceneCode,
  141. "view.vlookat": currentScene.value.initVisual
  142. ? currentScene.value.initVisual.vlookat
  143. : 0,
  144. "view.hlookat": currentScene.value.initVisual
  145. ? currentScene.value.initVisual.hlookat
  146. : 0,
  147. "autorotate.enabled": !!data.isAuto,
  148. "skin_settings.littleplanetintro":
  149. fixOpening[data.openingAnimationType || "小行星开场"],
  150. "skin_settings.lptswitch": unref(isShowOpeningAnimation),
  151. },
  152. passQueryParameters: true,
  153. });
  154. console.log("gemer", currentScene.value.icon);
  155. coverInfo.value = data.coverInfo || {};
  156. app.Scene.lock();
  157. //如果不需要开场封面就直接渲染
  158. if (!coverInfo.value?.isShowCover) {
  159. app.render();
  160. }
  161. if (isHavePano) {
  162. app.Scene.on("sceneReady", () => {
  163. if (app.krpanoDom) {
  164. let defaultMask = `%SWFPATH%/skin/masking_${lang}.png`;
  165. if (earthMask.value) {
  166. app.krpanoDom.set(`hotspot[nadirlogo].url`, defaultMask);
  167. app.krpanoDom.set(
  168. `hotspot[nadirlogo].visible`,
  169. earthMask.value.isShow
  170. );
  171. if (earthMask.value.icon) {
  172. app.krpanoDom.set(`hotspot[nadirlogo].url`, earthMask.value.icon);
  173. }
  174. }
  175. if (skyMask.value) {
  176. app.krpanoDom.set(`hotspot[peaklogo].url`, defaultMask);
  177. app.krpanoDom.set(
  178. `hotspot[peaklogo].visible`,
  179. skyMask.value.isShow
  180. );
  181. if (skyMask.value.icon) {
  182. app.krpanoDom.set(`hotspot[peaklogo].url`, skyMask.value.icon);
  183. }
  184. }
  185. app.krpanoDom.set(
  186. `layer[webvr_exitbutton].html`,
  187. t("common.exit_vr")
  188. );
  189. }
  190. let hotspots = [];
  191. if (currentScene.value.someData) {
  192. hotspots =
  193. typeof currentScene.value.someData == "string"
  194. ? JSON.parse(currentScene.value.someData).hotspots
  195. : currentScene.value.someData.hotspots;
  196. }
  197. console.log(hotspots, "hotspots");
  198. app.Tags.initHotspot(hotspots, false);
  199. });
  200. }
  201. });
  202. });
  203. const handlePass = () => {
  204. hasPasswordLock.value = false;
  205. };
  206. </script>
  207. <style lang="scss" scoped>
  208. .ui-view-layout {
  209. position: relative;
  210. }
  211. </style>