Home.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="homepage" v-if="show">
  3. <!-- <div class="clickable" @click="emits('close')"></div> -->
  4. <div id="kr_pano" style="width: 100vw; height: 100vh"></div>
  5. </div>
  6. </template>
  7. <script setup>
  8. import { onMounted, ref, onActivated, watch, nextTick } from "vue";
  9. const krpanoPath = ref(import.meta.env.VITE_KRPANO_DIR);
  10. const props = defineProps({
  11. show: {
  12. type: Boolean,
  13. default: () => true,
  14. },
  15. showKrpano: {
  16. type: Boolean,
  17. default: () => false,
  18. },
  19. });
  20. watch(
  21. () => props.show,
  22. (val) => {
  23. if (val) {
  24. nextTick(() => {
  25. initKrpano();
  26. });
  27. } else {
  28. }
  29. }
  30. );
  31. watch(
  32. () => props.showKrpano,
  33. (val) => {
  34. if (val) {
  35. nextTick(() => {
  36. initKrpano();
  37. });
  38. } else {
  39. }
  40. }
  41. );
  42. const emits = defineEmits(["close"]);
  43. onActivated(() => {});
  44. let krpano = null;
  45. let isHover = false;
  46. const hanlderEvent = () => {
  47. window.enterFDKK = () => {
  48. removepano("kr_pano");
  49. isHover = false;
  50. emits("close");
  51. };
  52. //完成加载
  53. window.LoadedScene = () => {
  54. setTimeout(() => {
  55. // krpano.set("view.hlookat", 5.685878490542688);
  56. // krpano.set("view.vlookat", 27.599464844622442);
  57. }, 0);
  58. };
  59. window.onHotspotOut = () => {
  60. // krpano.set("hotspot[eee].fillcolor", "0xFF6970");
  61. // isHover = false;
  62. };
  63. window.onHotspotHover = () => {
  64. // console.error('onHotspotHover')
  65. // if (!isHover) {
  66. // isHover = true;
  67. // krpano.set("hotspot[eee].fillcolor", "0xFFFFFF");
  68. // }
  69. };
  70. };
  71. const initKrpano = () => {
  72. embedpano({ xml: `${krpanoPath.value}tour.xml?x=${new Date().getTime()}`, target: "kr_pano", id: "krpanoSWFObject", passQueryParameters: true, onready: krpano_onready_callback });
  73. hanlderEvent();
  74. };
  75. const krpano_onready_callback = (krpano_interface) => {
  76. krpano = krpano_interface;
  77. window.krpano = krpano;
  78. };
  79. const track_mouse_interval_callback = () => {
  80. var mx = krpano.get("mouse.x");
  81. var my = krpano.get("mouse.y");
  82. var pnt = krpano.screentosphere(mx, my);
  83. var h = pnt.x;
  84. var v = pnt.y;
  85. console.error('x="' + mx + '" y="' + my + '" ath="' + h.toFixed(2) + '" atv="' + v.toFixed(2) + '"');
  86. };
  87. const track_mouse = () => {
  88. krpano.set("autorotate.enabled", false);
  89. krpano.call("hotspotClicked");
  90. track_mouse_interval_callback();
  91. };
  92. onMounted(() => {
  93. // initKrpano();
  94. });
  95. </script>
  96. <style lang="scss">
  97. .homepage {
  98. width: 100%;
  99. height: 100%;
  100. // background-image: url("/src/assets/shouye.png");
  101. background-position: center center;
  102. background-repeat: no-repeat;
  103. background-size: cover;
  104. position: absolute;
  105. overflow: hidden;
  106. z-index: 2;
  107. top: 0;
  108. left: 0;
  109. display: flex;
  110. justify-content: center;
  111. align-items: center;
  112. user-select: none;
  113. #pano {
  114. width: 100%;
  115. height: 100%;
  116. }
  117. .clickable {
  118. width: 52vw;
  119. height: 65vh;
  120. margin-top: 12vh;
  121. margin-right: 2vw;
  122. margin-right: 4vw;
  123. cursor: pointer;
  124. /* background: rgba(0, 0, 0, 0.5); */
  125. transform: skew(-5deg, -5deg);
  126. }
  127. }
  128. .isMo {
  129. .homepage {
  130. object-fit: scale-down;
  131. }
  132. }
  133. </style>