uni-load-more.vue 3.3 KB

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