<template>
  <div class="steps flex">
    <div class="step flex" v-for="(item, index) in bCList" :key="item.status">
      <div
        :class="
          'cricle' + ' ' + (status >= item.status ? 'speed-bg-color' : '')
        "
      >
        <span class="num">{{ index + 1 }}</span>
      </div>
      <div
        :class="
          'step_title' + ' ' + (status >= item.status ? 'speed-text-color' : '')
        "
      >
        {{ item.name }}
      </div>
      <div>
        <img
          src="../assets/img/signUp/left.png"
          alt=""
          v-if="item.status < 4"
        />
      </div>
    </div>

    <!-- 报名流程提示 -->
    <div class="vertical-steps" v-if="isShowStepsTips">
      <div class="vertical-steps-title">报名流程</div>
      <div class="vertical_close" @click="toShowSteps">
        <i class="el-icon-close"></i>
      </div>
      <div v-for="(item, index) in steps" :key="item">
        <div class="step">
          <div class="step-number">{{ index + 1 }}</div>
          <div class="step-content">
            <div class="triangle-left"></div>
            <div class="step-title">{{ item }}</div>
          </div>
          <div class="connector" v-if="index != 5"></div>
        </div>
      </div>
    </div>
    <div
      class="referInfoTips"
      v-show="status == 0 || status == 1 || status == 2 || status == 3"
      @click="toShowSteps"
    >
      <i class="el-icon-question"></i>
    </div>
  </div>
</template>

<script>
  /* eslint-disable */
  export default {
    name: "breadcrumb",
    props: {statusNum: [String, Number]}, //进度参数
    data() {
      return {
        status: this.statusNum,
        bCList: [],
        //  报名流程提示
        steps: [
          "登录报名系统",
          "提交报名信息，等待审核",
          "收到审核短信，登录系统缴费",
          "上传缴费截图，等待审核",
          "收到审核短信，登录系统",
          "下载入营通知书，完成报名",
        ],
        isShowStepsTips: false,
      };
    },
    created() {
      let code = this.$store.state.indexIdentity;
      const doubt_code = window.localStorage.getItem("doubt_code" + code);
      const doubt_info = window.localStorage.getItem("doubt_info" + code);
      const doubt_check = window.localStorage.getItem("doubt_check" + code);
      // console.log(doubt_check, "doubt_check");
      const newArr = [
        {
          name: "确认报名",
          status: 0,
        },
        {
          name: "填写邀请码",
          status: 1,
        },
        {
          name: "填写报名资料",
          status: 2,
        },
        {
          name: "报名资料审核",
          status: 3,
        },
        {
          name: "缴费",
          status: 4,
        },
      ];
      let arr = [];
      // console.log(newArr, "newArr");
      for (let i = 0; i < newArr.length; i++) {
        const item = newArr[i];
        if (
          (doubt_code == 0 && item.status == 1) ||
          (doubt_info == 0 && item.status == 2) ||
          (doubt_check == 0 && item.status == 3)
        ) {
        } else {
          arr.push(item);
        }
      }
      this.bCList = arr;
    },
    watch: {
      statusNum(val) {
        console.log(val, "statusNum");
        this.status = val;
      },
    },
    methods: {
      toShowSteps() {
        this.isShowStepsTips = !this.isShowStepsTips;
      },
    },
  };
</script>

<style scoped lang="scss">
  .flex {
    display: flex;
  }

  // 报名流程提示
  .referInfoTips {
    // position: absolute;
    // right: 1%;
    // top: 45%;
    margin-left: 20px;
    color: var(--color);

    i {
      font-size: 26px;
      cursor: pointer;
    }
  }

  .vertical-steps {
    position: absolute;
    right: 2%;
    top: 9.5%;
    // width: 280px;
    margin: 0 auto;
    background-color: #f8f8f8;
    padding: 30px 20px 20px;
    border-radius: 8px;
    z-index: 99;

    .vertical-steps-title {
      text-align: center;
      margin-bottom: 20px;
      font-weight: 600;
      font-size: 18px;
    }

    .vertical_close {
      position: absolute;
      right: 4%;
      top: 2%;
      cursor: pointer;
    }
  }

  .step {
    display: flex;
    margin-bottom: 10px;
    position: relative;

    .step-number {
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background-color: #ddd;
      color: #666;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 12px;
      margin-right: 15px;
      flex-shrink: 0;
      position: relative;
      z-index: 2;
      border: 2px solid white;
      box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3),
        /* 主阴影 */
      inset 0 2px 4px rgba(255, 255, 255, 0.3),
        /* 内阴影 */
      0 0 0 4px rgba(24, 144, 255, 0.1);
      /* 外发光效果 */
    }

    .step-number {
      background-color: var(--color);
      color: white;
    }

    .step-content {
      padding: 5px 0;
      display: flex;

      /* 向左三角形 */
      .triangle-left {
        width: 0;
        height: 0;
        border-top: 6px solid transparent;
        border-right: 12px solid #ffffff;
        border-bottom: 6px solid transparent;
      }

      .step-title {
        color: #333;
        font-size: 12px;
        background-color: #ffffff;
        width: 182px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        position: relative;
        top: -8px;
      }
    }

    .connector {
      position: absolute;
      left: 11px;
      top: 24px;
      bottom: -30px;
      width: 2px;
      border-left: 1.5px dotted var(--color);
      z-index: 1;
    }
  }

  .speed-bg-color {
    background-color: var(--color) !important;
  }

  .speed-text-color {
    color: var(--color) !important;
  }

  .steps {
    .step {
      align-items: center;

      .cricle {
        width: 30px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        color: #ffff;
        background: #d0ced0;
        border-radius: 15px;
        margin-right: 10px;
        font-size: 14px;
        font-family: PingFang SC;
      }

      .step_title {
        flex: 1;
        font-size: 14px;
        height: 20px;
        font-weight: 600;
        color: #d0ced0;
        line-height: 20px;
        font-family: PingFang SC;
      }

      img {
        margin: 0 15px 0 10px;
      }
    }
  }
</style>
