uni-load-more.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="uni-load-more" @click="onClick">
  3. <!-- #ifdef APP-NVUE -->
  4. <loading-indicator v-if="status === 'loading' && showIcon" :style="{color: color}" :animating="true"
  5. class="uni-load-more__img uni-load-more__img--nvue"></loading-indicator>
  6. <!-- #endif -->
  7. <!-- #ifdef APP-NVUE || H5 -->
  8. <text class="uni-load-more__text"
  9. :style="{color: color}">{{ status === 'more' ? contentText.contentdown : status === 'loading' ? contentText.contentrefresh : contentText.contentnomore }}</text>
  10. <!-- #endif -->
  11. </view>
  12. </template>
  13. <script>
  14. const platform = uni.getSystemInfoSync().platform
  15. export default {
  16. name: 'UniLoadMore',
  17. props: {
  18. status: {
  19. // 上拉的状态:more-loading前;loading-loading中;noMore-没有更多了
  20. type: String,
  21. default: 'more'
  22. },
  23. showIcon: {
  24. type: Boolean,
  25. default: true
  26. },
  27. iconType: {
  28. type: String,
  29. default: 'auto'
  30. },
  31. color: {
  32. type: String,
  33. default: '#777777'
  34. },
  35. contentText: {
  36. type: Object,
  37. default () {
  38. return {
  39. contentdown: '上拉显示更多',
  40. contentrefresh: '正在加载...',
  41. contentnomore: '没有更多数据了'
  42. }
  43. }
  44. }
  45. },
  46. data() {
  47. return {
  48. platform: platform
  49. }
  50. },
  51. methods: {
  52. onClick() {
  53. this.$emit('clickLoadMore', {
  54. detail: {
  55. status: this.status,
  56. }
  57. })
  58. }
  59. }
  60. }
  61. </script>
  62. <style scoped>
  63. .uni-load-more {
  64. /* #ifndef APP-NVUE */
  65. display: flex;
  66. /* #endif */
  67. flex-direction: row;
  68. height: 40px;
  69. align-items: center;
  70. justify-content: center;
  71. }
  72. .uni-load-more__text {
  73. font-size: 15px;
  74. }
  75. .uni-load-more__img {
  76. width: 24px;
  77. height: 24px;
  78. margin-right: 8px;
  79. }
  80. .uni-load-more__img--nvue {
  81. color: #666666;
  82. }
  83. .uni-load-more__img--android,
  84. .uni-load-more__img--ios {
  85. width: 24px;
  86. height: 24px;
  87. transform: rotate(0deg);
  88. }
  89. </style>