uni-load-more.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="uni-load-more">
  3. <view v-if="iconType==='circle' || iconType==='auto' && platform === 'android'" v-show="loadingType == 1 && showIcon" class="uni-load-more__img">
  4. <view :style="{borderColor : color}" class="loader-android" />
  5. </view>
  6. <view v-else v-show="loadingType == 1 && showIcon" class="uni-load-more__img">
  7. <view class="load1 load">
  8. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  9. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  10. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  11. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  12. </view>
  13. <view class="load2 load">
  14. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  15. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  16. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  17. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  18. </view>
  19. <view class="load3 load">
  20. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  21. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  22. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  23. <view :style="{ background: color }" class="uni-load-view_wrapper" />
  24. </view>
  25. </view>
  26. <text :style="{ color: color }" class="uni-load-more__text">
  27. {{loadingType == 0 ? contentText.contentdown : (loadingType == 1 ? contentText.contentrefresh : contentText.contentnomore)}}
  28. </text>
  29. </view>
  30. </template>
  31. <script>
  32. const platform = uni.getSystemInfoSync().platform
  33. export default {
  34. name: 'UniLoadMore',
  35. props: {
  36. loadingType: {
  37. //上拉的状态:0-loading前;1-loading中;2-没有更多了
  38. type: Number,
  39. default: 0
  40. },
  41. showIcon: {
  42. type: Boolean,
  43. default: true
  44. },
  45. iconType: {
  46. type: String,
  47. default: 'auto'
  48. },
  49. color: {
  50. type: String,
  51. default: '#777777'
  52. },
  53. contentText: {
  54. type: Object,
  55. default () {
  56. return {
  57. contentdown: '上拉显示更多',
  58. contentrefresh: '正在加载...',
  59. contentnomore: '没有更多数据了'
  60. }
  61. }
  62. }
  63. },
  64. data() {
  65. return {
  66. platform: platform
  67. }
  68. }
  69. }
  70. </script>
  71. <style>
  72. @charset "UTF-8";
  73. .uni-load-more {
  74. display: flex;
  75. flex-direction: row;
  76. height: 80upx;
  77. align-items: center;
  78. justify-content: center
  79. }
  80. .uni-load-more__text {
  81. font-size: 28upx;
  82. color: #999
  83. }
  84. .uni-load-more__img {
  85. position: relative;
  86. height: 24px;
  87. width: 24px;
  88. margin-right: 10px
  89. }
  90. .uni-load-more__img>.load {
  91. position: absolute
  92. }
  93. .uni-load-more__img>.load .uni-load-view_wrapper {
  94. width: 6px;
  95. height: 2px;
  96. border-top-left-radius: 1px;
  97. border-bottom-left-radius: 1px;
  98. background: #999;
  99. position: absolute;
  100. opacity: .2;
  101. transform-origin: 50%;
  102. animation: load .96s ease infinite
  103. }
  104. .uni-load-more__img>.load .uni-load-view_wrapper:nth-child(1) {
  105. transform: rotate(90deg);
  106. top: 2px;
  107. left: 9px
  108. }
  109. .uni-load-more__img>.load .uni-load-view_wrapper:nth-child(2) {
  110. transform: rotate(180deg);
  111. top: 11px;
  112. right: 0
  113. }
  114. .uni-load-more__img>.load .uni-load-view_wrapper:nth-child(3) {
  115. transform: rotate(270deg);
  116. bottom: 2px;
  117. left: 9px
  118. }
  119. .uni-load-more__img>.load .uni-load-view_wrapper:nth-child(4) {
  120. top: 11px;
  121. left: 0
  122. }
  123. .uni-load-more__img>.loader-android {
  124. position: absolute;
  125. left: 0;
  126. top: 0;
  127. right: 0;
  128. bottom: 0;
  129. box-sizing: border-box;
  130. border: solid 2px #777;
  131. border-radius: 50%;
  132. border-bottom-color: transparent !important;
  133. animation: loader-android 1s 0s linear infinite
  134. }
  135. .load1,
  136. .load2,
  137. .load3 {
  138. height: 24px;
  139. width: 24px
  140. }
  141. .load2 {
  142. transform: rotate(30deg)
  143. }
  144. .load3 {
  145. transform: rotate(60deg)
  146. }
  147. .load1 .uni-load-view_wrapper:nth-child(1) {
  148. animation-delay: 0s
  149. }
  150. .load2 .uni-load-view_wrapper:nth-child(1) {
  151. animation-delay: 80ms
  152. }
  153. .load3 .uni-load-view_wrapper:nth-child(1) {
  154. animation-delay: .16s
  155. }
  156. .load1 .uni-load-view_wrapper:nth-child(2) {
  157. animation-delay: .24s
  158. }
  159. .load2 .uni-load-view_wrapper:nth-child(2) {
  160. animation-delay: .32s
  161. }
  162. .load3 .uni-load-view_wrapper:nth-child(2) {
  163. animation-delay: .4s
  164. }
  165. .load1 .uni-load-view_wrapper:nth-child(3) {
  166. animation-delay: .48s
  167. }
  168. .load2 .uni-load-view_wrapper:nth-child(3) {
  169. animation-delay: .56s
  170. }
  171. .load3 .uni-load-view_wrapper:nth-child(3) {
  172. animation-delay: .64s
  173. }
  174. .load1 .uni-load-view_wrapper:nth-child(4) {
  175. animation-delay: .72s
  176. }
  177. .load2 .uni-load-view_wrapper:nth-child(4) {
  178. animation-delay: .8s
  179. }
  180. .load3 .uni-load-view_wrapper:nth-child(4) {
  181. animation-delay: .88s
  182. }
  183. @-webkit-keyframes load {
  184. 0% {
  185. opacity: 1
  186. }
  187. 100% {
  188. opacity: .2
  189. }
  190. }
  191. @-webkit-keyframes loader-android {
  192. 0% {
  193. transform: rotate(0)
  194. }
  195. 100% {
  196. transform: rotate(360deg)
  197. }
  198. }
  199. </style>