<template>
  <div class="DetailCard">
    <u-navbar back-icon-color="#000" title="居民管理" title-color="#000" title-width="300" title-size="32" 
        :title-bold="true" :background="backgroundNavbar" :is-fixed="true" height="44" z-index="999"></u-navbar>
    <div class="header-content-bg">
      <img src="https://cdn.sinoecare.com/i/2024/07/12/6690a1303d423.png" alt="">
    </div>
    <div class="middle">
      <div class="hint">家庭地址</div>
      <div class="areaHint">
        <u-icon name="map-fill" color="#73ABFF"></u-icon>
        <span>{{resident.currentAreaName}}{{resident.currentAddress || ''}}</span>
      </div>
    </div>
    <div class="bottom">
      <div class="hints">家庭成员 {{ data.family && data.family.length }}人</div>
      <div v-if="data.family && data.family.length > 0">
        <div class="card" v-for="(item, i) in data.family" :key="i" @click="toDetailPeople(item)">
          <img src="https://cdn.sinoecare.com/i/2024/07/16/669622c50d6be.png" alt="" class="bg-img" v-if="item.sex == 1">
          <img src="https://cdn.sinoecare.com/i/2024/07/16/669622c5b284c.png" alt="" class="bg-img" v-else>
          <div class="user-info">
            <div class="photos">
              <img :src="item.photo" alt="" v-if="item.photo" />
              <img src="https://cdn.sinoecare.com/i/2024/07/16/6695e2a0d95c9.png" alt="" v-else />
            </div>
            <div class="right">
              <div class="rightTop">
                <div class="rightTop-lefts">
                  <span class="names">{{ item.name }}</span>
                  <span class="fileStatuss" v-if="item.fileStatus == 1"> 已注销</span>
                  <span class="householdNames" v-if="item.householdName == 1">户主</span>
                  <span class="householdNames" v-else>
                    {{ $dict.getLabel('householdRelation', item.householdRelation) }}
                  </span>
                </div>

                <div class="rightTop-rights">
                  <u-section :show-line="false" sub-title="详情"></u-section>
                </div>
              </div>

              <div class="rightBottom">
                <span>身份证号：</span>
                <span>{{ item.idNumber.replace(/^(\w{6})\w{8}(.*)$/, '$1********$2') }}</span>
              </div>
              <span class="item-tag" v-for="(items, indexs) in item.residentLabelList" :key="indexs">{{ items.labelName }}</span>
              <!-- <div class="spacial" v-if="item.idNumber == data.resident.idNumber">
                <span v-for="(e,index) in spacialList" :key="index">{{e.applicationName}}</span>
              </div> -->
            </div>
          </div>
        </div>
      </div>

      <AiEmpty v-else></AiEmpty>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailCard',
  customNavigation: true,
  data() {
    return {
      id: '',
      data: [],
      resident: {},
      // spacialList: [],
      backgroundNavbar: {
        background: 'url(https://cdn.sinoecare.com/i/2024/07/12/6690a1309c7d3.png) no-repeat',
        backgroundSize: 'cover',
      },
    }
  },
  computed: {},
  watch: {},
  onLoad(o) {
    this.id = o.id
    this.$dict.load('householdRelation', 'fileStatus').then(() => {
      this.getDetail()
    })
  },
  onShow() {
    uni.setNavigationBarColor({
      frontColor: 'black',
      backgroundColor: '#ffffff'
    })
  },
  methods: {
    getDetail() {
      this.$instance.post(`/app/appresident/detail?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          this.data = res.data
          this.$forceUpdate()
          this.$nextTick(() => {
            this.resident = res.data.resident
            // this.spacialList = res.data.resident.tsrqInfos
            this.$forceUpdate()
          })
        }
      })
    },

    toDetailPeople(item) {
      uni.navigateTo({ url: `./DetailPeople?id=${item.id}&type=0` })
    },
  },
}
</script>

<style scoped lang="scss">
.DetailCard {
  height: 100%;
  .header-content-bg {
    width: 100%;
    position: fixed;
    z-index: -1;
    img {
      width: 100%;
      height: 592px;
    }
  }

  .middle {
    margin: 0 32px 0 32px;
    padding: 32px;
    background-color: #fff;
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.02);
    border-radius: 16px;
    z-index: 1;
    .hint {
      font-size: 32px;
      font-weight: 500;
      color: #333333;
    }
    .areaHint {
      margin-top: 22px;
      font-family: PingFangSC-Regular;
      font-weight: 400;
      font-size: 32px;
      color: #666;
      line-height: 44px;
      span {
        margin-left: 14px;
      }
    }
  }

  .bottom {
    margin: 32px 0 0 32px;
    background: #fff;
    padding: 32px;
    box-sizing: border-box;
    width: calc(100% - 64px);
    border-radius: 16px;
    .hints {
      height: 44px;
      font-family: PingFangSC-Medium;
      font-weight: 500;
      font-size: 32px;
      color: #333;
      margin-bottom: 32px;
    }
    .card {
      box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.08);
      border-radius: 16px;
      margin-bottom: 32px;
      width: 100%;
      .bg-img {
        width: 100%;
        height: 100px;
      }
      .user-info {
        display: flex;
        padding: 48px 32px;
        position: relative;
        width: 100%;
        box-sizing: border-box;
        margin-top: -100px;
      }
      .photos {
        img {
          width: 96px;
          height: 96px;
          border-radius: 50%;
        }
      }
      .right {
        margin-left: 40px;
        width: 100%;
        .rightTop {
          display: flex;
          justify-content: space-between;
          .rightTop-lefts {
            .names {
              display: inline-block;
              line-height: 44px;
              font-family: PingFangSC-SNaNpxibold;
              font-weight: 600;
              font-size: 32px;
              color: #333;
              margin-right: 16px;
            }
            .householdNames {
              display: inline-block;
              line-height: 44px;
              font-family: PingFangSC-Medium;
              font-weight: 500;
              font-size: 26px;
              color: #5AAD6A;
              
            }
            .fileStatuss {
              display: inline-block;
              width: 88px;
              line-height: 40px;
              text-align: center;
              background: #FFECEF;
              border-radius: 8px;
              font-family: PingFangSC-Regular;
              font-weight: 400;
              font-size: 24px;
              color: #F46;
              margin-right: 16px;
            }
          }
          .rightTop-rights {
            ::v-deep .u-section {
              .u-section__right-info {
                color: #3975c6 !important;
                .u-section__right-info__icon-arrow {
                  .u-icon {
                    .u-icon__icon {
                      color: #3975c6 !important;
                    }
                  }
                }
              }
            }
          }
        }
        .rightBottom {
          margin: 20px 0 16px 0;
          font-family: PingFangSC-Regular;
          font-weight: 400;
          font-size: 26px;
          color: #333;
          letter-spacing: 0;
        }
        .item-tag {
          display: inline-block;
          line-height: 44px;
          padding: 0 10px;
          background-color: #F0F2F5;
          font-family: PingFangSC-Regular;
          font-size: 24px;
          color: #8891A1;
          margin: 0 12px 8px 0;
          border-radius: 6px;
        }
        // .spacial {
        //   margin-top: 10px;
        //   white-space: wrap;
        //   span {
        //     margin-right: 10px;
        //     color: #ff4466;
        //   }
        // }
      }
    }
  }
}
</style>
