cl-loadmore.uvue 1.5 KB

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