提交 a6f26284 编写于 作者: K klausY

增加验证码功能

上级 fae4df79
...@@ -65,4 +65,20 @@ export const setUserAuthority = (data) => { ...@@ -65,4 +65,20 @@ export const setUserAuthority = (data) => {
method: 'post', method: 'post',
data: data data: data
}) })
} }
\ No newline at end of file
// @Tags User
// @Summary 验证码
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body api.SetUserAuth true "设置用户权限"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /user/setUserAuthority [post]
export const captcha = (data) => {
return service({
url: "/base/captcha",
method: 'post',
data: data
})
}
...@@ -16,6 +16,14 @@ ...@@ -16,6 +16,14 @@
<i :class="'el-input__icon el-icon-' + lock" @click="changeLock" slot="suffix"></i> <i :class="'el-input__icon el-icon-' + lock" @click="changeLock" slot="suffix"></i>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item>
<el-input
v-model="loginForm.captcha"
name="logVerify"
maxlength="10"
/>
<img :src="path + picPath" alt="请输入验证码" @click="loginVefify()" class="vPic">
</el-form-item>
<el-form-item> <el-form-item>
<el-button @click="submitForm" style="width:100%">登 录</el-button> <el-button @click="submitForm" style="width:100%">登 录</el-button>
</el-form-item> </el-form-item>
...@@ -27,6 +35,8 @@ ...@@ -27,6 +35,8 @@
<script> <script>
import { mapActions } from 'vuex' import { mapActions } from 'vuex'
import { captcha } from '@/api/user'
const path = process.env.VUE_APP_BASE_API
export default { export default {
name: 'Login', name: 'Login',
data() { data() {
...@@ -49,14 +59,22 @@ export default { ...@@ -49,14 +59,22 @@ export default {
lock: 'lock', lock: 'lock',
loginForm: { loginForm: {
username: '', username: '',
password: '' password: '',
captcha:'',
captchaId: '',
}, },
rules: { rules: {
username: [{ validator: checkUsername, trigger: 'blur' }], username: [{ validator: checkUsername, trigger: 'blur' }],
password: [{ validator: checkPassword, trigger: 'blur' }] password: [{ validator: checkPassword, trigger: 'blur' }]
} },
path:path,
logVerify:'',
picPath:''
} }
}, },
created() {
this.loginVefify()
},
methods: { methods: {
...mapActions('user', ['LoginIn']), ...mapActions('user', ['LoginIn']),
async login() { async login() {
...@@ -78,6 +96,13 @@ export default { ...@@ -78,6 +96,13 @@ export default {
}, },
changeLock() { changeLock() {
this.lock === 'lock' ? (this.lock = 'unlock') : (this.lock = 'lock') this.lock === 'lock' ? (this.lock = 'unlock') : (this.lock = 'lock')
},
loginVefify() {
console.log(this.logVerify)
captcha({}).then(ele=>{
this.picPath = ele.data.picPath
this.loginForm.captchaId = ele.data.captchaId
})
} }
} }
} }
...@@ -94,5 +119,9 @@ export default { ...@@ -94,5 +119,9 @@ export default {
margin-left: -22vw; margin-left: -22vw;
top: 25vh; top: 25vh;
} }
.vPic{
position: absolute;
right: 10px;
}
} }
</style> </style>
\ No newline at end of file
...@@ -95,4 +95,4 @@ module.exports = { ...@@ -95,4 +95,4 @@ module.exports = {
} }
) )
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册