HomeView.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <script setup>
  2. import { ref, computed, nextTick, onMounted } from "vue"
  3. import { useRouter, useRoute } from "vue-router"
  4. import { useStore } from "vuex"
  5. import Startup from "@/views/StartupView.vue"
  6. import useRollFu from "../rollFu.js"
  7. import HotspotDetail3 from "@/views/HotspotDetail3.vue"
  8. import HotspotDetail1 from "@/views/HotspotDetail1.vue"
  9. import PaintingDetail from '@/views/PaintingDetail.vue'
  10. const store = useStore()
  11. const router = useRouter()
  12. const route = useRoute()
  13. const { handleScroll } = useRollFu()
  14. const isShowOperationTip = ref(true)
  15. const isShowHotspotDetail1 = ref(false)
  16. const isShowHotspotDetail3 = ref(false)
  17. const curPageIndex = ref(0)
  18. const longDescText = computed(() => {
  19. return curPageIndex.value == 1
  20. ? configText.homepagePaintingDetailDescStem
  21. : curPageIndex.value == 2
  22. ? configText.homepagePaintingDetailDescLeaf
  23. : curPageIndex.value == 3
  24. ? configText.homepagePaintingDetailDescStone
  25. : curPageIndex.value == 4
  26. ? configText.homepagePaintingSummary
  27. : ""
  28. })
  29. const isShowVideoFadeToNextPage = ref(false)
  30. const isShowSkip = ref(false)
  31. const videoFadeToNextPageEl = ref(null)
  32. const paintingState = ref('1')
  33. const isShowPaintingDetial = ref(false)
  34. const longTitleText = computed(() => {
  35. return curPageIndex.value == 1
  36. ? "三竿修竹"
  37. : curPageIndex.value == 2
  38. ? "竹叶"
  39. : curPageIndex.value == 3
  40. ? "卧石、枯树和灌木"
  41. : ""
  42. })
  43. // 滑动逻辑
  44. const scrollFu = (val) => {
  45. if (val == -1) {
  46. // 上滚
  47. // console.log("上滚")
  48. curPageIndex.value =
  49. curPageIndex.value > 0 ? curPageIndex.value - 1 : curPageIndex.value
  50. } else if (val == 1) {
  51. // 下滚
  52. console.log("下滚")
  53. isShowOperationTip.value = false
  54. if (curPageIndex.value < 4) {
  55. curPageIndex.value = curPageIndex.value + 1
  56. } else if (curPageIndex.value == 4) {
  57. // 播放视频
  58. isShowVideoFadeToNextPage.value = true
  59. nextTick(() => {
  60. videoFadeToNextPageEl.value.play()
  61. })
  62. setTimeout(() => {
  63. isShowSkip.value = true
  64. }, 2000)
  65. }
  66. }
  67. }
  68. onMounted(() => {
  69. if (route.query.page) {
  70. curPageIndex.value = parseInt(route.query.page)
  71. }
  72. })
  73. </script>
  74. <template>
  75. <div class="home">
  76. <!-- 过渡到更多详情页视频 -->
  77. <video
  78. v-if="isShowVideoFadeToNextPage"
  79. ref="videoFadeToNextPageEl"
  80. muted
  81. class="fade-to-next-page"
  82. src="@/assets/videos/fade-from-home-to-more-content.mp4"
  83. @ended="
  84. router.push({
  85. name: 'MoreContent',
  86. })
  87. "
  88. />
  89. <Transition name="fade-in">
  90. <BtnSkip
  91. v-if="isShowSkip"
  92. @click="
  93. router.push({
  94. name: 'MoreContent',
  95. })
  96. "
  97. />
  98. </Transition>
  99. <!-- 滚动区域 -->
  100. <div
  101. ref="scroller"
  102. class="scroller"
  103. @wheel="($event) => handleScroll($event, (val) => scrollFu(val))"
  104. >
  105. <div class="scroller-content" />
  106. </div>
  107. <!-- 背景 -->
  108. <div class="bg-mask" />
  109. <!-- 开场动画 -->
  110. <Transition name="fade-out">
  111. <Startup
  112. v-if="!store.state.haveShownStartup"
  113. class="startup"
  114. />
  115. <!-- <Startup
  116. v-if="true"
  117. class="startup"
  118. /> -->
  119. </Transition>
  120. <!-- 首页标题 -->
  121. <div
  122. class="title-wrap"
  123. :style="{
  124. opacity: curPageIndex == 0 ? 1 : 0,
  125. }"
  126. >
  127. <img
  128. class="title"
  129. src="@/assets/images/home-title.png"
  130. alt=""
  131. draggable="false"
  132. >
  133. <div class="sub-text">
  134. 南京博物院<br>
  135. 绢本 墨笔<br>
  136. 元 李衎<br>
  137. </div>
  138. </div>
  139. <!-- 作品、作者简介 -->
  140. <div
  141. ref="longDesc"
  142. class="long-desc"
  143. :class="{ 'long-desc-ac': curPageIndex == 0 || curPageIndex == 4 }"
  144. :style="{ opacity: curPageIndex == 0 || curPageIndex == 4 ? 1 : 0 }"
  145. >
  146. <div
  147. class="page2-box"
  148. @click="
  149. // () => {
  150. // router.push('/painting-detail?idx=home');
  151. // }
  152. isShowPaintingDetial =true,
  153. paintingState = '1'
  154. "
  155. >
  156. <img
  157. src="@/assets/images/icon_home_detail-min.png"
  158. alt=""
  159. >
  160. <div>作品简介</div>
  161. </div>
  162. <div
  163. class="page2-box"
  164. style="margin-top: 10px"
  165. @click="
  166. // () => {
  167. // router.push('/painting-detail?idx=home&state=2');
  168. // }
  169. isShowPaintingDetial =true,
  170. paintingState = '2'
  171. "
  172. >
  173. <img
  174. src="@/assets/images/icon_home_author-min.png"
  175. alt=""
  176. >
  177. <div>作者简介</div>
  178. </div>
  179. </div>
  180. <!-- 画作 -->
  181. <div
  182. class="painting-wrap"
  183. :class="{
  184. 'painting-wrap2': curPageIndex == 1 || curPageIndex == 3,
  185. 'painting-wrap3': curPageIndex == 2,
  186. }"
  187. @click="
  188. () => {
  189. curPageIndex == 1 ? (curPageIndex = 2) : '';
  190. }
  191. "
  192. >
  193. <img
  194. class="painting-border"
  195. src="@/assets/images/painting-border-new.png"
  196. alt=""
  197. draggable="false"
  198. >
  199. <img
  200. class="painting-stem"
  201. src="@/assets/images/home-painting1.jpg"
  202. alt=""
  203. draggable="false"
  204. >
  205. <img
  206. class="painting-stem"
  207. src="@/assets/images/home-painting2.jpg"
  208. alt=""
  209. draggable="false"
  210. >
  211. <img
  212. :style="{ opacity: curPageIndex == 1 ? 1 : 0, zIndex: 3 }"
  213. class="painting-stem"
  214. src="@/assets/images/home-painting-stem.jpg"
  215. alt=""
  216. >
  217. <img
  218. class="painting-stem"
  219. src="@/assets/images/img_zhuye-min2.png"
  220. alt=""
  221. :style="{
  222. opacity: curPageIndex == 2 ? 1 : 0,
  223. zIndex: 2,
  224. }"
  225. draggable="false"
  226. >
  227. <img
  228. class="painting-stem"
  229. src="@/assets/images/img_stone_all-min.png"
  230. :style="{
  231. opacity: curPageIndex == 3 ? 1 : 0,
  232. zIndex: 2,
  233. }"
  234. alt=""
  235. draggable="false"
  236. >
  237. </div>
  238. <!-- 热点层1 -->
  239. <div class="hotspot-wrap">
  240. <HotspotForHomepage
  241. v-show="curPageIndex == 0 || curPageIndex == 4"
  242. class="hotspot-1"
  243. @click="isShowHotspotDetail1 = true"
  244. />
  245. <HotspotForHomepage
  246. v-show="curPageIndex == 0 || curPageIndex == 4"
  247. class="hotspot-3"
  248. @click="isShowHotspotDetail3 = true"
  249. />
  250. </div>
  251. <!-- 轴/卷/册热点详情 -->
  252. <Transition name="fade-in-out">
  253. <HotspotDetail3
  254. v-if="isShowHotspotDetail3"
  255. class="hotspot-detail"
  256. @close="isShowHotspotDetail3 = false"
  257. />
  258. </Transition>
  259. <!-- 材质热点详情 -->
  260. <Transition name="fade-in-out">
  261. <HotspotDetail1
  262. v-if="isShowHotspotDetail1"
  263. class="hotspot-detail"
  264. @close="isShowHotspotDetail1 = false"
  265. />
  266. </Transition>
  267. <!-- 滑动提示 -->
  268. <OperationTip
  269. v-show="curPageIndex == 0"
  270. class="operation-tip"
  271. text="向下滑动"
  272. :is-show="isShowOperationTip"
  273. />
  274. <!-- 画作详情 -->
  275. <PaintingDetail
  276. v-if="isShowPaintingDetial"
  277. class="painting-detail"
  278. :idx="'home'"
  279. :state="paintingState"
  280. @close="isShowPaintingDetial = false"
  281. />
  282. <!-- 文字介绍 -->
  283. <div
  284. class="text-box"
  285. :style="{
  286. opacity:
  287. curPageIndex == 1 ||
  288. curPageIndex == 2 ||
  289. curPageIndex == 3 ||
  290. curPageIndex == 4
  291. ? 1
  292. : 0,
  293. left: curPageIndex == 4 ? '4%':''
  294. }"
  295. >
  296. <div class="text-box-title">
  297. {{ longTitleText }}
  298. </div>
  299. <!-- <div v-if="curPageIndex == 2">
  300. 竹子的画法
  301. </div> -->
  302. <div
  303. class="text-box-desc"
  304. v-html="longDescText"
  305. />
  306. </div>
  307. </div>
  308. </template>
  309. <style lang="less" scoped>
  310. .home {
  311. width: 100%;
  312. height: 100%;
  313. > video.fade-to-next-page {
  314. position: absolute;
  315. left: 0;
  316. top: 0;
  317. width: 100%;
  318. height: 100%;
  319. object-fit: cover;
  320. z-index: 20;
  321. }
  322. > .scroller {
  323. width: 100vw;
  324. max-height: 100vh;
  325. overflow: auto;
  326. background: rgba(255, 255, 0, 0);
  327. position: absolute;
  328. top: 0;
  329. z-index: 10;
  330. opacity: 0;
  331. .scroller-content {
  332. width: 100%;
  333. height: 200vh;
  334. }
  335. }
  336. > .bg-mask {
  337. position: absolute;
  338. left: 0;
  339. top: 0;
  340. width: 100%;
  341. height: 100%;
  342. // background: rgba(60, 89, 71, 0.65);
  343. background: url(@/assets/images/bg-mask.png);
  344. background-size: 100% 100%;
  345. }
  346. > .startup {
  347. z-index: 20;
  348. }
  349. > .title-wrap {
  350. position: absolute;
  351. right: 25%;
  352. top: 50%;
  353. transform: translateY(-50%);
  354. width: 100px;
  355. height: 45%;
  356. z-index: 5;
  357. transition: opacity 1.5s ease;
  358. > img.title {
  359. position: absolute;
  360. left: 0;
  361. top: 0;
  362. width: 100%;
  363. height: 100%;
  364. }
  365. > .sub-text {
  366. position: absolute;
  367. left: 110%;
  368. top: 46%;
  369. transform: translateY(-50%);
  370. writing-mode: vertical-lr;
  371. font-family: KaiTi;
  372. font-weight: 400;
  373. font-size: 20px;
  374. color: #ffffff;
  375. line-height: 30px;
  376. white-space: pre;
  377. letter-spacing: 0.2em;
  378. text-align: center;
  379. }
  380. }
  381. > .long-desc {
  382. position: absolute;
  383. bottom: 30px;
  384. right: 30px;
  385. color: white;
  386. overflow: hidden;
  387. font-family: KaiTi;
  388. color: #ffffff;
  389. animation: none;
  390. display: flex;
  391. flex-direction: column;
  392. justify-content: space-between;
  393. z-index: 10;
  394. transition: opacity 1.5s ease;
  395. > .page2-box {
  396. display: flex;
  397. flex-direction: column;
  398. justify-content: center;
  399. align-items: center;
  400. cursor: pointer;
  401. > img {
  402. width: 75%;
  403. margin-bottom: 10px;
  404. }
  405. > div {
  406. font-size: calc(
  407. 20 / v-bind("windowSizeWhenDesignForRef") *
  408. v-bind("windowSizeInCssForRef")
  409. );
  410. font-family: KaiTi;
  411. }
  412. }
  413. }
  414. > .painting-wrap {
  415. position: absolute;
  416. left: 50%;
  417. top: 50%;
  418. width: 551.84px;
  419. height: 937.05px;
  420. // background: green;
  421. transform: translate(-50%, -50%);
  422. z-index: 1;
  423. transition: top 1.5s ease, left 1.5s ease, width 1.5s ease, height 1.5s ease;
  424. > .painting-border {
  425. width: 100%;
  426. height: 100%;
  427. position: absolute;
  428. }
  429. > .painting-stem {
  430. width: 80%;
  431. height: calc(
  432. 371 / v-bind("windowSizeWhenDesignForRef") *
  433. v-bind("windowSizeInCssForRef")
  434. );
  435. position: absolute;
  436. left: 50%;
  437. transform: translate(-50%, 26%);
  438. transition: opacity 1.5s ease;
  439. }
  440. }
  441. > .painting-wrap2 {
  442. left: 63%;
  443. top: 46%;
  444. width: calc(551.84px * 1.45);
  445. height: calc(937.05px * 1.45);
  446. }
  447. > .painting-wrap3 {
  448. left: 50%;
  449. top: 0%;
  450. width: calc(551.84px * 5.45);
  451. height: calc(937.05px * 5.45);
  452. }
  453. > .hotspot-wrap {
  454. position: absolute;
  455. left: 50%;
  456. top: 50%;
  457. transform: translate(-46%, -50%);
  458. width: 551.84px;
  459. height: 937.05px;
  460. z-index: 7;
  461. pointer-events: none;
  462. will-change: transform;
  463. backface-visibility: hidden;
  464. z-index: 10;
  465. transition: opacity 1.5s ease;
  466. & > div {
  467. z-index: 100;
  468. transition: all 1.5s ease-in-out;
  469. cursor: pointer;
  470. // transition: all 1.5s ease-in-out;
  471. }
  472. > .hotspot-1 {
  473. position: absolute;
  474. top: 100px;
  475. right: 25px;
  476. pointer-events: initial;
  477. }
  478. // > .hotspot-2 {
  479. // position: absolute;
  480. // left: 60px;
  481. // top: 60px;
  482. // pointer-events: initial;
  483. // }
  484. > .hotspot-3 {
  485. position: absolute;
  486. bottom: 0px;
  487. right: 25px;
  488. pointer-events: initial;
  489. }
  490. }
  491. > .hotspot-detail {
  492. z-index: 21;
  493. }
  494. > .operation-tip {
  495. position: absolute;
  496. right: 30px;
  497. transform: translateX(-50%);
  498. top: 50%;
  499. transform: translateY(-50%);
  500. }
  501. >.painting-detail{
  502. width: 100%;
  503. height: 100%;
  504. position: absolute;
  505. top: 0;
  506. left: 0;
  507. z-index: 30;
  508. }
  509. > .text-box {
  510. max-width: 450px;
  511. position: absolute;
  512. top: 50%;
  513. transform: translateY(-50%);
  514. left: 10%;
  515. color: #ffffff;
  516. font-size: 30px;
  517. line-height: 38px;
  518. font-family: "KaiTi";
  519. transition: opacity 1.5s ease;
  520. z-index: 10;
  521. transition: left 1.5s ease;
  522. .text-box-title {
  523. font-size: 42px;
  524. line-height: 48px;
  525. margin-bottom: 30px;
  526. }
  527. .text-box-desc{
  528. text-indent: 2em;
  529. }
  530. }
  531. }
  532. </style>