<template>
    <view>
        <view class="head">
            <view class="label">
                基本信息
            </view>
            <view class="content">
                仅显示已填信息<text style="padding: 0 2.5px;" /> <u-switch activeColor="#C40C24" v-model="unShowAll" />
            </view>
        </view>
        <view style="padding-left: 10px;background-color: #fff;" v-for="item in showList" :key="item.key"
            hover-class="navigator-hover" @click="onClick(item)">
            <view class="item" v-if="!unShowAll || detail[item.key] || item.value">
                <view class="content">
                    <view class="label">
                        {{ item.label }}:
                    </view>
                    <view class="value">
                        {{ detail[item.key] || item.value || '--' }}
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    props: {
        showList: {
            type: Array
        },
        detail: {
            type: Object
        }
    },
    data() {
        return {
            unShowAll: false,
        }
    },
    methods: {
        onClick(item) {
            if (!item.funName) return;
            switch (item.funName) {
                case 'callPhone':
                    if (this.detail[item.key] || item.value) this.callPhone(this.detail[item.key] || item.value)
                    break;
            }
        }
    },
}
</script>

<style lang="scss" scoped>
.head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100vw;
    height: 45px;
    background: #F7F7F7;
    padding: 0 10px;
    box-sizing: border-box;

    .label {
        font-family: PingFang SC, PingFang SC;
        font-weight: bold;
        font-size: 15px;
        color: #333333;
        line-height: 22px;
    }

    .content {
        display: flex;
        align-items: center;
        font-family: PingFang SC, PingFang SC;
        font-size: 14px;
        color: #999999;
    }
}

.item {
    width: 100%;
    box-sizing: border-box;
    border-bottom: 0.5px solid #ddd;

    .content {
        display: flex;
        width: 100%;
        padding: 15px 0;
        padding-right: 10px;
        box-sizing: border-box;
        border-bottom: 0.5px solid #F2F2F2;

        .label {
            width: 100px;
            margin-right: 10px;
            line-height: 20px;
            font-family: Source Han Sans SC, Source Han Sans SC;
            font-size: 14px;
            color: #666666;
            flex-shrink: 0;
        }

        .value {
            flex: 1;
            line-height: 20px;
            font-family: Source Han Sans SC, Source Han Sans SC;
            font-size: 14px;
            color: #333333;
        }
    }

    .content:last-child {
        border-bottom: 0;
    }
}
</style>