<template>
|
<div class="login-container">
|
<div class="project-name">WMS</div>
|
<div class="login-form">
|
<div class="form-user" @keypress="loginPress">
|
<div class="login-text">
|
<div>
|
<div>欢迎登录...</div>
|
<div class="login-line"></div>
|
</div>
|
<div style="flex: 1"></div>
|
</div>
|
<div class="login-text-small">WELCOME TO LOGIN</div>
|
<div class="item">
|
<div class="input-icon el-icon-user"></div>
|
<input
|
type="text"
|
v-focus
|
v-model="userInfo.userName"
|
placeholder="请输入账号"
|
/>
|
</div>
|
<div class="item">
|
<div class="input-icon el-icon-lock"></div>
|
<input
|
type="password"
|
v-focus
|
v-model="userInfo.password"
|
placeholder="请输入密码"
|
/>
|
</div>
|
|
<div class="item station-select-item">
|
<div class="input-icon el-icon-lock"></div>
|
<el-select
|
v-model="stationValue"
|
placeholder="选择站台"
|
class="station-select"
|
@change="handleStationChange"
|
>
|
<el-option
|
v-for="item in stationOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</div>
|
|
|
<div class="item">
|
<div class="input-icon el-icon-mobile"></div>
|
<input
|
v-focus
|
type="text"
|
v-model="userInfo.verificationCode"
|
placeholder="输入验证码"
|
/>
|
<div class="code" @click="getVierificationCode">
|
<img v-show="codeImgSrc != ''" :src="codeImgSrc" />
|
</div>
|
</div>
|
</div>
|
<div class="loging-btn">
|
<el-button
|
size="large"
|
:loading="loading"
|
color="#3a6cd1"
|
:dark="true"
|
@click="login"
|
long
|
>
|
<span v-if="!loading">登录</span>
|
<span v-else>正在登录...</span>
|
</el-button>
|
</div>
|
</div>
|
|
<img class="login-bg" src="/static/login_bg.png" />
|
</div>
|
</template>
|
|
<script>
|
import {
|
defineComponent,
|
ref,
|
reactive,
|
toRefs,
|
getCurrentInstance,
|
onMounted,
|
} from "vue";
|
import { useRouter, useRoute } from "vue-router";
|
import store from "../store/index";
|
import http from "@/../src/api/http.js";
|
import { stationManager, STATION_STORAGE_KEY } from "@/../src/uitils/stationManager";
|
export default defineComponent({
|
setup(props, context) {
|
store.commit("clearUserInfo", "");
|
const loading = ref(false);
|
const codeImgSrc = ref("");
|
const value = ref("");
|
const userInfo = reactive({
|
userName: "",
|
password: "",
|
verificationCode: "",
|
UUID: undefined,
|
});
|
const stationValue = ref("");
|
const stationOptions = reactive([
|
{ label: "站台2", value: "2-1" },
|
{ label: "站台3", value: "3-1" },
|
]);
|
// 初始化站台值
|
onMounted(() => {
|
// 从本地存储加载保存的站台值
|
const savedStation = stationManager.getStation();
|
if (savedStation) {
|
stationValue.value = savedStation;
|
} else if (stationOptions.length > 0) {
|
// 如果没有保存的值,使用第一个选项
|
stationValue.value = stationOptions[0].value;
|
}
|
});
|
const handleStationChange = (value) => {
|
// 保存站台选择到本地存储
|
if (value) {
|
stationManager.saveStation(value);
|
// 也保存到Vuex/store中,方便全局访问
|
store.commit("setStation", value);
|
}
|
};
|
|
const getVierificationCode = () => {
|
http.get("/api/User/getVierificationCode").then((x) => {
|
codeImgSrc.value = "data:image/png;base64," + x.img;
|
userInfo.UUID = x.uuid;
|
});
|
};
|
getVierificationCode();
|
|
let appContext = getCurrentInstance().appContext;
|
let $message = appContext.config.globalProperties.$message;
|
let router = useRouter();
|
|
const login = () => {
|
if (!userInfo.userName) return $message.error("请输入用户名");
|
if (!userInfo.password) return $message.error("请输入密码");
|
if (!userInfo.verificationCode) {
|
return $message.error("请输入验证码");
|
}
|
|
// 确保站台值已保存
|
if (stationValue.value) {
|
stationManager.saveStation(stationValue.value);
|
store.commit("setStation", stationValue.value);
|
}
|
|
loading.value = true;
|
http.post("/api/User/login", userInfo, "正在登录....").then((result) => {
|
if (!result.status) {
|
loading.value = false;
|
getVierificationCode();
|
return $message.error(result.message);
|
}
|
$message.success("登录成功,正在跳转!");
|
store.commit("setUserInfo", result.data);
|
|
router.push({ path: "/" });
|
});
|
};
|
const loginPress = (e) => {
|
if (e.keyCode == 13) {
|
login();
|
}
|
};
|
const openUrl = (url) => {
|
window.open(url, "_blank");
|
};
|
return {
|
loading,
|
codeImgSrc,
|
getVierificationCode,
|
login,
|
userInfo,
|
loginPress,
|
openUrl,
|
stationOptions,
|
stationValue,
|
handleStationChange,
|
};
|
},
|
directives: {
|
focus: {
|
inserted: function (el) {
|
el.focus();
|
},
|
},
|
},
|
});
|
</script>
|
<style lang="less" scoped>
|
.login-container {
|
display: flex;
|
width: 100%;
|
height: 100%;
|
background: rgb(246, 247, 252);
|
justify-content: flex-end;
|
align-items: center;
|
}
|
|
.login-form {
|
align-items: center;
|
width: 50%;
|
display: flex;
|
flex-direction: column;
|
z-index: 999;
|
|
.form-user {
|
.item {
|
border-radius: 5px;
|
border: 1px solid #ececec;
|
display: flex;
|
margin-bottom: 30px;
|
background: #ffff;
|
height: 45px;
|
padding-left: 20px;
|
align-items: center;
|
|
&.station-select-item {
|
padding-left: 0;
|
|
.input-icon {
|
margin-left: 20px;
|
min-width: 20px;
|
}
|
}
|
|
.code {
|
position: relative;
|
cursor: pointer;
|
width: 74px;
|
padding: 5px 10px 0 0;
|
display: flex;
|
align-items: center;
|
}
|
|
.input-icon {
|
color: #7a7a7a;
|
padding-right: 20px;
|
display: flex;
|
align-items: center;
|
}
|
}
|
}
|
|
input:-webkit-autofill {
|
box-shadow: 0 0 0px 1000px white inset;
|
-webkit-box-shadow: 0 0 0px 1000px white inset !important;
|
}
|
|
input {
|
background: white;
|
display: block;
|
box-sizing: border-box;
|
width: 100%;
|
min-width: 0;
|
margin: 0;
|
padding: 0;
|
color: #323233;
|
text-align: left;
|
border: 0;
|
outline: none;
|
font-size: 16px;
|
height: 100%;
|
line-height: normal;
|
}
|
|
select {
|
background: white;
|
display: block;
|
box-sizing: border-box;
|
width: 100%;
|
min-width: 0;
|
margin: 0;
|
padding: 0;
|
color: #323233;
|
text-align: left;
|
border: 0;
|
outline: none;
|
font-size: 16px;
|
}
|
}
|
|
.form-user,
|
.loging-btn {
|
width: 400px;
|
}
|
|
.loging-btn {
|
box-shadow: 2px 4px 11px #a4c2ff;
|
margin-top: 10px;
|
|
button {
|
padding: 21px;
|
font-size: 14px !important;
|
width: 100%;
|
}
|
}
|
|
.login-text {
|
font-weight: bolder;
|
font-size: 20px;
|
letter-spacing: 2px;
|
position: relative;
|
display: flex;
|
|
.login-line {
|
z-index: -1;
|
padding: 5px;
|
position: relative;
|
top: -8px;
|
width: 100%;
|
background-image: linear-gradient(to right, #6598ff, white);
|
}
|
}
|
|
.login-text-small {
|
margin-bottom: 20px;
|
font-size: 13px;
|
color: #7d7c7c;
|
}
|
|
.login-bg {
|
left: 0;
|
position: absolute;
|
height: 100%;
|
width: 50%;
|
z-index: 0;
|
}
|
|
.project-name {
|
position: absolute;
|
top: 40px;
|
left: 40px;
|
z-index: 9999;
|
font-weight: bolder;
|
background-image: linear-gradient(to right, #1850c1, #9c009c);
|
-webkit-background-clip: text;
|
color: transparent;
|
font-size: 25px;
|
}
|
|
// 下拉框自定义样式 - 移除所有交互效果
|
.station-select {
|
width: 100%;
|
height: 100%;
|
flex: 1;
|
|
:deep(.el-input) {
|
height: 100%;
|
cursor: pointer; // 添加指针显示为可点击
|
}
|
|
:deep(.el-input__wrapper) {
|
height: 100%;
|
box-shadow: none;
|
border: none;
|
padding: 0;
|
background: transparent;
|
|
// 移除所有hover、focus效果
|
&:hover, &:focus, &.is-focus {
|
box-shadow: none !important;
|
outline: none !important;
|
border: none !important;
|
}
|
}
|
|
:deep(.el-input__inner) {
|
height: 100%;
|
padding-left: 10px;
|
padding-top: 10px;
|
font-size: 16px;
|
color: #323233;
|
cursor: pointer; // 添加指针显示为可点击
|
|
&::placeholder {
|
color: #c0c4cc;
|
}
|
}
|
|
:deep(.el-input__suffix) {
|
display: flex;
|
align-items: center;
|
height: 100%;
|
}
|
|
:deep(.el-select__caret) {
|
height: 100%;
|
display: flex;
|
align-items: center;
|
margin-right: 10px;
|
}
|
|
// 移除整个组件上的任何hover和focus样式
|
&:hover, &:focus, &.is-focus {
|
:deep(.el-input__wrapper) {
|
box-shadow: none !important;
|
outline: none !important;
|
border: none !important;
|
}
|
}
|
}
|
|
// 修改全局的下拉框样式
|
:deep(.el-select-dropdown) {
|
border: 1px solid #ececec;
|
border-radius: 5px;
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
.el-select-dropdown__item {
|
height: 45px;
|
line-height: 45px;
|
font-size: 16px;
|
color: #323233;
|
padding: 0 20px;
|
|
&:hover {
|
background-color: #f5f7fa;
|
}
|
|
&.selected {
|
color: #3a6cd1;
|
font-weight: normal;
|
background-color: #f0f7ff;
|
}
|
}
|
|
// 隐藏滚动条或调整滚动条样式
|
&::-webkit-scrollbar {
|
width: 6px;
|
}
|
|
&::-webkit-scrollbar-track {
|
background: #f1f1f1;
|
border-radius: 3px;
|
}
|
|
&::-webkit-scrollbar-thumb {
|
background: #c1c1c1;
|
border-radius: 3px;
|
}
|
}
|
|
// 移除所有input的focus和hover样式
|
input {
|
&:hover, &:focus {
|
border: none !important;
|
outline: none !important;
|
box-shadow: none !important;
|
}
|
}
|
</style>
|
<style lang="less" scoped>
|
.app-link {
|
text-align: center;
|
padding-top: 5px;
|
font-size: 12px;
|
width: 400px;
|
padding-left: 40px;
|
display: flex;
|
|
a {
|
flex: 1;
|
position: relative;
|
cursor: pointer;
|
width: 70px;
|
color: #666666;
|
margin: 2px 10px 0 0;
|
}
|
|
img {
|
display: none;
|
}
|
|
a:hover {
|
color: #0545f6 !important;
|
|
img {
|
display: block;
|
position: absolute;
|
z-index: 999999999;
|
top: -130px;
|
width: 120px;
|
left: -22px;
|
border: 1px solid #b1b1b1;
|
}
|
}
|
}
|
|
.login-footer {
|
position: absolute;
|
width: 50%;
|
bottom: 0.5rem;
|
font-size: 12px;
|
text-align: center;
|
padding-bottom: 10px;
|
color: #4f4f4f;
|
|
a {
|
margin-right: 10px;
|
font-size: 12px;
|
color: #4f4f4f;
|
}
|
|
div {
|
margin-bottom: 5px;
|
}
|
|
a:hover {
|
cursor: pointer;
|
color: #0540e3 !important;
|
}
|
}
|
|
.account-info {
|
font-size: 12px;
|
color: #636363;
|
margin-top: 15px;
|
}
|
</style>
|
|
<style lang="less" scoped>
|
@media screen and (max-width: 700px) {
|
.login-bg,
|
.account-info,
|
.app-link,
|
.login-footer,
|
.project-name {
|
display: none;
|
}
|
|
.login-container {
|
padding: 2rem;
|
justify-content: center;
|
}
|
|
.login-form {
|
width: 100%;
|
}
|
|
.form-user,
|
.loging-btn {
|
width: 100%;
|
}
|
}
|
</style>
|