BambooList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="bamboo-list">
  3. <img
  4. class="bg"
  5. :style="{
  6. opacity: isShowDetail ? 1 : 0.5,
  7. }"
  8. src="@/assets/images/bamboo-list/bg.jpg"
  9. alt=""
  10. draggable="false"
  11. >
  12. <BtnBack
  13. class="btn-back"
  14. @click="onClickBack"
  15. />
  16. <!-- 竹林各元素 -->
  17. <div
  18. ref="scrollTarget"
  19. class="scroll-target"
  20. >
  21. <div
  22. class="layer-1"
  23. :style="{
  24. left: layer1Left + 'px',
  25. }"
  26. >
  27. <img
  28. class="weed"
  29. :style="{
  30. opacity: isShowDetail ? 0 : 1,
  31. }"
  32. src="@/assets/images/bamboo-list/weed.png"
  33. alt=""
  34. draggable="false"
  35. >
  36. <img
  37. class="leaf"
  38. :style="{
  39. opacity: isShowDetail ? 0 : 1,
  40. }"
  41. src="@/assets/images/bamboo-list/leaf.png"
  42. alt=""
  43. draggable="false"
  44. >
  45. <img
  46. class="bamboo shui-zhu"
  47. :class="{
  48. focused: showDetailIdx === 0,
  49. hide: isShowDetail && showDetailIdx !== 0
  50. }"
  51. src="@/assets/images/bamboo-list/shui-zhu.png"
  52. alt=""
  53. draggable="false"
  54. >
  55. <HotspotCompSmall
  56. v-show="!isShowDetail"
  57. class="hotspot-shui-zhu"
  58. @click="onClickHotspot(0)"
  59. >
  60. 水竹
  61. </HotspotCompSmall>
  62. <img
  63. class="bamboo zi-zhu"
  64. :class="{
  65. focused: showDetailIdx === 1,
  66. hide: isShowDetail && showDetailIdx !== 1
  67. }"
  68. src="@/assets/images/bamboo-list/zi-zhu.png"
  69. alt=""
  70. draggable="false"
  71. >
  72. <HotspotCompSmall
  73. v-show="!isShowDetail"
  74. class="hotspot-zi-zhu"
  75. @click="onClickHotspot(1)"
  76. >
  77. 紫竹
  78. </HotspotCompSmall>
  79. <img
  80. class="bamboo mei-lu-zhu"
  81. :class="{
  82. focused: showDetailIdx === 2,
  83. hide: isShowDetail && showDetailIdx !== 2
  84. }"
  85. src="@/assets/images/bamboo-list/mei-lu-zhu.png"
  86. alt=""
  87. draggable="false"
  88. >
  89. <HotspotCompSmall
  90. v-show="!isShowDetail"
  91. class="hotspot-mei-lu-zhu"
  92. @click="onClickHotspot(2)"
  93. >
  94. 梅鹿竹
  95. </HotspotCompSmall>
  96. <img
  97. class="bamboo nan-zhu"
  98. :class="{
  99. focused: showDetailIdx === 3,
  100. hide: isShowDetail && showDetailIdx !== 3
  101. }"
  102. src="@/assets/images/bamboo-list/nan-zhu.png"
  103. alt=""
  104. draggable="false"
  105. >
  106. <HotspotCompSmall
  107. v-show="!isShowDetail"
  108. class="hotspot-nan-zhu"
  109. @click="onClickHotspot(3)"
  110. >
  111. 楠竹
  112. </HotspotCompSmall>
  113. <img
  114. class="bamboo xiang-fei-zhu"
  115. :class="{
  116. focused: showDetailIdx === 4,
  117. hide: isShowDetail && showDetailIdx !== 4
  118. }"
  119. src="@/assets/images/bamboo-list/xiang-fei-zhu.png"
  120. alt=""
  121. draggable="false"
  122. >
  123. <HotspotCompSmall
  124. v-show="!isShowDetail"
  125. class="hotspot-xiang-fei-zhu"
  126. @click="onClickHotspot(4)"
  127. >
  128. 湘妃竹
  129. </HotspotCompSmall>
  130. <img
  131. class="bamboo dan-zhu"
  132. :class="{
  133. focused: showDetailIdx === 5,
  134. hide: isShowDetail && showDetailIdx !== 5
  135. }"
  136. src="@/assets/images/bamboo-list/dan-zhu.png"
  137. alt=""
  138. draggable="false"
  139. >
  140. <HotspotCompSmall
  141. v-show="!isShowDetail"
  142. class="hotspot-dan-zhu"
  143. @click="onClickHotspot(5)"
  144. >
  145. 单竹
  146. </HotspotCompSmall>
  147. </div>
  148. </div>
  149. <!-- 详情 -->
  150. <Transition name="fade-in-out">
  151. <div
  152. v-if="isShowDetail"
  153. class="detail-wrap-outter"
  154. >
  155. <div
  156. class="detail-wrap"
  157. >
  158. <h1>{{ bambooList[showDetailIdx].label }}</h1>
  159. <p v-html="bambooList[showDetailIdx].info" />
  160. </div>
  161. </div>
  162. </Transition>
  163. </div>
  164. </template>
  165. <script setup>
  166. import { ref, computed, watch, onMounted, onBeforeUnmount, inject, nextTick } from "vue"
  167. import { useRoute, useRouter } from "vue-router"
  168. import { useStore } from "vuex"
  169. import useSmoothSwipe from "@/useFunctions/useSmoothSwipe.js"
  170. import { useWindowSize } from "@vueuse/core"
  171. const route = useRoute()
  172. const router = useRouter()
  173. const store = useStore()
  174. const $env = inject('$env')
  175. const windowWidthDesign = 1920
  176. const windowHeightDesign = 1080 - 71 - 37 // 设计稿里视口高度。注意要减去上下边栏
  177. const scrollTarget = ref(null)
  178. const { width: windowWidth, height: windowHeight } = useWindowSize()
  179. const maxTranslateLength = computed(() => {
  180. return (windowHeight.value * windowWidthDesign) / windowHeightDesign
  181. })
  182. const {
  183. translateLength,
  184. } = useSmoothSwipe({
  185. scrollTargetRef: scrollTarget,
  186. maxTranslateLength,
  187. viewportWidth: windowWidth,
  188. })
  189. // layer1Left位移
  190. const layer1InitialLeft = 0
  191. const layer1Left = ref(layer1InitialLeft)
  192. watch(
  193. translateLength,
  194. (v) => {
  195. layer1Left.value = layer1InitialLeft - v
  196. },
  197. {
  198. immediate: true,
  199. }
  200. )
  201. const bambooList = ref([
  202. {
  203. label: '水竹',
  204. info: '竿可高6米许,粗达3厘米;篷耳小,形状为卵形或长椭圆形。锋舌边缘生有短白纤毛。筝片直立,呈三角形至狭长三角形。叶片为线状披针形或披针形,下表面基部有些许毛。'
  205. },
  206. {
  207. label: '紫竹',
  208. info: '紫竹幼竿绿色,覆盖细柔毛和白粉,幕环有毛,籍鞘背面红褐色或绿色加深。斑点微小或无,锌鞘上端常密集,带微量白粉和淡褐色刺毛。叶片小而薄,窄披针形,先端尖长。'
  209. },
  210. {
  211. label: '梅鹿竹',
  212. info: '梅鹿竹斑纹相连,圆形,外轮廓深色,斑心发白。有些竹地呈青灰色,上有兽斑状斑痕,酷似梅花鹿的花纹。'
  213. },
  214. {
  215. label: '楠竹',
  216. info: '单轴散生型常绿乔木状竹类植物,株高约20米,径可达12-30厘米,呈直立状,基部节间长1-6厘米,中部节间长达40厘米,新秆上具细柔毛后脱落。'
  217. },
  218. {
  219. label: '湘妃竹',
  220. info: '中小型竹,竿高5米-10米,竿环及箨(tuò)环隆起,竿箨黄褐色,有黑褐色斑点,箨耳较小,矩圆形或镰形,箨叶三角形或带形,橘红色,边缘绿色,叶带状披针形,叶舌发达,有叶耳及长肩毛。'
  221. },
  222. {
  223. label: '单竹',
  224. info: '民间俗称“苦慈”,竹质细腻,纤维韧性极强,可制成薄如蝉翼、细如发丝的竹篾丝,编织成绸似、绢似的精美竹编工艺品。'
  225. },
  226. ])
  227. const isShowDetail = ref(false)
  228. const showDetailIdx = ref(-1)
  229. function onClickHotspot(idx) {
  230. showDetailIdx.value = idx
  231. isShowDetail.value = true
  232. }
  233. function onClickBack() {
  234. if (isShowDetail.value) {
  235. isShowDetail.value = false
  236. showDetailIdx.value = -1
  237. } else {
  238. router.go(-1)
  239. }
  240. }
  241. </script>
  242. <style lang="less" scoped>
  243. .bamboo-list{
  244. position: absolute;
  245. left: 0;
  246. top: 0;
  247. width: 100%;
  248. height: 100%;
  249. background-color: #d3e2cd;
  250. >img.bg{
  251. position: absolute;
  252. left: 0;
  253. top: 0;
  254. width: 100%;
  255. height: 100%;
  256. object-fit: cover;
  257. transition: all 1s;
  258. }
  259. >.btn-back{
  260. z-index: 1;
  261. }
  262. > .scroll-target {
  263. height: 100%;
  264. width: 100%;
  265. display: flex;
  266. gap: 100px;
  267. overflow: hidden;
  268. position: relative;
  269. z-index: 0;
  270. >.layer-1{
  271. position: absolute;
  272. height: 100%;
  273. >img.weed{
  274. position: absolute;
  275. left: 0;
  276. bottom: calc(-50px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  277. height: calc(410px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  278. transition: all 1s;
  279. }
  280. >img.leaf{
  281. position: absolute;
  282. left: 0;
  283. top: calc(-80px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  284. height: calc(442px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  285. z-index: 1;
  286. transition: all 1s;
  287. }
  288. >img.bamboo{
  289. transition: all 1s;
  290. }
  291. >img.bamboo.hide{
  292. opacity: 0;
  293. }
  294. >img.bamboo.focused{
  295. left: calc(v-bind('translateLength') * 2px + 20vw); // 为什么要乘以2?我自己也不知道。。。
  296. }
  297. >img.shui-zhu{
  298. position: absolute;
  299. left: calc(100px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  300. top: 0;
  301. height: 100%;
  302. z-index: 1;
  303. }
  304. >.hotspot-shui-zhu{
  305. position: absolute;
  306. left: calc(185px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  307. top: calc(350px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  308. z-index: 2;
  309. }
  310. >img.zi-zhu{
  311. position: absolute;
  312. left: calc(390px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  313. top: 0;
  314. height: 100%;
  315. z-index: 0;
  316. }
  317. >.hotspot-zi-zhu{
  318. position: absolute;
  319. left: calc(510px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  320. top: calc(152px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  321. z-index: 2;
  322. }
  323. >img.mei-lu-zhu{
  324. position: absolute;
  325. left: calc(390px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  326. top: 0;
  327. height: 100%;
  328. z-index: 1;
  329. }
  330. >.hotspot-mei-lu-zhu{
  331. position: absolute;
  332. left: calc(710px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  333. top: calc(274px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  334. z-index: 2;
  335. }
  336. >img.nan-zhu{
  337. position: absolute;
  338. left: calc(1140px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  339. top: 0;
  340. height: 100%;
  341. z-index: 1;
  342. }
  343. >.hotspot-nan-zhu{
  344. position: absolute;
  345. left: calc(1160px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  346. top: calc(217px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  347. z-index: 2;
  348. }
  349. >img.xiang-fei-zhu{
  350. position: absolute;
  351. left: calc(1350px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  352. top: 0;
  353. height: 100%;
  354. z-index: 1;
  355. }
  356. >.hotspot-xiang-fei-zhu{
  357. position: absolute;
  358. left: calc(1695px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  359. top: calc(71px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  360. z-index: 2;
  361. }
  362. >img.dan-zhu{
  363. position: absolute;
  364. left: calc(1500px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  365. top: 0;
  366. height: 100%;
  367. z-index: 1;
  368. }
  369. >.hotspot-dan-zhu{
  370. position: absolute;
  371. left: calc(1620px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  372. top: calc(358px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  373. z-index: 2;
  374. }
  375. }
  376. }
  377. >.detail-wrap-outter{
  378. position: absolute;
  379. left: 0;
  380. top: 0;
  381. width: 100%;
  382. height: 100%;
  383. >.detail-wrap{
  384. position: absolute;
  385. top: 17.6vh;
  386. left: 50%;
  387. >h1{
  388. font-family: KingHwa_OldSong, KingHwa_OldSong;
  389. font-weight: 400;
  390. font-size: 60px;
  391. color: #FFFFFF;
  392. line-height: 75px;
  393. text-shadow: 0px 0px 2px rgba(0,0,0,0.25);
  394. margin-bottom: 1em;
  395. }
  396. >p{
  397. width: 24.2vw;
  398. margin-left: 60px;
  399. font-family: KaiTi, KaiTi;
  400. font-weight: 400;
  401. font-size: 30px;
  402. color: #FFFFFF;
  403. line-height: 45px;
  404. text-align: justified;
  405. }
  406. }
  407. }
  408. }
  409. </style>