mp-swiper.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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" style="position: relative;">
  10. <image :src="item.image" mode=""></image>
  11. <view class="content">
  12. <text class="">{{shopDetail.name}}</text>
  13. <tki-qrcode style="margin-top: -100rpx;" cid="1" ref="qrcode-charge" :val="shopDetail.id" size="260" :onval="true"
  14. :loadMake="true" :usingComponents="true" />
  15. </view>
  16. </view>
  17. </swiper-item>
  18. </swiper>
  19. </view>
  20. <view class="center">
  21. <view class="cu-btn flex round text-lg"
  22. style="padding: 46rpx 0;background-color: #EF9944;color: #FFFFFF;width: 76%;">
  23. 生成海报
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import tkiQrcode from "tki-qrcode"
  30. export default {
  31. props: {
  32. list: Array
  33. },
  34. components: {
  35. tkiQrcode
  36. },
  37. data() {
  38. return {
  39. screenHeight: 0,
  40. animationData: {
  41. 0: {},
  42. 1: {},
  43. 2: {},
  44. 3: {}
  45. },
  46. title: '0',
  47. indicatorDots: false,
  48. autoplay: false,
  49. previousMargin: uni.upx2px(82) + 'px',
  50. nextMargin: uni.upx2px(82) + 'px',
  51. circular: true,
  52. zoomParam: 1.10,
  53. swiperCurrentIndex: 0,
  54. data: [],
  55. max: 0,
  56. //商户详情
  57. shopDetail: {}
  58. }
  59. },
  60. computed: {
  61. fullHeight() {
  62. const res = uni.getSystemInfoSync();
  63. return res.windowHeight - (res.statusBarHeight + 44) + 'px';
  64. }
  65. },
  66. async mounted(option) {
  67. let res = await this.$api.shop.detail({
  68. id: this.vuex_shopId
  69. })
  70. this.shopDetail = res.data
  71. },
  72. created() {
  73. this.animation = uni.createAnimation();
  74. this.animation.scale(this.zoomParam).step();
  75. this.animationData[0] = this.animation.export();
  76. },
  77. methods: {
  78. change(e) {
  79. this.swiperCurrentIndex = e.detail.current;
  80. this.title = e.detail.currentItemId;
  81. for (let key in this.animationData) {
  82. if (e.detail.currentItemId == key) {
  83. this.animation.scale(this.zoomParam).step();
  84. this.animationData[key] = this.animation.export();
  85. } else {
  86. this.animation.scale(1.0).step();
  87. this.animationData[key] = this.animation.export();
  88. }
  89. }
  90. this.$emit('change', this.swiperCurrentIndex)
  91. }
  92. }
  93. }
  94. </script>
  95. <style>
  96. page {
  97. display: flex;
  98. flex-wrap: wrap;
  99. }
  100. .content {
  101. position: absolute;
  102. display: flex;
  103. flex-direction: column;
  104. justify-content: center;
  105. align-items: center;
  106. top: 30rpx;
  107. }
  108. .save-btn {
  109. background-color: #EF9944;
  110. color: #FFFFFF;
  111. }
  112. .swiper-container {
  113. display: flex;
  114. align-items: center;
  115. }
  116. .swiper-item {
  117. display: flex;
  118. flex-wrap: wrap;
  119. justify-content: center;
  120. margin-left: auto;
  121. margin-right: auto;
  122. height: 760upx;
  123. width: 544upx;
  124. line-height: 300upx;
  125. text-align: center;
  126. margin-bottom: 50upx;
  127. }
  128. .swiper-tall {
  129. display: flex;
  130. align-items: center;
  131. }
  132. .swiper-title {
  133. margin-top: -100rpx;
  134. width: 760upx;
  135. text-align: center;
  136. }
  137. </style>