ImageBlock3.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <Touchable
  3. touchable
  4. v-bind="props"
  5. :flexShrink="0"
  6. :innerStyle="{ borderRadius: theme.resolveThemeSize(radius), overflow: 'hidden', }"
  7. @click="$emit('click')"
  8. >
  9. <Image
  10. :src="src"
  11. :width="imageWidth"
  12. :height="imageHeight"
  13. :radius="imageRadius"
  14. :defaultImage="defaultImage"
  15. mode="aspectFill"
  16. />
  17. <FlexView direction="column">
  18. <slot name="desc">
  19. <IconTextBlock
  20. :title="title"
  21. :titleProps="titleProps"
  22. :desc="desc"
  23. :descProps="descProps"
  24. :extra="extra"
  25. :extraProps="extraProps"
  26. :extraMpSlotState="Boolean($slots.extra)"
  27. >
  28. <template v-if="$slots.extra" #extra>
  29. <slot name="extra" />
  30. </template>
  31. </IconTextBlock>
  32. </slot>
  33. <slot name="footer" />
  34. </FlexView>
  35. </Touchable>
  36. </template>
  37. <script lang="ts">
  38. /**
  39. * 组件说明:图片块3。
  40. *
  41. * 该组件可以用于显示图片,左边图片,右边描述。
  42. *
  43. * 该组件的默认高度为 200rpx。
  44. */
  45. export default {}
  46. </script>
  47. <script setup lang="ts">
  48. import { useTheme } from '@/components/theme/ThemeDefine';
  49. import FlexView, { type FlexProps } from '../../layout/FlexView.vue';
  50. import Image from '../../basic/Image.vue';
  51. import Touchable from '@/components/feedback/Touchable.vue';
  52. import IconTextBlock from './IconTextBlock.vue';
  53. import type { TextProps } from '@/components/basic/Text.vue';
  54. export interface ImageBlock3Props extends Partial<FlexProps> {
  55. /**
  56. * 宽度
  57. */
  58. imageWidth?: string | number;
  59. /**
  60. * 高度。
  61. */
  62. imageHeight?: string | number;
  63. /**
  64. * 默认图片。
  65. */
  66. defaultImage?: string;
  67. /**
  68. * 图片的路径。
  69. */
  70. src?: string;
  71. /**
  72. * 图片的圆角。
  73. */
  74. imageRadius?: string | number;
  75. /**
  76. * 图片下方显示标题。
  77. */
  78. title?: string | number;
  79. /**
  80. * 图片下方显示描述。
  81. */
  82. desc?: string | number;
  83. /**
  84. * 图片下方显示额外信息。
  85. */
  86. extra?: string | number;
  87. /**
  88. * 图片下方显示标题的文字属性。
  89. */
  90. titleProps?: TextProps;
  91. /**
  92. * 图片下方显示描述的文字属性。
  93. */
  94. descProps?: TextProps;
  95. /**
  96. * 图片下方显示额外信息的文字属性。
  97. */
  98. extraProps?: TextProps;
  99. }
  100. const theme = useTheme();
  101. const props = withDefaults(defineProps<ImageBlock3Props>(), {
  102. imageWidth: 150,
  103. imageHeight: 150,
  104. imageRadius: 0,
  105. backgroundColor: "white",
  106. direction: "row",
  107. align: "center",
  108. overflow: "hidden",
  109. gap:20,
  110. })
  111. defineEmits([
  112. "click"
  113. ])
  114. </script>