|
|
|
@ -54,8 +54,7 @@
|
|
|
|
|
<a-button :loading="submitLoading" class="submit-btn" type="primary" @click="submitLogin">
|
|
|
|
|
确认登录
|
|
|
|
|
</a-button>
|
|
|
|
|
<div class="des">管理员登录</div>
|
|
|
|
|
</div>
|
|
|
|
|
<a-button class="admin-login-btn" type="link" @click="adminLogin">管理员登录</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
@ -100,6 +99,37 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
adminLogin() {
|
|
|
|
|
if (!this.checkEmail()) {
|
|
|
|
|
this.$message.error('请输入正确格式的邮箱');
|
|
|
|
|
return; // 邮箱格式不正确时,不执行后续代码
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.adminLoading = true;
|
|
|
|
|
AdminLogin(this.form).then((response) => {
|
|
|
|
|
this.adminLoading = false;
|
|
|
|
|
if (response && response.status) {
|
|
|
|
|
this.$store.commit('user/saveToken', response.data.token);
|
|
|
|
|
this.$store.commit('user/saveLoginUser', response.data.admin);
|
|
|
|
|
this.$router.push("/admin-home");
|
|
|
|
|
this.$message.success("管理员登录成功");
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.data.msg || "管理员登录失败");
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
this.adminLoading = false;
|
|
|
|
|
let errorMessage = "管理员登录请求失败,请稍后重试";
|
|
|
|
|
if (error.response && error.response.data && error.response.data.msg) {
|
|
|
|
|
errorMessage = error.response.data.msg;
|
|
|
|
|
} else if (error.message) {
|
|
|
|
|
errorMessage = error.message;
|
|
|
|
|
}
|
|
|
|
|
console.error("管理员登录请求错误:", error);
|
|
|
|
|
this.$message.error(errorMessage);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
submitLogin() {
|
|
|
|
|
if (this.checkEmail()) {
|
|
|
|
|
let type = this.submitType === '1' ? "passwrod" : "email"
|
|
|
|
@ -266,5 +296,22 @@ export default {
|
|
|
|
|
.title-with-logo span {
|
|
|
|
|
white-space: nowrap; /* 防止文本换行 */
|
|
|
|
|
}
|
|
|
|
|
.admin-login-btn {
|
|
|
|
|
display: block; /* 使按钮独占一行 */
|
|
|
|
|
width: 100%; /* 宽度100% */
|
|
|
|
|
padding: 0px; /* 内边距 */
|
|
|
|
|
background-color: transparent; /* 透明背景 */
|
|
|
|
|
color: #4a90e2; /* 文字颜色 */
|
|
|
|
|
border: none; /* 无边框 */
|
|
|
|
|
font-size: 14px; /* 字体大小 */
|
|
|
|
|
cursor: pointer; /* 鼠标悬停时显示手型 */
|
|
|
|
|
text-align: center; /* 文字居中 */
|
|
|
|
|
margin-top: 10px; /* 与上一个按钮的间距 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-login-btn:hover {
|
|
|
|
|
background-color: #e6f7ff; /* 鼠标悬停时的背景颜色 */
|
|
|
|
|
color: #1890ff; /* 鼠标悬停时的文字颜色 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|