<template>
  <div class="Detail">
    <div class="user-list">
      <div class="item">
        <h2 class="name">{{info.name}}
          <span @click="callPhone(info.phone)">{{info.phone}}</span><img :src="$cdn + 'common/phone.png'" alt="" @click="callPhone(info.phone)" class="phone-icon" />
        </h2>
        <p><img src="./components/img/idnumber-icon.png" alt=""><span class="start-name">{{info.idNumber}}</span></p>
        <p><img src="./components/img/org-icon.png" alt=""><span class="start-name">{{info.startAreaName}}</span></p>
        <p><img src="./components/img/blue-icon.png" alt=""><span class="start-name">{{info.arriveAreaName}}</span></p>
        <p><img src="./components/img/time-icon.png" alt="">{{info.arriveTime}}</p>
      </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.type == 0? 'color:#42D784;' : 'color:#f46;'">{{$dict.getLabel('epidemicMemberType', info.type)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">返乡事由</div>
        <div class="value">{{info.description}}</div>
      </div>
      <div class="item-flex">
        <div class="label">出发地区</div>
        <div class="value" :style="{color: info.denger == 1 ? '#FF4466' : '#333'}">{{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">{{$dict.getLabel('epidemicRecentTravel', info.travelType)}}</div>
      </div>
      <div class="item-flex border-none">
        <div class="label" style="width:100%;">火车车次/航班号/汽车出发地</div>
      </div>
      <p class="line-p">{{info.startAddress}}</p>
      <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.arriveAddress}}</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.arriveTime.substring(0, 16)}}</div>
      </div>
      <div class="item-flex">
        <div class="label">填报时间</div>
        <div class="value">{{info.arriveTime.substring(0, 16)}}</div>
      </div>
    </div>
    <div class="line-bg" style="padding-bottom: 56px;"></div>
    <div class="footer">
      <div @click="addHealth">纳入健康上报</div>
      <div class="confirm" @click="toContent">防控措施</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('epidemicMemberType', 'epidemicRecentTravel', 'epidemicTouchInFourteen', 'epidemicRecentTestResult', 'epidemicRecentHealth').then(() => {
      this.id = option.id
      this.getDetail()
    })
    uni.$on('updateDetail', () => {
      this.getDetail()
    })
  },
  methods: {
    getDetail() {
      this.$http.post(`/app/appepidemicbackhomerecord/queryDetailById?id=${this.id}`).then((res) => {
        if (res.data && 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})
    },
    toContent() {
      uni.navigateTo({url: `./Content?id=${this.id}`})
    },
    addHealth() {
      this.$confirm("是否将当前人员纳入健康上报监测 ?").then(() => {
        // this.$http.post("/app/appvillagerintegralshoporder/confirmExchange", null, {
        //   params: {orderId}
        // }).then(res => {
        //   if (res?.code == 0) {
        //     this.$u.toast("操作成功!")
        //     this.getDetail()
        //   }
        // })
      }).catch(() => 0)
    }
  },
}
</script>

<style lang="scss" scoped>
.Detail {
  .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: 36px;
        span {
          font-size: 32px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #4181ff;
          line-height: 44px;
          margin: 0 20px 0 32px;
        }
        img {
          width: 32px;
          height: 32px;
          vertical-align: middle;
        }
      }
      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: top;
        }
      }
      .color-999{
        margin-bottom: 24px;
        color: #999;
      }
      .start-name{
        display: inline-block;
        width: calc(100% - 50px);
      }
    }
  }
  .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;
      }
      .color-0{
        color: #42D784;
      }
      .color-1{
        color: #f46;
      }
      .color-2{
        color: #f46;
      }
    }
    .line-p{
      line-height: 44px;
      color: #333;
      padding: 18px 0;
      border-bottom: 1px solid #ddd;
      font-size: 32px;
      font-family: PingFangSC-Regular, PingFang SC;
    }
    .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;
    box-shadow: inset 0px 1px 0px 0px #EEEEEE;
    font-size: 32px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
    display: flex;
    div{
      flex: 1;
      color: #333;
      background-color: #fff;
    }
    .confirm{
      background: #1365DD;
      color: #FFF;
    }
  }
  .border-none{
    border-bottom: 0!important;
  }
}
</style>
