uni-load-more.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="uni-load-more">
  3. <view class="uni-load-more__img" v-show="status === 'loading' && showIcon">
  4. <view class="load1 load">
  5. <view class="item" :style="{background:color}"></view>
  6. <view class="item" :style="{background:color}"></view>
  7. <view class="item" :style="{background:color}"></view>
  8. <view class="item" :style="{background:color}"></view>
  9. </view>
  10. <view class="load2 load">
  11. <view class="item" :style="{background:color}"></view>
  12. <view class="item" :style="{background:color}"></view>
  13. <view class="item" :style="{background:color}"></view>
  14. <view class="item" :style="{background:color}"></view>
  15. </view>
  16. <view class="load3 load">
  17. <view class="item" :style="{background:color}"></view>
  18. <view class="item" :style="{background:color}"></view>
  19. <view class="item" :style="{background:color}"></view>
  20. <view class="item" :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. import { mapState, mapMutations } from 'vuex';
  28. export default {
  29. name: "uni-load-more",
  30. props: {
  31. status: {
  32. //上拉的状态:more-loading前;loading-loading中;noMore-没有更多了
  33. type: String,
  34. default: 'more'
  35. },
  36. showIcon: {
  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: this.$t('hea.sljzgd'),
  49. contentrefresh: this.$t('hea.loading'),
  50. contentnomore: this.$t('hea.nomore')
  51. };
  52. }
  53. }
  54. },
  55. data() {
  56. return {}
  57. },
  58. computed: {
  59. ...mapState(['lang'])
  60. },
  61. watch: {
  62. lang(val) {
  63. this.$set(this.contentText,'contentdown',this.$t('hea.sljzgd'))
  64. this.$set(this.contentText,'contentrefresh',this.$t('hea.loading'))
  65. this.$set(this.contentText,'contentnomore',this.$t('hea.nomore'))
  66. }
  67. },
  68. }
  69. </script>
  70. <style>
  71. @charset "UTF-8";
  72. .uni-load-more {
  73. display: flex;
  74. flex-direction: row;
  75. height: 80upx;
  76. align-items: center;
  77. justify-content: center
  78. }
  79. .uni-load-more__text {
  80. font-size: 28upx;
  81. color: #999
  82. }
  83. .uni-load-more__img {
  84. height: 24px;
  85. width: 24px;
  86. margin-right: 10px
  87. }
  88. .uni-load-more__img>.load {
  89. position: absolute
  90. }
  91. .uni-load-more__img>.load .item {
  92. width: 6px;
  93. height: 2px;
  94. border-top-left-radius: 1px;
  95. border-bottom-left-radius: 1px;
  96. background: #999;
  97. position: absolute;
  98. opacity: .2;
  99. transform-origin: 50%;
  100. animation: load 1.56s ease infinite
  101. }
  102. .uni-load-more__img>.load .item:nth-child(1) {
  103. transform: rotate(90deg);
  104. top: 2px;
  105. left: 9px
  106. }
  107. .uni-load-more__img>.load .item:nth-child(2) {
  108. transform: rotate(180deg);
  109. top: 11px;
  110. right: 0
  111. }
  112. .uni-load-more__img>.load .item:nth-child(3) {
  113. transform: rotate(270deg);
  114. bottom: 2px;
  115. left: 9px
  116. }
  117. .uni-load-more__img>.load .item:nth-child(4) {
  118. top: 11px;
  119. left: 0
  120. }
  121. .load1,
  122. .load2,
  123. .load3 {
  124. height: 24px;
  125. width: 24px
  126. }
  127. .load2 {
  128. transform: rotate(30deg)
  129. }
  130. .load3 {
  131. transform: rotate(60deg)
  132. }
  133. .load1 .item:nth-child(1) {
  134. animation-delay: 0s
  135. }
  136. .load2 .item:nth-child(1) {
  137. animation-delay: .13s
  138. }
  139. .load3 .item:nth-child(1) {
  140. animation-delay: .26s
  141. }
  142. .load1 .item:nth-child(2) {
  143. animation-delay: .39s
  144. }
  145. .load2 .item:nth-child(2) {
  146. animation-delay: .52s
  147. }
  148. .load3 .item:nth-child(2) {
  149. animation-delay: .65s
  150. }
  151. .load1 .item:nth-child(3) {
  152. animation-delay: .78s
  153. }
  154. .load2 .item:nth-child(3) {
  155. animation-delay: .91s
  156. }
  157. .load3 .item:nth-child(3) {
  158. animation-delay: 1.04s
  159. }
  160. .load1 .item:nth-child(4) {
  161. animation-delay: 1.17s
  162. }
  163. .load2 .item:nth-child(4) {
  164. animation-delay: 1.3s
  165. }
  166. .load3 .item:nth-child(4) {
  167. animation-delay: 1.43s
  168. }
  169. @-webkit-keyframes load {
  170. 0% {
  171. opacity: 1
  172. }
  173. 100% {
  174. opacity: .2
  175. }
  176. }
  177. </style>