From 97fbcafbcf9c214de42f276a17a5f5b5d1619d80 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期一, 05 二月 2024 17:22:35 +0800 Subject: [PATCH] 登录页面配置和验证码问题 --- src/views/login/loginView.vue | 33 ++++++++++++++++++++++++++++----- 1 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/views/login/loginView.vue b/src/views/login/loginView.vue index c6d28f7..2c768ed 100644 --- a/src/views/login/loginView.vue +++ b/src/views/login/loginView.vue @@ -19,9 +19,10 @@ autocomplete="off" /> </el-form-item> - <!-- <el-form-item label="纭瀵嗙爜" prop="checkPass"> - <el-input v-model="ruleForm.checkPass" type="password" autocomplete="off" /> - </el-form-item> --> + <el-form-item label="" prop="code"> + <el-input v-model="ruleForm.code" autocomplete="off" style="width: 70%"> </el-input> + <img class="login-code" :src="captcha" @click="getCaptchaData" /> + </el-form-item> <el-form-item> <el-button type="primary" @click="submitForm(ruleFormRef)">鐧诲綍</el-button> </el-form-item> @@ -32,8 +33,9 @@ </template> <script setup lang="ts"> -import { ref, reactive } from 'vue' +import { ref, reactive, onMounted } from 'vue' import type { FormInstance, FormRules } from 'element-plus' +import { getCaptcha } from '@/api' const ruleFormRef = ref<FormInstance>() @@ -65,7 +67,28 @@ const ruleForm = reactive({ pass: '', // checkPass: '', - accountNumber: '' + accountNumber: '', + code: '' +}) + +const captcha = ref('') + +const getCaptchaData = () => { + getCaptcha().then((rsp) => { + if (rsp.code == 200) { + this.captchaId = rsp.data.captchaId + this.captcha = rsp.data.picPath + } + }) +} +onMounted(() => { + // 鑾峰彇楠岃瘉鐮� + getCaptcha().then((rsp) => { + if (rsp.code == 200) { + this.captchaId = rsp.data.captchaId + this.captcha = rsp.data.picPath + } + }) }) const rules = reactive<FormRules<typeof ruleForm>>({ -- Gitblit v1.8.0