<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Springboot+Vue實現(xiàn)滑動驗證成功后登錄功能

          共 9353字,需瀏覽 19分鐘

           ·

          2020-08-28 01:23


          點擊上方?web項目開發(fā)選擇?設(shè)為星標(biāo)


          優(yōu)質(zhì)文章,及時送達(dá)






          效果圖


          前端登錄初始頁面

          拖動驗證條頁面

          登錄成功頁面

          成功后跳轉(zhuǎn)頁面






          環(huán)境介紹


          JDK:1.8

          數(shù)據(jù)庫:Mysql5.6

          前端:Vue

          后端:SpringBoot






          完整源碼獲取




          掃碼關(guān)注回復(fù)括號內(nèi)文字【滑動驗證】獲取源碼


          如果你在運(yùn)行這個代碼的過程中有遇到問題,請加小編微信xxf960513,我拉你進(jìn)對應(yīng)微信學(xué)習(xí)群!!幫助你快速掌握這個功能代碼!






          核心代碼介紹


          UserController.class


          ?package?com.example.login.controller;import com.example.login.entity.User;import com.example.login.service.UserService;import io.swagger.annotations.Api;import io.swagger.annotations.ApiOperation;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import?org.springframework.web.bind.annotation.*;import?java.util.Map;@Api(description = "用戶接口")@RestController@RequestMapping("/user")public class UserController {    @Autowired????private?UserService?userService;    @ApiOperation(value = "用戶登錄", notes = "用戶登錄")    @PostMapping("/login")    public Map login(@RequestBody User user) {        Map map = userService.login(user.getUsername(), user.getPassword());        return map;    }}


          UserService.class


          package?com.example.login.service;import com.example.login.entity.User;import com.example.login.mapper.UserMapper;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import java.util.HashMap;import?java.util.Map;@Servicepublic class UserService {    @Autowired????public?UserMapper?userMapper;    public Map<String, Object> login(String username, String password) {        Map<String, Object> map = new HashMap<>();        User user = userMapper.getUserByName(username);        if (user == null) {            map.put("code", "0001");            map.put("msg", "該賬號不存在!");            return map;        }        if (!password.equals(user.getPassword())) {            map.put("code", "0002");            map.put("msg", "密碼錯誤!");            return map;        }        map.put("code", "0000");        map.put("msg", "登錄成功!");        map.put("data", user);        return map;    }}


          index.vue


          <template>  <div class="login-container">????<el-form?ref="loginForm"?:model="loginForm"?:rules="loginRules"?class="login-form"?auto-complete="on"?label-position="left">      <div class="title-container">        <h3 class="title">Login Formh3>      div>
          <el-form-item prop="username"> <span class="svg-container"> <svg-icon icon-class="user" /> span> <el-input ref="username" v-model="loginForm.username" placeholder="Username" name="username" type="text" tabindex="1" auto-complete="on" /> el-form-item>
          <el-form-item prop="password"> <span class="svg-container"> <svg-icon icon-class="password" /> span> <el-input :key="passwordType" ref="password" v-model="loginForm.password" :type="passwordType" placeholder="Password" name="password" tabindex="2" auto-complete="on" @keyup.enter.native="handleLogin" /> <span class="show-pwd" @click="showPwd"> <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> span> el-form-item>
          <el-form-item> <JcRange @successFun="onSuccessFun" /> el-form-item>
          <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:20px;margin-top: 20px;" @click.native.prevent="handleLogin">Loginel-button>
          <div class="tips"> <span style="color: #409EFF;" @click="handleGet">免費(fèi)注冊span> <span style="color: #ccc;" @click="handleGet">忘記密碼span> div>
          el-form> div>template>
          <script>import { validUsername } from "@/utils/validate";import JcRange from "@/views/login/jcRange.vue";import axios from "axios";export default { name: "Login", data() { const validateUsername = (rule, value, callback) => { if (!validUsername(value)) { callback(new Error("Please enter the correct user name")); } else { callback(); } }; const validatePassword = (rule, value, callback) => { if (value.length < 6) { callback(new Error("The password can not be less than 6 digits")); } else { callback(); } }; return { loginForm: { username: "admin", password: "123456" }, loginRules: { username: [ { required: true, trigger: "blur", validator: validateUsername } ], password: [ { required: true, trigger: "blur", validator: validatePassword } ] }, loading: false, passwordType: "password", redirect: undefined, status: false }; }, components: { JcRange },??watch:?{ }, methods: { showPwd() { if (this.passwordType === "password") { this.passwordType = ""; } else { this.passwordType = "password"; } this.$nextTick(() => { this.$refs.password.focus(); }); }, async handleLogin() { const that = this; const { username, password } = this.loginForm; this.$refs.loginForm.validate(valid => { if (valid) { if (!that.status) { return this.$message.error("請按住滑塊,拖動到最右邊"); } this.loading = true; axios({ method: "post", url: "http://139.159.147.237:9534/user/login", data: { username, password } }).then(res => { that.loading = false; if (res.data.code == "0000") { that.$message({ message: res.data.msg, type: "success" }); setTimeout(() => { window.open( "https://mp.weixin.qq.com/mp/appmsgalbum?action=getalbum&__biz=MzI2NjA1OTMwMg==&scene=24&album_id=1337183186920767488#wechat_redirect", "_blank" ); }, 1000); } else { that.$message.error(res.data.msg); } }); } else { console.log("error submit!!"); return false; } }); },
          // 監(jiān)聽滑塊成功事件 onSuccessFun(e) { this.status = e; }, handleGet() { this.$message("正在開發(fā)中"); } }};script>
          <style lang="scss">/* 修復(fù)input 背景不協(xié)調(diào) 和光標(biāo)變色 *//* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
          $bg: #283443;$light_gray: #fff;$cursor: #fff;
          @supports (-webkit-mask: none) and (not (cater-color: $cursor)) { .login-container .el-input input { color: $cursor; }}
          /* reset element-ui css */.login-container { .el-input { display: inline-block; height: 47px; width: 85%;
          input { background: transparent; border: 0px; -webkit-appearance: none; border-radius: 0px; padding: 12px 5px 12px 15px; color: $light_gray; height: 47px; caret-color: $cursor;
          &:-webkit-autofill { box-shadow: 0 0 0px 1000px $bg inset !important; -webkit-text-fill-color: $cursor !important; } }??} .el-form-item { border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(0, 0, 0, 0.1); border-radius: 5px; color: #454545; }}style>
          <style lang="scss" scoped>$bg: #2d3a4b;$dark_gray: #889aa4;$light_gray:?#eee;.login-container { min-height: 100%; width: 100%; background-color: $bg;??overflow:?hidden; .login-form { position: relative; width: 520px; max-width: 100%; padding: 160px 35px 0; margin: 0 auto; overflow: hidden;??} .tips { font-size: 14px; color: #fff; margin-bottom: 10px; display: flex;????justify-content:?space-between; span { &:first-of-type { margin-right: 16px; } }??} .svg-container { padding: 6px 5px 6px 15px; color: $dark_gray; vertical-align: middle; width: 30px; display: inline-block;??} .title-container {????position:?relative; .title { font-size: 26px; color: $light_gray; margin: 0px auto 40px auto; text-align: center; font-weight: bold; } }
          .show-pwd { position: absolute; right: 10px; top: 7px; font-size: 16px; color: $dark_gray; cursor: pointer; user-select: none; }}style>


          main.js


          import?Vue?from?"vue";import?"normalize.css/normalize.css";?//?A?modern?alternative?to?CSS?resetsimport ElementUI from "element-ui";import "element-ui/lib/theme-chalk/index.css";//?import?locale?from?'element-ui/lib/locale/lang/en'?//?lang?i18nimport?"@/styles/index.scss";?//?global?cssimport App from "./App";import store from "./store";import?router?from?"./router";import "@/icons"; // iconimport?"@/permission";?//?permission?controlimport echarts from "echarts";/** * If you don't want to use mock-server * you want to use MockJs for mock api * you can execute: mockXHR() * * Currently MockJs will be used in the production environment, * please remove it before going online ! ! ! */if (process.env.NODE_ENV === "production") {  const { mockXHR } = require("../mock");  mockXHR();}// set ElementUI lang to ENVue.use(ElementUI);// 如果想要中文版 element-ui,按如下方式聲明//?Vue.use(ElementUI)Vue.config.productionTip?=?false;new Vue({  el: "#app",  router,  store,  render: h => h(App)});


          t_user.sql


          SET FOREIGN_KEY_CHECKS=0;---------------------------- Table structure for T_USER-- ----------------------------DROP TABLE IF EXISTS `T_USER`;CREATE TABLE `T_USER` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `username` varchar(32) NOT NULL,  `pwd` varchar(64) NOT NULL,  `zt` smallint(255) NOT NULL COMMENT '0:未激活,1:已激活',  `createdate` date NOT NULL,  `email` varchar(255) NOT NULL,  `code` varchar(32) NOT NULL,  PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;


          --完--


          如果你覺得這個案例以及我們的分享思路不錯,對你有幫助,請分享給身邊更多需要學(xué)習(xí)的朋友。別忘了《留言+點在看》給作者一個鼓勵哦!



          推薦案例


          1、springboot+mybatis+vue前后端分離實現(xiàn)用戶登陸注冊功能

          2、SpringBoot+Vue前后分離實現(xiàn)郵件發(fā)送功能

          3、SpringBoot+Spring Data JPA+Vue前后端分離實現(xiàn)分頁功能

          4、SpringBoot+Spring Data JPA+Vue前后端分離實現(xiàn)Excel導(dǎo)出功能

          5、Spring Boot + Vue前后端分離實現(xiàn)圖片上傳功能

          6、springboot+jpa+tymeleaf實現(xiàn)分頁功能

          7、springboot+jpa+thymeleaf實現(xiàn)信息修改功能

          8、SpringBoot+vue開發(fā)微信小程序留言功能

          9、SpringBoot實現(xiàn)生成帶參數(shù)的小程序二維碼功能

          10、springboot+jpa+thymeleaf實現(xiàn)信息增刪改查功能

          11、用java實現(xiàn)Graphics2D繪制驗證碼功能

          12、Springboot+layui前后端分離實現(xiàn)word轉(zhuǎn)pdf功能

          13、用java將本地圖片轉(zhuǎn)base64格式, 再轉(zhuǎn)圖片!你用過這個功能?

          14、springboot+layui+thymelefe實現(xiàn)用戶批量添加功能

          15、springboot+Tymeleaf實現(xiàn)用戶密碼MD5加鹽解密登錄

          16、springboot+vue實現(xiàn)用戶注冊后必須通過郵箱激活才能登錄激活才能登錄

          17、SpringBoot+Vue實現(xiàn)用戶頭像修改功能

          18、Springboot+Vue實現(xiàn)富文本發(fā)表文章功能

          19、springboot+vue實現(xiàn)不同管理權(quán)限的用戶登陸展示的菜單欄目不同功能

          20、Springboot+vue實現(xiàn)上傳視頻并在線播放功能

          21、SpringBoot+Vue前后端分離實現(xiàn)郵件定時發(fā)送功能

          22、springboot+vue實現(xiàn)多圖片同時上傳功能

          23、Springboot+Vue前后端分離實現(xiàn)Excle文件導(dǎo)入并在前端頁面回顯功能

          24、Springboot+Vue實現(xiàn)從數(shù)據(jù)庫中獲取數(shù)據(jù)生成樹狀圖在前端頁面展示功能

          25、Springboot+Vue實現(xiàn)從數(shù)據(jù)庫中獲取數(shù)據(jù)生成餅狀圖并在前端頁面展示功能

          26、Springboot+Vue實現(xiàn)批量文件上傳(pdf、word、excel)并支持在線預(yù)覽功能



          溫暖提示


          為了方便大家更好的學(xué)習(xí),本公眾號經(jīng)常分享一些完整的單個功能案例代碼給大家去練習(xí),如果本公眾號沒有你要學(xué)習(xí)的功能案例,你可以聯(lián)系小編(微信:xxf960513)提供你的小需求給我,我安排我們這邊的開發(fā)團(tuán)隊免費(fèi)幫你完成你的案例。
          注意:只能提單個功能的需求不能要求功能太多,比如要求用什么技術(shù),有幾個頁面,頁面要求怎么樣?


          #vue##springboot##滑動驗證#

          瀏覽 112
          點贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  亚洲高清无码免费视频 | 青青青青青青操 | 欧美乱伦熟妇 | 精品中文字幕在线播放 | 月亚洲综合在线 |