From d922b18d12b9d37f9279c4732daf6451e79ff601 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期一, 18 三月 2024 14:52:47 +0800 Subject: [PATCH] 注掉alert(JWT失效,即将跳转至登录页)弹窗 --- src/views/login/loginView.vue | 50 ++++++++++++++++++++++++++++---------------------- 1 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/views/login/loginView.vue b/src/views/login/loginView.vue index 533d652..3059412 100644 --- a/src/views/login/loginView.vue +++ b/src/views/login/loginView.vue @@ -20,8 +20,12 @@ /> </el-form-item> <el-form-item label="" prop="code"> - <el-input v-model="ruleForm.code" placeholder="楠岃瘉鐮�" autocomplete="off" style="width: 70%"> </el-input> - <img class="login-code" :src="captcha" @click="getCaptchaData" /> + <el-input v-model="ruleForm.code" placeholder="楠岃瘉鐮�" autocomplete="off" style="width: 70%"> + <template #append> + <img class="login-code" :src="captcha" @click="getCaptchaData" /> + </template> + </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> @@ -36,7 +40,7 @@ import { ref, reactive, onMounted } from 'vue' import type { FormInstance, FormRules } from 'element-plus' import { getCaptcha, login } from '@/api' -import { setToken } from '@/common/utils/index' +import { setToken, getToken } from '@/common/utils/index' import { ElMessage } from 'element-plus' import { useRouter } from 'vue-router' @@ -78,11 +82,9 @@ const captchaId = ref('') const getCaptchaData = () => { - getCaptcha().then((rsp) => { - if (rsp.code == 200) { - captcha.value = rsp.data.picPath - captchaId.value = rsp.data.captchaId - } + getCaptcha().then((rsp: any) => { + captcha.value = rsp?.data?.picPath + captchaId.value = rsp?.data?.captchaId }) } onMounted(() => { @@ -107,19 +109,17 @@ password: ruleForm.pass, captcha: ruleForm.code, captchaId: captchaId.value - }).then((rsp) => { - if (rsp.code == 200) { - console.log(rsp) - setToken(rsp.token) - ElMessage({ - message: '鐧诲綍鎴愬姛锛�', - type: 'success' - }) - ruleForm.accountNumber = '' - ruleForm.pass = '' - ruleForm.code = '' - router.push('/') - } + }).then((rsp: any) => { + console.log(rsp) + setToken(rsp?.data?.token) + ElMessage({ + message: '鐧诲綍鎴愬姛锛�', + type: 'success' + }) + ruleForm.accountNumber = '' + ruleForm.pass = '' + ruleForm.code = '' + router.push('/') }) } else { console.log('error submit!') @@ -185,7 +185,13 @@ } } } - +.login-code { + height: 40px - 2px; + display: block; + margin: 0px -20px; + border-top-right-radius: 2px; + border-bottom-right-radius: 2px; +} ::v-deep .el-form-item__content { display: flex; align-items: center; -- Gitblit v1.8.0