load-more.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="load-more">
  3. <view class="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="load-more__text" :style="{ color }">{{ text }}</text>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. name: 'load-more',
  29. props: {
  30. status: {
  31. // more - 上拉的状态
  32. // loading - 下拉加载
  33. // nomore - 没有更多了
  34. type: String,
  35. default: 'more'
  36. },
  37. showIcon: {
  38. type: Boolean,
  39. default: true
  40. },
  41. color: {
  42. type: String,
  43. default: '#777777'
  44. },
  45. contentText: {
  46. type: Object,
  47. default() {
  48. return {
  49. pulldown: '上拉显示更多',
  50. refresh: '正在加载...',
  51. nomore: '没有更多数据了'
  52. };
  53. }
  54. }
  55. },
  56. computed: {
  57. text() {
  58. const { status, contentText } = this;
  59. if (status === 'more') return contentText.pulldown;
  60. if (status === 'loading') return contentText.refresh;
  61. return contentText.nomore;
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss">
  67. .load-more {
  68. display: flex;
  69. flex-direction: row;
  70. height: 80upx;
  71. align-items: center;
  72. justify-content: center;
  73. &__text {
  74. font-size: 28upx;
  75. color: #999;
  76. }
  77. &__img {
  78. height: 24px;
  79. width: 24px;
  80. margin-right: 10px;
  81. > view {
  82. position: absolute;
  83. view {
  84. width: 6px;
  85. height: 2px;
  86. border-top-left-radius: 1px;
  87. border-bottom-left-radius: 1px;
  88. background: #999;
  89. position: absolute;
  90. opacity: 0.2;
  91. transform-origin: 50%;
  92. animation: load 1.56s ease infinite;
  93. &:nth-child(1) {
  94. transform: rotate(90deg);
  95. top: 2px;
  96. left: 9px;
  97. }
  98. &:nth-child(2) {
  99. transform: rotate(180deg);
  100. top: 11px;
  101. right: 0;
  102. }
  103. &:nth-child(3) {
  104. transform: rotate(270deg);
  105. bottom: 2px;
  106. left: 9px;
  107. }
  108. &:nth-child(4) {
  109. top: 11px;
  110. left: 0;
  111. }
  112. }
  113. }
  114. }
  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>