Commit b78378ce446323df8f85f4d71fe9fb86061ea3e9

Authored by xingyu
1 parent e842d2e0

AJ-Captcha vue2 增加验证码二次校验

yudao-ui-admin/src/api/login.js
@@ -3,10 +3,11 @@ import { getRefreshToken } from '@/utils/auth' @@ -3,10 +3,11 @@ import { getRefreshToken } from '@/utils/auth'
3 import service from '@/utils/request' 3 import service from '@/utils/request'
4 4
5 // 登录方法 5 // 登录方法
6 -export function login(username, password, socialType, socialCode, socialState) { 6 +export function login(username, password, captchaVerification, socialType, socialCode, socialState) {
7 const data = { 7 const data = {
8 username, 8 username,
9 password, 9 password,
  10 + captchaVerification,
10 // 社交相关 11 // 社交相关
11 socialType, 12 socialType,
12 socialCode, 13 socialCode,
yudao-ui-admin/src/store/modules/user.js
@@ -36,11 +36,12 @@ const user = { @@ -36,11 +36,12 @@ const user = {
36 Login({ commit }, userInfo) { 36 Login({ commit }, userInfo) {
37 const username = userInfo.username.trim() 37 const username = userInfo.username.trim()
38 const password = userInfo.password 38 const password = userInfo.password
  39 + const captchaVerification = userInfo.captchaVerification
39 const socialCode = userInfo.socialCode 40 const socialCode = userInfo.socialCode
40 const socialState = userInfo.socialState 41 const socialState = userInfo.socialState
41 const socialType = userInfo.socialType 42 const socialType = userInfo.socialType
42 return new Promise((resolve, reject) => { 43 return new Promise((resolve, reject) => {
43 - login(username, password, socialType, socialCode, socialState).then(res => { 44 + login(username, password, captchaVerification, socialType, socialCode, socialState).then(res => {
44 res = res.data; 45 res = res.data;
45 // 设置 token 46 // 设置 token
46 setToken(res) 47 setToken(res)
yudao-ui-admin/src/views/login.vue
@@ -132,6 +132,7 @@ export default { @@ -132,6 +132,7 @@ export default {
132 loginType: "uname", 132 loginType: "uname",
133 username: "admin", 133 username: "admin",
134 password: "admin123", 134 password: "admin123",
  135 + captchaVerification: "",
135 mobile: "", 136 mobile: "",
136 mobileCode: "", 137 mobileCode: "",
137 rememberMe: false, 138 rememberMe: false,
@@ -213,7 +214,8 @@ export default { @@ -213,7 +214,8 @@ export default {
213 tenantName: tenantName ? tenantName : this.loginForm.tenantName, 214 tenantName: tenantName ? tenantName : this.loginForm.tenantName,
214 }; 215 };
215 }, 216 },
216 - handleLogin() { 217 + handleLogin(params) {
  218 + console.info(params)
217 this.$refs.loginForm.validate(valid => { 219 this.$refs.loginForm.validate(valid => {
218 if (valid) { 220 if (valid) {
219 this.loading = true; 221 this.loading = true;
@@ -229,6 +231,7 @@ export default { @@ -229,6 +231,7 @@ export default {
229 removeRememberMe() 231 removeRememberMe()
230 removeTenantName() 232 removeTenantName()
231 } 233 }
  234 + this.loginForm.captchaVerification = params.captchaVerification
232 // 发起登陆 235 // 发起登陆
233 // console.log("发起登录", this.loginForm); 236 // console.log("发起登录", this.loginForm);
234 this.$store.dispatch(this.loginForm.loginType === "sms" ? "SmsLogin" : "Login", this.loginForm).then(() => { 237 this.$store.dispatch(this.loginForm.loginType === "sms" ? "SmsLogin" : "Login", this.loginForm).then(() => {