<template>
  <div class="page" v-if="showPage">
    <div class="top">
      <div class="img-title">填报信息</div>

      <div class="cards">
        <div class="cards-left">申请人</div>
        <div class="cards-right">{{ detail.residentName }}</div>
      </div>

      <div class="cards">
        <div class="cards-left">联系电话</div>
        <div class="cards-right">{{ detail.residentPhone }}</div>
      </div>

      <div class="cards">
        <div class="cards-left">申请时间</div>
        <div class="cards-right">
          <span>{{ detail.createTime }}</span>
        </div>
      </div>

      <div class="cards">
        <div class="cards-left">积分类型</div>
        <div class="cards-right">
          {{ $dict.getLabel('atWillReportType', detail.applyIntegralType) }}
        </div>
      </div>

      <div class="cardss">
        <div class="cards-left">事件描述</div>
        <div class="cards-right">{{ detail.description }}</div>
      </div>

      <div class="cardes">
        <div class="img-top">图片资料</div>

        <img :src="item.url" alt="" v-for="(item, index) in detail.applyFiles" :key="index" @click.stop="previewImage(detail.applyFiles, item.url)" style="width: 122px; height: 122px; margin-right: 4px" />
      </div>
    </div>

    <div class="middle" v-if="detail.auditStatus != 0">
      <div class="img-title">审核详情</div>

      <div class="cards" v-if="detail.auditStatus == 1 || detail.auditStatus == 2">
        <div class="cards-left">审核结果</div>
        <div class="cards-right" :class="detail.auditStatus == 0 ? 'status2' : detail.auditStatus == 1 ? 'status0' : detail.auditStatus == 2 ? 'status1' : ''">
          {{ $dict.getLabel('auditStatus', detail.auditStatus) }}
        </div>
      </div>

      <div class="cards" v-if="detail.auditStatus == 1">
        <div class="cards-left">积分规则类型</div>
        <div class="cards-right">
          <span>
            {{ $dict.getLabel('atWillReportType', detail.applyIntegralType) }}
          </span>
        </div>
      </div>

      <div class="cards" v-if="detail.auditStatus == 1">
        <div class="cards-left">积分规则事项</div>
        <div class="cards-right" style="width: 75%; text-align: right">{{ detail.auditRuleName }}</div>
      </div>

      <div class="cards" v-if="detail.auditStatus == 1">
        <div class="cards-left">积分调整</div>
        <div class="cards-right" style="width: 75%; text-align: right">
          <span>{{ detail.auditIntegral }}分</span>
        </div>
      </div>

      <div class="cards" v-if="detail.auditStatus == 1 || detail.auditStatus == 2">
        <div class="cards-left">审核人</div>
        <div class="cards-right" style="width: 75%; text-align: right">{{ detail.auditUserName }}</div>
      </div>

      <div class="cards" v-if="detail.auditStatus == 1 || detail.auditStatus == 2">
        <div class="cards-left">审核时间</div>
        <div class="cards-right" style="width: 75%; text-align: right">{{ detail.auditTime }}</div>
      </div>
    </div>

    <div class="bottoms" v-if="detail.auditStatus == 2">
      <div class="cards">
        <span class="lefts">驳回理由</span>
        <span class="rights">
          {{ detail.auditOpinion }}
        </span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Detail',
  computed: {},
  data() {
    return {
      id: '',
      detail: {},
      showPage: false,
    }
  },
  onLoad(option) {
    this.id = option.id
    this.$dict.load('atWillReportType', 'auditStatus').then(() => {
      this.getDetail()
    })
  },
  onShow() {
    uni.setNavigationBarTitle({
      title: '积分申请详情',
    })
  },
  methods: {
    getDetail() {
      this.$instance.post(`/app/appvillagerintegraldeclare/queryDetailById?id=${this.id}`).then((res) => {
        if (res.code == 0) {
          this.detail = res.data
          this.showPage = true
        }
      })
    },

    previewImage(images, img) {
      uni.previewImage({
        urls: images.map((v) => v.url),
        current: img,
      })
    },
  },
}
</script>
<style scoped lang="scss">
.page {
  background: #fff;
  .top,
  .middle,
  .bottom {
    padding: 32px 32px 0 32px;
    background-color: #fff;

    .img-title {
      font-size: 36px;
      font-weight: 600;
    }

    .cards {
      display: flex;
      justify-content: space-between;
      border-bottom: 2px solid #eee;
      padding: 34px 0;
      line-height: 40px;
      font-size: 28px;

      .cards-left {
        color: #999;
      }

      .cards-right {
        color: #333;
        line-height: 44px;
      }

      .status0 {
        color: #42d784;
      }
      .status1 {
        color: #ff4466;
      }
      .status2 {
        color: #ff883c;
      }
    }

    .cardss {
      display: flex;
      justify-content: space-between;
      border-bottom: 2px solid #eee;
      padding: 36px 0;
      line-height: 40px;
      font-size: 28px;

      .cards-left {
        width: 170px;
        color: #999;
      }

      .cards-right {
        width: calc(100% - 170px);
        color: #333;
        text-align: right;
      }
    }

    .cardes {
      border-bottom: 2px solid #eee;
      padding: 36px 0;
      font-size: 28px;
      .img-top {
        color: #999;
        padding-bottom: 16px;
      }
    }
  }
  .bottoms {
    padding: 0 32px 32px 32px;
    background-color: #fff;
    .cards {
      display: flex;
      border-bottom: 2px solid #eee;
      padding: 34px 0;
      line-height: 40px;
      font-size: 28px;

      .lefts {
        display: inline-block;
        width: 160px;
        color: #999;
      }

      .rights {
        width: calc(100% - 160px);
        color: #333;
        line-height: 44px;
      }
    }
  }
}
</style>
