<template>
  <view class="step">
    <view class="step-list">
      <view v-for="i in options.length" :key="i" class="step-item" :style="{ width: `${100 / options.length}%` }">
        <view class="item-li" :class="[
          currentStep <= i ? '' : 'ok',
          currentStep === i ? 'active' : '',
        ]">
          <view :class="[i == 1 ? '' : 'step-dash step-dash1']"></view>
          <image v-if="currentStep > i" src="/static/images/success.png" alt="" />
          <text v-else></text>
          <view :class="[i == options.length ? '' : 'step-dash step-dash2']"></view>
        </view>
      </view>
    </view>
    <view class="step-ul">
      <view v-for="t in options" :key="t" class="step-li" :style="{ width: `${100 / options.length}%` }">
        {{ t }}
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
const props = defineProps<{
  currentStep: number;
  options: Array<string>;
}>();
</script>
<style scoped lang="scss">
@import "@/uni.scss";

.step {
  padding-bottom: px2rpx(31);

  .step-list {
    display: flex;
    align-items: center;

    .step-item {
      display: flex;
      justify-content: center;
      align-items: center;

      .item-li {
        display: flex;
        width: 100%;
        justify-content: center;
        align-items: center;

        span {
          display: inline-block;
          width: px2rpx(44);
          height: px2rpx(44);
          aspect-ratio: 1/1;
          border-radius: 114px;
          border: 2px solid #beb6b6;
          position: relative;

          &::after {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            content: "";
            width: px2rpx(4);
            height: px2rpx(4);
            border-radius: 50%;
            background: #beb6b6;
          }
        }

        em {
          height: px2rpx(2);
          flex: 1 0 0;
          background: transparent;
        }

        .step-dash {
          height: px2rpx(2);
          flex: 1 0 0;
          background: #beb6b6;
        }

        img {
          display: inline-block;
          width: px2rpx(44);
          height: px2rpx(44);
        }
      }

      .active {
        span {
          display: inline-block;
          width: px2rpx(44);
          height: px2rpx(44);
          aspect-ratio: 1/1;
          border-radius: 114px;
          border: 2px solid #ff4766;
          position: relative;

          &::after {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            content: "";
            width: px2rpx(4);
            height: px2rpx(4);
            border-radius: 50%;
            background: #ff4766;
          }
        }

        em {
          height: px2rpx(2);
          flex: 1 0 0;
          background: transparent;
        }

        .step-dash {
          height: px2rpx(2);
          flex: 1 0 0;
          background: #beb6b6;
        }

        .step-dash1 {
          background: #ff4766;
        }
      }

      .ok {
        span {
          display: inline-block;
          width: px2rpx(44);
          height: px2rpx(44);
          aspect-ratio: 1/1;
          border-radius: 114px;
          border: 2px solid #ff4766;
          position: relative;

          &::after {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            content: "";
            width: px2rpx(4);
            height: px2rpx(4);
            border-radius: 50%;
            background: #ff4766;
          }
        }

        em {
          height: px2rpx(2);
          flex: 1 0 0;
          background: transparent;
        }

        .step-dash {
          height: px2rpx(2);
          flex: 1 0 0;
          background: #ff4766;
        }
      }
    }
  }

  .step-ul {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    color: #474747;
    text-align: center;
    font-family: Roboto;
    font-size: px2rpx(14);
    font-style: normal;
    font-weight: 400;
    line-height: px2rpx(20);
    letter-spacing: px2rpx(0.014);

    .step-li {
      text-align: center;
    }
  }
}
</style>
