HotspotDetail3.vue 6.1 KB

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