<template>
    <div class="card-model" :style="{ backgroundColor: theme }" @click="onHandleViewDetails">
        <div class="f-14">
            <svg-icon :icon-class="iconType" class="icon-box" />
            {{ cardTitle }}
        </div>
        <div class="f-count-wrapper">
            <div class="f-count">{{ cardNum }}</div>
        </div>
        <!-- <div class="f-14">
            较上月{{ isReduce ? '增高' : '降低' }}{{ ratio }}%

            <svg-icon v-if="!isReduce" icon-class="down_arrow" />
            <svg-icon v-else icon-class="up_arrow" />
        </div> -->
    </div>
</template>

<script>
export default {
    props: {
        // 主题背景色
        theme: {
            type: String,
            default: '#ffa94c'
        },
        // 标题
        cardTitle: {
            type: String,
            default: ''
        },
        // 图标类型
        iconType: {
            type: String,
            default: 'demand_count'
        },
        // 是否降低
        isReduce: {
            type: Boolean,
            default: true
        },
        // 数量
        cardNum: {
            type: Number,
            default: 0
        },
        // 百分比
        ratio: {
            type: Number,
            default: 0
        }
    },

    methods: {
        onHandleViewDetails() {
            console.log('查询二级页面', this.cardTitle)
            // 使用自定义事件 通知父组件打开二级页面
            // this.$emit('onOpenLevelTwoPages', this.cardTitle)
        }
    }
}
</script>

<style scoped lang="scss">
.card-model {
    width: 100%;
    height: 100%;
    padding: 6px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* 初始阴影 */
    transition: transform 0.3s ease; /* 添加过渡效果 */

    & div {
        width: 100%;
        // padding-left: 40px;
        transform: translateX(40px);
    }

    .f-14 {
        position: relative;
        font-size: 14px;
        letter-spacing: 1px;
        width:100%;
        .icon-box {
            font-size: 18px;
            position: absolute;
            transform: translateX(-120%);
        }
    }

    .f-count-wrapper {
        width: 100%;
        display: flex;
        justify-content: center; /* 水平居中 */
        align-items: flex-end; /* 垂直靠下 */
        margin-top: 10px;
    }
    .f-count {
        margin: 4px 0;
        font-size: 18px;
        font-weight: bold;
        letter-spacing: 2px;
    }


}

.card-model:hover {
    cursor: pointer;
    transform: scale(1.03);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); /* 鼠标移入时更明显的阴影 */
}
</style>
