<template>
  <div class="detail" v-if="pageShow">

    <div class="detail-header">
      <div class="user">
        <div class="header">
          <h3>{{ info.name }}</h3>
          <div style="color: #4181FF;" @click="call(info.phone)"><u-icon name="phone" color="#4181FF" size="28"></u-icon>拨打电话</div>
        </div>
        <div class="idNumber">
          <span>身份证号：</span>
          <span>{{ info.idNumber }}</span>
        </div>
        <div class="phone">
          <span>手机号码：</span>
          <span>{{ info.phone }}</span>
        </div>
        <div class="picture">
          <div class="healthPic">
            <img src="components/resultPic.png" alt="" @click="preview()">
            <span>健康码</span>
          </div>
          <div class="nucleinPic">
            <img src="components/resultPic.png" alt="" @click="preview()">
            <span>核酸证明</span>
          </div>
        </div>
      </div>
      <div class="card">
        <div class="item-info">
          <div class="item-info__item">
            <div class="pic">
              <img class="img" src="components/start.png"/>
              <div class="lines"></div>
            </div>
            <span>{{ info.startAreaName }}</span>
          </div>
          <div class="item-info__item">
            <div class="pic">
              <img class="img" src="components/end.png"/>
            </div>
            <span>{{ info.arriveAreaName }}</span>
          </div>
          <div class="item-info__item">
            <image class="image" src="/static/img/to-date.png"/>
            <span>{{ info.arriveTime && info.arriveTime.substr(0, info.arriveTime.length - 3) }} 到达</span>
          </div>
        </div>
      </div>

      <div class="info">
      <div class="detail-info">
        <h2>行程信息<span>省外高风险地区</span></h2>

        <div class="detail-info__item">
          <div class="left">
            <label>出发地</label>
          </div>
          <div class="right">
            <span :style="{color: info.denger == 1 ? '#FF4466' : '#333'}">{{ info.startAreaName }}</span>
          </div>
        </div>

        <div class="detail-info__item">
          <div class="left">
            <label>交通工具</label>
          </div>
          <div class="right">
            <span>{{ $dict.getLabel('epidemicRecentTravel', info.travelType) }}</span>
          </div>
        </div>

        <div class="detail-info__item_wrap">
          <div class="left">
            <label>火车车次/航班号/汽车出发地</label>
          </div>
          <div class="right">
            <span>{{ $dict.getLabel('epidemicRecentTravel', info.travelType) }}</span>
          </div>
        </div>

        <div class="detail-info__item">
          <div class="left">
            <label>目的地</label>
          </div>
          <div class="right">
            <span>{{ info.arriveAreaName }}</span>
          </div>
        </div>

        <div class="detail-info__item">
          <div class="left">
            <label>居住地点</label>
          </div>
          <div class="right">
            <span>{{ info.startAreaName }}</span>
          </div>
        </div>

        <div class="detail-info__item">
          <div class="left">
            <label>行程安排</label>
          </div>
          <div class="right">
            <span>{{ info.startAddress }}</span>
          </div>
        </div>

        <div class="detail-info__item">
          <div class="left">
            <label>预计/实际抵达时间</label>
          </div>
          <div class="right">
            <span>{{ info.startTime && info.startTime.substr(0, info.startTime.length - 3) }}</span>
          </div>
        </div>


        <div class="detail-info__item">
          <div class="left">
            <label>预计离开时间</label>
          </div>
          <div class="right">
            <span>{{ info.arriveTime && info.arriveTime.substr(0, info.arriveTime.length - 3) }}</span>
          </div>
        </div>
      </div>

    </div>
    </div>


  </div>
</template>

<script>
export default {
  appName: "返乡登记详情",
  data() {
    return {
      info: {},
      pageShow: false,
      files: [],
    }
  },

  onLoad(query) {
    this.$loading()
    this.$dict.load(['epidemicRecentHealth', 'epidemicRecentTravel', 'epidemicTouchInFourteen', 'epidemicMemberType', 'epidemicRecentTestResult']).then(() => {
      this.getInfo(query.id)
    })
  },

  methods: {
    preview(url) {
      uni.previewImage({
        urls: this.info.checkPhoto.map(v => v.url),
        current: url
      })
    },

    // previewImg(images, img) {
    //   uni.previewImage({
    //     urls: images.map((v) => v.url),
    //     current: img,
    //   })
    // },

    getInfo(id) {
      this.$instance.post(`/app/appepidemicbackhomerecord/queryDetailById?id=${id}`).then(res => {
        if (res.code === 0) {
          this.info = res.data
          this.info.checkPhoto = JSON.parse(res.data.checkPhoto)
          let healthName = ''
          this.info.isHealth = false
          res.data.health.split(',').forEach(v => {
            if (v > 0) {
              this.info.isHealth = true
            }
            healthName = healthName + this.$dict.getLabel('epidemicRecentHealth', v)
          })
          this.info.healthName = healthName

          this.$nextTick(() => {
            this.pageShow = true
          })
        }

        this.$hideLoading()
      })
    },

    call(phone) {
      uni.makePhoneCall({
        phoneNumber: phone
      })
    }
  }
}
</script>

<style lang="scss">
.detail {
  padding-bottom: 40px;

  .detail-header {
    padding: 32px 32px 100px 32px;
    background: linear-gradient(135deg, #6496FF 0%, #4F75FF 100%);
    position: relative;

    .user {
      width: 100%;
      background: #FFFFFF;
      box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.02);
      border-radius: 16px;
      padding: 32px;
      box-sizing: border-box;
      .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        h3 {
          font-size: 40px;
          color: #333333;
          font-weight: 600;
        }

      }
      .idNumber,
      .phone {
        color: #999999;
        font-size: 26px;
        margin-top: 8px;
      }
      .picture {
        display: flex;
        margin-top: 24px;
        .healthPic,
        .nucleinPic {
          width: 192px;
          height: 192px;
          border-radius: 8px;
          position: relative;
          img {
            width: 100%;
            height: 100%;
          }
          span {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 40px;
            line-height: 40px;
            background: rgb(27, 27, 27, 0.85);
            color: #fff;
            font-size: 22px;
            text-align: center;
            border-radius: 0 0 8px 8px;
          }
        }
        .healthPic {
          margin-right: 24px;
        }

      }
    }

    .card {
      margin-top: 32px;
      background: rgba(70, 106, 233);
      border-radius: 16px;
      padding: 32px;
      box-sizing: border-box;
      .item-info {
        .item-info__item {
          display: flex;
          margin-bottom: 8px;

          &:last-child {
            margin-bottom: 0;
          }
          .pic {
            position: relative;
            .img {
              width: 12px;
              height: 12px;
            }
            .lines {
              position: absolute;
              top: 32px;
              left: 4px;
              width: 4px;
              height: 100%;
              border-left: 4px dotted #CCCCCC;
            }
          }

          .img {
              width: 12px;
              height: 12px;
              position: relative;
            }

          .image {
            width: 32px;
            height: 32px;
          }

          span:last-child {
            color: #fff;
            font-size: 28px;
            margin-left: 16px;
          }
        }
      }
    }

    .info {
      position: absolute;
      top: 93%;
      left: 50%;
      width: 100%;
      transform: translate(-50%, 1%);

      .detail-info {
        padding: 0 32px;
        background: #fff;
        border-radius: 16px 16px 0 0;

        & > h2 {
          height: 116px;
          line-height: 116px;
          font-size: 38px;
          font-weight: 600;
          color: #333;
          span {
            float: right;
            font-size: 28px;
            color: #FF4466;
            font-weight: normal;
          }
        }

        .detail-info__item {
          display: flex;
          justify-content: space-between;
          padding: 34px 0;
          border-bottom: 1px solid #DDDDDD;

          &:last-child {
            border: none;
          }

          .left {
            display: flex;
            line-height: 1.3;
            max-width: 360px;

            label {
              position: relative;
              color: #999999;
              font-size: 32px;
            }
          }

          .right {
            display: flex;
            max-width: 450px;

            span {
              color: #333333;
              font-size: 32px;
              text-align: right;
            }

            image {
              width: 40px;
              height: 40px;
            }
          }
        }

        .detail-info__item_wrap {
          display: block;
          border-bottom: 1px solid #DDDDDD;
          padding: 34px 0;
          .left {
            color: #999999;
            font-size: 32px;
          }
          .right {
            margin-top: 20px;
          }
        }
      }
    }
  }
}
</style>
