HotspotDetail3.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div
  3. class="hotspot-detail-3"
  4. @wheel="($event) => handleScrollThrottle($event, () => scrollFu(-1),() => scrollFu(1))"
  5. >
  6. <img
  7. v-show="state === 1"
  8. class="bg-img"
  9. src="@/assets/images/hots-detail-bg-state1.jpg"
  10. alt=""
  11. >
  12. <img
  13. v-show="state === 2"
  14. class="bg-img"
  15. src="@/assets/images/hots-detail-bg-state2.jpg"
  16. alt=""
  17. >
  18. <img
  19. v-show="state === 3"
  20. class="bg-img"
  21. src="@/assets/images/hots-detail-bg-state3.jpg"
  22. alt=""
  23. >
  24. <!-- 滑动提示 -->
  25. <OperationTip
  26. class="operation-tip"
  27. text="向下滑动"
  28. :is-show="isShowOperationTip"
  29. />
  30. <!-- 阴影 -->
  31. <img
  32. class="shadow-box"
  33. :src="shadow"
  34. :style="{ width: state === 1 ? '20%' : state === 2 ? '80%' :'35%',bottom: state === 1 ?'-15px':'' }"
  35. >
  36. <img
  37. class="content1"
  38. :src="hots3StateContent1"
  39. :style="{
  40. opacity: state === 1 ? 1 : 0,
  41. }"
  42. alt=""
  43. >
  44. <div
  45. id="content2"
  46. ref="content2Dom"
  47. :style="{
  48. opacity: state === 2 ? 1 : 0,
  49. }"
  50. class="content2"
  51. >
  52. <img
  53. id="content2Img"
  54. :src="hots3StateContent2"
  55. alt=""
  56. >
  57. </div>
  58. <img
  59. class="content3"
  60. :style="{
  61. opacity: state === 3 ? 1 : 0,
  62. }"
  63. :src="hots3StateContent3"
  64. alt=""
  65. >
  66. <div class="btns-box">
  67. <img
  68. :src="state == 1 || hoverIndex== 1 ? hots3StateBtn1Ac : hots3StateBtn1"
  69. alt=""
  70. @mouseenter="hoverIndex = 1"
  71. @mouseleave="hoverIndex = null"
  72. @click="state = 1"
  73. >
  74. <img
  75. :src="state == 2 || hoverIndex== 2 ? hots3StateBtn2Ac : hots3StateBtn2"
  76. alt=""
  77. @mouseenter="hoverIndex = 2"
  78. @mouseleave="hoverIndex = null"
  79. @click="goState2"
  80. >
  81. <img
  82. :src="state == 3 || hoverIndex== 3 ? hots3StateBtn3Ac : hots3StateBtn3"
  83. alt=""
  84. @mouseenter="hoverIndex = 3"
  85. @mouseleave="hoverIndex = null"
  86. @click="state = 3"
  87. >
  88. </div>
  89. <BtnBack @click="emit('close')" />
  90. </div>
  91. </template>
  92. <script setup>
  93. import { ref, computed } from "vue"
  94. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  95. import { useWindowSize } from "@vueuse/core"
  96. const emit = defineEmits(["close"])
  97. const windowHeightDesign = 1080 - 71 - 37 // 设计稿里视口高度。注意要减去上下边栏
  98. const { width: windowWidth, height: windowHeight } = useWindowSize()
  99. // 三个按钮
  100. import hots3StateBtn1 from "@/assets/images/hots-detail-btn-state1.png"
  101. import hots3StateBtn2 from "@/assets/images/hots-detail-btn-state2.png"
  102. import hots3StateBtn3 from "@/assets/images/hots-detail-btn-state3.png"
  103. import hots3StateBtn1Ac from "@/assets/images/hots-detail-btn-state1-ac.png"
  104. import hots3StateBtn2Ac from "@/assets/images/hots-detail-btn-state2-ac.png"
  105. import hots3StateBtn3Ac from "@/assets/images/hots-detail-btn-state3-ac.png"
  106. // 三个阴影
  107. import hots3StateShadow1 from "@/assets/images/img_shadow_1.png"
  108. import hots3StateShadow2 from "@/assets/images/img_shadow_2.png"
  109. import hots3StateShadow3 from "@/assets/images/img_shadow_3.png"
  110. // 三个内容
  111. import hots3StateContent1 from "@/assets/images/hots-detail-content-state1.png"
  112. import hots3StateContent2 from "@/assets/images/hots-detail-content-state2.png"
  113. import hots3StateContent3 from "@/assets/images/hots-detail-content-state3.png"
  114. import useRollFu from "../rollFu.js"
  115. const { windowSizeInCssForRef, windowSizeWhenDesignForRef } = useSizeAdapt()
  116. // 轴1 卷2 册3
  117. const state = ref(1)
  118. const hoverIndex = ref(0)
  119. // const isShowOperationTip = ref(false)
  120. const { handleScrollThrottle } = useRollFu()
  121. // 滑动逻辑
  122. const scrollFu = (val) => {
  123. isShowOperationTip.value = false
  124. if (val == -1) {
  125. // 上滚
  126. if (state.value == 1) {
  127. state.value = 3
  128. } else {
  129. state.value -= 1
  130. }
  131. } else if (val == 1) {
  132. // 下滚
  133. if (state.value == 3) {
  134. state.value = 1
  135. } else {
  136. state.value += 1
  137. }
  138. }
  139. }
  140. // const homeBg = computed(() => {
  141. // return `url(${state.value == 1 ? hots3StateBg1 : state.value == 2 ? hots3StateBg2 : hots3StateBg3})`
  142. // })
  143. const shadow = computed(() => {
  144. return state.value == 1
  145. ? hots3StateShadow1
  146. : state.value == 2
  147. ? hots3StateShadow2
  148. : hots3StateShadow3
  149. })
  150. const content2Dom = ref(null)
  151. const isShowOperationTip = ref(true)
  152. const goState2 = () => {
  153. state.value = 2
  154. setTimeout(() => {
  155. // if (content2Dom.value) {
  156. // const x = 310 / 780
  157. // const allWidth = document
  158. // .getElementById("content2Img")
  159. // .getBoundingClientRect().width
  160. // content2Dom.value.scrollLeft = allWidth * x
  161. // // isShowOperationTip.value = true
  162. // }
  163. }, 5)
  164. }
  165. </script>
  166. <style lang="less" scoped>
  167. .hotspot-detail-3 {
  168. position: absolute;
  169. left: 0;
  170. top: 0;
  171. width: 100%;
  172. height: 100%;
  173. // background-image: v-bind(homeBg);
  174. // background-size: cover;
  175. background-repeat: no-repeat;
  176. background-position: top left;
  177. display: flex;
  178. flex-direction: column;
  179. justify-content: space-evenly;
  180. z-index: 3;
  181. .bg-img {
  182. width: 100%;
  183. height: 100%;
  184. object-fit: cover;
  185. object-position: top left;
  186. position: fixed;
  187. top: 0;
  188. left: 0;
  189. z-index: -1;
  190. object-position: bottom;
  191. }
  192. .shadow-box {
  193. position: absolute;
  194. bottom: calc(
  195. 80 / v-bind("windowSizeWhenDesignForRef") *
  196. v-bind("windowSizeInCssForRef")
  197. );
  198. left: 50%;
  199. transform: translateX(-50%);
  200. }
  201. .content1 {
  202. // width: 90%;
  203. max-height: 90vh;
  204. position: absolute;
  205. left: 50%;
  206. transform: translateX(-50%);
  207. transition: opacity 1s ease;
  208. }
  209. .content2 {
  210. width: 100%;
  211. background-position: left top;
  212. overflow: auto;
  213. position: absolute;
  214. transition: opacity 1s ease;
  215. z-index: 2;
  216. display: flex;
  217. justify-content:center;
  218. img {
  219. // height: 90vh;
  220. width: 80%;
  221. }
  222. }
  223. .content3 {
  224. position: absolute;
  225. // width: 100%;
  226. height: 80vh;
  227. left: 50%;
  228. transform: translateX(-50%);
  229. transition: opacity 1s ease;
  230. }
  231. .operation-tip {
  232. position: absolute;
  233. right: calc(30px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  234. transform: translateX(-50%);
  235. top: 50%;
  236. transform: translateY(-50%);
  237. }
  238. .btns-box {
  239. // width: 55%;
  240. height: calc(200px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  241. position: absolute;
  242. left: calc(30px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  243. // transform: translateX(-50%);
  244. bottom: calc(30px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  245. display: flex;
  246. flex-direction: column;
  247. justify-content: space-evenly;
  248. z-index: 10;
  249. > img {
  250. width: calc(35px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  251. width: calc(35px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  252. cursor: pointer;
  253. }
  254. }
  255. }
  256. </style>