IndexImage.vue 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div class="index-image">
  3. <img :src="require('@/assets/images/index.png')" class="bg-image" @load="loadBg" />
  4. <div class="index-inner-swiper" :style="swiperItemStyle">
  5. <swiper v-if="showSwiper" :options="swiperOptions">
  6. <swiper-slide class="index-inner-slide">
  7. <img
  8. :src="require('@/assets/images/1home.png')"
  9. alt
  10. @click="$router.push({ name: 'Apartment' })"
  11. />
  12. </swiper-slide>
  13. <swiper-slide class="index-inner-slide">
  14. <img
  15. :src="require('@/assets/images/2home.png')"
  16. alt
  17. @click="$router.push({ name: 'Office' })"
  18. />
  19. </swiper-slide>
  20. </swiper>
  21. </div>
  22. <div class="index-pos-hander" :style="handerStyle">
  23. <img :src="require('@/assets/images/toLeft.png')" alt />
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'IndexImage',
  30. data() {
  31. return {
  32. showSwiper: false,
  33. swiperOptions: {
  34. autoplay: {
  35. delay: 2500,
  36. disableOnInteraction: false
  37. }
  38. },
  39. swiperItemStyle: {},
  40. handerStyle: {}
  41. }
  42. },
  43. methods: {
  44. loadBg(e) {
  45. const { offsetTop, width, height, naturalWidth, naturalHeight } = e.target
  46. const widthRatio = width / naturalWidth
  47. const heightRatio = height / naturalHeight
  48. this.swiperItemStyle = {
  49. width: `${636 * widthRatio}px`, // 636 是图片原始宽度
  50. height: `${637 * heightRatio}px`, // 637 是图片原始高度
  51. top: `${offsetTop + 1612 * heightRatio}px`,
  52. left: `${352 * widthRatio}px`
  53. }
  54. this.handerStyle = {
  55. top: `${offsetTop + 1800 * heightRatio}px`,
  56. left: `${1020 * widthRatio}px`
  57. }
  58. this.showSwiper = true
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .index-image {
  65. position: relative;
  66. background-color: #1d429d;
  67. width: 100%;
  68. height: 100%;
  69. display: flex;
  70. align-items: center;
  71. overflow: hidden;
  72. .bg-image {
  73. width: 100%;
  74. pointer-events: none;
  75. z-index: 100;
  76. }
  77. .index-inner-swiper {
  78. position: absolute;
  79. .index-inner-slide {
  80. background: transparent;
  81. }
  82. img {
  83. width: 100%;
  84. height: 100%;
  85. }
  86. }
  87. .index-pos-hander {
  88. position: absolute;
  89. z-index: 200;
  90. width: 64px;
  91. height: 56px;
  92. animation: slidefade 2s infinite;
  93. img {
  94. width: 100%;
  95. height: 100%;
  96. }
  97. }
  98. }
  99. </style>