先勾选协议选框,才能进行下一步

先勾选协议选框,才能进行下一步

效果图:
未选中
已选中

<template>
  <div class="con">
    <div>
      <div class="input_con">
        <div>真实姓名</div>
        <input v-model.trim="realname" class="input" type="text" placeholder="请输入姓名" />
      </div>
      <div class="input_con">
        <div>证件类型</div>
        <div class="input">身份证</div>
      </div>
      <div class="input_con">
        <div>证件号码</div>
        <input v-model.trim="idcard" class="input" type="text" placeholder="请输入身份证号" />
      </div>
    </div>
    <div class="foot">
    <div @click="confirm" class="confirm"  v-show="hideshow1">
      <div class="con_button" :class="input_check ? 'agreebtn' : 'notagree'">确认添加</div>
    </div>
    <div class="agree">
      <input type="checkbox" @click="check()" id="input_agree" />
      <div>我已阅读并同意《隐私政策》</div>
    </div>
    </div>
  </div>
</template>
<script>
import {  Toast } from "vant"
import { isCardNo } from './../utils/common'
export default {
  data() {
    return {
      realname: '',
      idcard: '',
      input_check: false,
      hideshow: true,
    }
  },
  methods: {
    confirm () {
      if (this.input_check === false) {
        Toast('请先勾选同意隐私政策')
        return
      }
      if (!this.realname && !this.idcard) {
        Toast('请输入信息')
        return 
      }
      // 判断姓名
      var regu = "^[ ]+$";
      var re = new RegExp(regu)
      if(!this.realname || this.realname == null || re.test(this.realname)){
        Toast('请输入姓名')
        return 
      }
      if(!this.idcard || this.idcard == null || re.test(this.idcard)){
        Toast('请输入证件号码')
        return 
      }
      // 判断身份证
      let res = isCardNo(this.idcard)
      console.log(res) 
      if(res.pass === false){
        Toast(res.tip)
        return
      } else {
        Toast('身份证输入正确')
      }
    },
    check () {
      var obj = document.getElementById('input_agree')
      if(obj.checked == true){
        console.log('选中')
        this.input_check = true
      } else {
        console.log('取消选中')
         this.input_check = false
      }
    }
  },
  watch: {
    realname () {
      // console.log(this.realname)
    },
    idcard () {
      // console.log(this.idcard)
    }
  }
}
</script>
<style scoped>
.con{
  color: #333333;
  font-size: 1rem;
}
.input_con {
  display: flex;
  width: 100vw;
  height: 55px;
  align-items: center;
  background-color: #fff;
  border-bottom: 1px solid #eee;
  padding: 0 5vw;
}
.input{
  background-color: #fff;
  text-align: right;
  flex: 1;
  margin-left: 4vw;
  font-size: 1rem;
}
.foot{
  position: absolute;
  bottom: 6vh;
  text-align: center;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.agree{
  display: flex;
  align-items: center;
  margin-top: 2vh;
}
.con_button{
  width: 86.6vw;
  height: 5.54vh;
  width: 325px;
  height: 45px;
  line-height: 45px;
  font-size: 1.1rem;
  color: #fff;
  border-radius: 22.5px;
}
.notagree{
  background-color: #ccc;
}
.agreebtn{
  background-image: linear-gradient(#61D3A4, #5BC9AB);
}
</style>
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值