sendVerification.vue 2.78 KB
<template>
  <div class="verification_container">
    <NafmHeader navClass="nafmii-head-bg3" />
    <div class="verification">

      <h2>输入短信验证码</h2>
      <p>已经向您的手机<span>{{shortPhone}}</span>发送验证码</p>

      <van-field v-model.trim="password" clearable label="" type="tel" maxlength="6" placeholder="请输入验证码">
        <template #button>
          <SendVerificationCode :phone="phone" :data="objParams" />
        </template>
      </van-field>
      <div class="login_btn" :class="{loginActive:isBothValue}" @click="handleFinish">{{type=='wechat'?'完 成':'下一步'}}</div>
    </div>
  </div>
</template>
<script>
import SendVerificationCode from '@/components/SendVerificationCode'
export default {
  name: 'SendVerification',
  components: {
    SendVerificationCode
  },
  data() {
    return {
      phone: '',
      shortPhone: '',
      password: '',
      objParams: {
        type: 'phone'
      },
      type: ''
    }
  },
  computed: {
    isBothValue() {
      if (this.password) {
        return true
      } else {
        return false
      }
    }
  },
  mounted() {
    const { phone, type } = this.$route.query;
    this.type = type
    this.phone = phone
    if (this.phone) {
      const phoneArr = this.phone.split('');
      this.shortPhone = phoneArr.splice(7, 11).join("")
    }
  },
  methods: {
    handleFinish() {
      const { type } = this.$route.query
      if (!this.password) {
        Toast(this.$t('toast.verification'))
        return
      }

      if (type == 'wechat') {
        // todo wechat api
        Toast(this.$t('toast.unbindingSuccess'))
        this.$router.push({
          path: '/user/setting'
        })
      } else {
        // 重置密码
        this.$router.push({
          path: '/user/resetPassword',
          query: {
            source: 'mine'
          }
        })
      }
    }
  }
}
</script>
<style lang="less" scoped>
.verification {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  width: 384px;
  margin: 0 auto;
  h2 {
    font-size: 24px;
    color: #333;
    margin-top: 16px;
  }
  p {
    font-size: 12px;
    color: #333;
    margin-top: 8px;
    margin-bottom: 50px;
    span {
      color: #106abc;
    }
  }
}
.login_btn {
  width: 100%;
  border-radius: 5px;
  text-align: center;
  height: 45px;
  line-height: 45px;
  color: #fff;
  font-size: 16px;
  margin-top: 40px;
  background-image: linear-gradient(to right, #25a3df, #106abc);
  opacity: 0.3;
}

.loginActive {
  opacity: 1;
}
/deep/ .van-cell:not(:last-child)::after {
  border-bottom: 1px solid #efefef;
}

/deep/ .van-cell {
  padding-right: 0 !important;
  padding-left: 0 !important;
  border-bottom: 1px solid #ebedf0;
}

/deep/ .van-cell:not(:last-child)::after {
  border: none;
}
</style>