time-line.vue 2.06 KB
<template>
  <ul class="time-line-wrapper">
    <li
      :class="
        deliveryList.length === 1
          ? 'time-line-item show-left-border'
          : 'time-line-item'
      "
      v-for="(deliveryDetail, i) in deliveryList"
      :key="i"
    >
      <i :class="i === 0 ? iconClass : 'time-line-label'"></i>
      <div
        :class="
          isGoingOn && i === 0 ? 'content-wrapper active' : 'content-wrapper'
        "
      >
        <p class="remark">{{ deliveryDetail.acceptRemark }}</p>
        <p class="time">{{ deliveryDetail.createTimeStr }}</p>
        <slot name="content" :detail="deliveryDetail"></slot>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  props: {
    deliveryList: {
      type: Array,
      default: []
    },
    isGoingOn: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    iconClass: function() {
      return this.isGoingOn
        ? "iconfont iconxuanzhongduigou custom-icon active"
        : "iconfont iconxuanzhongduigou custom-icon";
    }
  }
};
</script>

<style lang="scss" scoped>
.time-line-wrapper {
  padding: 40px 0 80px 20px;

  .time-line-item {
    position: relative;
    padding: 0 40px 40px 40px;
    border-left: 1px solid #eee;
    font-size: 28px;
    color: #999;
    display: flex;
    align-items: flex-start;

    &.show-left-border {
      border-left: 1px solid #eee !important;
    }

    .content-wrapper {
      margin-top: -8px;
      line-height: 1;

      &.active .remark {
        color: #000;
      }

      .remark {
        margin-bottom: 20px;
      }
    }

    &:last-child {
      border-left: none;
      padding-bottom: 0;
    }

    .custom-icon {
      width: 40px;
      height: 40px;
      font-size: 40px;
      line-height: 1;
      left: -21px;
      top: -10px;
      position: absolute;
      background: #fff;

      &.active {
        color: #000;
      }
    }

    .time-line-label {
      width: 20px;
      height: 20px;
      background: #eee;
      border-radius: 50%;
      display: block;
      position: absolute;
      left: -10px;
    }
  }
}
</style>