PoemList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. <template>
  2. <!-- pc端才使用 v-touch-->
  3. <!--
  4. v-touch:swipe.left="() => onSwipeChange(1)"
  5. v-touch:swipe.right="() => onSwipeChange(-1)"
  6. :swipe-options="{ direction: 'horizontal' }"
  7. -->
  8. <div
  9. class="poem-list-page"
  10. @touchstart="(e) => touchstart(e.touches[0].pageX)"
  11. @touchmove="(e) => touchmove(e.touches[0].pageX)"
  12. @touchend="(e) => touchend((val) => onSwipeChange(val))"
  13. >
  14. <div
  15. class="RWbox"
  16. :style="`width: ${domWidth}px; left:-${
  17. baseRWboxLeft ? 500 : indexAc * pageWidth}px;
  18. `"
  19. >
  20. <div
  21. v-for="(item1, index1) in listRes"
  22. :key="index1"
  23. :class="`ROW ROW${item1.waiClass + 1} ROWW${index1 + 1}`"
  24. :style="`width:${pageWidth}px; opacity:${
  25. index1 === indexAc ? '1' : isOpcMove ? '0' : ''
  26. }`"
  27. >
  28. <img
  29. v-for="(item2, index2) in item1.imgArr"
  30. :key="index2"
  31. :style="`transform: translateX(${isMoveFu(
  32. index1,
  33. item2.moveNum
  34. )}px);`"
  35. :class="item2.classTxt"
  36. :src="require(`@/assets/images/RW/${item2.imgName}.png`)"
  37. alt=""
  38. >
  39. <!-- 诗句内容 -->
  40. <div
  41. class="ROWtxt"
  42. :class="[`typesetting-${getTypesettingIdx(item1['类型'])}`]"
  43. >
  44. <div class="inner-wrap">
  45. <div class="title-wrap">
  46. <h1>《{{ item1["标题"] }}》</h1>
  47. <div class="sub-title">
  48. <span class="author">{{ item1["作者"] }}</span>
  49. <span class="age">{{ item1["朝代"] }}</span>
  50. </div>
  51. </div>
  52. <p>{{ item1["正文"] }}</p>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <!-- 最底部的文字提示 -->
  58. <div :class="`RWind ${txtTit ? 'RWindShow' : ''}`">
  59. 暂无更多内容
  60. </div>
  61. <!-- 操作提示 -->
  62. <OperationTip
  63. class="operation-tip"
  64. :direction="'h'"
  65. :text="'下一章'"
  66. color="green"
  67. :is-show="isShowOperationTip"
  68. />
  69. <!-- 返场视频 -->
  70. <div :class="`backVideo ${backVideoFlag ? 'backVideoShow' : ''}`">
  71. <video
  72. ref="backVideoRef"
  73. src="@/assets/images/RW/play.mp4"
  74. playsinline
  75. muted
  76. webkit-playsinline="true"
  77. x5-video-player-type="h5"
  78. />
  79. </div>
  80. <!-- 返回按钮 -->
  81. <div class="RWback">
  82. <BtnBack
  83. class="button-back"
  84. @click="btnBackFu"
  85. />
  86. </div>
  87. <!-- 选择 时代 -->
  88. <div
  89. :class="`RWsBtn ${ageFlga ? 'RWsBtnHide' : ''}`"
  90. @click="ageFlga = true"
  91. >
  92. <img
  93. class=""
  94. :src="require(`@/assets/images/icon_menu.png`)"
  95. alt=""
  96. >
  97. </div>
  98. <!-- 选择时代出来的元素 -->
  99. <div :class="`RWage ${ageFlga ? 'RWageShow' : ''}`">
  100. <div
  101. v-for="item in ageList"
  102. :key="item"
  103. :class="`RWageRow ${ageAc === item ? 'RWageRowAc' : ''}`"
  104. @click="cutAgeFu(item)"
  105. >
  106. {{ item }}
  107. </div>
  108. <div
  109. class="RWageImg"
  110. @click="ageFlga = false"
  111. >
  112. <img
  113. class=""
  114. :src="require(`@/assets/images/icon_close.png`)"
  115. alt=""
  116. >
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script setup>
  122. import { ref, onMounted } from "vue"
  123. import { useRouter } from "vue-router"
  124. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  125. import { arrList } from "./PoemList.js"
  126. import useMoveFu from "../moveFu"
  127. const { touchstart, touchmove, touchend } = useMoveFu()
  128. /**
  129. * 排版
  130. */
  131. function getTypesettingIdx(poemType) {
  132. switch (poemType) {
  133. case "七绝":
  134. return 1
  135. case "七律":
  136. return 2
  137. case "五绝":
  138. return 3
  139. case "五律":
  140. return 4
  141. default:
  142. return 2
  143. }
  144. }
  145. // 提示语的显示隐藏
  146. const titShow = ref(true)
  147. const router = useRouter()
  148. // 返场视频ref
  149. const backVideoRef = ref("")
  150. const backVideoFlag = ref(false)
  151. // 点击返回
  152. const btnBackFu = () => {
  153. backVideoRef.value.play()
  154. setTimeout(() => {
  155. backVideoFlag.value = true
  156. }, 100)
  157. setTimeout(() => {
  158. router.replace({
  159. name: "MoreContent",
  160. query: {
  161. anchorIdx: 1,
  162. },
  163. })
  164. }, 2200)
  165. }
  166. const { windowSizeInCssForRef, windowSizeWhenDesignForRef } = useSizeAdapt()
  167. const listRes = ref(arrList)
  168. // 元素总宽度
  169. const domWidth = ref(0)
  170. const pageWidth = ref(0)
  171. // 当前选中索引
  172. const indexAc = ref(0)
  173. const baseRWboxLeft = ref(true)
  174. onMounted(() => {
  175. setTimeout(() => {
  176. baseRWboxLeft.value = false
  177. }, 500)
  178. })
  179. // 底部文字提示显示和隐藏
  180. const txtTit = ref(false)
  181. const poemList = configExcel["诗词"]
  182. const isOpcMove = ref(true)
  183. // 时代数组
  184. const ageList = ref([])
  185. // 时代选中
  186. const ageAc = ref(poemList[0]["朝代"])
  187. // 时代显示隐藏切换
  188. const ageFlga = ref(false)
  189. // 切换时代
  190. const cutAgeFu = (val) => {
  191. const index = listRes.value.findIndex((v) => v["朝代"] === val)
  192. if (indexAc.value === index) return
  193. isShowOperationTip.value = false
  194. titShow.value = false
  195. isOpcMove.value = false
  196. setTimeout(() => {
  197. isOpcMove.value = true
  198. }, 500)
  199. indexAc.value = index
  200. ageAc.value = val
  201. }
  202. onMounted(() => {
  203. const tempArr = []
  204. const imgDataLenght = arrList.length
  205. // 整个数组能分为多少段,向上取整
  206. const isArrNum = Math.ceil(poemList.length / imgDataLenght)
  207. for (let i = 0; i < isArrNum; i++) {
  208. tempArr.push(poemList.slice(i * imgDataLenght, (i + 1) * imgDataLenght))
  209. }
  210. const ageListTemp = []
  211. const arrRes = []
  212. tempArr.forEach((v1) => {
  213. v1.forEach((v2, i2) => {
  214. v2.imgArr = arrList[i2]
  215. v2.waiClass = i2
  216. arrRes.push(v2)
  217. if (!ageListTemp.includes(v2["朝代"])) ageListTemp.push(v2["朝代"])
  218. })
  219. })
  220. // console.log("-----", arrRes)
  221. ageList.value = ageListTemp
  222. listRes.value = arrRes
  223. const fullWidth = window.innerWidth >= 500 ? 500 : window.innerWidth
  224. pageWidth.value = fullWidth
  225. // 总盒子的宽度
  226. domWidth.value = fullWidth * poemList.length
  227. })
  228. // 向右是-1
  229. // 向左是 1
  230. const indexFlag = ref(0)
  231. const isShowOperationTip = ref(true)
  232. // 左右滑动
  233. const onSwipeChange = (val) => {
  234. isShowOperationTip.value = false
  235. let numResTemp = indexAc.value + val
  236. let indexFlagTemp = -val
  237. if (val === -1 && indexAc.value === 0) {
  238. // 第一个页面左滑
  239. txtTit.value = true
  240. setTimeout(() => {
  241. txtTit.value = false
  242. }, 1000)
  243. return
  244. }
  245. if (val === 1 && indexAc.value === listRes.value.length - 1) {
  246. // numResTemp = 0
  247. txtTit.value = true
  248. setTimeout(() => {
  249. txtTit.value = false
  250. }, 1000)
  251. return
  252. }
  253. titShow.value = false
  254. indexAc.value = numResTemp
  255. indexFlag.value = indexFlagTemp
  256. // 底部朝代也要变化
  257. ageAc.value = listRes.value[numResTemp]["朝代"]
  258. }
  259. // 是否触发移动的逻辑
  260. const isMoveFu = (index, num) => {
  261. let numRes
  262. if (index === indexAc.value) numRes = 0
  263. else numRes = indexFlag.value * num * 2
  264. return numRes
  265. }
  266. </script>
  267. <style lang="less" scoped>
  268. .poem-list-page {
  269. position: relative;
  270. width: 100%;
  271. height: 100%;
  272. background-color: #f3f4ef;
  273. .RWsBtn {
  274. position: absolute;
  275. z-index: 22;
  276. right: 20px;
  277. bottom: 20px;
  278. width: 30px;
  279. height: 30px;
  280. border-radius: 50%;
  281. background-color: rgba(0, 0, 0, 0.5);
  282. display: flex;
  283. justify-content: center;
  284. align-items: center;
  285. opacity: 1;
  286. transition: all 0.5s;
  287. & > img {
  288. width: 20px;
  289. }
  290. }
  291. .RWsBtnHide {
  292. opacity: 0;
  293. pointer-events: none;
  294. }
  295. .RWage {
  296. position: absolute;
  297. z-index: 22;
  298. right: -220px;
  299. bottom: 20px;
  300. display: flex;
  301. align-items: center;
  302. justify-content: flex-end;
  303. width: calc(100% - 70px);
  304. height: 30px;
  305. transition: all 0.5s;
  306. opacity: 0;
  307. pointer-events: none;
  308. .RWageRow {
  309. transition: all 0.5s;
  310. width: 30px;
  311. height: 30px;
  312. border-radius: 4px;
  313. background-color: rgba(0, 0, 0, 0.5);
  314. font-family: KingHwa_OldSong;
  315. font-size: 16px;
  316. margin-right: 15px;
  317. text-align: center;
  318. line-height: 30px;
  319. color: #fff;
  320. border: 1px solid transparent;
  321. }
  322. .RWageRowAc {
  323. color: #d6cda1;
  324. border: 1px solid #d6cda1;
  325. font-size: 18px;
  326. }
  327. .RWageImg {
  328. width: 30px;
  329. height: 30px;
  330. border-radius: 50%;
  331. background-color: rgba(0, 0, 0, 0.5);
  332. display: flex;
  333. justify-content: center;
  334. align-items: center;
  335. & > img {
  336. width: 20px;
  337. }
  338. }
  339. }
  340. .RWageShow {
  341. right: 20px;
  342. opacity: 1;
  343. pointer-events: auto;
  344. }
  345. .RWbox {
  346. width: 8000px;
  347. height: 100%;
  348. overflow: hidden;
  349. position: relative;
  350. display: flex;
  351. background-image: url("../assets/images/RW/bg_caizhi.jpg");
  352. background-size: contain;
  353. transition: left 0.8s;
  354. .ROW {
  355. position: relative;
  356. transition: opacity 1.2s;
  357. & > img {
  358. position: absolute;
  359. bottom: 0;
  360. height: 100%;
  361. transition: transform 1s;
  362. }
  363. }
  364. .ROW {
  365. .ROW1_1 {
  366. left: 0;
  367. }
  368. .ROW1_2 {
  369. z-index: 2;
  370. right: 0;
  371. }
  372. .ROW1_3 {
  373. right: 5%;
  374. }
  375. .ROW2_1 {
  376. z-index: 2;
  377. left: -38%;
  378. }
  379. .ROW2_2 {
  380. right: 5%;
  381. }
  382. .ROW2_3 {
  383. z-index: 3;
  384. right: -20%;
  385. }
  386. .ROW3_1 {
  387. left: -36%;
  388. }
  389. .ROW3_2 {
  390. height: 15%;
  391. left: 10%;
  392. }
  393. .ROW3_3 {
  394. z-index: 2;
  395. height: 15%;
  396. right: 10%;
  397. }
  398. .ROW3_4 {
  399. right: 0%;
  400. }
  401. .ROW3_5 {
  402. right: -5%;
  403. }
  404. .ROW4_1 {
  405. left: -35%;
  406. }
  407. .ROW4_2 {
  408. left: -40%;
  409. height: 15%;
  410. }
  411. .ROW4_3 {
  412. left: 10%;
  413. height: 20%;
  414. }
  415. .ROW4_4 {
  416. right: 6%;
  417. height: 15%;
  418. }
  419. .ROW4_5 {
  420. right: -17%;
  421. }
  422. .ROW5_1 {
  423. left: -45%;
  424. }
  425. .ROW5_2 {
  426. z-index: 2;
  427. left: -17%;
  428. }
  429. .ROW5_3 {
  430. z-index: 3;
  431. left: 5%;
  432. height: 15%;
  433. }
  434. .ROW5_4 {
  435. z-index: 3;
  436. left: 30%;
  437. height: 15%;
  438. }
  439. .ROW5_5 {
  440. right: -6%;
  441. }
  442. .ROW6_1 {
  443. z-index: 3;
  444. left: 2%;
  445. height: 15%;
  446. }
  447. .ROW6_2 {
  448. left: -10%;
  449. }
  450. .ROW6_3 {
  451. z-index: 2;
  452. left: -13%;
  453. }
  454. .ROW6_4 {
  455. right: -10%;
  456. }
  457. .ROW6_5 {
  458. right: -10%;
  459. }
  460. }
  461. .ROWtxt {
  462. display: flex;
  463. justify-content: center;
  464. align-items: center;
  465. width: 100%;
  466. height: 100%;
  467. writing-mode: vertical-rl;
  468. position: relative;
  469. z-index: 10;
  470. .inner-wrap {
  471. > .title-wrap {
  472. position: relative;
  473. width: fit-content;
  474. height: fit-content;
  475. > h1 {
  476. font-family: KingHwa_OldSong;
  477. font-weight: 400;
  478. font-size: calc(
  479. 36 / v-bind("windowSizeWhenDesignForRef") *
  480. v-bind("windowSizeInCssForRef")
  481. );
  482. color: black;
  483. line-height: calc(
  484. 36 / v-bind("windowSizeWhenDesignForRef") *
  485. v-bind("windowSizeInCssForRef")
  486. );
  487. white-space: pre;
  488. letter-spacing: 0.1em;
  489. }
  490. > .sub-title {
  491. position: absolute;
  492. left: 0;
  493. top: 50%;
  494. transform: translate(-140%, -50%);
  495. display: flex;
  496. align-items: center;
  497. > .author {
  498. white-space: pre;
  499. font-family: KaiTi;
  500. font-weight: 400;
  501. font-size: 20px;
  502. color: #b9aa70;
  503. letter-spacing: 0em;
  504. margin-inline-end: calc(
  505. 6 / v-bind("windowSizeWhenDesignForRef") *
  506. v-bind("windowSizeInCssForRef")
  507. );
  508. }
  509. > .age {
  510. display: inline-block;
  511. width: calc(
  512. 21 / v-bind("windowSizeWhenDesignForRef") *
  513. v-bind("windowSizeInCssForRef")
  514. );
  515. height: calc(
  516. 21 / v-bind("windowSizeWhenDesignForRef") *
  517. v-bind("windowSizeInCssForRef")
  518. );
  519. background-color: #b6a261;
  520. border-radius: 50%;
  521. display: flex;
  522. justify-content: center;
  523. align-items: center;
  524. font-family: KaiTi;
  525. font-weight: 400;
  526. font-size: calc(
  527. 16 / v-bind("windowSizeWhenDesignForRef") *
  528. v-bind("windowSizeInCssForRef")
  529. );
  530. color: #ffffff;
  531. }
  532. }
  533. }
  534. > p {
  535. margin-right: calc(
  536. 40 / v-bind("windowSizeWhenDesignForRef") *
  537. v-bind("windowSizeInCssForRef")
  538. );
  539. font-family: KaiTi;
  540. font-weight: 400;
  541. font-size: calc(
  542. 20 / v-bind("windowSizeWhenDesignForRef") *
  543. v-bind("windowSizeInCssForRef")
  544. );
  545. color: black;
  546. line-height: 1.6em;
  547. white-space: pre;
  548. letter-spacing: 0.2em;
  549. }
  550. }
  551. }
  552. .ROWtxt.typesetting-1 {
  553. > .inner-wrap {
  554. transform: translate(10%, -20%);
  555. > p {
  556. margin-top: calc(
  557. 232 / v-bind("windowSizeWhenDesignForRef") *
  558. v-bind("windowSizeInCssForRef")
  559. );
  560. }
  561. }
  562. }
  563. .ROWtxt.typesetting-2 {
  564. > .inner-wrap {
  565. transform: translate(10%, -4%);
  566. > p {
  567. margin-top: calc(
  568. 102 / v-bind("windowSizeWhenDesignForRef") *
  569. v-bind("windowSizeInCssForRef")
  570. );
  571. }
  572. }
  573. }
  574. .ROWtxt.typesetting-3 {
  575. > .inner-wrap {
  576. transform: translate(0, -9%);
  577. > p {
  578. margin-top: calc(
  579. 135 / v-bind("windowSizeWhenDesignForRef") *
  580. v-bind("windowSizeInCssForRef")
  581. );
  582. }
  583. }
  584. }
  585. .ROWtxt.typesetting-4 {
  586. > .inner-wrap {
  587. transform: translate(10%, -10%);
  588. > p {
  589. margin-top: calc(
  590. 200 / v-bind("windowSizeWhenDesignForRef") *
  591. v-bind("windowSizeInCssForRef")
  592. );
  593. }
  594. }
  595. }
  596. }
  597. .ROW1 {
  598. .ROWtxt {
  599. padding-top: 15%;
  600. padding-right: 40%;
  601. }
  602. }
  603. .ROW2 {
  604. .ROWtxt {
  605. padding-right: 24%;
  606. }
  607. }
  608. .ROW3 {
  609. .ROWtxt {
  610. padding-right: 30%;
  611. }
  612. }
  613. .ROWW19 {
  614. .ROWtxt {
  615. padding-top: 87%;
  616. }
  617. }
  618. // 底部文字提示
  619. .RWind {
  620. position: absolute;
  621. bottom: 15%;
  622. left: 50%;
  623. transform: translateX(-50%);
  624. z-index: 30;
  625. font-size: 14px;
  626. color: #b9aa70;
  627. letter-spacing: 4px;
  628. opacity: 0;
  629. transition: opacity 0.5s;
  630. pointer-events: none;
  631. font-family: KingHwa_OldSong;
  632. }
  633. .RWindShow {
  634. opacity: 1;
  635. }
  636. // 操作提示
  637. .operation-tip {
  638. position: absolute;
  639. z-index: 30;
  640. left: 50%;
  641. bottom: 7%;
  642. transform: translateX(-50%);
  643. color: #7f9470;
  644. font-size: 12px;
  645. letter-spacing: 3px;
  646. pointer-events: none;
  647. display: flex;
  648. align-items: center;
  649. opacity: 1;
  650. transition: opacity 1s;
  651. img {
  652. width: 30px;
  653. }
  654. }
  655. .operation-tipHide {
  656. opacity: 0;
  657. }
  658. // 返场视频
  659. .backVideo {
  660. position: absolute;
  661. top: 0;
  662. left: 0;
  663. width: 100%;
  664. height: 100%;
  665. z-index: 30;
  666. opacity: 0;
  667. pointer-events: none;
  668. transition: opacity 2s;
  669. & > video {
  670. width: 100%;
  671. }
  672. }
  673. .backVideoShow {
  674. opacity: 1;
  675. pointer-events: auto;
  676. }
  677. // 返回按钮
  678. .RWback {
  679. position: absolute;
  680. z-index: 22;
  681. left: 20px;
  682. bottom: 20px;
  683. width: 30px;
  684. height: 30px;
  685. border-radius: 50%;
  686. background-color: rgba(0, 0, 0, 0.5);
  687. display: flex;
  688. justify-content: center;
  689. align-items: center;
  690. }
  691. .btn-back {
  692. position: absolute;
  693. top: 50%;
  694. left: 50%;
  695. transform: translate(-50%, -50%);
  696. max-width: 100%;
  697. max-height: 100%;
  698. }
  699. }
  700. </style>