index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="home">
  3. <ul class="home-menu">
  4. <li
  5. v-for="index in 4"
  6. :key="index"
  7. class="home-menu-item"
  8. :style="{
  9. backgroundImage: `url(${
  10. mIndex === index - 1
  11. ? MIMAGES[index - 1].active
  12. : MIMAGES[index - 1].default
  13. })`,
  14. }"
  15. @click="handleMenu(index)"
  16. />
  17. </ul>
  18. <div class="map">
  19. <div
  20. v-for="(item, index) in POINTS"
  21. :key="index"
  22. :class="[`map-point point-${index + 1}`, { active: pIndex === index }]"
  23. @click="pIndex === index ? (pIndex = -1) : (pIndex = index)"
  24. >
  25. <img :src="item.img2" />
  26. <transition name="slide-fade">
  27. <div
  28. v-if="pIndex === index"
  29. class="point-popup"
  30. :class="{ 'has-btn': index === 2 || index === 0 || index === 3 }"
  31. >
  32. <img class="point-popup__title" :src="POINTS[pIndex].img" />
  33. <el-scrollbar scroll-y class="point-popup-scrollbar">
  34. <div
  35. class="point-popup__content"
  36. v-html="POINTS[pIndex].content"
  37. />
  38. </el-scrollbar>
  39. <div
  40. v-if="index === 3"
  41. class="point-popup__btn"
  42. @click="$router.push({ name: 'step4Detail' })"
  43. >
  44. 小岔沟
  45. </div>
  46. <div
  47. v-if="index === 2"
  48. class="point-popup__btn"
  49. @click="$router.push({ name: 'step3Detail' })"
  50. >
  51. 青石嘴战役
  52. </div>
  53. <div
  54. v-if="index === 0"
  55. class="point-popup__btn"
  56. @click="$router.push({ name: 'step1Detail' })"
  57. >
  58. 单家集的灯火
  59. </div>
  60. </div>
  61. </transition>
  62. </div>
  63. </div>
  64. <div class="home-tab">
  65. <div class="story" @click="$router.push({ name: 'story' })" />
  66. <div class="biographies" @click="biographiesVisible = true" />
  67. </div>
  68. </div>
  69. <Biographies v-model:visible="biographiesVisible" />
  70. <SharePopup v-model:visible="shareVisible" />
  71. </template>
  72. <script setup>
  73. import { ref } from "vue";
  74. import { POINTS, MIMAGES } from "./constants";
  75. import Biographies from "./components/Biographies/index.vue";
  76. import { useRouter } from "vue-router";
  77. import SharePopup from "./components/SharePopup.vue";
  78. const router = useRouter();
  79. const mIndex = ref(-1);
  80. const pIndex = ref(-1);
  81. const shareVisible = ref(false);
  82. const biographiesVisible = ref(false);
  83. const handleMenu = (index) => {
  84. const item = MIMAGES[index - 1];
  85. if (item.routeName) {
  86. router.push({ name: item.routeName, query: item.query });
  87. } else if (item.href) {
  88. window.location.href = item.href;
  89. } else if (item.type === "share") {
  90. shareVisible.value = true;
  91. }
  92. };
  93. </script>
  94. <style lang="scss" scoped>
  95. @use "./index.scss";
  96. </style>