HotspotDetail3.vue 6.3 KB

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