Files
cz-web/src/views/home/cpns/HomeBusinessCards.vue
2026-10-13 15:12:51 +08:00

146 lines
2.8 KiB
Vue

<script setup lang="ts">
import type { BusinessType } from '@/types/api'
import type { BusinessLine } from '@/types/business/home'
interface Props {
lines: BusinessLine[]
}
defineProps<Props>()
const FALLBACK_ACTIVE: BusinessType[] = ['internet']
</script>
<template>
<section class="home-business">
<h3 class="home-business__title">业务服务</h3>
<div class="home-business__grid">
<RouterLink
v-for="line in lines"
:key="line.id"
:to="`/business/${line.id}`"
class="home-business__card"
:class="{
'home-business__card--active': FALLBACK_ACTIVE.includes(line.id),
}"
>
<span class="home-business__check" aria-hidden="true" />
<h4 class="home-business__name">
{{ line.name }}
</h4>
<p class="home-business__desc">
{{ line.desc }}
</p>
</RouterLink>
</div>
</section>
</template>
<style lang="less" scoped>
.home-business {
padding: @spacing-xl;
border: none;
border-radius: @radius-base;
background: @white;
&__title {
margin: 0 0 @spacing-lg;
font-size: @font-size-xl;
font-weight: 600;
color: @home-ink;
}
&__grid {
display: flex;
gap: @spacing-base;
}
&__card {
position: relative;
.flex(column, flex-start, flex-start);
flex: 1 1 0;
min-width: 0;
min-height: 160px;
box-sizing: border-box;
padding: @spacing-lg;
overflow: hidden;
border: 1px solid @border-color;
border-radius: @radius-base;
background: @white;
transition:
transform 0.2s,
box-shadow 0.2s,
border-color 0.2s;
&:hover {
border-color: @primary-color;
box-shadow: @shadow-base;
transform: translateY(-2px);
}
}
&__check {
position: absolute;
top: 27px;
right: 37px;
flex-shrink: 0;
width: 31px;
height: 31px;
border: 1px solid @home-ring;
border-radius: @radius-round;
&::after {
content: '';
position: absolute;
inset: 0;
width: 21px;
height: 21px;
margin: auto;
border-radius: @radius-round;
background: @white;
opacity: 0;
}
}
&__name {
margin: @spacing-xxl 0 0;
font-size: @font-size-lg;
font-weight: 500;
line-height: 1.4;
color: @home-ink;
}
&__desc {
margin: @spacing-xs 0 0;
font-size: @font-size-sm;
font-weight: 400;
line-height: 1.5;
color: @text-color-secondary;
.multi-ellipsis(2);
}
&__card--active {
border-color: @primary-color;
background: @filter-selected-bg;
.home-business__check {
border-color: @primary-color;
&::after {
opacity: 1;
background: @primary-color;
}
}
.home-business__name {
color: @primary-strong;
}
.home-business__desc {
color: @text-color-secondary;
}
}
}
</style>