
<template>
  <div class="login">
    <span class="title">欢迎业主注册！</span>
    <div class="inputLabel">
      <input type="text" placeholder="请输入手机号码" v-model="form.mobile">
    </div>
    <div class="inputLabel">
      <input type="text" placeholder="请输入密码" v-model="form.password">
    </div>
    <div class="inputLabel">
      <input type="text" v-model="form.verificationCode" placeholder="请输入短信验证码">
      <div class="code" @click="goTimeOver">{{ over?'获取验证码':number }}</div>
    </div>
    <div class="btn" @click="resiger">
      <span>注册</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "resiger",
  methods:{
    resiger(){
      let params = {
        ...this.form
      }
        this.$api.resiger(params).then(res=>{
          this.$router.push({name:'home'})
        })
    },
    goTimeOver(){
      if(this.over){

        this.$api.verificationCode({mobile:this.form.mobile}).then(res=>{
          this.number = 60
          this.over = false
          this.timer = setInterval(()=>{
            this.number --
            if(this.number == 0){
              this.over = true
              clearInterval(this.timer)
            }
          },1000)
        })
      }else{

      }

    },
  },
  data(){
    return {
      form:{
        mobile:'',
        password:'',
        verificationCode:''
      },
      timer:null,
      over:true,
      number:60

    }
  },
}
</script>

<style scoped lang="less">
.login{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  .inputLabel{
    margin-bottom: 20px;
    position: relative;
    input{
      width: 299px;
      padding: 0 10px;
      height: 48px;
      background: #F4F5F6;
      border-radius: 8px;
      opacity: 0.8;
      border: none;
      outline: none;
    }
    .code{
      position: absolute;
      background-color: #6C5DD3;
      color: white;
      right: 0;top:0;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 30px;
      padding: 10px 20px;
      border-radius: 8px;
    }
  }
  .change{
    margin-bottom: 20px;
    display: inline-block;
    width: 90%;
    text-align: right;
    margin-right: 10%;
  }
  .btn{
    width: 319px;
    height: 56px;
    background: #6C5DD3;
    border-radius: 16px;
    text-align: center;
    line-height: 56px;
    color: white;
  }
  .title{
    width: 90%;
    display: inline-block;
    text-align: left;
    height: 36px;
    font-size: 28px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #01040D;
    line-height: 36px;
    margin-left: 10%;
    margin-bottom: 60px;
    margin-top: 30px;
  }
}
</style>