<template>
  <div class="BackUserList">
    <div class="user-list">
      <div class="item">
        <h2 class="name">{{info.name}}的返乡登记信息</h2>
        <p><img src="./components/img/org-icon.png" alt="">{{info.startAreaName}}</p>
        <p><img src="./components/img/blue-icon.png" alt="">{{info.arriveAreaName}}</p>
        <p><img src="./components/img/time-icon.png" alt="">{{info.createTime}}</p>
      </div>
    </div>
    <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" 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" :style="info.type == 0 ? 'color:#42D784;' : 'color:#f46;'">{{$dict.getLabel('epidemicMemberType', info.type)}}</div>
      </div>
    </div>
    <div class="line-bg"></div>
    <div class="info">
      <div class="title">行程信息</div>
      <div class="item-flex">
        <div class="label">出行方式</div>
        <div class="value">{{$dict.getLabel('epidemicRecentTravel', info.travelType)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">出发时间</div>
        <div class="value">{{info.startTime.substring(0, 16)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">出发地区</div>
        <div class="value">{{info.startAreaName}}</div>
      </div>
      <div class="item-flex">
        <div class="label">出发地址</div>
        <div class="value">{{info.startAddress}}</div>
      </div>
      <div class="item-flex">
        <div class="label">到达时间</div>
        <div class="value">{{info.arriveTime.substring(0, 16)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">返乡地区</div>
        <div class="value">{{info.arriveAreaName}}</div>
      </div>
      <div class="item-flex">
        <div class="label">返乡地址</div>
        <div class="value">{{info.arriveAddress}}</div>
      </div>
      <div class="item-flex">
        <div class="label">行程描述</div>
        <div class="value">{{info.description}}</div>
      </div>
    </div>
    <div class="line-bg"></div>
    <div class="info">
      <div class="title">核酸检测信息</div>
      <div class="item-flex">
        <div class="label">核酸检测日期</div>
        <div class="value">{{info.checkTime}}</div>
      </div>
      <div class="item-flex">
        <div class="label">核酸检测结果</div>
        <div class="value" :style="info.checkResult == 1 ? 'color:#f46;' : 'color:#42D784;'">{{$dict.getLabel('epidemicRecentTestResult', info.checkResult)}}</div>
      </div>
      <div class="item-flex border-none">
        <div style="color:#999;">本人健康码截图或核酸检测报告</div>
      </div>
      <div class="img-list">
        <img :src="item.url" alt="" v-for="(item, index) in info.checkPhoto" :key="index" @click="previewImage(info.checkPhoto, item.url)">
      </div>
    </div>
    <div class="line-bg"></div>
    <div class="info">
      <div class="title">健康状况</div>
      <div class="item-flex">
        <div class="label">当前体温</div>
        <div class="value" :style="info.temperature >= 37.3 ? 'color:#f46;' : ''">{{info.temperature}}℃</div>
      </div>
      <div class="item-flex">
        <div class="label" style="width:360px;">14天内是否接触新冠确诊或疑似患者</div>
        <div class="value" :class="'color-'+info.touchInFourteen">{{$dict.getLabel('epidemicTouchInFourteen', info.touchInFourteen)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">当前健康状况</div>
        <div class="value" >
          <span v-for="(item, index) in info.health" :key="index" :style="item != 0 ? 'color:#FF4466;' : ''"><span v-if="index>0">;</span>{{$dict.getLabel('epidemicRecentHealth', item)}}</span>
        </div>
      </div>
    </div>
    <div class="line-bg"></div>
    <div class="info" v-if="list.length">
      <div class="title">异常处理情况</div>
      <div class="error-list">
        <div class="item" v-for="(item, index) in list" :key="index">
          <p>{{item.content}}</p>
          <div>{{item.createTime}}
            <span>{{item.createUserName}}</span>
          </div>
        </div>
      </div>
      <div class="item-flex" v-if="info.releaseName">
        <div class="label">异常解除人</div>
        <div class="value">{{info.releaseName}}</div>
      </div>
      <div class="item-flex" v-if="info.releaseName">
        <div class="label">异常解除时间</div>
        <div class="value">{{info.releaseTime}}</div>
      </div>
      
    </div>
    <div class="line-bg" style="padding-bottom: 56px;"></div>
    <div class="footer" @click="toError" v-if="info.status != 1">异常情况处理</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('epidemicMemberType', '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>
.BackUserList {
  .user-list{
    margin-bottom: 24px;
    .item{
      padding: 32px 64px 24px;
      background-color: #fff;
      .name{
        font-size: 36px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333;
        line-height: 50px;
        margin-bottom: 8px;
        .status{
          float: right;
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          color: #FF4466;
          line-height: 40px;
        }
      }
      p{
        font-size: 28px;
        font-family: PingFangSC-Regular, PingFang SC;
        color: #333;
        line-height: 40px;
        margin-bottom: 8px;
        img{
          width: 32px;
          height: 32px;
          margin-right: 18px;
          vertical-align: middle;
        }
      }
      .color-999{
        margin-bottom: 24px;
        color: #999;
      }
    }
  }
  .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 {
      .item {
        width: 100%;
        background: #f4f7fe;
        border-radius: 8px;
        padding: 24px 24px 18px 24px;
        box-sizing: border-box;
        margin-bottom: 16px;
        p {
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          color: #343d65;
          line-height: 40px;
          word-break: break-all;
          margin-bottom: 12px;
        }
        div {
          font-size: 24px;
          font-family: PingFangSC-Regular, PingFang SC;
          color: #666;
          line-height: 34px;
          span {
            display: inline-block;
            margin-left: 32px;
          }
        }
      }
    }
    .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>
