barrageY.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="wrapper" :style="{ paddingTop: top + 'px' }">
  3. <view class="scroll-content" :animation="animationData" @transitionend="animalEnd">
  4. <view class="item" v-for="(item, index) in data" :key="index">
  5. <image :src="resource.barrage" class="bg" />
  6. <image
  7. :src="item.avatar"
  8. class="image"
  9. style="display: inline-block; vertical-align: middle"
  10. />
  11. <view class="context" style="display: inline-block">
  12. <view class="flex-align">
  13. <text class="text">{{ item.nickname }}购买</text>
  14. <text :style="{ color: LEVEL_MAP[item.level].color }" class="marginX2">
  15. {{ LEVEL_MAP[item.level].title }}
  16. </text>
  17. <image
  18. :src="item.cover"
  19. class="marginL5 radius4"
  20. style="width: 40rpx; height: 40rpx"
  21. />
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { LEVEL_MAP } from '@/utils/config'
  30. import resource from '@/utils/resource'
  31. export default {
  32. props: {
  33. top: {
  34. type: Number,
  35. default: 0
  36. }
  37. },
  38. data() {
  39. return {
  40. resource,
  41. data: null,
  42. LEVEL_MAP,
  43. animationData: null
  44. }
  45. },
  46. created() {
  47. this.animation = wx.createAnimation({
  48. timingFunction: 'linear'
  49. })
  50. },
  51. beforeDestroy() {
  52. this.animation = null
  53. this.animationData = null
  54. },
  55. methods: {
  56. start(value) {
  57. this.data = value
  58. this.$nextTick(() => {
  59. this.startAnimal()
  60. })
  61. },
  62. startAnimal() {
  63. this.animation.translateY(0).step({
  64. duration: 0
  65. })
  66. this.animationData = this.animation.export()
  67. setTimeout(() => {
  68. const lenght = this.data.length
  69. this.animation.translateY(-lenght * 37).step({
  70. duration: lenght * 1000
  71. })
  72. this.animationData = this.animation.export()
  73. }, 100)
  74. },
  75. animalEnd() {
  76. this.startAnimal()
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .wrapper {
  83. position: relative;
  84. height: 260rpx;
  85. width: 370rpx;
  86. overflow: hidden;
  87. }
  88. .scroll-content {
  89. position: relative;
  90. height: 260rpx;
  91. white-space: nowrap;
  92. width: 370rpx;
  93. }
  94. .bg {
  95. position: absolute;
  96. width: 320rpx;
  97. height: 60rpx;
  98. top: -6rpx;
  99. left: 0rpx;
  100. opacity: 0.6;
  101. }
  102. .item {
  103. position: relative;
  104. margin-left: 28rpx;
  105. padding-left: 8rpx;
  106. margin-bottom: 24rpx;
  107. height: 60rpx;
  108. border-radius: 24rpx;
  109. background: rgba($color: #000000, $alpha: 0.2);
  110. // border: 1rpx solid rgba(255, 255, 255, 0.2);
  111. // overflow: hidden;
  112. .image {
  113. width: 48rpx;
  114. height: 48rpx;
  115. border-radius: 24rpx;
  116. margin-left: -2rpx;
  117. }
  118. .context {
  119. padding: 0 20rpx;
  120. color: #fff;
  121. font-size: 20rpx;
  122. .text {
  123. opacity: 0.7;
  124. }
  125. }
  126. }
  127. </style>