<template>
  <div class="DetailPeople">
    <div class="top">
      <div class="photos">
        <img :src="data.resident.photo" alt="" v-if="data.resident && data.resident.photo" />
        <img src="./components/img/44.png" alt="" v-else />
      </div>

      <div class="right">
        <div class="rightTop">
          <span class="names">{{ data.resident && data.resident.name }}</span>

          <span class="householdNames">
            {{ $dict.getLabel('householdRelation', data.resident && data.resident.householdRelation) }}
          </span>
        </div>

        <div class="rightBottom" v-if="data.resident && data.resident.phone">{{ data.resident.phone }}</div>
      </div>
    </div>

    <div class="line"></div>

    <div class="middle">
      <div class="hint">个人基本信息</div>

      <div class="contents">
        <div class="item">
          <span>籍贯</span>
          <span>{{ data.resident && data.resident.birthplaceAreaName }}</span>
        </div>

        <div class="item">
          <span>身份证号</span>
          <span>{{ data.resident && data.resident.idNumber.replace(/^(\w{6})\w{8}(.*)$/, '$1****$2') }}</span>
        </div>

        <div class="item">
          <span>民族</span>
          <span v-if="data.resident && data.resident.householdName"> {{ $dict.getLabel('nation', data.resident.householdName) }}</span>
        </div>

        <div class="item">
          <span>文化程度</span>
          <span v-if="data.resident && data.resident.education">{{ $dict.getLabel('education', data.resident.education) }}</span>
        </div>

        <div class="item">
          <span>婚姻状况</span>
          <span v-if="data.resident && data.resident.maritalStatus">{{ $dict.getLabel('maritalStatus', data.resident.maritalStatus) }}</span>
        </div>

        <div class="item">
          <span>政治面貌</span>
          <span v-if="data.resident && data.resident.politicsStatus">{{ $dict.getLabel('politicsStatus', data.resident.politicsStatus) }}</span>
        </div>

        <div class="item">
          <span>兵役状况</span>
          <span v-if="data.resident && data.resident.militaryStatus">{{ $dict.getLabel('militaryStatus', data.resident.militaryStatus) }}</span>
        </div>

        <div class="item">
          <span>宗教信仰</span>
          <span v-if="data.resident && data.resident.faithType">{{ $dict.getLabel('faithType', data.resident.faithType) }}</span>
        </div>

        <div class="item">
          <span>职业</span>
          <span v-if="data.resident && data.resident.job">{{ $dict.getLabel('job', data.resident.job) }}</span>
        </div>
      </div>
    </div>

    <div class="lines"></div>

    <div class="bottom">
      <div class="hint">联络信息</div>

      <div class="contents">
        <div class="item">
          <span>联系方式</span>
          <span class="phones" v-if="data.resident && data.resident.phone" @click="callPhone(data.resident.phone)">{{ data.resident.phone }}</span>
        </div>

        <div class="item">
          <span>现住址</span>
          <span v-if="data.resident && data.resident.currentAreaName">{{ data.resident.currentAreaName }}</span>
        </div>

        <div class="item">
          <span>现住详细地址</span>
          <span v-if="data.resident && data.resident.currentAddress">{{ data.resident.currentAddress }}</span>
        </div>

        <div class="item">
          <span>户籍地址</span>
          <span v-if="data.resident && data.resident.householdAreaName">{{ data.resident.householdAreaName }}</span>
        </div>

        <div class="item">
          <span>户籍详细地址</span>
          <span v-if="data.resident && data.resident.householdAddress">{{ data.resident.householdAddress }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailPeople',
  components: {},
  props: {},
  data() {
    return {
      id: '',
      data: [],
    }
  },
  computed: {},
  watch: {},
  onLoad(o) {
    this.id = o.id
    this.$dict.load('householdRelation', 'nation', 'education', 'maritalStatus', 'politicsStatus', 'militaryStatus', 'faithType', 'job').then(() => {
      this.getDetail()
    })
  },
  onShow() {
    document.title =  '家庭成员信息' 
  },
  methods: {
    getDetail() {
      this.$http.post(`/app/appresident/detail?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          this.data = res.data
          // this.$nextTick(() => {
          //   this.currentAreaName = res.data.resident.currentAreaName
          // })
        }
      })
    },
    callPhone(phone) {
      uni.makePhoneCall({ phoneNumber: phone })
    },
  },
}
</script>

<style scoped lang="scss">
.DetailPeople {
  height: 100%;
  background: #fff;
  .top {
    display: flex;
    padding: 48px 32px 32px 32px;
    .photos {
      img {
        width: 112px;
        height: 112px;
        border-radius: 50%;
      }
    }
    .right {
      display: flex;
      flex-direction: column;
      width: 100%;
      margin-left: 24px;
      .rightTop {
        display: flex;
        justify-content: space-between;
        .names {
          font-size: 32px;
          font-weight: 600;
        }
        .householdNames {
          margin-left: 30px;
          font-size: 26px;
          font-weight: 500;
          color: #5aad6a;
        }
      }
      .rightBottom {
        margin-top: 16px;
      }
    }
  }

  .line {
    height: 8px;
    background: #f5f5f5;
  }

  .middle,
  .bottom {
    padding: 0 32px;

    .hint {
      padding: 32px 0;
    }

    .contents {
      .item {
        display: flex;
        justify-content: space-between;
        padding: 14px 0;
        .phones {
          color: #3d94fb;
        }
      }
    }
  }

  .lines {
    height: 4px;
    background: #f5f5f5;
  }
}
</style>
