<template>
  <div class="Detail">
    <div class="info">
      <div class="title">基本信息</div>
      <div class="item-flex">
        <div class="label">姓名</div>
        <div class="value">{{info.reportUser.name}}</div>
      </div>
      <div class="item-flex">
        <div class="label">身份证号</div>
        <div class="value">{{info.reportUser.idNumberText}}</div>
      </div>
      <div class="item-flex">
        <div class="label">联系方式</div>
        <div class="value" style="color:#4181FF;" @click="callPhone(info.reportUser.phone)">
          <img :src="$cdn + 'common/phone.png'" alt="" class="phone-icon" >
          {{info.reportUser.phone}}</div>
      </div>
      <div class="item-flex">
        <div class="label">到达地区</div>
        <div class="value">{{info.reportUser.areaName}}</div>
      </div>
      <div class="item-flex">
        <div class="label">详细地址</div>
        <div class="value">{{info.reportUser.address}}</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" :style="info.temperature > 37.2 ? 'color:#f46;' : ''" >{{info.temperature}}</div>
      </div>
      <div class="item-flex">
        <div class="label" style="width:360px;">近14天内是否接触新冠确诊或疑似患者</div>
        <div class="value" :style="info.contactPatients == 1 ? 'color:#f46;' : ''">{{$dict.getLabel('epidemicTouchInFourteen', info.contactPatients)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">当前健康状况</div>
        <div class="value" >
          <span v-if="info.abnormalHealth != 1">没有异常</span>
          <span v-else style="color:#FF4466;">{{$dict.getLabel('EP_abnormalType', info.abnormalType)}}</span>
        </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" v-if="info.nucleicAcidDate">{{info.nucleicAcidDate.substring(0, 10)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">检测结果</div>
        <div class="value" :style="info.nucleicAcidResult == 1 ? 'color:#f46;' : ''">{{$dict.getLabel('EP_nucleicAcidResult', info.nucleicAcidResult)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">健康码</div>
        <div class="value" :style="info.jkmType != 1 && info.jkmType != 0 ? 'color:#f46;' : ''">{{$dict.getLabel('EP_jkmType', info.jkmType)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">已接种试剂</div>
        <div class="value">{{$dict.getLabel('EP_vaccinationCount', info.vaccinationCount)}}</div>
      </div>
      <div class="item-flex border-none">
        <div class="label" style="width:100%;">本人健康码截图/核酸检测报告</div>
      </div>
      <div class="img-list">
        <img :src="info.jkmUrl" alt="" @click="previewImage(info.jkmUrl)">
      </div>
    </div>
   
    <div class="line-bg"></div>
    <div class="info" v-if="info.handleLogs && info.handleLogs.length">
      <div class="title">风险处置记录</div>
      <div class="error-list">
        <div class="item" v-for="(item, index) in info.handleLogs" :key="index">
          <p>{{item.content}}</p>
          <div>{{item.createTime}}
            <span>{{item.createUserName}}</span>
          </div>
        </div>
      </div>
      <div style="height:16px;"></div>
    </div>
    <!-- <div class="line-bg" style="padding-bottom: 56px;"></div>
    <div class="footer" v-if="info.status == 1" @click="toError">风险处置</div> -->
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  data() {
    return {
      id: '',
      info: {},
      userName: '',
    }
  },
  computed: { ...mapState(['user']) },
  onShow() {
    document.title = this.userName + '的上报'
  },
  onLoad(option) {
    this.$dict.load('EP_abnormalType', 'epidemicTouchInFourteen', 'EP_nucleicAcidResult', 'EP_jkmType', 'EP_vaccinationCount').then(() => {
      this.id = option.id
      this.getDetail()
    })
    uni.$on('updateDetail', () => {
      this.getDetail()
    })
    uni.$emit('updateList')
    this.userName = option.name
  },
  methods: {
    getDetail() {
      this.$http.post(`/app/appepidemicpreventionhealthreportinfo/queryDetailById?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          this.info = res.data
          this.info.reportUser.idNumberText = this.info.reportUser.idNumber.replace(/(.{6}).*(.{4})/,"$1********$2")
        }
      })
    },
    callPhone(phone) {
      uni.makePhoneCall({phoneNumber: phone})
    },
    previewImage(img) {
      var imgs = [{url: img}]
      uni.previewImage({
        urls: imgs.map(v => v.url),
        current: img
      })
    },
    toError() {
      uni.navigateTo({url: `./ErrorInfo?id=${this.info.reportUser.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;
      overflow: hidden;
      span {
        float: right;
        font-family: PingFangSC-Regular;
        font-size: 32px;
        color: #999;
        font-weight: 400;
      }
    }
    .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;
    }
  }
  .table-content {
    padding: 32px 0 48px 0;
    .item {
      width: 100%;
      display: flex;
      border-bottom: 1px solid #ccc;
      border-right: 1px solid #ccc;
      box-sizing: border-box;
      div {
        flex: 1;
        padding: 16px 48px;
        line-height: 40px;
        font-family: PingFangSC-Regular;
        font-size: 28px;
        color: #333;
        border-left: 1px solid #ccc;
        box-sizing: border-box;
      }
    }
    .table-header {
      background: #F7F7F7;
      border: 1px solid #ccc;
      border-left: none;
    }
  }
  .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;
  }
  .line-text {
    line-height: 80px;
    border-bottom: 1px solid #ddd;
    font-family: PingFangSC-Regular;
    font-size: 32px;
    color: #333;
  }
}
</style>
