uni-load-more.vue 3.3 KB

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