<template>
  <div class="Detail">
    <div class="info">
      <div class="title">基本信息</div>
      <div class="item-flex">
        <div class="label">管理区域</div>
        <div class="value">{{info.name}}</div>
      </div>
      <div class="item-flex">
        <div class="label">管理对象</div>
        <div class="value">{{info.idNumber}}</div>
      </div>
      <div class="item-flex">
        <div class="label">身份证号</div>
        <div class="value">{{info.idNumber}}</div>
      </div>
      <div class="item-flex">
        <div class="label">手机号码</div>
        <div class="value" style="color:#4181FF;" @click="callPhone(info.phone)">
          <img :src="$cdn + 'common/phone.png'" alt="" class="phone-icon" >
          {{info.phone}}</div>
      </div>
      <div class="item-flex">
        <div class="label">居家状态</div>
        <div class="value">{{info.idNumber}}</div>
      </div>
      <div class="item-flex">
        <div class="label">隔离时间</div>
        <div class="value">{{info.idNumber}}</div>
      </div>
      <div class="item-flex">
        <div class="label">隔离策略</div>
        <div class="value">{{info.idNumber}}</div>
      </div>
    </div>
    <div class="line-bg"></div>
    <div class="info">
      <div class="title">核酸采集信息（已采样<span style="color:#f46;">3</span>次）</div>
      <div class="error-list">
        <div class="item">
          <div>
            <span>采样人：张三</span>
            <span>联系方式：18164065622</span>
          </div>
          <p>采样时间：2022-09-22 16:06:59</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  data() {
    return {
      id: '',
      info: {},
      list: []
    }
  },
  computed: { ...mapState(['user']) },
  onShow() {
    document.title = '采样信息'
  },
  onLoad(option) {
    // this.$dict.load('epidemicRecentPersonType', 'epidemicRecentTravel', 'epidemicTouchInFourteen', 'epidemicRecentTestResult', 'epidemicRecentHealth').then(() => {
    //   this.id = option.id
    //   this.getDetail()
    //   this.getList()
    // })
    // uni.$on('updateDetail', () => {
    //   this.getList()
    //   this.getDetail()
    // })
  },
  methods: {
    getList() {
      this.$http.post(`/app/appepidemicunusuallog/list?recordId=${this.id}`).then((res) => {
        if (res.code == 0) {
          this.list = res.data.records
        }
      })
    },
    getDetail() {
      this.$http.post(`/app/appepidemicbackhomerecord/queryDetailById?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          if(res.data.checkTime) {
            res.data.checkTime = res.data.checkTime.substring(0, 10)
          }
          this.info = res.data
          this.info.checkPhoto = JSON.parse(this.info.checkPhoto)
          this.info.health = this.info.health.split(',')
          this.info.idNumber = res.data.idNumber.replace(/(.{6}).*(.{4})/,"$1********$2")
        }
      })
    },
    callPhone(phone) {
      uni.makePhoneCall({phoneNumber: phone})
    },
    previewImage(images, img) {
      uni.previewImage({
        urls: images.map(v => v.url),
        current: img
      })
    },
    toError() {
      uni.navigateTo({url: `./ErrorInfo?id=${this.id}`})
    }
  },
}
</script>

<style lang="scss" scoped>
.Detail {
  .info{
    background-color: #fff;
    padding: 0 32px;
    .title{
      line-height: 116px;
      background: #FFF;
      font-size: 38px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #333;
    }
    .item-flex{
      padding: 34px 0;
      border-bottom: 1px solid #ddd;
      display: flex;
      justify-content: space-between;
      line-height: 44px;
      font-size: 32px;
      font-family: PingFangSC-Regular, PingFang SC;
      .label{
        width: 206px;
        color: #999;
      }
      .value{
        width: calc(100% - 206px);
        word-break: break-all;
        color: #333;
        text-align: right;
        .phone-icon{
          width: 40px;
          height: 40px;
          vertical-align: middle;
          margin-right: 8px;
        }
      }
      .color-0{
        color: #42D784;
      }
      .color-1{
        color: #f46;
      }
      .color-2{
        color: #1365DD;
      }
    }
    .img-list{
      padding-bottom: 32px;
      img{
        width: 320px;
        height: 320px;
      }
    }
    .item-flex:nth-last-of-type(1){
      border-bottom: 0;
    }
    .error-list {
      padding-bottom: 48px;
      .item {
        width: 100%;
        background: #f4f7fe;
        border-radius: 8px;
        padding: 24px 24px 18px 24px;
        box-sizing: border-box;
        margin-bottom: 16px;
        color: #343d65;
        font-size: 28px;
        font-family: PingFangSC-Regular, PingFang SC;
        line-height: 40px;
        div {
          display: flex;
          justify-content: space-between;
          margin-bottom: 16px;
        }
      }
    }
    .text-p{
      line-height: 44px;
      color: #333;
      padding-bottom: 16px;
    }
  }
  .line-bg{
    width: 100%;
    height: 24px;
    background-color: #F3F6F9;
  }
  .footer{
    width: 100%;
    height: 112px;
    line-height: 112px;
    background: #1365DD;
    box-shadow: inset 0px 1px 0px 0px #EEEEEE;
    font-size: 32px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #FFF;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
  }
  .border-none{
    border-bottom: 0!important;
  }
}
</style>
