cl-loadmore.uvue 1.6 KB

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