BambooBookView.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <script setup>
  2. import { ref, onMounted } from 'vue'
  3. import { useRouter } from 'vue-router'
  4. const router = useRouter()
  5. import BambooBookScene1 from '@/views/BambooBookScene1.vue'
  6. import BambooBookScene2 from '@/views/BambooBookScene2.vue'
  7. import BambooBookScene3 from '@/views/BambooBookScene3.vue'
  8. // 当前滑动到第几屏
  9. const curIndex = ref(0)
  10. const toBack = () => {
  11. router.replace({
  12. name: 'MoreContent',
  13. query: {
  14. anchorIdx: 1,
  15. }
  16. })
  17. }
  18. const data1 = configZhuPu['杆']
  19. const data2 = configZhuPu['枝']
  20. const data3 = configZhuPu['叶']
  21. const curList = ref([])
  22. const isStart = ref(true)
  23. const isBack = ref(false)
  24. const NextPage = (curPart) => {
  25. // curIndex.value = 2
  26. isShowIndex3.value = true
  27. switch (curPart) {
  28. case 1:
  29. curList.value = data1
  30. return
  31. case 2:
  32. curList.value = data2
  33. return
  34. case 3:
  35. curList.value = data3
  36. return
  37. }
  38. }
  39. const isChange = ref(false)
  40. const onSlideRight = () => {
  41. curIndex.value = 1
  42. isChange.value = true
  43. }
  44. const onSlideLeft = () => {
  45. isStart.value = false
  46. curIndex.value = 0
  47. }
  48. const isShowIndex3 = ref(false)
  49. </script>
  50. <template>
  51. <div class="home">
  52. <!-- 第一屏 -->
  53. <Transition name="fade-in-out">
  54. <div class="page1">
  55. <BambooBookScene1
  56. v-if="curIndex !== 2"
  57. :class="{ 'goLeft1':curIndex === 1,'goRight1':curIndex === 0 && !isStart }"
  58. @slide-right="onSlideRight"
  59. @close="toBack"
  60. />
  61. <BambooBookScene2
  62. v-if="curIndex == 1 || curIndex == 0 && !isStart"
  63. :class="{ 'goLeft2':curIndex === 1 ,'goRight2':curIndex === 0 && !isStart && !isBack}"
  64. class="onRight2"
  65. :ischange="isChange"
  66. @slide-left="onSlideLeft"
  67. @next="NextPage"
  68. @close="onSlideLeft"
  69. />
  70. </div>
  71. </Transition>
  72. <!-- 第二屏 -->
  73. <!-- <Transition name="fade-in-out">
  74. </Transition> -->
  75. <!-- 第三屏 -->
  76. <Transition name="fade-in-out">
  77. <BambooBookScene3
  78. v-if="isShowIndex3"
  79. :list="curList"
  80. @close="() => { isShowIndex3 = false }"
  81. />
  82. </Transition>
  83. </div>
  84. </template>
  85. <style lang="less" scoped>
  86. .home {
  87. width: 100%;
  88. height: 100%;
  89. // .onRight1{
  90. // }
  91. .page1 {
  92. width: 100%;
  93. height: 100%;
  94. .onLeft1{
  95. transform: translateX(-100%);
  96. }
  97. .onLeft2{
  98. transform: translateX(0%);
  99. }
  100. .onRight1{
  101. transform: translateX(0%);
  102. }
  103. .onRight2 {
  104. transform: translateX(100%)
  105. }
  106. .goLeft1 {
  107. animation: on-left1 1.5s forwards;
  108. @keyframes on-left1 {
  109. 0% {
  110. transform: translateX(0);
  111. }
  112. 100% {
  113. transform: translateX(-100%);
  114. }
  115. }
  116. }
  117. .goLeft2 {
  118. animation: on-left2 1.5s forwards;
  119. @keyframes on-left2 {
  120. 0% {
  121. transform: translateX(100%);
  122. }
  123. 100% {
  124. transform: translateX(0%);
  125. }
  126. }
  127. }
  128. .goRight1 {
  129. animation: on-right1 1.5s forwards;
  130. @keyframes on-right1 {
  131. 0% {
  132. transform: translateX(-100%);
  133. }
  134. 100% {
  135. transform: translateX(0%);
  136. }
  137. }
  138. }
  139. .goRight2 {
  140. animation: on-right2 1.5s forwards;
  141. @keyframes on-right2 {
  142. 0% {
  143. transform: translateX(0%);
  144. }
  145. 100% {
  146. transform: translateX(100%);
  147. }
  148. }
  149. }
  150. }
  151. }
  152. </style>