index.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="home">
  3. <VueDraggableResizable
  4. :x="mapX"
  5. :y="mapY"
  6. :w="mapWidth"
  7. :h="mapHeight"
  8. :draggable="true"
  9. :resizable="true"
  10. :handles="[]"
  11. >
  12. <img class="home__map" src="./images/map-min.png" />
  13. <div
  14. v-for="(item, index) in POINTS"
  15. :key="index"
  16. class="home-point"
  17. :class="[{ active: pointIndex === index }, `point${index}`]"
  18. @click="handlePoint(index)"
  19. >
  20. <img :src="item.img2" />
  21. </div>
  22. </VueDraggableResizable>
  23. <ul class="home-menu">
  24. <li v-for="(item, index) in MIMAGES" :key="index">
  25. <img :src="item.default" @click="handleMenu(index)" />
  26. </li>
  27. </ul>
  28. <div class="home-tab">
  29. <div class="story" />
  30. <div class="biographies" @click="$router.push({ name: 'story' })" />
  31. </div>
  32. </div>
  33. <SharePopup v-model:visible="shareVisible" />
  34. <VanPopup
  35. v-model:show="pointDetailVisible"
  36. :overlay="true"
  37. position="bottom"
  38. class="point-panel"
  39. :overlay-style="{
  40. background: 'transparent',
  41. }"
  42. @closed="pointIndex = -1"
  43. >
  44. <template v-if="activePoint">
  45. <div class="point-panel-img">
  46. <img :class="`c${pointIndex}`" :src="activePoint.img" />
  47. </div>
  48. <div class="point-panel-content" v-html="activePoint.content" />
  49. </template>
  50. </VanPopup>
  51. </template>
  52. <script setup>
  53. import { ref, computed } from "vue";
  54. import VueDraggableResizable from "vue-draggable-resizable";
  55. import "vue-draggable-resizable/style.css";
  56. import { POINTS, MIMAGES } from "./constants";
  57. import SharePopup from "@/components/SharePopup.vue";
  58. import { useRouter } from "vue-router";
  59. const mapWidth = window.innerWidth * (1600 / 750);
  60. const mapHeight = window.innerWidth * (1215 / 750);
  61. const mapX = window.innerWidth * (30 / 750);
  62. const mapY = window.innerWidth * (80 / 750);
  63. const router = useRouter();
  64. const pointIndex = ref(-1);
  65. const shareVisible = ref(false);
  66. const pointDetailVisible = ref(false);
  67. const activePoint = computed(() => POINTS[pointIndex.value]);
  68. const handlePoint = (index) => {
  69. pointIndex.value = index;
  70. pointDetailVisible.value = true;
  71. };
  72. const handleMenu = (index) => {
  73. const item = MIMAGES[index];
  74. if (item.routeName) {
  75. router.push({ name: item.routeName, query: item.query });
  76. } else if (item.href) {
  77. window.location.href = item.href;
  78. } else if (item.type === "share") {
  79. shareVisible.value = true;
  80. }
  81. };
  82. </script>
  83. <style lang="scss" scoped>
  84. @use "./index.scss";
  85. </style>