fs-card.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="fs-card" :class="{'fs-card-full': full, 'fs-card-gutter': gutter}" @click="handleClick">
  3. <view class="fs-card-box" :class="{'fs-card-radius': radius, shadow}">
  4. <view class="fs-card-title" v-if="slots.title || title" :style="titleStyle">
  5. <slot name="title">{{title}}</slot>
  6. </view>
  7. <view :class="{'fs-card-content': contentPadding}">
  8. <slot></slot>
  9. </view>
  10. <view class="fs-card-ft" v-if="slots.footer">
  11. <slot name="footer"></slot>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import { useSlots } from 'vue'
  18. const props = defineProps({
  19. title: String,
  20. titleStyle: {
  21. type: Object,
  22. default() {
  23. return {}
  24. }
  25. },
  26. full: Boolean,
  27. gutter: Boolean,
  28. radius: {
  29. type: Boolean,
  30. default: true
  31. },
  32. shadow: {
  33. type: Boolean,
  34. default: false
  35. },
  36. contentPadding: Boolean,
  37. link: String,
  38. linkType: {
  39. type: String,
  40. default: 'navigateTo'
  41. },
  42. })
  43. const slots = useSlots()
  44. const emits = defineEmits(['click'])
  45. const handleClick = () => {
  46. if (props.link) {
  47. uni[props.linkType]({
  48. url: props.link
  49. })
  50. }
  51. emits('click')
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .fs-card{
  56. margin-left: var(--gutter);
  57. margin-right: var(--gutter);
  58. &-box{
  59. background-color: #fff;
  60. overflow: hidden;
  61. }
  62. &-radius{
  63. border-radius: var(--radius);
  64. }
  65. &-title{
  66. padding: 20rpx var(--gutter);
  67. border-bottom: 2rpx solid var(--border-color);
  68. }
  69. &-ft{
  70. padding: 20rpx var(--gutter);
  71. border-top: 2rpx solid var(--border-color);
  72. }
  73. &-content{
  74. padding: 20rpx var(--gutter);
  75. }
  76. &-full{
  77. margin-left: 0;
  78. margin-right: 0;
  79. }
  80. &-gutter{
  81. margin-bottom: var(--gutter-v);
  82. }
  83. }
  84. </style>