<template>
  <div class="detail">
    <div class="detail-info">
      <h2>健康状况</h2>
      <div class="detail-info__item">
        <div class="left">
          <label>当前体温</label>
        </div>
        <div class="right">
          <span :style="{color: info.temperature >= 37.3 ? '#FF4466' : '#42D784'}">{{ info.temperature }}℃</span>
        </div>
      </div>
      <div class="detail-info__item">
        <div class="left">
          <label>14天内是否接触新冠确诊或疑似患者</label>
        </div>
        <div class="right">
          <span :style="{color: info.contactPatients === '0' ? '#42D784' : '#FF4466'}">{{ $dict.getLabel('epidemicTouchInFourteen', info.contactPatients) }}</span>
        </div>
      </div>
      <div class="detail-info__item">
        <div class="left">
          <label>当前健康状况</label>
        </div>
        <div class="right">
          <span :style="{color: info.health == 0 ? '#42D784' : '#FF4466'}">{{ $dict.getLabel('EP_healthType', info.health) }}</span>
        </div>
      </div>
    </div>
    <div class="detail-info">
      <h2>核酸检测信息</h2>
      <div class="detail-info__item">
        <div class="left">
          <label>核酸检测日期</label>
        </div>
        <div class="right">
          <span>{{ info.nucleicAcidDate && info.nucleicAcidDate.substr(0, info.nucleicAcidDate.length - 8 ) }}</span>
        </div>
      </div>
      <div class="detail-info__item">
        <div class="left">
          <label>核酸检测结果</label>
        </div>
        <div class="right">
          <span :style="{color: info.nucleicAcidResult === '0' ? '#42D784' : '#FF4466'}">{{ $dict.getLabel('EP_nucleicAcidResult', info.nucleicAcidResult) }}</span>
        </div>
      </div>
      <div class="detail-info__item">
        <div class="left">
          <label>健康码状态</label>
        </div>
        <div class="right">
          <span :style="{color: info.jkmType == 0 || info.jkmType == 1? '#42D784' : '#FF4466'}">{{ $dict.getLabel('EP_jkmType', info.jkmType) }}</span>
        </div>
      </div>
      <div class="detail-info__item">
        <div class="left">
          <label>已接种疫苗次数</label>
        </div>
        <div class="right">
          <span>{{ $dict.getLabel('EP_vaccinationCount', info.vaccinationCount) }}</span>
        </div>
      </div>
      <div class="detail-info__item detail-info__item--img" v-if="info.jkmUrl">
        <div class="left">
          <label>本人健康码截图</label>
        </div>
        <div class="right">
          <img :src="info.jkmUrl" @click="preview(info.jkmUrl)" />
        </div>
      </div>
      <div class="detail-info__item detail-info__item--img" v-if="info.nucleicAcidUrl">
        <div class="left">
          <label>本人核酸检测结果截图</label>
        </div>
        <div class="right">
          <img :src="info.nucleicAcidUrl" @click="preview(info.nucleicAcidUrl)" />
        </div>
      </div>
    </div>

    <div class="btn-wrapper">
      <div class="btn" hover-class="text-hover" @click="back">返回</div>
    </div>
  </div>
</template>

<script>
  export default {
    appName:"上报详情",
    data () {
      return {
        info: {},
        pageShow: false,
        jkmUrlArr: [],
        nucleicAcidUrlArr: [],
      }
    },

    onLoad (query) {
      this.$loading()
      this.$dict.load(['epidemicTouchInFourteen', 'EP_healthType', 'EP_nucleicAcidResult', 'EP_jkmType', 'EP_vaccinationCount']).then(() => {
        this.getInfo(query.id)
      })
    },

    methods: {
      preview (url) {
        uni.previewImage({
          urls: [url],
          current: url
        })
      },

      getInfo (id) {
        this.$instance.post(`/app/appepidemicpreventionhealthreportinfo/queryDetailById?id=${id}`).then(res => {
          if (res.code === 0) {
            this.info = res.data
            this.jkmUrlArr.push({url: res.data.jkmUrl})
            this.nucleicAcidUrlArr = [res.data.nucleicAcidUrl]
            this.pageShow = true
            this.$hideLoading()
          } else {
            this.$loading()
          }
        })
      },

      call (phone) {
        uni.makePhoneCall({
          phoneNumber: phone
        })
      },

      back() {
        uni.navigateBack()
      }
    }
  }
</script>

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

    .detail-header {
      padding: 32px;
      background: #fff;

      h2 {
        margin-bottom: 32px;
        color: #333333;
        font-size: 40px;
        font-weight: 600;
      }

      .item-info {
        .item-info__item {
          display: flex;
          align-items: center;
          margin-bottom: 8px;

          &:last-child {
            margin-bottom: 0;
          }

          image {
            width: 32px;
            height: 32px;
            margin-right: 16px;
          }

          span {
            color: #333;
            font-size: 28px;
          }
        }
      }
    }

    .detail-info {
      margin-top: 24px;
      padding: 0 32px;
      background: #fff;

      & > h2 {
        height: 116px;
        line-height: 116px;
        font-size: 38px;
        font-weight: 600;
        color: #333;
      }

      .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--img {
        display: block;

        .right {
          flex-wrap: wrap;
          max-width: 100%;
          margin-top: 34px;

          image {
            width: 226px;
            height: 226px;
            margin: 0 9px 9px 0;

            &:nth-of-type(3n) {
              margin-right: 0;
            }
          }
        }
      }
    }
  }
</style>
