<template>
  <div class="refund-steps">
    <div class="title">{{ currentTitle }}</div>
    <div class="steps-con flex-default">
      <div
        class="item flex-default"
        v-for="(item, index) of list"
        :key="`step-item-${index}`"
      >
        <m-icon :size="9" icon="icon-refund-steps-check" v-if="index < current" />
        <m-icon :size="9" :icon="currentIcon" v-else-if="index == current" />
        <div class="dot" v-else />
        <div class="label">{{ item.label }}</div>
        <div class="line" />
      </div>
    </div>
  </div>
</template>

<script>
import { RefundStatus } from "@/enums";
export default {
  props: ["status"],
  data() {
    return {
      currentMap: {
        [RefundStatus.APPLY]: {
          index: 0,
          icon: "icon-refund-steps-check",
          title: "待审核",
        },
        [RefundStatus.REVIEW_SUCCESS]: {
          index: 1,
          icon: "icon-refund-steps-check",
          title: "审核通过",
        },
        [RefundStatus.REVIEW_FAIL]: {
          index: 1,
          icon: "icon-refund-steps-fail",
          title: "已关闭",
        },
        [RefundStatus.CANCEL]: {
          index: 0,
          icon: "icon-refund-steps-check",
          title: "已撤销",
        },
        [RefundStatus.SUCCESS]: {
          index: 2,
          icon: "icon-refund-steps-check",
          title: "已退款",
        },
      },
      list: [
        { label: "提交申请" },
        { label: "商家审核" },
        { label: "退款成功" },
      ],
    };
  },
  computed: {
    current() {
      return this.currentMap[this.status].index;
    },
    currentIcon() {
      return this.currentMap[this.status].icon;
    },
    currentTitle() {
      return this.currentMap[this.status].title;
    },
    showSteps() {
      return this.status != RefundStatus.CANCEL;
    },
  },
};
</script>

<style lang="less">
.refund-steps {
  height: 128px;
  background: linear-gradient(270deg, #488FF7 0%, #2C66F5 100%);
  color: #ffffff;
  padding: 15px 17px;
  > .title {
    font-size: 16px;
    font-weight: bold;
    line-height: 18px;
    margin-bottom: 17px;
  }
  > .steps-con {
    align-items: center;
    justify-content: center;
    .item {
      flex-direction: column;
      align-items: center;
      width: 117px;
      position: relative;
    }
    .item .dot {
      width: 9px;
      height: 9px;
      border: 1px solid #ffffff;
      border-radius: 50%;
    }
    .item .label {
      font-size: 12px;
      margin-top: 9px;
    }
    .item .line {
      height: 1px;
      width: 102px;
      position: absolute;
      top: 4px;
      left: ~"calc(50% + 6px)";
      background: #ffffff;
    }
    .item:nth-last-of-type(1) .line {
      display: none;
    }
  }
}
</style>