spring boot+vue 实现登录注册图形验证码功能

大家好我是程序员凡心,感谢大家支持我~!挑战全网最详细图形验证码

第一步导pom文件

第二步编写config

第三步编写CaptureController

第三步编写AccountController

第四步给实体类加个变量

第五步vue前端login页面

<el-form-item prop="name">
  <div style="display: flex;justify-content: center;margin: 20px 0">
  <el-input size="medium"  style="width: 160px;margin-top: 20px" placeholder="请输入图形验证码" prefix-icon="el-icon-user" v-model="user.verCode"></el-input>
  <img :src="captchaUtl"  @click="clickImg" width="160px" height="60px" style="margin-left: 10px" />
  </div>
</el-form-item>
clickImg(){
  this.key=Math.random();
  this.captchaUtl='http://localhost:9090/captcha?key='+this.key;
}
return{
  user:{},
  key:'',

}

mounted(){
  this.key=Math.random();
  this.captchaUtl='http://localhost:9090/captcha?key='+this.key;

},

 

login(){
  this.request.post("account/login?key="+this.key,this.user).then(res => {
    if(res.code === '200'){
      let user=res.data;
      localStorage.setItem('user',JSON.stringify(user))
      if(user && user.level && 1 === user.level){
        this.$router.push("/adminPerson");
      }
      if(user && user.level && 2 === user.level){
        this.$router.push("/teacherPerson");
      }
      if(user && user.level && 3 === user.level){

        this.$router.push("/studentPerson");
      }
    }else {
      this.$message.error(res.msg);
      this.clickImg();

    }
  })
},
  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值