uni-load-more.vue 3.4 KB

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