<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="currentIcon" v-if="index <= current" />
        <div class="dot" v-else />
        <div class="label">{{ item.label }}</div>
        <div class="line" />
      </div>
    </div>
  </div>
</template>

<script>
import { DeliveryRefundStatus, DeliveryRefundStatusObj } from "@/enums";
export default {
  props: ["status"],
  data() {
    return {
      list: [
        { label: "提交申请" },
        { label: "商家审核" },
        { label: "寄回商品" },
        { label: "商家退款" },
        { label: "退款成功" },
      ],
      currentMap: {
        [DeliveryRefundStatus.APPLY]: {
          index: 0,
          icon: "icon-refund-steps-check",
          title: "待审核",
        },
        [DeliveryRefundStatus.REVIEW_SUCCESS]: {
          index: 1,
          icon: "icon-refund-steps-check",
          title: "请退货并填写物流信息",
        },
        [DeliveryRefundStatus.EXPRESS]: {
          index: 2,
          icon: "icon-refund-steps-check",
          title: "等待商家收货",
        },
        [DeliveryRefundStatus.SHOP_REFUND]: {
          index: 3,
          icon: "icon-refund-steps-check",
          title: "退款中",
        },
        [DeliveryRefundStatus.SUCCESS]: {
          index: 4,
          icon: "icon-refund-steps-check",
          title: "已完成",
        },
        [DeliveryRefundStatus.REVIEW_FAIL]: {
          index: 1,
          icon: "icon-refund-steps-fail",
          title: "已关闭",
        },
        [DeliveryRefundStatus.CANCEL]: {
          index: 0,
          icon: "icon-refund-steps-check",
          title: "已撤销",
        },
      },
    };
  },
  computed: {
    current() {
      return this.currentMap[this.status].index;
    },
    currentTitle() {
      return this.currentMap[this.status].title;
    },
    currentIcon(){
      return this.currentMap[this.status].icon
    }
  },
};
</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: 70px;
      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: 57px;
      position: absolute;
      top: 4px;
      left: ~"calc(50% + 6px)";
      background: #ffffff;
    }
    .item:nth-last-of-type(1) .line {
      display: none;
    }
  }
}
</style>