<!--
 * @Author: jiangzaicheng jiangzaicheng_jzc@163.com
 * @Date: 2022-07-04 15:41:06
 * @LastEditors: jiangzaicheng jiangzaicheng_jzc@163.com
 * @LastEditTime: 2022-07-25 09:50:14
 * @FilePath: \mcep-h5\src\views\authentication\LoginView.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="loginform">
    <div class="rarle">
      <tatle-bar :tatle="tatleName"></tatle-bar>
    </div>

    <div class="login">
      <van-row  style="padding: 10% 0%;">
        <van-col span="24">
          <p class="polog"><span class="font-size-18-dhc" style="padding: 2% 0%;font-weight: 600;">用户注册</span> </p>
        </van-col>
        <van-col span="24"><span class="font-size-12-dhc" style="font-weight: 400; font-family: 'Arial Normal', 'Arial';
}">请使用机号码进行注册</span></van-col>
      </van-row>
      <van-form>
        <div class="logindiv">
          <span class="sopan">手机号码</span>
          <van-field v-model="phone" label="+86   |" :border="true" placeholder="请输入手机号" />
          <van-divider />
        <span class="sopan">身份证号</span>
          <van-field v-model="idCard" :border="true" placeholder="请输入身份证号" />
          <van-divider />
        </div>
        <span class="sopan">短信验证码</span>
        <div>

          <van-row >
            <van-col span="16">
              <van-field v-model="sms" center clearable placeholder="请输入短信验证码">
                <!-- <van-divider /> -->
              </van-field>
            </van-col>
            <van-col span="8"><a @click="getPhonePost()">{{getCmstotal}}</a></van-col>
          </van-row>

          <div class="logindiv">
            <span class="sopan">设置密码</span>
            <van-field v-model="password" type="password" center clearable placeholder="请填写新密码" />
            <!-- <van-divider /> -->
          </div>
          <div class="logindiv">
            <span class="sopan">确认密码</span>
            <van-field v-model="restpassword" type="password" center clearable placeholder="请确认新密码" />
            <!-- <van-divider /> -->
          </div>



        </div>
        <div style="margin: 16px;">
          <van-button square block type="info" native-type="submit" @click="registSystem()">注册</van-button>
        </div>
      </van-form>
      <!-- <van-radio name="1" shape="square" v-model ="radio" @click="returen()">
          <span>本人已阅读<a href="javascpt">《线上金融服务平台注册服务协议》</a></span>
        </van-radio> -->
      <div>
        <van-checkbox v-model="checked" shape="square" style="padding:0% 4%;">
          <span>本人已阅读<a href="#">《线上金融服务平台注册服务协议》</a></span>
        </van-checkbox>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import apiService from "@/services/api.service";
import { Code } from "@/constants/enum/general/code.enum";
import { RestfulResponse } from "@/model/domain/RestfulResponse";
import registApi from "@/constants/api/login/regist-mgt.api";
import commonApi from "@/constants/api/login/common.api";
import { Toast } from "vant";

@Component({
  name: "ForgetPassView",
})
export default class ForgetPassView extends Vue {
  tatleName = "用户注册"
  phone: string = "" //电话
  password: string = ""//密码
  restpassword: string = ""//确认密码
  getCmstotal = "获取短信验证码";
  sms: string = ""//短信
  // radio: boolean = false
    timer: any = "";//定时器
  time: number = 60;//计数
  radio: string = "0"
  checked: boolean = false;

  registSystem() {
    if (this.password === this.restpassword && this.checked) {
      let param = {
        phone: this.phone,
        //短信验证码TODO
        phoneVerifyCode: this.sms,
        //数字渠道
        method:"3",
        pwd: this.password,
        serviceAgreeStatus:this.checked
      }
      apiService.general(registApi.registSystem, undefined, param, undefined).then((response: RestfulResponse) => {
        console.log(response);
        if (response.code == Code.SUCCESS.code) {
          this.$router.push({
            name: `Mianview`,
            params: {
              data: response.data
            }
          })
        }
      });
    }
  }

//计时器
  changeCmstotal() {
    this.getCmstotal = this.time + "s重发验证码";
    this.timer = setInterval(() => {
      this.time--;
      this.getCmstotal = this.time + "s重发验证码";
      if (this.time < 0) {
        clearInterval(this.time)
        this.getCmstotal = "获取短信验证码";
      }
    }, 1000)

  }
getPhonePost(){
 let param={
    phoneCode:this.phone
 }
 apiService.general(commonApi.getPicCode,param,undefined,undefined).then((response: RestfulResponse) => {
       
        if (response.code == Code.SUCCESS.code) {
          Toast('短信发送成功，5分钟有效');
          this.changeCmstotal()
        }else{
           Toast('短信发送失败,请重试');
        }
    })
    

}


  created() {
    
  }
  returen() {


  }
}
</script>
<style lang="scss" scoped>
.loginform {
  width: 100%;
  height: 100%;
}

.logindiv {
  line-height: 20px;
}

.van-button {
  border-radius: 6px;
}

.polog {
  margin: 0px;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
  -webkit-font-feature-settings: "kern";
  -moz-font-feature-settings: "kern";
  -moz-font-feature-settings: "kern=1";
  font-kerning: normal;
}



.van-col--15 {
  margin-top: 2%;
}

.van-col--24 {
  margin-left: 6%;
}

.forget {}

.sopan {

  margin-top: 5px;
  margin-left: 6%;
}

// .login{
//   margin-top: 20%;
// }
</style>
