<template>
    <div class="main_box">
        <!-- <navbar title="地址信息"></navbar> -->
        <div class="address_mian">
            <div class="firm_address_main" v-if="addressType == '0'">
                <div class="item">
                    <div class="item_left">经营地址</div>
                    <div class="item_right">
                        <div v-for="(item, index) in jydzList" :key="index" class="item_right_box">
                            <div class="item_right_adress">
                                <span>{{ item.address }}</span>
                                <span class="source">{{ item.source }}</span>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="item">
                    <div class="item_left">注册地址</div>
                    <div class="item_right">
                        <div v-for="(item, index) in zcdzList" :key="index" class="item_right_box">
                            <div class="item_right_adress">
                                <span>{{ item.address }}</span>
                                <span class="source">{{ item.source }}</span>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div class="firm_address_main" v-if="addressType == '1'">
                <div class="item">
                    <div class="item_left">家庭地址</div>
                    <div class="item_right">
                        <div v-for="(item, index) in jtdzList" :key="index" class="item_right_box">
                            <div class="item_right_adress">
                                <span>{{ item.address }}</span>
                                <span class="source">{{ item.source }}</span>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="item">
                    <div class="item_left">户籍地址</div>
                    <div class="item_right">
                        <div v-for="(item, index) in hjdzList" :key="index" class="item_right_box">
                            <div class="item_right_adress">
                                <span>{{ item.address }}</span>
                                <span class="source">{{ item.source }}</span>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="item">
                    <div class="item_left">工作地址</div>
                    <div class="item_right">
                        <div v-for="(item, index) in gzdzList" :key="index" class="item_right_box">
                            <div class="item_right_adress">
                                <span>{{ item.address }}</span>
                                <span class="source">{{ item.source }}</span>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="item">
                    <div class="item_left">常住地址</div>
                    <div class="item_right">
                        <div v-for="(item, index) in czdzList" :key="index" class="item_right_box">
                            <div class="item_right_adress">
                                <span>{{ item.address }}</span>
                                <span class="source">{{ item.source }}</span>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="item">
                    <div class="item_left">联系地址</div>
                    <div class="item_right">
                        <div v-for="(item, index) in lxdzList" :key="index" class="item_right_box">
                            <div class="item_right_adress">
                                <span>{{ item.address }}</span>
                                <span class="source">{{ item.source }}</span>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="item">
                    <div class="item_left">身份证地址</div>
                    <div class="item_right">
                        <div v-for="(item, index) in sfzdzList" :key="index" class="item_right_box">
                            <div class="item_right_adress">
                                <span>{{ item.address }}</span>
                                <span class="source">{{ item.source }}</span>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</template>
<script>
import navbar from '../../components/navbar/navbar.vue';
import { visitList } from "@/service/api/custome";

export default {
    props:{
        addressType: {
            type: String,
            default: "",   
        },
    },
    data() {
        return {
            // addressType: '',
            jtdzList: [],
            hjdzList: [],
            gzdzList: [],
            czdzList: [],
            lxdzList: [],
            sfzdzList: [],
            jydzList: [],
            zcdzList: [],
        }
    },
    components: {
        navbar: navbar,
    },
    created() {
        // this.addressType = sessionStorage.getItem('addressType')
        this.init()
    },
    methods: {
        init() {
            let custId = sessionStorage.getItem('custId')
            visitList(custId).then(res => {
                if (res.code == 200) {
                    let list = res.data.addressDetails
                    if (this.addressType == '0') {
                        this.jydzList = list.filter(item => item.addressName == '经营地址')
                        this.zcdzList = list.filter(item => item.addressName == '注册地址')
                    } else if (this.addressType == '1') {
                        this.jtdzList = list.filter(item => item.addressName == '家庭地址')
                        this.hjdzList = list.filter(item => item.addressName == '户籍地址')
                        this.gzdzList = list.filter(item => item.addressName == '工作地址')
                        this.czdzList = list.filter(item => item.addressName == '常住地址')
                        this.lxdzList = list.filter(item => item.addressName == '联系地址')
                        this.sfzdzList = list.filter(item => item.addressName == '身份证地址')
                    }


                }
            })
        },
    }
}
</script>
<style lang="less" scoped>
.address_mian {
    // padding-top: 46px;
    // min-height: 100vh;
    font-size: 14px;
    // padding-bottom: 60px;
}

.firm_address_main {
    background-color: #fff;
    // padding: 15px 20px 0 20px;

}

.item {
    display: flex;
    justify-content: space-between;
    align-items: start;
    // margin-top: 15px;
    border-bottom: 1px solid rgba(89, 89, 89, 0.1);
    // padding-bottom: 15px;
    line-height: 40px;
    padding: 0px 20px;
}

.item_left {
    color: rgb(22, 13, 13);
    width: 30%;
}

.item_right {
    color: rgb(22, 13, 13);
    width: 85%;
}

.item_right_adress {
    padding: 5px 0;
}

.source {
    background-color: #edf3fe;
    padding: 0 10px;
    border: 1px solid #dae7fe;
    color: #4886f8;
}
</style>