BambooBookScene3.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <script setup>
  2. import { onMounted, inject, ref, computed } from 'vue'
  3. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  4. import { Swiper, SwiperSlide } from 'swiper/vue'
  5. import { Pagination } from 'swiper/modules'
  6. // import { Pagination } from 'swiper'
  7. // import 'swiper/css'
  8. // import 'swiper/css/pagination'
  9. const $env = inject('$env')
  10. const {
  11. windowSizeInCssForRef,
  12. windowSizeWhenDesignForRef,
  13. } = useSizeAdapt()
  14. const emit = defineEmits(['close'])
  15. const props = defineProps({
  16. list: {
  17. type: Array,
  18. default: () => { return [] },
  19. },
  20. })
  21. const modules = [Pagination]
  22. const swiperRef = ref(null) // 用于访问Swiper实例
  23. const swiperRealIndex = ref(0)
  24. const displayedPages = ref([])
  25. const currentIndex = ref(0)
  26. const slideChange = (item) => {
  27. swiperRealIndex.value = item.activeIndex
  28. // 这里只是一个简单的示例,根据实际需要调整逻辑
  29. const totalSlides = props.list.length // 总幻灯片数量
  30. const visibleRange = 5 // 每次显示的分页指示器数量(可以根据需要调整)
  31. currentIndex.value = swiperRealIndex.value % 5// 当前幻灯片索引
  32. // console.log('currentIndex', currentIndex)
  33. // displayedPages.value = totalSlides / 5
  34. // let start = Math.max(0, currentIndex.value - Math.floor(visibleRange / 2))
  35. // let end = Math.min(totalSlides - 1, start + visibleRange - 1)
  36. if (swiperRealIndex.value >= totalSlides - totalSlides % visibleRange ) {
  37. displayedPages.value = Array.from({ length: totalSlides % visibleRange }, (_, i) => 0 + i)
  38. // console.log('displayedPages', totalSlides, visibleRange, swiperRealIndex.value, displayedPages.value)
  39. } else {
  40. displayedPages.value = Array.from({ length: 5 }, (_, i) => 0 + i)
  41. }
  42. console.log('displayedPages', totalSlides, visibleRange, swiperRealIndex.value, displayedPages.value)
  43. }
  44. const curPercentage = computed(() => {
  45. return currentIndex.value
  46. }, {
  47. immediate: true,
  48. })
  49. // 跳转到指定幻灯片
  50. const goToSlide = (index) => {
  51. swiperRef.value.slideTo(index)
  52. }
  53. onMounted(() => {
  54. const totalSlides = props.list.length // 总幻灯片数量
  55. const visibleRange = 5 // 每次显示的分页指示器数量(可以根据需要调整)
  56. const currentIndex = swiperRealIndex.value// 当前幻灯片索引
  57. let start = Math.max(0, currentIndex - Math.floor(visibleRange / 2))
  58. let end = Math.min(totalSlides - 1, start + visibleRange - 1)
  59. displayedPages.value = Array.from({ length: end - start + 1 }, (_, i) => start + i)
  60. })
  61. </script>
  62. <template>
  63. <div class="screen-box">
  64. <div class="screen-box3">
  65. <Swiper
  66. ref="swiperRef"
  67. class="step-list"
  68. :modules="modules"
  69. @slide-change="slideChange"
  70. >
  71. <SwiperSlide
  72. v-for="(item, index) in list"
  73. :key="index"
  74. class="step-item"
  75. >
  76. <!-- <div>{{ item['名称'] }}</div> -->
  77. <div class="name-box">
  78. {{ item['画法'] }}
  79. <div class="name-box2">
  80. {{ item['名称'] }}
  81. </div>
  82. <!-- <div
  83. v-for="(item1,index1) in item['显示名称']"
  84. :key="index1"
  85. >
  86. {{ item1 }}
  87. </div> -->
  88. </div>
  89. <img
  90. :src="`${$env.BASE_URL}configMultiMedia/zhupuImages/${item['图片名称'] ? item['图片名称'] : item['名称']}.png`"
  91. alt=""
  92. >
  93. </SwiperSlide>
  94. </Swiper>
  95. <!-- 自定义分页器 -->
  96. <ProgressBar
  97. class="progress-bar"
  98. :totle-unit="displayedPages.length"
  99. :cur-percentage="curPercentage"
  100. :type="1"
  101. color-ac="#FFFFFF"
  102. color="#FFFFFF60"
  103. />
  104. <!-- <div class="custom-pagination">
  105. <span
  106. v-for="(index, i) in displayedPages"
  107. :key="i"
  108. :class="{ 'pagination-bullet': true, 'swiper-pagination-bullet-active': index === currentIndex }"
  109. @click="goToSlide(index)"
  110. />
  111. </div> -->
  112. <div class="system-btns">
  113. <BtnBack @click="emit('close')" />
  114. </div>
  115. </div>
  116. </div>
  117. </template>
  118. <style lang='less' scoped>
  119. ::v-deep {
  120. .swiper-pagination-bullet {
  121. border: 1px solid white;
  122. background: none;
  123. width: 10px;
  124. height: 10px;
  125. opacity: 1;
  126. }
  127. .swiper-pagination-bullet-active {
  128. background: white;
  129. }
  130. .swiper-horizontal>.swiper-pagination-bullets .swiper-pagination-bullet,
  131. .swiper-pagination-horizontal.swiper-pagination-bullets .swiper-pagination-bullet {
  132. margin: 0 calc(5 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  133. }
  134. // .custom-pagination {
  135. // width: 100%;
  136. // height: 10px;
  137. // display: flex;
  138. // justify-content: center;
  139. // align-items: center;
  140. // position: fixed;
  141. // bottom: calc(30 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  142. // span {
  143. // width: 10px;
  144. // height: 10px;
  145. // margin: 0 calc(5 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  146. // border-radius: 50px;
  147. // border: 1px solid rgb(245, 243, 243);
  148. // }
  149. // }
  150. .progress-bar{
  151. position: absolute;
  152. left: 0;
  153. bottom: 15px;
  154. left: 50%;
  155. transform: translateX(-50%);
  156. width: 90%;
  157. height: 15px;
  158. z-index: 3;
  159. color: #e1edd95d;
  160. transition: all 1s;
  161. z-index: 12;
  162. }
  163. }
  164. .screen-box {
  165. width: 100%;
  166. height: 100%;
  167. position: absolute;
  168. top:0;
  169. left:0;
  170. .screen-box3 {
  171. width: 100%;
  172. height: 100%;
  173. background: url(@/assets/images/screen-box3.png);
  174. background-size: cover;
  175. .step-list {
  176. width: 100%;
  177. height: calc(100% - 15px);
  178. .step-item {
  179. width: 100%;
  180. height: 100%;
  181. display: flex;
  182. justify-content: center;
  183. align-items: center;
  184. position: relative;
  185. >.name-box {
  186. position: absolute;
  187. left: calc(70 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  188. top: calc(100 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  189. writing-mode: vertical-rl;
  190. letter-spacing: 12px;
  191. background: url(@/assets/images/name-bg.png);
  192. background-size: 100% 100%;
  193. padding: 10px;
  194. color: #476446;
  195. font-family: 'KingHwa_OldSong';
  196. font-size: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  197. line-height: calc(29 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  198. // >:nth-child(odd){
  199. // color:#7B916B;
  200. // font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  201. // line-height: calc(21 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  202. // transform: translateX(-40%)
  203. // }
  204. .name-box2 {
  205. position: absolute;
  206. bottom: 0;
  207. right: 0;
  208. transform: translate(100%, 30%);
  209. writing-mode: vertical-rl;
  210. letter-spacing: 8px;
  211. font-family: 'KingHwa_OldSong';
  212. font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  213. line-height: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  214. color: #7B916B;
  215. white-space: nowrap;
  216. }
  217. }
  218. >img {
  219. // width: 40%;
  220. max-width: 50%;
  221. max-height: 80vh;
  222. margin-left: calc(50 /v-bind('windowSizeWhenDesignForRef')* v-bind('windowSizeInCssForRef'));
  223. margin-top: 10%;
  224. }
  225. }
  226. }
  227. .system-btns {
  228. width: 100%;
  229. padding: 0 calc(20 / v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  230. display: flex;
  231. justify-content: space-between;
  232. position: absolute;
  233. bottom: calc(20 /v-bind(windowSizeWhenDesignForRef) * v-bind(windowSizeInCssForRef));
  234. z-index: 20;
  235. }
  236. }
  237. }
  238. </style>