<template>
  <div class="familyInfo">
    <div class="card-list">
      <div class="item" v-for="(item, index) in familyList" :key="index" @click="$linkTo(`./memberInfo?id=${item.id}`)">
        <div class="userpic">
          <img :src="item.photo" alt="" v-if="item.photo">
          <img src="https://cdn.cunwuyun.cn/dvcp/myFamily/tx.png" alt="" v-else>
        </div>
        <div class="user-info">
          <p class="name">{{ item.name }}</p>
          <div class="idNumber">{{ item.idNumber.replace(/(.{6}).*(.{4})/, '$1********$2') }}</div>
        </div>
        <div class="relation" :style="{color:item.householdRelation == 11? '#4181FF' : '#999999' }">
          {{ $dict.getLabel('householdRelation',item.householdRelation) }}
        </div>
        <div class="arrowRoght">
          <u-icon name="arrow-right"></u-icon>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  name: 'familyInfo',
  appName: '家庭详情',
  data() {
    return {
      idNumber: '',
      familyList: {},
    }
  },
  onLoad(o) {
    this.$dict.load('householdRelation')
    this.idNumber = o.idNumber
    this.getList()
  },
  methods: {
    getList() {
      this.$instance.post('/app/appresident/queryHomeMember',null,{
        params: {
          idNumber: this.idNumber
        }
      }).then(res => {
        if(res.code == 0) {
          this.familyList = res.data.family
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.familyInfo {

  .card-list {
    padding: 32px 32px 32px 20px;
    box-sizing: border-box;
    .item {
      display: flex;
      background: #FFF;
      padding: 32px;
      border-radius: 16px;
      box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.04);
      margin-bottom: 24px;
      .userpic {
        width: 96px;
        height: 96px;
        margin-right: 10px;
        img {
          border-radius: 50%;
          width: 100%;
          height: 100%;
        }
      }

      .user-info {
        width: calc(100% - 226px);
        .name {
          font-size: 32px;
          font-weight: 600;
        }
        .idNumber {
          margin-top: 8px;
          color: #999999;
        }
      }

      .relation {
        width: 80px;
        align-self: center;
      }

      .arrowRoght {
        width: 40px;
        align-self: center;
      }
    }
  }
  
}
</style>