<template>
  <div class="complaint-details bg-grey">
    <div class="details-title bgWhite">
      <div :class="itemData.complaintStatus == 1 ? ['active', 'title'] : ['title']">
        {{ detailData.complaintStatus === 1 ? "待处理" : "已完成" }}
      </div>
      <div class="tips" v-if="detailData.complaintStatus === 1">
        投诉提交成功，请等待平台处理
      </div>
      <div class="tips" v-else>处理结果：{{ detailData.result }}</div>
    </div>
    <div class="details-information bgWhite">
      <div class="order flex-default">
        <div class="label">投诉订单</div>
        <div class="value">
          {{ detailData.complaintId }}
        </div>
      </div>
      <div class="desc flex-default">
        <div class="label">投诉描述</div>
        <div class="value">
          {{ detailData.description }}
        </div>
      </div>
    </div>
    <div class="details-enclosure bgWhite flex-default">
      <div class="label">附件</div>
      <div class="value">
        <img
          :src="item"
          :key="index"
          v-for="(item, index) in detailData.attachments"
        />
      </div>
    </div>
    <div class="details-information bgWhite">
      <div class="order flex-default">
        <div class="label">关联单号</div>
        <div class="value">
          {{ detailData.orderId }}
        </div>
      </div>
      <div class="desc flex-default" style="border: 0; padding-top: 0">
        <div class="label">订单类型</div>
        <div class="value" style="font-size: 14px">
          {{ detailData.orderType && OrderTypeObj[detailData.orderType].label }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { OrderTypeObj } from "@/enums";
export default {
  data() {
    return {
      id: "",
      detailData: {},
      OrderTypeObj,
    };
  },
  methods: {
    getComplaintDetail() {
      this.$showLoading();
      this.$api({
        apiName: "detailComplaintById",
        postData: { id: this.id },
        success: (res) => {
          res.attachments = JSON.parse(res.attachments);
          this.detailData = res;
          this.$hideLoading();
        },
      });
    },
  },
  mounted() {
    this.id = this.$route.params.id;
    this.getComplaintDetail();
  },
};
</script>

<style lang="less">
.complaint-details {
  height: 100%;
  .bgWhite {
    padding: 0 16px;
    background-color: #ffffff;
    color: #140603;
    margin-bottom: 10px;
  }
  .details-title {
    text-align: center;
    .title {
      font-size: 18px;
      color: #FA9F37;
      font-weight: bold;
      line-height: 18px;
      padding-top: 17px;
    }
    .active {
      color: #2C66F5;
    }
    .tips {
      color: #999999;
      font-size: 13px;
      line-height: 13px;
      padding: 9px 0 18px;
    }
  }
  .details-information {
    .label,
    .value {
      font-size: 14px;
      line-height: 17px;
      color: #140603;
    }
    .label {
      padding-right: 20px;
      flex-shrink: 0;
    }
    .order,
    .desc {
      padding: 18px 0;
    }
    .desc {
      border-top: 1px solid #f1f1f1;
      .value {
        font-size: 13px;
      }
    }
  }
  .details-enclosure {
    padding: 20px 16px 8px;
    .label {
      width: 75px;
      font-size: 14px;
      color: #140603;
      line-height: 14px;
      flex-shrink: 0;
    }
    .value {
      overflow: hidden;
      img {
        width: 75px;
        height: 75px;
        float: left;
        background-color: #eaeaea;
        margin: 0 12px 12px 0;
        border-radius: 5px;
      }
    }
  }
}
</style>
