<template>
  <div class="fill-container">
    <!-- 步骤条部分 -->
    <van-steps :active="active">
      <van-step>绑定手机</van-step>
      <van-step>填写资料</van-step>
      <van-step>上传证照</van-step>
      <van-step>医生简介</van-step>
    </van-steps>

    <!-- 填写资料表单部分 -->
    <div v-if="active === 1">
      <doctorFillInfomation @doctorFillForm="getDoctorFillForm"></doctorFillInfomation>

    </div>

    <!-- 上传证照部分 -->
    <div
      v-if="active === 2"
      class="bg-color"
    >
      <uploadLicense @handleLicenseForm="getLicenseForm"></uploadLicense>
    </div>

    <!-- 医生简介部分 -->
    <div v-if="active === 3">
      <doctorIntroduction @handleSubmitAudit="getSubmitAudit"></doctorIntroduction>
    </div>
  </div>
</template>

<script>
import doctorFillInfomation from '../../../components/doctorRegister/doctorFillInfomation'
import uploadLicense from '../../../components/doctorRegister/uploadLicense'
import doctorIntroduction from '../../../components/doctorRegister/doctorIntroduction'
import { reqDoctorSubmit, registerJump } from '../../../api/doctorRegister/doctorRegister'
export default {
  components: { doctorFillInfomation, uploadLicense, doctorIntroduction },
  data() {
    return {
      active: 1,
      registerParams: {
        caPersonUrl: ""
      }
    }
  },
  methods: {
    // 获取医生擅长和医生简介信息并且提交审核
    async getSubmitAudit(e) {
      console.log('之前的form数据: ', this.registerParams)
      this.registerParams = { ...this.registerParams, ...e }
      this.registerParams.isEducationDoctor = this.registerParams.isEducationDoctor=='是'?1:0
      this.registerParams.phone = window.sessionStorage.getItem('phone')
      console.log("请求参数: ", this.registerParams)
      const {data: response} = await reqDoctorSubmit(this.registerParams)
      if(response.success!==1) return this.$toast(response.messages)
      this.$router.push('/doctorMine')
    },

    // 获取医生上传证书的form表单
    getLicenseForm(e) {
      // 全部通过
      console.log("caPersonUrl: ", e.caPersonUrl)
      this.registerParams = { ...this.registerParams, ...e }
      this.registerParams.caPersonUrl = e.caPersonUrl
      const redirectCode = this.getCookie('redirectCode')
      this.hadnleNextStep()
    },

    // 获取医生填写资料页面传递过来的form表单
    getDoctorFillForm(e) {
      this.registerParams = { ...this.registerParams, ...e }
      this.hadnleNextStep()
    },

    // 进入下一步骤
    hadnleNextStep() {
      this.active++
    },

  },
  created() {
  }
};
</script>

<style lang="less" scoped>
@bgColor: #f7f7f7;
/deep/.van-steps__items {
  text-align: left;
}
.fill-container {
  height: 100vh;
  background-color: #f7f7f7;
}

.next-step-btn {
  /*   position: absolute;
  bottom: 5%;
  transform: translate(-50%); */
  margin: 0.5rem 0;
  width: 90%;
}

.bg-color {
  background-color: @bgColor;
}
</style>