mp-swiper.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="swiper">
  3. <view class="swiper-title">
  4. <swiper :style="{height:fullHeight}" class="swiper-tall" :indicator-dots="indicatorDots"
  5. :autoplay="autoplay" :previous-margin="previousMargin" :next-margin="nextMargin" :circular="circular"
  6. @change="change" :current="swiperCurrentIndex">
  7. <swiper-item class="swiper-container" v-for="(item,index) in list" :key="index" :item-id="index"
  8. :data-year="index">
  9. <view :animation="animationData[index]" class="swiper-item" >
  10. <image :src="item.image" mode=""></image>
  11. </view>
  12. </swiper-item>
  13. </swiper>
  14. </view>
  15. <view class="center flex-direction">
  16. <text style="margin-bottom: 50rpx;font-size: 32rpx;">{{list[swiperCurrentIndex].name}}</text>
  17. <view @click="createPoster" class="cu-btn flex round text-lg"
  18. style="padding: 46rpx 0;background-color: #EF9944;color: #FFFFFF;width: 76%;">
  19. 下一步
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import tkiQrcode from "tki-qrcode"
  26. export default {
  27. props: {
  28. list: Array
  29. },
  30. components: {
  31. tkiQrcode
  32. },
  33. data() {
  34. return {
  35. screenHeight: 0,
  36. animationData: {
  37. 0: {},
  38. 1: {},
  39. 2: {},
  40. 3: {}
  41. },
  42. title: '0',
  43. indicatorDots: false,
  44. autoplay: false,
  45. previousMargin: uni.upx2px(82) + 'px',
  46. nextMargin: uni.upx2px(82) + 'px',
  47. circular: true,
  48. zoomParam: 1.10,
  49. swiperCurrentIndex: 0,
  50. data: [],
  51. max: 0,
  52. }
  53. },
  54. computed: {
  55. fullHeight() {
  56. const res = uni.getSystemInfoSync();
  57. return res.windowHeight - (res.statusBarHeight + 44) + 'px';
  58. }
  59. },
  60. created() {
  61. this.animation = uni.createAnimation();
  62. this.animation.scale(this.zoomParam).step();
  63. this.animationData[0] = this.animation.export();
  64. },
  65. methods: {
  66. createPoster() {
  67. this.$emit('click', this.swiperCurrentIndex)
  68. },
  69. change(e) {
  70. this.swiperCurrentIndex = e.detail.current;
  71. this.title = e.detail.currentItemId;
  72. for (let key in this.animationData) {
  73. if (e.detail.currentItemId == key) {
  74. this.animation.scale(this.zoomParam).step();
  75. this.animationData[key] = this.animation.export();
  76. } else {
  77. this.animation.scale(1.0).step();
  78. this.animationData[key] = this.animation.export();
  79. }
  80. }
  81. this.$emit('change', this.list[this.swiperCurrentIndex].image)
  82. }
  83. }
  84. }
  85. </script>
  86. <style>
  87. page {
  88. display: flex;
  89. flex-wrap: wrap;
  90. }
  91. .save-btn {
  92. background-color: #EF9944;
  93. color: #FFFFFF;
  94. }
  95. .swiper-container {
  96. display: flex;
  97. align-items: center;
  98. }
  99. .swiper-item {
  100. display: flex;
  101. flex-wrap: wrap;
  102. justify-content: center;
  103. margin-left: auto;
  104. margin-right: auto;
  105. height: 760upx;
  106. width: 544upx;
  107. line-height: 300upx;
  108. text-align: center;
  109. margin-bottom: 50upx;
  110. }
  111. .swiper-tall {
  112. display: flex;
  113. align-items: center;
  114. }
  115. .swiper-title {
  116. margin-top: -100rpx;
  117. width: 760upx;
  118. text-align: center;
  119. }
  120. </style>