<template>
  <div class="photo-detail" v-if="pageShow">
    <h2>{{ info.content }}</h2>
    <div class="status-name" :class="'status-' + info.eventStatus">
      {{ $dict.getLabel('clapEventStatus', info.eventStatus) }}
    </div>
    <div class="photo-detail__info">
      <div class="photo-detail__item">
        <i>事件类型</i>
        <span>{{ info.groupName }}</span>
      </div>
      <div class="photo-detail__item">
        <i>所属网格</i>
        <span>{{ info.girdName }}</span>
      </div>
      <div class="photo-detail__item">
        <i>上报时间</i>
        <span>{{ info.createTime }}</span>
      </div>
      <div class="photo-detail__img" style="border: none;">
        <i>照片</i>
        <div class="photo-detail__img--imgs">
          <image v-for="(item, index) in info.files" @click="preview(item.url)" :key="index" :src="item.url"/>
        </div>
        <span v-if="info.files && !info.files.length">暂无照片</span>
      </div>
    </div>
    <div class="result" v-if="info.eventStatus > 1">
      <h2>处理详情</h2>
      <div class="result-info">
        <h2>处理结果</h2>
        <p>{{ result.doExplain || '-' }}</p>
      </div>
      <div class="photo-detail__img" v-if="result.files.length">
        <i>照片</i>
        <div class="photo-detail__img--imgs">
          <image @click="previewResult(item.url)" v-for="(item, index) in result.files" :key="index" :src="item.url"/>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  appName: "随手拍详情",
  data() {
    return {
      pageShow: false,
      info: {},
      result: {}
    }
  },

  onLoad(query) {
    this.$loading()
    this.$dict.load(['clapEventStatus']).then(() => {
      this.getInfo(query.id)
    })
  },

  methods: {
    getInfo(id) {
      this.$instance.post(`/app/appclapeventinfo/queryDetailById?id=${id}`).then(res => {
        if (res.code === 0) {
          this.info = res.data
          if (res.data.eventStatus > 1) {
            this.result = res.data.processList[0]
          }
          this.$nextTick(() => {
            this.pageShow = true
          })
        }

        this.$hideLoading()
      }).catch(() => {
        this.$hideLoading()
      })
    },

    previewResult(url) {
      uni.previewImage({
        urls: this.result.files.map(v => v.url),
        current: url
      })
    },

    preview(url) {
      uni.previewImage({
        urls: this.info.files.map(v => v.url),
        current: url
      })
    }
  }
}
</script>

<style lang="scss">
.photo-detail {
  padding: 32px;
  margin-bottom: 60px;
  background: #fff;

  & > h2 {
    line-height: 1.3;
    margin-bottom: 26px;
    color: #333333;
    text-align: justify;
    font-size: 40px;
  }

  .status-name {
    width: 96px;
    height: 44px;
    line-height: 44px;
    margin-bottom: 20px;
    text-align: center;
    background: #FF883C;
    color: #fff;
    font-size: 26px;
    border-radius: 8px;

    &.status-1 {
      background: #1AAAFF;
    }

    &.status-2 {
      background: #42D784;
    }

    &.status-3 {
      background: #FF4466;
    }
  }

  .photo-detail__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 112px;
    font-size: 32px;
    border-bottom: 1px solid #DDDDDD;

    i {
      color: #999999;
      font-size: 32px;
    }

    span {
      color: #333333;
    }
  }

  .result {
    & > h2 {
      height: 116px;
      line-height: 116px;
      font-size: 38px;
      color: #333;
      font-weight: 600;
      border-top: 1px solid #DDDDDD;
    }

    .result-info {
      h2 {
        height: 112px;
        line-height: 112px;
        color: #999999;
        font-size: 32px;
      }

      p {
        line-height: 1.3;
        padding-bottom: 32px;
        color: #333333;
        font-size: 32px;
      }
    }
  }

  .photo-detail__img {
    border-top: 1px solid #DDDDDD;
    padding: 32px 0;

    & > i {
      display: block;
      margin-bottom: 32px;
      color: #999999;
      font-size: 32px;
    }

    .photo-detail__img--imgs {
      display: flex;
      flex-wrap: wrap;

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

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