mp-swiper -tmp.vue 3.5 KB

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