index.vue 3.49 KB
<template>
  <div class="main">
    <div class="step-box">
      <template v-for="(i,index) in stepList">
        <div
          :key="index"
          :class="['step',{'active':index <= step},{'hideArc':index != step}]"
        >
          <div class="step-arc">
            <div class="outset"></div>
            <div class="inset"></div>
            <div
              class="line"
              v-if="index > 0"
            ></div>
          </div>
          {{i}}
        </div>
      </template>
    </div>
    <template v-if="step == 0">
      <transition name="fade">
        <step-one @step_one_success="step_one_success"></step-one>
      </transition>
    </template>
    <template v-if="step == 1">
      <transition name="fade">
        <step-two
          :values="values"
          @step_two_success="step_two_success"
        ></step-two>
      </transition>
    </template>
    <template v-if="step == 2">
      <transition name="fade">
        <step-done></step-done>
      </transition>
    </template>
  </div>
</template>

<script type='text/ecmascript-6'>
import stepOne from './step-one'
import stepTwo from './step-two'
import stepDone from './step-done'
export default {
  name: 'index',
  data () {
    return {
      step: 0,
      stepList: ['绑定车架号', '绑定挪车码', '完成'],
      values: {}
    }
  },
  components: {
    'step-one': stepOne,
    'step-two': stepTwo,
    'step-done': stepDone
  },
  mounted () {
  },
  methods: {
    step_one_success (data) {
      this.values = data
      this.step = 1
    },
    step_two_success () {
      this.step = 2
    }
  }
}
</script>

<style  lang='scss'>
html,
body {
  background-color: rgb(247, 247, 247);
}
.step-box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #ffffff;
  box-shadow: 0 2px 8px 0 rgba(59, 147, 217, 0.1);
  height: 100px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 2;
  .step {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    color: #b9b9b9;
    &-arc {
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 14px;
      position: relative;
      .outset {
        position: absolute;
        background-color: rgba($color: #dddddd, $alpha: 0.2);
        width: 100%;
        height: 100%;
        border-radius: 100%;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
      .inset {
        width: 16px;
        height: 16px;
        border-radius: 100%;
        background: #dddddd;
      }
      .line {
        position: absolute;
        width: 90px;
        height: 2px;
        background: #dddddd;
        border-radius: 1px;
        top: 50%;
        transform: translateY(-50%);
        left: -94px;
      }
    }
  }
  .step.active {
    color: #008fff;
    .step-arc {
      .inset {
        background: #008fff;
      }
      .line {
        background: #008fff;
      }
      .outset {
        animation: Lumos 3.6s infinite;
        background-color: rgba($color: #008fff, $alpha: 0.2);
      }
      @keyframes Lumos {
        0% {
          opacity: 0.5;
          width: 50%;
          height: 50%;
        }
        50% {
          width: 100%;
          height: 100%;
          opacity: 1;
        }
        100% {
          opacity: 0.5;
          width: 50%;
          height: 50%;
        }
      }
    }
  }
  .step.active.hideArc {
    .step-arc {
      .outset {
        display: none;
      }
    }
  }
}
</style>