SectionCard.vue
1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<template>
<view class="bg-white rounded-[32rpx] mb-[32rpx] pb-[56rpx] overflow-hidden shadow-sm">
<!-- Section Header -->
<view v-if="title" class="px-[40rpx] py-[32rpx]" :style="{ background: bgGradient }">
<text class="text-[#1f2937] text-[32rpx] font-normal">{{ title }}</text>
</view>
<!-- Section Items -->
<view class="flex flex-col">
<view v-for="(item, index) in items" :key="index" class="flex flex-col">
<SectionItem
:icon="item.icon"
:title="item.title"
:subtitle="item.subtitle"
:route="item.route"
@click="handleItemClick(item)"
/>
<!-- Divider -->
<view v-if="index < items.length - 1" class="w-[626rpx] h-[2rpx] bg-[#e5e7eb] mx-auto mt-[32rpx]"></view>
</view>
</view>
</view>
</template>
<script setup>
import SectionItem from './SectionItem.vue'
/**
* Section Card Component
* @description 可复用的分组卡片组件,用于展示带标题的项目列表
*/
defineProps({
/**
* Section 标题
*/
title: {
type: String,
default: ''
},
/**
* Section 背景渐变色
* @example 'linear-gradient(90deg, #F3E8FF 0%, #E9D5FF 100%)'
*/
bgGradient: {
type: String,
default: ''
},
/**
* 项目列表
* @example [{ icon: 'Edit', title: '标题', subtitle: '副标题', route: '/page/path' }]
*/
items: {
type: Array,
required: true,
default: () => []
}
})
const emit = defineEmits(['item-click'])
/**
* 处理项目点击
* @param {Object} item - 点击的项目数据
*/
const handleItemClick = (item) => {
emit('item-click', item)
}
</script>
<script>
export default {
name: 'SectionCard'
}
</script>