uni-load-more.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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}">{{status === 'more' ? contentText.contentdown : (status === 'loading' ? contentText.contentrefresh : contentText.contentnomore)}}</text>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. name: "uni-load-more",
  29. props: {
  30. status: {
  31. //上拉的状态:more-loading前;loading-loading中;noMore-没有更多了
  32. type: String,
  33. default: 'more'
  34. },
  35. showIcon: {
  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. @charset "UTF-8";
  61. .uni-load-more {
  62. display: flex;
  63. flex-direction: row;
  64. height: 80upx;
  65. align-items: center;
  66. justify-content: center
  67. }
  68. .uni-load-more__text {
  69. font-size: 28upx;
  70. color: #999
  71. }
  72. .uni-load-more__img {
  73. height: 24px;
  74. width: 24px;
  75. margin-right: 10px
  76. }
  77. .uni-load-more__img>view {
  78. position: absolute
  79. }
  80. .uni-load-more__img>view view {
  81. width: 6px;
  82. height: 2px;
  83. border-top-left-radius: 1px;
  84. border-bottom-left-radius: 1px;
  85. background: #999;
  86. position: absolute;
  87. opacity: .2;
  88. transform-origin: 50%;
  89. animation: load 1.56s ease infinite
  90. }
  91. .uni-load-more__img>view view:nth-child(1) {
  92. transform: rotate(90deg);
  93. top: 2px;
  94. left: 9px
  95. }
  96. .uni-load-more__img>view view:nth-child(2) {
  97. transform: rotate(180deg);
  98. top: 11px;
  99. right: 0
  100. }
  101. .uni-load-more__img>view view:nth-child(3) {
  102. transform: rotate(270deg);
  103. bottom: 2px;
  104. left: 9px
  105. }
  106. .uni-load-more__img>view view:nth-child(4) {
  107. top: 11px;
  108. left: 0
  109. }
  110. .load1,
  111. .load2,
  112. .load3 {
  113. height: 24px;
  114. width: 24px
  115. }
  116. .load2 {
  117. transform: rotate(30deg)
  118. }
  119. .load3 {
  120. transform: rotate(60deg)
  121. }
  122. .load1 view:nth-child(1) {
  123. animation-delay: 0s
  124. }
  125. .load2 view:nth-child(1) {
  126. animation-delay: .13s
  127. }
  128. .load3 view:nth-child(1) {
  129. animation-delay: .26s
  130. }
  131. .load1 view:nth-child(2) {
  132. animation-delay: .39s
  133. }
  134. .load2 view:nth-child(2) {
  135. animation-delay: .52s
  136. }
  137. .load3 view:nth-child(2) {
  138. animation-delay: .65s
  139. }
  140. .load1 view:nth-child(3) {
  141. animation-delay: .78s
  142. }
  143. .load2 view:nth-child(3) {
  144. animation-delay: .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.3s
  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: .2
  164. }
  165. }
  166. </style>