<template>
|
<div class="login-wrapper">
|
<!-- 顶部装饰条 -->
|
<div class="top-bar"></div>
|
|
<!-- 主内容区 -->
|
<div class="main-content">
|
<!-- 左侧:生产场景图 + 文字 -->
|
<div class="left-section">
|
<div class="scene-container">
|
<div class="factory-icon">
|
<el-icon :size="80" color="var(--el-color-primary)"><FirstAidKit /></el-icon>
|
</div>
|
<div class="production-flow">
|
<div class="flow-item">
|
<div class="flow-dot"></div>
|
<span>原料入库</span>
|
</div>
|
<div class="flow-line"></div>
|
<div class="flow-item">
|
<div class="flow-dot"></div>
|
<span>生产加工</span>
|
</div>
|
<div class="flow-line"></div>
|
<div class="flow-item">
|
<div class="flow-dot"></div>
|
<span>质量检测</span>
|
</div>
|
<div class="flow-line"></div>
|
<div class="flow-item">
|
<div class="flow-dot"></div>
|
<span>成品出库</span>
|
</div>
|
</div>
|
</div>
|
<div class="slogan">
|
<h1>智能生产管理平台</h1>
|
<p>让生产更高效 · 让管理更智能</p>
|
</div>
|
</div>
|
|
<!-- 右侧:登录卡片 -->
|
<div class="right-section">
|
<div class="login-card">
|
<div class="card-decoration">
|
<div class="deco-line"></div>
|
<div class="deco-line"></div>
|
</div>
|
|
<div class="login-title">
|
<div class="title-icon">
|
<el-icon :size="32" color="#fff"><UserFilled /></el-icon>
|
</div>
|
<div class="title-text">
|
<h2>账号登录</h2>
|
<span>Production Management System</span>
|
</div>
|
</div>
|
|
<el-form ref="loginRef" :model="loginForm" :rules="loginRules">
|
<el-form-item prop="username">
|
<div class="custom-input">
|
<span class="input-label">账号</span>
|
<el-input
|
v-model="loginForm.username"
|
type="text"
|
size="large"
|
auto-complete="off"
|
placeholder="请输入登录账号"
|
>
|
<template #prefix>
|
<el-icon><Avatar /></el-icon>
|
</template>
|
</el-input>
|
</div>
|
</el-form-item>
|
|
<el-form-item prop="password">
|
<div class="custom-input">
|
<span class="input-label">密码</span>
|
<el-input
|
v-model="loginForm.password"
|
type="password"
|
size="large"
|
auto-complete="off"
|
placeholder="请输入登录密码"
|
show-password
|
@keyup.enter="handleLogin"
|
>
|
<template #prefix>
|
<el-icon><Key /></el-icon>
|
</template>
|
</el-input>
|
</div>
|
</el-form-item>
|
|
<div class="login-options">
|
<el-checkbox v-model="loginForm.rememberMe">
|
<span class="remember-text">记住登录状态</span>
|
</el-checkbox>
|
</div>
|
|
<el-button
|
:loading="loading"
|
size="large"
|
type="primary"
|
class="submit-btn"
|
@click.prevent="handleLogin"
|
>
|
<el-icon v-if="!loading" class="btn-icon"><Right /></el-icon>
|
<span>{{ loading ? '登录中...' : '立即登录' }}</span>
|
</el-button>
|
</el-form>
|
</div>
|
</div>
|
</div>
|
|
<!-- 底部装饰 -->
|
<div class="bottom-decoration">
|
<div class="wave"></div>
|
</div>
|
</div>
|
</template>
|
|
<script setup>
|
import { getCodeImg } from "@/api/login"
|
import Cookies from "js-cookie"
|
import { encrypt, decrypt } from "@/utils/jsencrypt"
|
import useUserStore from "@/store/modules/user"
|
|
const userStore = useUserStore()
|
const route = useRoute()
|
const router = useRouter()
|
const { proxy } = getCurrentInstance()
|
|
const loginForm = ref({
|
username: "",
|
password: "",
|
rememberMe: false,
|
})
|
|
const loginRules = {
|
username: [{ required: true, trigger: "blur", message: "请输入账号" }],
|
password: [{ required: true, trigger: "blur", message: "请输入密码" }],
|
}
|
|
const loading = ref(false)
|
const captchaEnabled = ref(true)
|
const redirect = ref(undefined)
|
|
watch(
|
route,
|
(newRoute) => {
|
redirect.value = newRoute.query && newRoute.query.redirect
|
},
|
{ immediate: true }
|
)
|
|
function handleLogin() {
|
proxy.$refs.loginRef.validate((valid) => {
|
if (valid) {
|
loading.value = true
|
Cookies.set("username", loginForm.value.username, { expires: 30 })
|
Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 })
|
Cookies.set("rememberMe", loginForm.value.rememberMe, { expires: 30 })
|
userStore
|
.loginCheckFactory(loginForm.value)
|
.then(() => {
|
const query = route.query
|
const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
|
if (cur !== "redirect") {
|
acc[cur] = query[cur]
|
}
|
return acc
|
}, {})
|
router.push({ path: redirect.value || "/", query: otherQueryParams })
|
})
|
.catch(() => {
|
loading.value = false
|
if (captchaEnabled.value) {
|
getCode()
|
}
|
})
|
}
|
})
|
}
|
|
function getCode() {
|
getCodeImg().then((res) => {
|
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
if (captchaEnabled.value) {
|
loginForm.value.uuid = res.uuid
|
}
|
})
|
}
|
|
function getCookie() {
|
const username = Cookies.get("username")
|
const password = Cookies.get("password")
|
const rememberMe = Cookies.get("rememberMe")
|
loginForm.value = {
|
username: username === undefined ? loginForm.value.username : username,
|
password: password === undefined ? loginForm.value.password : decrypt(password),
|
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
|
}
|
}
|
|
getCode()
|
getCookie()
|
</script>
|
|
<style lang="scss" scoped>
|
.login-wrapper {
|
min-height: 100vh;
|
background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
|
position: relative;
|
overflow: hidden;
|
display: flex;
|
flex-direction: column;
|
}
|
|
// 顶部装饰条
|
.top-bar {
|
height: 4px;
|
background: linear-gradient(90deg, var(--el-color-primary-dark-2) 0%, var(--el-color-primary) 50%, var(--el-color-primary-light-3) 100%);
|
}
|
|
// 主内容区
|
.main-content {
|
flex: 1;
|
display: flex;
|
padding: 60px 80px;
|
gap: 80px;
|
align-items: center;
|
max-width: 1400px;
|
margin: 0 auto;
|
width: 100%;
|
}
|
|
// 左侧区域
|
.left-section {
|
flex: 1;
|
display: flex;
|
flex-direction: column;
|
gap: 50px;
|
}
|
|
.scene-container {
|
background: #fff;
|
border-radius: 24px;
|
padding: 50px;
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
|
}
|
|
.factory-icon {
|
width: 140px;
|
height: 140px;
|
background: linear-gradient(135deg, var(--el-color-primary-light-9) 0%, var(--el-color-primary-light-8) 100%);
|
border-radius: 50%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
margin: 0 auto 40px;
|
border: 4px solid var(--el-color-primary-light-7);
|
}
|
|
.production-flow {
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
gap: 8px;
|
}
|
|
.flow-item {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
gap: 8px;
|
|
.flow-dot {
|
width: 12px;
|
height: 12px;
|
background: var(--el-color-primary);
|
border-radius: 50%;
|
box-shadow: 0 0 0 4px var(--el-color-primary-light-8);
|
}
|
|
span {
|
font-size: 13px;
|
color: #64748b;
|
font-weight: 500;
|
}
|
}
|
|
.flow-line {
|
width: 40px;
|
height: 2px;
|
background: linear-gradient(90deg, var(--el-color-primary-light-5), var(--el-color-primary));
|
}
|
|
.slogan {
|
text-align: center;
|
|
h1 {
|
font-size: 36px;
|
font-weight: 700;
|
color: #1e293b;
|
margin: 0 0 12px;
|
letter-spacing: 2px;
|
}
|
|
p {
|
font-size: 16px;
|
color: #64748b;
|
margin: 0;
|
letter-spacing: 1px;
|
}
|
}
|
|
// 右侧区域
|
.right-section {
|
width: 440px;
|
}
|
|
.login-card {
|
background: #fff;
|
border-radius: 20px;
|
padding: 40px;
|
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
|
position: relative;
|
overflow: hidden;
|
}
|
|
.card-decoration {
|
position: absolute;
|
top: 0;
|
right: 0;
|
width: 120px;
|
height: 120px;
|
|
.deco-line {
|
position: absolute;
|
background: var(--el-color-primary-light-7);
|
border-radius: 2px;
|
|
&:nth-child(1) {
|
width: 80px;
|
height: 4px;
|
top: 30px;
|
right: -20px;
|
transform: rotate(-45deg);
|
}
|
|
&:nth-child(2) {
|
width: 50px;
|
height: 4px;
|
top: 50px;
|
right: -10px;
|
transform: rotate(-45deg);
|
}
|
}
|
}
|
|
.login-title {
|
display: flex;
|
align-items: center;
|
gap: 16px;
|
margin-bottom: 40px;
|
|
.title-icon {
|
width: 56px;
|
height: 56px;
|
background: linear-gradient(135deg, var(--el-color-primary) 0%, var(--el-color-primary-light-3) 100%);
|
border-radius: 14px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
box-shadow: 0 4px 12px var(--el-color-primary-light-5);
|
}
|
|
.title-text {
|
h2 {
|
font-size: 24px;
|
font-weight: 600;
|
color: #1e293b;
|
margin: 0 0 4px;
|
}
|
|
span {
|
font-size: 12px;
|
color: #94a3b8;
|
text-transform: uppercase;
|
letter-spacing: 1px;
|
}
|
}
|
}
|
|
.custom-input {
|
.input-label {
|
display: block;
|
font-size: 14px;
|
color: #475569;
|
margin-bottom: 8px;
|
font-weight: 500;
|
}
|
|
:deep(.el-input__wrapper) {
|
border-radius: 10px;
|
box-shadow: 0 0 0 1px #e2e8f0;
|
padding: 0 16px;
|
height: 50px;
|
transition: all 0.3s;
|
|
&:hover {
|
box-shadow: 0 0 0 1px var(--el-color-primary-light-5);
|
}
|
|
&:focus-within {
|
box-shadow: 0 0 0 2px var(--el-color-primary);
|
}
|
}
|
|
:deep(.el-input__inner) {
|
height: 50px;
|
font-size: 15px;
|
color: #334155;
|
|
&::placeholder {
|
color: #cbd5e1;
|
}
|
}
|
|
:deep(.el-input__prefix) {
|
color: var(--el-color-primary);
|
font-size: 18px;
|
margin-right: 10px;
|
}
|
}
|
|
:deep(.el-form-item) {
|
margin-bottom: 24px;
|
}
|
|
.login-options {
|
margin: 8px 0 32px;
|
|
.remember-text {
|
font-size: 14px;
|
color: #64748b;
|
}
|
|
:deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
|
background-color: var(--el-color-primary);
|
border-color: var(--el-color-primary);
|
}
|
}
|
|
.submit-btn {
|
width: 100%;
|
height: 52px;
|
border-radius: 10px;
|
font-size: 16px;
|
font-weight: 600;
|
background: linear-gradient(135deg, var(--el-color-primary) 0%, var(--el-color-primary-light-2) 100%);
|
border: none;
|
box-shadow: 0 4px 16px var(--el-color-primary-light-5);
|
transition: all 0.3s;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
gap: 8px;
|
|
&:hover {
|
transform: translateY(-2px);
|
box-shadow: 0 6px 20px var(--el-color-primary-light-4);
|
}
|
|
.btn-icon {
|
font-size: 18px;
|
}
|
}
|
|
.card-footer {
|
margin-top: 32px;
|
padding-top: 24px;
|
border-top: 1px solid #f1f5f9;
|
text-align: center;
|
|
p {
|
color: #94a3b8;
|
font-size: 13px;
|
margin: 0;
|
}
|
}
|
|
// 底部装饰
|
.bottom-decoration {
|
height: 80px;
|
position: relative;
|
|
.wave {
|
position: absolute;
|
bottom: 0;
|
left: 0;
|
right: 0;
|
height: 60px;
|
background: linear-gradient(90deg, var(--el-color-primary-light-9) 0%, var(--el-color-primary-light-8) 100%);
|
clip-path: polygon(0 100%, 100% 100%, 100% 30%, 75% 60%, 50% 40%, 25% 70%, 0 50%);
|
}
|
}
|
|
// 响应式
|
@media (max-width: 1100px) {
|
.main-content {
|
flex-direction: column;
|
padding: 40px;
|
gap: 40px;
|
}
|
|
.left-section {
|
order: 2;
|
}
|
|
.right-section {
|
width: 100%;
|
max-width: 440px;
|
order: 1;
|
}
|
|
.slogan {
|
display: none;
|
}
|
}
|
|
@media (max-width: 480px) {
|
.main-content {
|
padding: 20px;
|
}
|
|
.login-card {
|
padding: 30px 24px;
|
}
|
|
.scene-container {
|
padding: 30px 20px;
|
}
|
|
.production-flow {
|
flex-wrap: wrap;
|
gap: 16px;
|
|
.flow-line {
|
display: none;
|
}
|
}
|
}
|
</style>
|