HotspotDetail3.vue 5.9 KB

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