<template>
  <div class="integralDetail">
    <div class="detail">
      <div class="title">
        <h1>{{ info.applyItemName }}</h1>
        <p :class="info.status==0?'status0':info.status==1?'status1':'status2'">{{ $dict.getLabel('appIntegralApplyEventStatus', info.status) }}</p>
      </div>
      <div class="content">{{ info.content }}</div>
      <div class="imgs" v-if="images.length">
        <image v-for="(img, i) in images" @click="preview(img.url,images)" :key="i" class="banner" :src="img.url"/>
      </div>
      <div class="imgs" v-if="videos.length">
        <video v-for="(video, ins) in videos" :key="ins" class="file-img" :src="video.url"/>
      </div>

      <div class="refuse" v-if="info.status == 2">
        <p><span></span>未通过理由</p>
        <div class="desc">{{ info.auditDesc }}</div>
      </div>
    </div>

    <div class="btn-wrapper" v-if="info.status==2">
      <div class="btn" hover-class="text-hover" @click="$linkTo(`./integralAdd?id=${info.id}`)">修改</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "integralDetail",
  appName: "积分申请详情",
  data() {
    return {
      id: '',
      info: {},
      images: [],
      videos: [],
    }
  },
  methods: {
    getDetail() {
      this.$instance.post(`/app/appintegraluserapply/queryDetailById?id=${this.id}`).then(res=> {
        if(res?.data) {
          this.info = res.data
          this.images = res.data.files.filter(e=> (['jpeg','jpg','png', 'JPG'].includes(e.postfix.split('.')[1])))
          this.videos = res.data.files.filter(e => (['mp4', 'MP4', 'MOV'].includes(e.postfix.split('.')[1])))
        }
      })
    },
    preview(url, imgs) {
      uni.previewImage({
        urls: imgs.map((v) => v.url),
        current: url,
      })
    },
  },
  onLoad(o) {
    this.id = o.id
    this.getDetail()
    uni.$on('edit',()=> {
      this.getDetail()
    })
  }
}
</script>

<style lang="scss" scoped>
.integralDetail {
  padding: 24px 0 120px 0;

  .detail {
    .title {
      padding: 32px 32px;
      box-sizing: border-box;
      display: flex;
      justify-content: space-between;
      background: #FFF;
      h1 {
        font-size: 34px;
        font-weight: 600;
      }
      p {
        font-size: 28px;
        font-weight: 400;
      }
      .status0 {
        color: #FF9A40;
      }
      .status1 {
        color: #5AAD6A;
      }
      .status2 {
        color: #CD413A;
      }
    }
    .content {
      font-size: 28px;
      font-weight: 400;
      background: #FFF;
      padding: 0 32px;
      box-sizing: border-box;
    }
    .imgs {
      display: flex;
      flex-wrap: wrap;
      padding: 20px 32px;
      box-sizing: border-box;
      background: #FFF;

      image,
      video {
        width: 226px;
        height: 226px;
        margin: 0 4px 4px 0;
      }
      image:nth-child(3n + 0),
      video:nth-child(3n + 0) {
        margin: 0;
      }
    }
    .refuse {
      background: #FFF;
      padding: 32px 32px;
      box-sizing: border-box;
      margin-top: 24px;
      p {
        margin-bottom: 32px;
        font-size: 30px;
        font-weight: 400;
        color: #333333;
        span {
          display: inline-block;
          width: 12px;
          height: 12px;
          background: #CD413A;
          border-radius: 50%;
          margin-right: 8px;
        }
      }
      .desc {
        font-size: 28px;
        font-weight: 400;
        color: #666666;
      }
    }
  }

  ::v-deep .btn-wrapper {
    background: #FFF;
  }

  ::v-deep .btn-wrapper .btn {
    height: 80px;
    line-height: 80px;
    border-radius: 40px;
  }
}
</style>