load-more.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="load-more" v-if="loadingType !== -1" :style="{ marginTop: marginTop + 'px' }">
  3. <view class="loading-img" v-show="loadingType === 1 && showImage">
  4. <view class="load1">
  5. <view :style="{ background: color }"></view>
  6. <view :style="{ background: color }"></view>
  7. <view :style="{ background: color }"></view>
  8. <view :style="{ background: color }"></view>
  9. </view>
  10. <view class="load2">
  11. <view :style="{ background: color }"></view>
  12. <view :style="{ background: color }"></view>
  13. <view :style="{ background: color }"></view>
  14. <view :style="{ background: color }"></view>
  15. </view>
  16. <view class="load3">
  17. <view :style="{ background: color }"></view>
  18. <view :style="{ background: color }"></view>
  19. <view :style="{ background: color }"></view>
  20. <view :style="{ background: color }"></view>
  21. </view>
  22. </view>
  23. <text class="loading-text" :style="{ color: color }">
  24. {{ loadingText ? loadingText : loadingType === 0 ? loadingTexts.down : loadingType === 1 ? loadingTexts.refresh : loadingType === 2 ? loadingTexts.noMore : loadingTexts.wrong }}
  25. </text>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name: 'load-more',
  31. props: {
  32. // 上拉的状态:0-loading前;1-loading中;2-没有更多了;3-没有更多了
  33. loadingType: {
  34. type: Number,
  35. default: -1
  36. },
  37. loadingText: {
  38. type: String,
  39. default: ''
  40. },
  41. loadingTexts: {
  42. type: Object,
  43. default: () => {
  44. return {
  45. down: '上拉显示更多',
  46. refresh: '正在加载...',
  47. noMore: '没有更多数据了',
  48. wrong: '没有更多数据了!'
  49. };
  50. }
  51. },
  52. showImage: {
  53. type: Boolean,
  54. default: true
  55. },
  56. color: {
  57. type: String,
  58. default: '#777777'
  59. },
  60. top: {
  61. type: Number,
  62. default: 20
  63. }
  64. },
  65. data() {
  66. return {
  67. marginTop: 0
  68. };
  69. },
  70. created() {
  71. this.marginTop = this.$logic.rpx2px(this.top);
  72. },
  73. };
  74. </script>
  75. <style>
  76. .load-more {
  77. display: flex;
  78. flex-direction: row;
  79. height: 80upx;
  80. align-items: center;
  81. justify-content: center;
  82. }
  83. .loading-img {
  84. height: 48rpx;
  85. width: 48rpx;
  86. margin-right: 20rpx;
  87. }
  88. .loading-text {
  89. font-size: 30rpx;
  90. color: #777777;
  91. }
  92. .loading-img > view {
  93. position: absolute;
  94. }
  95. .load1,
  96. .load2,
  97. .load3 {
  98. height: 50rpx;
  99. width: 50rpx;
  100. }
  101. .load2 {
  102. transform: rotate(30deg);
  103. }
  104. .load3 {
  105. transform: rotate(60deg);
  106. }
  107. .loading-img > view view {
  108. width: 12rpx;
  109. height: 4rpx;
  110. border-top-left-radius: 1px;
  111. border-bottom-left-radius: 1px;
  112. background: #777;
  113. position: absolute;
  114. opacity: 0.2;
  115. transform-origin: 50%;
  116. -webkit-animation: load 1.56s ease infinite;
  117. }
  118. .loading-img > view view:nth-child(1) {
  119. transform: rotate(90deg);
  120. top: 2px;
  121. left: 9px;
  122. }
  123. .loading-img > view view:nth-child(2) {
  124. -webkit-transform: rotate(180deg);
  125. top: 11px;
  126. right: 0px;
  127. }
  128. .loading-img > view view:nth-child(3) {
  129. transform: rotate(270deg);
  130. bottom: 4rpx;
  131. left: 18rpx;
  132. }
  133. .loading-img > view view:nth-child(4) {
  134. top: 22rpx;
  135. left: 0px;
  136. }
  137. .load1 view:nth-child(1) {
  138. animation-delay: 0s;
  139. }
  140. .load2 view:nth-child(1) {
  141. animation-delay: 0.13s;
  142. }
  143. .load3 view:nth-child(1) {
  144. animation-delay: 0.26s;
  145. }
  146. .load1 view:nth-child(2) {
  147. animation-delay: 0.39s;
  148. }
  149. .load2 view:nth-child(2) {
  150. animation-delay: 0.52s;
  151. }
  152. .load3 view:nth-child(2) {
  153. animation-delay: 0.65s;
  154. }
  155. .load1 view:nth-child(3) {
  156. animation-delay: 0.78s;
  157. }
  158. .load2 view:nth-child(3) {
  159. animation-delay: 0.91s;
  160. }
  161. .load3 view:nth-child(3) {
  162. animation-delay: 1.04s;
  163. }
  164. .load1 view:nth-child(4) {
  165. animation-delay: 1.17s;
  166. }
  167. .load2 view:nth-child(4) {
  168. animation-delay: 1.3s;
  169. }
  170. .load3 view:nth-child(4) {
  171. animation-delay: 1.43s;
  172. }
  173. @-webkit-keyframes load {
  174. 0% {
  175. opacity: 1;
  176. }
  177. 100% {
  178. opacity: 0.2;
  179. }
  180. }
  181. </style>