<template>
    <view class="contact-card">
        <view class="base">
            <view class="avatar">梅梅</view>
            <view class="name">
                <view>
                    <text>李雷</text>
                    <TIcon :name="parseIcon('icon')" :color="parseIcon('color')" />
                </view>
                <text class="role">采购员</text>
            </view>
        </view>
        <view class="extract">
            <view>
                <text>联系电话</text>
                <text>18138952909</text>
            </view>
            <view>
                <text>联系地址</text>
                <text>广东省广州市增城区东进商城</text>
            </view>
        </view>
    </view>
</template>

<script setup lang="ts">
import { PropType, computed } from 'vue'

type TSex = {
    icon: string
    color: string
}
interface ItemProps {
    id: number
    sex: number
}
const props = defineProps({
    item: {
        type: Object as PropType<ItemProps>,
        default: () => ({})
    }
})
const sexMap: Record<number, TSex> = {
    1: { icon: 'icon-male', color: '#0E66FB' },
    2: { icon: 'icon-female', color: '#F350CD' }
}
const parseIcon = computed(() => (type: string) => {
    return sexMap[props.item.sex][type]
})
</script>

<style lang="scss" scoped>
.contact-card {
    @include flex-direction;
    margin: 0 32rpx 20rpx;
    padding: 20rpx 24rpx;
    background-color: $white-1;
    border-radius: 16rpx;
    .base {
        @include flex-align;
        .avatar {
            @include flex-center;
            width: 100rpx;
            height: 100rpx;
            border-radius: 999px;
            background-color: $blue-1;
            color: $white-1;
        }
        .name {
            margin-left: 16rpx;
            > view {
                @include flex-align;
                gap: 8rpx;
            }
            .role {
                font-size: 30rpx;
                color: $gray-2;
            }
        }
    }
    .extract {
        @include flex-direction;
        gap: 20rpx;
        margin-top: 24rpx;
        > view {
            display: flex;
            gap: 32rpx;
        }
    }
}
</style>
