hookehuyr

refactor(components): 优化 SectionCard 组件内置渐变色逻辑

- 在 SectionCard 组件内添加默认渐变色处理
- 移除三个页面中的重复渐变色处理代码
- 统一使用浅蓝色渐变 background: linear-gradient(90deg, #EFF6FF 0%, #DBEAFE 100%)
- 保持 API 返回自定义渐变色的兼容性
- 简化页面代码,提升可维护性

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
<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 }">
<view v-if="title" class="px-[40rpx] py-[32rpx]" :style="{ background: computedBgGradient }">
<text class="text-[#1f2937] text-[32rpx] font-normal">{{ title }}</text>
</view>
......@@ -23,13 +23,14 @@
</template>
<script setup>
import { computed } from 'vue'
import SectionItem from './SectionItem.vue'
/**
* Section Card Component
* @description 可复用的分组卡片组件,用于展示带标题的项目列表
*/
defineProps({
const props = defineProps({
/**
* Section 标题
*/
......@@ -38,8 +39,9 @@ defineProps({
default: ''
},
/**
* Section 背景渐变色
* Section 背景渐变色(可选)
* @example 'linear-gradient(90deg, #F3E8FF 0%, #E9D5FF 100%)'
* @description 如果不传,则使用默认的浅蓝色渐变
*/
bgGradient: {
type: String,
......@@ -59,6 +61,20 @@ defineProps({
const emit = defineEmits(['item-click'])
/**
* 默认的卡片渐变背景色
* @description 统一的浅蓝色渐变,用于所有卡片
*/
const DEFAULT_GRADIENT = 'linear-gradient( 90deg, #EFF6FF 0%, #DBEAFE 100%)'
/**
* 计算最终的背景渐变色
* @description 如果传入了 bgGradient 则使用传入的,否则使用默认渐变
*/
const computedBgGradient = computed(() => {
return props.bgGradient || DEFAULT_GRADIENT
})
/**
* 处理项目点击
* @param {Object} item - 点击的项目数据
*/
......
......@@ -9,7 +9,6 @@
v-for="(section, index) in sections"
:key="index"
:title="section.title"
:bg-gradient="section.bgGradient"
:items="section.items"
@item-click="handleItemClick"
/>
......@@ -32,7 +31,6 @@ const go = useGo()
const sections = shallowRef([
{
title: '家庭成员',
bgGradient: 'linear-gradient(90deg, #F3E8FF 0%, #E9D5FF 100%)',
items: [
{
title: '成员列表',
......@@ -48,7 +46,6 @@ const sections = shallowRef([
},
{
title: '健康档案',
bgGradient: 'linear-gradient(90deg, #F0FDF4 0%, #DCFCE7 100%)',
items: [
{
title: '体检报告',
......@@ -64,7 +61,6 @@ const sections = shallowRef([
},
{
title: '资产管理',
bgGradient: 'linear-gradient(90deg, #FFF7ED 0%, #FFEDD5 100%)',
items: [
{
title: '保单管理',
......@@ -80,7 +76,6 @@ const sections = shallowRef([
},
{
title: '生活服务',
bgGradient: 'linear-gradient(90deg, #E0F2FE 0%, #BAE6FD 100%)',
items: [
{
title: '高端医疗',
......
......@@ -9,7 +9,6 @@
v-for="(section, index) in sections"
:key="index"
:title="section.title"
:bg-gradient="section.bgGradient"
:items="section.items"
@item-click="handleItemClick"
/>
......
......@@ -9,7 +9,6 @@
v-for="(section, index) in sections"
:key="index"
:title="section.title"
:bg-gradient="section.bgGradient"
:items="section.items"
@item-click="handleItemClick"
/>
......