Commit 4e7bd7e5 authored by “yiyousong”'s avatar “yiyousong”

feat:登录添加验证码校验

parent b171f9a7
import http from "../request/http"; import http from "../request/http";
let baseURL = process.env.VUE_APP_API_BASE_URL let baseURL = process.env.VUE_APP_API_BASE_URL;
// 1.2.1. 登录 // 1.2.1. 登录
export function LoginInterface(params) { export function LoginInterface(params) {
return http.post(`${baseURL}/zwfw/login/login`, params); return http.post(`${baseURL}/zwfw/login/login`, params);
...@@ -20,3 +20,9 @@ export function changePassword(params) { ...@@ -20,3 +20,9 @@ export function changePassword(params) {
export function editPassword(params) { export function editPassword(params) {
return http.post(`${baseURL}/zwfw/user/reset/password`, params); return http.post(`${baseURL}/zwfw/user/reset/password`, params);
} }
// 获取图形验证码
export function createCode(params) {
return http.post(`${baseURL}/zwfw/securitycode/createCode`, params, {
responseType: "blob",
});
}
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
placeholder="请输入用户名" placeholder="请输入用户名"
onfocus="this.placeholder=''" onfocus="this.placeholder=''"
onblur="this.placeholder='请输入用户名'" onblur="this.placeholder='请输入用户名'"
style="width: 520px; height: 50px" style="width: 520px; height: 52px"
class="user" class="user"
v-model="form.loginName" v-model="form.loginName"
/> />
...@@ -33,16 +33,19 @@ ...@@ -33,16 +33,19 @@
v-model="form.password" v-model="form.password"
@pressEnter="handleSubmit" @pressEnter="handleSubmit"
/> />
<!-- <a-input </a-form-model-item>
type="password" <a-form-model-item prop="code">
placeholder="请输入密码" <div class="code" style="width: 520px; height: 52px">
onfocus="this.placeholder=''" <a-input
onblur="this.placeholder='请输入密码'" placeholder="请输入验证码"
style="width: 520px; height: 52px" onfocus="this.placeholder=''"
class="password" onblur="this.placeholder='请输入验证码'"
v-model="form.password" style="height: 52px"
@pressEnter="handleSubmit" v-model="form.code"
/> --> @pressEnter="handleSubmit"
/>
<img :src="imgCode" @click="createCode" />
</div>
</a-form-model-item> </a-form-model-item>
<a-form-model-item> <a-form-model-item>
<a-button <a-button
...@@ -65,17 +68,22 @@ import { LoginInterface } from "@/api/user.js"; ...@@ -65,17 +68,22 @@ import { LoginInterface } from "@/api/user.js";
export default { export default {
data() { data() {
return { return {
api: process.env.VUE_APP_API_BASE_URL,
imgCode: "",
form: { form: {
loginName: "", loginName: "",
password: "", password: "",
code: "",
}, },
rules: { rules: {
loginName: [{ required: true, message: "请输入账号", trigger: "blur" }], loginName: [{ required: true, message: "请输入账号", trigger: "blur" }],
password: [{ required: true, message: "请输入密码", trigger: "blur" }], password: [{ required: true, message: "请输入密码", trigger: "blur" }],
code: [{ required: true, message: "请输入验证码", trigger: "blur" }],
}, },
}; };
}, },
created() { created() {
this.createCode();
let token = this.$Storage.get(2, "Authorization"); let token = this.$Storage.get(2, "Authorization");
if (token) { if (token) {
this.$router.push("/home/dataManagement/dataAdmin"); this.$router.push("/home/dataManagement/dataAdmin");
...@@ -84,6 +92,13 @@ export default { ...@@ -84,6 +92,13 @@ export default {
methods: { methods: {
// ...mapMutations("user", ["SET_USERDATA"]), // ...mapMutations("user", ["SET_USERDATA"]),
// ...mapActions("user", ["getCensusList", "getAppsList"]), // ...mapActions("user", ["getCensusList", "getAppsList"]),
// 获取验证码
createCode() {
// 加时间戳印记用于刷新gif
let mark = new Date().getTime();
this.imgCode =
this.api + "/zwfw/securitycode/createCode" + `?mark=${mark}`;
},
handleSubmit() { handleSubmit() {
this.$refs.formData.validate(async (valid) => { this.$refs.formData.validate(async (valid) => {
if (valid) { if (valid) {
...@@ -133,8 +148,6 @@ export default { ...@@ -133,8 +148,6 @@ export default {
padding-top: 30px; padding-top: 30px;
.user, .user,
/deep/.password { /deep/.password {
text-align: center;
border-color: #dadada;
margin: auto; margin: auto;
margin-bottom: 5px; margin-bottom: 5px;
margin-top: 8px; margin-top: 8px;
...@@ -144,7 +157,6 @@ export default { ...@@ -144,7 +157,6 @@ export default {
color: rgb(111, 164, 227); color: rgb(111, 164, 227);
font-size: 16px; font-size: 16px;
} }
border: 1px solid #dadada !important;
} }
} }
/deep/.ant-col-offset-4 { /deep/.ant-col-offset-4 {
...@@ -169,6 +181,20 @@ export default { ...@@ -169,6 +181,20 @@ export default {
} }
} }
} }
.code {
display: flex;
align-items: center;
.ant-input {
height: 100%;
border-radius: 4px 0px 0px 4px;
flex: 1;
}
img {
height: 52px;
border-radius: 0px 4px 4px 0px;
cursor: pointer;
}
}
} }
input::-webkit-input-placeholder { input::-webkit-input-placeholder {
/* WebKit browsers */ /* WebKit browsers */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment