Files
klp-mono/apps/hand-factory/components/klp-ui/k-info-card/k-info-card.vue

145 lines
2.7 KiB
Vue
Raw Normal View History

2025-10-27 13:21:43 +08:00
<template>
<view class="card-container" :style="{ borderRadius: borderRadius }">
<!-- 头部区域 -->
<view class="card-header" :style="headerStyle">
<text class="header-title">{{ title }}</text>
<text class="header-value">{{ value }}</text>
</view>
<!-- 信息容器条件渲染 -->
<view v-if="info && info.length" class="info-container">
<view v-for="(item, rowIndex) in info" :key="rowIndex" class="info-item">
<text class="info-label">{{ item.label }}</text>
<text class="info-value">
{{ item.value }}
<text v-if="item.unit" class="unit-text">{{ item.unit }}</text>
</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'DeviceInfoCard',
props: {
title: {
type: String,
required: true
},
value: {
type: [String, Number],
required: true
},
info: {
type: Array,
default: () => []
},
// 样式相关props
borderRadius: {
type: String,
default: '10rpx'
},
headerStyle: {
type: Object,
default: () => ({
backgroundColor: '#d9edf6',
border: '1px solid #d9edf6'
})
},
itemWidth: {
type: String,
default: '48%' // 控制信息项宽度
}
}
}
</script>
<style scoped>
2025-10-29 15:38:20 +08:00
/* 简洁信息卡片容器 */
2025-10-27 13:21:43 +08:00
.card-container {
overflow: hidden;
2025-10-29 15:38:20 +08:00
background: #ffffff;
border-radius: 16rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
border: 1rpx solid #e8e8e8;
transition: all 0.2s ease;
&:active {
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
}
2025-10-27 13:21:43 +08:00
}
2025-10-29 15:38:20 +08:00
/* 简洁头部样式 */
2025-10-27 13:21:43 +08:00
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
2025-10-29 15:38:20 +08:00
padding: 24rpx 30rpx;
background: #1a73e8;
2025-10-27 13:21:43 +08:00
}
.header-title {
font-size: 32rpx;
2025-10-29 15:38:20 +08:00
color: #ffffff;
font-weight: 600;
2025-10-27 13:21:43 +08:00
}
.header-value {
font-size: 36rpx;
2025-10-29 15:38:20 +08:00
color: #ffffff;
font-weight: 700;
2025-10-27 13:21:43 +08:00
}
/* 信息容器 */
.info-container {
2025-10-29 15:38:20 +08:00
padding: 30rpx;
2025-10-27 13:21:43 +08:00
display: flex;
box-sizing: border-box;
flex-wrap: wrap;
2025-10-29 15:38:20 +08:00
gap: 20rpx;
background: #fff;
2025-10-27 13:21:43 +08:00
}
.info-row {
display: flex;
justify-content: space-between;
2025-10-29 15:38:20 +08:00
margin-bottom: 20rpx;
2025-10-27 13:21:43 +08:00
}
2025-10-29 15:38:20 +08:00
/* 信息项 */
2025-10-27 13:21:43 +08:00
.info-item {
display: flex;
align-items: baseline;
2025-10-29 15:38:20 +08:00
flex: 0 0 calc(50% - 10rpx);
padding: 16rpx 20rpx;
background: #f8f9fa;
border-radius: 10rpx;
border: 1rpx solid #e8e8e8;
transition: all 0.2s ease;
&:active {
background: #f0f2f5;
}
2025-10-27 13:21:43 +08:00
}
.info-label {
color: #666;
2025-10-29 15:38:20 +08:00
font-size: 26rpx;
2025-10-27 13:21:43 +08:00
flex-shrink: 0;
margin-right: 16rpx;
}
.info-value {
color: #333;
2025-10-29 15:38:20 +08:00
font-size: 28rpx;
2025-10-27 13:21:43 +08:00
font-weight: 500;
word-break: break-all;
}
.unit-text {
font-size: 0.8em;
color: #999;
margin-left: 6rpx;
}
</style>