cl-loadmore.uvue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="cl-loadmore-wrapper">
  3. <view class="cl-loadmore">
  4. <cl-loading
  5. :size="28"
  6. :pt="{
  7. className: `mr-2 ${pt.icon?.className}`
  8. }"
  9. v-if="loading"
  10. ></cl-loading>
  11. <cl-text
  12. :pt="{
  13. className: pt.text?.className
  14. }"
  15. >{{ message }}</cl-text
  16. >
  17. </view>
  18. <cl-safe-area type="bottom" v-if="safeAreaBottom"></cl-safe-area>
  19. </view>
  20. </template>
  21. <script lang="ts" setup>
  22. import { t } from "@/locale";
  23. import { computed } from "vue";
  24. import { parsePt } from "@/cool";
  25. import type { PassThroughProps } from "../../types";
  26. defineOptions({
  27. name: "cl-loadmore"
  28. });
  29. const props = defineProps({
  30. pt: {
  31. type: Object,
  32. default: () => ({})
  33. },
  34. // 是否加载中
  35. loading: {
  36. type: Boolean,
  37. default: false
  38. },
  39. // 加载中显示内容
  40. loadingText: {
  41. type: String,
  42. default: () => t("加载中")
  43. },
  44. // 是否加载完成
  45. finish: {
  46. type: Boolean,
  47. default: false
  48. },
  49. // 加载完成显示内容
  50. finishText: {
  51. type: String,
  52. default: () => t("没有更多了")
  53. },
  54. // 是否显示底部安全区
  55. safeAreaBottom: {
  56. type: Boolean,
  57. default: false
  58. }
  59. });
  60. type PassThrough = {
  61. className?: string;
  62. icon?: PassThroughProps;
  63. text?: PassThroughProps;
  64. };
  65. const pt = computed(() => parsePt<PassThrough>(props.pt));
  66. // 消息内容
  67. const message = computed(() => {
  68. if (props.finish) {
  69. return props.finishText;
  70. }
  71. if (props.loading) {
  72. return props.loadingText;
  73. }
  74. return "";
  75. });
  76. </script>
  77. <style lang="scss" scoped>
  78. .cl-loadmore-wrapper {
  79. @apply flex flex-col items-center justify-center py-2;
  80. }
  81. .cl-loadmore {
  82. @apply flex flex-row items-center justify-center;
  83. }
  84. </style>