|
@@ -16,12 +16,19 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="pwd">
|
|
|
<el-input type="password" placeholder="密码" v-model="loginForm.pwd" input-style="height:40px" tabindex="2"
|
|
|
- @keyup.enter="submitForm()">
|
|
|
+ >
|
|
|
<template #prepend>
|
|
|
<el-button icon="Lock"></el-button>
|
|
|
</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item prop="captchaCode">
|
|
|
+ <el-input placeholder="请输入验证码" v-model="loginForm.captchaCode" input-style="height:40px;" style="flex:1;" tabindex="3"
|
|
|
+ @keyup.enter="submitForm()">
|
|
|
+
|
|
|
+ </el-input>
|
|
|
+ <img :src="captchaImgUrl" style="z-index: 100;border-radius: 2px;cursor: pointer;" @click="loadCaptcha"/>
|
|
|
+ </el-form-item>
|
|
|
<div class="login-btn">
|
|
|
<el-button type="primary" @click="submitForm()" size="default" tabindex="3" :loading="isLoading">登录</el-button>
|
|
|
</div>
|
|
@@ -46,21 +53,24 @@ import { useHomeStore } from "../store/home.js"
|
|
|
const loginForm = reactive({
|
|
|
loginId: '',
|
|
|
pwd: '',
|
|
|
+ captchaCode:null,
|
|
|
+ captchaId:null
|
|
|
});
|
|
|
|
|
|
const rules = {
|
|
|
loginId: [{required: true, message: "请输入用户名",trigger: "blur"}],
|
|
|
- pwd: [{ required: true, message: "请输入密码", trigger: "blur" }]
|
|
|
+ pwd: [{ required: true, message: "请输入密码", trigger: "blur" }],
|
|
|
+ captchaCode: [{ required: true, message: "请输入验证码", trigger: "blur" }]
|
|
|
};
|
|
|
-
|
|
|
+ const captchaImgUrl=ref(null)
|
|
|
const isLoading=ref(false)
|
|
|
const login = ref(null);
|
|
|
const submitForm = () => {
|
|
|
login.value.validate((valid) => {
|
|
|
if (valid) {
|
|
|
isLoading.value=true
|
|
|
- let {loginId,pwd}=loginForm
|
|
|
- loginAPI.checkLogin({loginId,pwd}).then(resp=>{
|
|
|
+ let {loginId,pwd,captchaCode,captchaId}=loginForm
|
|
|
+ loginAPI.checkLogin({loginId,pwd,captchaCode,captchaId}).then(resp=>{
|
|
|
/* console.log(resp)
|
|
|
isLoading.value=false
|
|
|
if(resp.code===0){
|
|
@@ -93,7 +103,18 @@ import { useHomeStore } from "../store/home.js"
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ const loadCaptcha=()=>{
|
|
|
+ loginAPI.getCaptcha().then(resp=>{
|
|
|
+ if(resp.code==0){
|
|
|
+ captchaImgUrl.value=resp.data.img
|
|
|
+ loginForm.captchaId=resp.data.captchaId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
+ onMounted(()=>{
|
|
|
+ loadCaptcha()
|
|
|
+ })
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|