HotspotDetail3.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div class="hotspot-detail-3">
  3. <!-- 阴影 -->
  4. <img
  5. class="shadow-box"
  6. :src="shadow"
  7. :style="{ width: state === 1 ? '50%' : '80%' }"
  8. >
  9. <img
  10. v-show="state == 1"
  11. class="content1"
  12. :src="hots3StateContent1"
  13. alt=""
  14. >
  15. <div
  16. v-show="state == 2"
  17. id="content2"
  18. ref="content2Dom"
  19. class="content2"
  20. >
  21. <img
  22. id="content2Img"
  23. :src="hots3StateContent2"
  24. alt=""
  25. >
  26. </div>
  27. <img
  28. v-show="state == 3"
  29. class="content3"
  30. :src="hots3StateContent3"
  31. alt=""
  32. >
  33. <div class="btns-box">
  34. <img
  35. :src="state == 1 ? hots3StateBtn1 : hots3StateBtn1Ac"
  36. alt=""
  37. @click="state = 1"
  38. >
  39. <img
  40. :src="state == 2 ? hots3StateBtn2 : hots3StateBtn2Ac"
  41. alt=""
  42. @click="goState2"
  43. >
  44. <img
  45. :src="state == 3 ? hots3StateBtn3 : hots3StateBtn3Ac"
  46. alt=""
  47. @click="state = 3"
  48. >
  49. </div>
  50. <BtnBack @click="emit('close')" />
  51. </div>
  52. </template>
  53. <script setup>
  54. import { ref, computed, onMounted } from "vue"
  55. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  56. const emit = defineEmits(['close'])
  57. // 三个背景图
  58. import hots3StateBg1 from '@/assets/images/hots-detail-bg-state1.png'
  59. import hots3StateBg2 from '@/assets/images/hots-detail-bg-state2.png'
  60. import hots3StateBg3 from '@/assets/images/hots-detail-bg-state3.png'
  61. // 三个按钮
  62. import hots3StateBtn1 from '@/assets/images/hots-detail-btn-state1.png'
  63. import hots3StateBtn2 from '@/assets/images/hots-detail-btn-state2.png'
  64. import hots3StateBtn3 from '@/assets/images/hots-detail-btn-state3.png'
  65. import hots3StateBtn1Ac from '@/assets/images/hots-detail-btn-state1-ac.png'
  66. import hots3StateBtn2Ac from '@/assets/images/hots-detail-btn-state2-ac.png'
  67. import hots3StateBtn3Ac from '@/assets/images/hots-detail-btn-state3-ac.png'
  68. // 三个阴影
  69. import hots3StateShadow1 from '@/assets/images/img_shadow_1.png'
  70. import hots3StateShadow2 from '@/assets/images/img_shadow_2.png'
  71. import hots3StateShadow3 from '@/assets/images/img_shadow_3.png'
  72. // 三个内容
  73. import hots3StateContent1 from '@/assets/images/hots-detail-content-state1.png'
  74. import hots3StateContent2 from '@/assets/images/hots-detail-content-state2.png'
  75. import hots3StateContent3 from '@/assets/images/hots-detail-content-state3.png'
  76. const {
  77. windowSizeInCssForRef,
  78. windowSizeWhenDesignForRef,
  79. } = useSizeAdapt()
  80. // 轴1 卷2 册3
  81. const state = ref(1)
  82. const homeBg = computed(() => {
  83. return `url(${state.value == 1 ? hots3StateBg1 : state.value == 2 ? hots3StateBg2 : hots3StateBg3})`
  84. })
  85. const shadow = computed(() => {
  86. return state.value == 1 ? hots3StateShadow1 : state.value == 2 ? hots3StateShadow2 : hots3StateShadow3
  87. })
  88. const content2Dom = ref(null)
  89. const goState2 = () => {
  90. state.value = 2
  91. setTimeout(() => {
  92. if (content2Dom.value) {
  93. const x = 310 / 780
  94. const allWidth = document.getElementById('content2Img').getBoundingClientRect().width
  95. console.log(allWidth * x)
  96. content2Dom.value.scrollLeft = allWidth * x
  97. }
  98. }, 5)
  99. }
  100. </script>
  101. <style lang="less" scoped>
  102. .hotspot-detail-3 {
  103. position: absolute;
  104. left: 0;
  105. top: 0;
  106. width: 100%;
  107. height: 100%;
  108. background-image: v-bind(homeBg);
  109. background-size: cover;
  110. background-repeat: no-repeat;
  111. background-position: top left;
  112. display: flex;
  113. flex-direction: column;
  114. justify-content: space-evenly;
  115. z-index: 3;
  116. .shadow-box {
  117. position: absolute;
  118. bottom: calc(80 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  119. left: 50%;
  120. transform: translateX(-50%);
  121. }
  122. .content1 {
  123. width: 90%;
  124. max-height: 80vh;
  125. position: absolute;
  126. left: 50%;
  127. transform: translateX(-50%);
  128. bottom: calc(130 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  129. }
  130. .content2{
  131. width: 100%;
  132. background-position: left top;
  133. overflow: auto;
  134. img{
  135. // height: 50vh;
  136. width: 990px;
  137. }
  138. }
  139. .btns-box {
  140. width: 55%;
  141. position: absolute;
  142. left: 50%;
  143. transform: translateX(-50%);
  144. display: flex;
  145. justify-content: space-evenly;
  146. bottom: calc(35 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  147. >img {
  148. width: calc(35 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  149. width: calc(35 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  150. }
  151. }
  152. }
  153. </style>