<template>
  <div class="pass">
    <div class="p_content">
      <div>
        <!-- <img src="@/assets/img/signUp/icon-shenhe.png" alt="" /> -->
        <i class="icon-icon"></i>
      </div>
      <div>同学你好，你的报名资料已提交</div>
      <div>请等待工作人员审核，审核结果将于1-3个工作日发布，请留意网站</div>
      <div v-if="this.examine_status == 1">审核已通过</div>
      <div v-if="this.examine_status == 2">提示:{{ this.examine_reason }}</div>
      <div class="btn" v-show="this.examine_status == 2">
        <el-button @click="Lasting()">上一步 </el-button>
      </div>
      <div class="btn" v-show="this.examine_status == 1">
        <el-button @click="paying()">下一步 </el-button>
      </div>
    </div>
  </div>
</template>

<script>
/* eslint-disable */

import { signUpInit, signBack } from "r/index/signUp";
export default {
  name: "Pass",
  data() {
    return {
      examine_status: window.localStorage.getItem(
        "examine_status" + this.$store.state.indexIdentity
      ),
      examine_reason: window.localStorage.getItem(
        "examine_reason" + this.$store.state.indexIdentity
      ),
      signBackStatus: "",
      status_val: "",
    };
  },
  created() {
    this.signUpInit(this.status_val);
  },

  watch: {},
  methods: {
    Lasting() {
      signBack({}).then((res) => {
        console.log(res, "signBack");
        if (res.data.code != 200) {
          return this.$message.error(res.data.message);
        }
        // console.log(res.data.status, "signBack.status");
        this.signBackStatus = res.data.status;
        this.$emit("getstatus", res.data.status);
        this.$message.success(res.data.message);
      });
    },
    paying() {
      this.$emit("is_next", 1);
      //  console.log(is_next);
    },
    signUpInit(status_val) {
      console.log(status_val, "11111");

      // console.log(isNexts, "2222");
      signUpInit({}).then((res) => {
        console.log(res, "signUpInit");
        if (res.data.code != 200) {
          if (res.data.code == 400001) {
            this.status = 6;
            this.type = "success";
          }
          return this.$message.error(res.data.message);
        }
        this.status = res.data.status;
        // console.log(this.status, "11111");
        // 点击下一步传值给status,更新
        if (status_val != null) {
          this.status = status_val;
        } else {
          this.status = res.data.status;
          // console.log(this.status, "11111");
        }
        // doubt_code，doubt_info，doubt_check。0为不填写，1为填写
        if (this.status == 0) {
          this.type = "examInfo";
        } else if (this.status == 1) {
          //  是否填写邀请码
          if (this.doubt_code == 0) {
            this.type = "referInfo";
            this.status = 2;
          } else {
            this.type = "invitation";
            this.status = 1;
          }
        } else if (this.status == 2) {
          console.log(this.doubt_info, "doubt_info");
          // 是否填写个人资料
          if (this.doubt_info == 0) {
            this.type = "check";
            this.status = 3;
          } else {
            this.type = "referInfo";
            this.status = 2;
          }
        } else if (this.status == 3) {
          // 是否审核个人资料
          if (this.doubt_check == 0) {
            this.type = "pay";
            this.status = 4;
          } else {
            this.type = "check";
            this.status = 3;
          }
        } else if (this.status == 4) {
          this.type = "check";
          this.status = 3;
          // console.log(this.status, "this.status ");
          // console.log(this.isNexts ,'this.isNexts ')

          if (this.isNexts == 1) {
            // console.log(11111);
            if (res.data.examine_status == 1) {
              console.log(333);
              this.type = "pay";
              this.status = 4;
            } else if (res.data.examine_status == 2) {
              this.type = "referInfo";
              this.status = 2;
              // return this.$message.error(res.data.examine_reason);
            }
          }
        } else if (this.status == 5) {
          this.type = "pay";
        } else if (this.status == 6) {
          this.type = "success";
        }
        this.$emit("getStatus", this.type);
      
        const code = this.$store.state.indexIdentity;
        //订单支付金额
        window.localStorage.setItem("has_amount" + code, res.data.has_amount);
        window.localStorage.setItem("campsite_id" + code, res.data.campsite_id);
        window.localStorage.setItem("order_no" + code, res.data.order_no);
        this.examine_status = res.data.examine_status;
        window.localStorage.setItem(
          "examine_status" + code,
          res.data.examine_status
        ); //返回错误原因
        window.localStorage.setItem(
          "examine_reason" + code,
          res.data.examine_reason
        ); //资料审核状态
        // window.localStorage.setItem("achievement_path", res.data.achievement_path); //上传的图片
        const aPath = res.data.achievement_path;
        if (aPath) {
          let arr = aPath.split(",");
          let fileList = [];
          fileList = arr.map((item) => {
            let obj = {
              url: item,
            };
            return obj;
          });
          const code = this.$store.state.indexIdentity;
          window.localStorage.setItem(
            "sign_up_file_" + window.localStorage.getItem("phone" + code),
            JSON.stringify(fileList)
          ); //上传的图片
        }
      });
    },
  },
};
</script>

<style  lang="scss" scoped>
@import "a/scss/btn";
@import "a/scss/index";
@import "a/style";
@font-face {
  font-family: "icomoon";
  src: url("../../../assets/fonts/icomoon.eot?dcunb6");
  src: url("../../../assets/fonts/icomoon.eot?dcunb6#iefix")
      format("embedded-opentype"),
    url("../../../assets/fonts/icomoon.ttf?dcunb6") format("truetype"),
    url("../../../assets/fonts/icomoon.woff?dcunb6") format("woff"),
    url("../../../assets/fonts/icomoon.svg?dcunb6#icomoon") format("svg");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

.btn {
  padding-bottom: 0 !important;
}
.pass {
  padding: 0 56px 65px 56px;
  .p_content {
    i {
      font-size: 100px;
      color: var(--color);
    }
    div {
      text-align: center;
      font-size: 16px;
      font-weight: 500;
      color: #666666;
      line-height: 18px;
    }
    :nth-child(2) {
      margin: 24px 0;
    }
    :nth-child(3) {
      margin: 0 0 50px 0;
    }
  }
}
</style>
