card-menu.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <script setup lang="ts">
  2. import Card from '@/components/card.vue'
  3. defineProps({
  4. customClass: {
  5. type: String,
  6. default: '',
  7. },
  8. items: {
  9. type: Array as PropType<
  10. {
  11. title: string
  12. desc?: string
  13. icon: string
  14. class: string
  15. colStart?: number
  16. colEnd?: number
  17. rowStart?: number
  18. rowEnd?: number
  19. iconSize?: number
  20. gridItemClass?: string
  21. path?: string
  22. }[]
  23. >,
  24. default: () => [],
  25. },
  26. })
  27. const handleCilck = async ({ path }: any) => {
  28. path && uni.navigateTo({ url: path })
  29. }
  30. </script>
  31. <template>
  32. <view class="my-6 grid grid-gap-2.5" :class="customClass">
  33. <template v-for="it of items" :key="it.title">
  34. <div :class="it.gridItemClass" @click="handleCilck(it)">
  35. <card
  36. :custom-class="
  37. [
  38. it.class,
  39. 'flex flex-col justify-between items-center',
  40. it.colStart ? `col-start-${it.colStart}` : '',
  41. it.colEnd ? `col-end-${it.colEnd}` : '',
  42. it.rowStart ? `row-start-${it.rowStart}` : '',
  43. it.rowEnd ? `row-end-${it.rowEnd}` : '',
  44. ].join(' ')
  45. "
  46. >
  47. <div class="my-3.5 flex flex-col justify-start h-full">
  48. <div class="text-black/80 text-base font-normal font-['PingFang_SC'] leading-[10.18px]">
  49. {{ it.title }}
  50. </div>
  51. <div class="mt-1 text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
  52. {{ it.desc }}
  53. </div>
  54. </div>
  55. <view class="flex-1 w-full flex items-end justify-end">
  56. <wd-img :src="it.icon" :width="it.iconSize ?? 24" :height="it.iconSize ?? 24"></wd-img>
  57. </view>
  58. </card>
  59. </div>
  60. </template>
  61. </view>
  62. </template>