<template>
  <div class="f-main">
    <div class="content-top">
      <p>验证手机</p>
    </div>
    <div>
      <ul class="select-item">
        <li class="item" @click="jump('mobile')">
          <img src="/images/all/icon01.png">
          <span>通过验证手机</span>
          <i class="fa fa-angle-right second"></i>
        </li>
        <li class="item" @click="jump('email')" v-if="hasEmail">
          <img src="/images/all/icon02.png">
          <span>通过验证邮箱</span>
          <i class="fa fa-angle-right second"></i>
        </li>
        <li class="item" @click="jump('questions')" v-if="hasQuestion">
          <img src="/images/all/icon03.png">
          <span>通过验证密保</span>
          <i class="fa fa-angle-right second"></i>
        </li>
        <li class="item" @click="jump('appeal')">
          <img src="/images/all/icon04.png">
          <i></i><span>通过人工申诉</span>
          <i class="fa fa-angle-right second"></i>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'step-select',
    data () {
      return {
        hasEmail: false,
        hasQuestion: false,
        mobile: '',
        email: '',
        questions: ''
      }
    },
    mounted () {
      this.$nextTick(() => {
        this.getVerifyWay()
      })
    },
    methods: {
      jump (type) {
        this.$emit('stepEvent', type)
        if (type === 'mobile') {
          this.$emit('setDataEvent', this.mobile)
        } else if (type === 'email') {
          this.$emit('setDataEvent', this.email)
        } else if (type === 'questions') {
          this.$emit('setDataEvent', this.questions)
        } else if (type === 'appeal') {
          // 跳转到申诉页面
        }
      },
      // 获取验证方式
      getVerifyWay () {
        this.$http.get('/update/user/checkType')
          .then(response => {
            if (response.data.success) {
              this.mobile = response.data.content.mobile
              if (response.data.content.email) {
                this.hasEmail = true
                this.email = response.data.content.email
              }
              if (response.data.content.questions) {
                this.hasQuestion = true
                this.questions = response.data.content.questions
              }
            }
          }).catch(err => {
            console.log(err)
          })
      }
    }
  }
</script>

<style scoped type="text/scss" lang="scss">
  .select-item {
    padding-top:.5rem;
    .item {
      position:relative;
      padding-left:.4rem;
      margin-bottom:.2rem;
      line-height: 1.5rem;
      background: #f4f4f4;
      font-size: .32rem;
      span{
        color:#505050;
        margin-left:.4rem;
      }
      i{
        display:inline-block;
        position:absolute;
        right:.4rem;
        line-height: 1.5rem;
        font-size:.45rem;

      }
    }
  }
</style>
