feat: 更新登录页面与API逻辑

This commit is contained in:
pikachu1995@126.com
2026-07-06 15:59:14 +08:00
parent 235362d5b0
commit e13ca6281d
3 changed files with 335 additions and 123 deletions

View File

@@ -21,9 +21,9 @@ export const postVerifyImg = (params) => {
}; };
// 获取系统基础信息 // 获取系统基础信息(登录页等场景无需 token
export const getBaseSite = () => { export const getBaseSite = () => {
return getRequest(`${commonUrl}/common/common/site`); return getRequestWithNoToken(`${commonUrl}/common/common/site`);
}; };
// 上传文件 // 上传文件

View File

@@ -1,58 +1,74 @@
<template> <template>
<div class="login" @click="$refs.verify.show = false"> <div class="login" @click="$refs.verify.show = false">
<el-row class="flex" @keyup.enter="submitLogin"> <div class="login-brand">
<el-col style="width: 368px"> <div class="brand-inner">
<Header /> <p class="brand-name">LILISHOP</p>
<el-row style="flex-direction: column"> <h1 class="brand-title">企业级电商运营管理平台</h1>
<el-form <p class="brand-desc">为平台运营团队提供稳定高效可扩展的管理能力</p>
ref="usernameLoginForm" <ul class="brand-features">
:model="form" <li>全渠道订单与售后协同处理</li>
:rules="rules" <li>商品营销会员一体化运营</li>
class="form" <li>多店铺管理与经营数据分析</li>
> </ul>
<el-form-item prop="username"> </div>
<el-input <p class="brand-copyright">Copyright © {{ year }} Lilishop</p>
v-model="form.username" </div>
size="large"
clearable
placeholder="请输入用户名"
autocomplete="off"
>
<template #prefix>
<el-icon><User /></el-icon>
</template>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
v-model="form.password"
type="password"
size="large"
show-password
placeholder="请输入密码"
autocomplete="off"
>
<template #prefix>
<el-icon><Lock /></el-icon>
</template>
</el-input>
</el-form-item>
</el-form>
<el-row> <div class="login-panel" @keyup.enter="submitLogin">
<el-button <div class="login-wrap">
class="login-btn" <Header />
type="primary"
<div class="login-intro">
<h2 class="login-title">账号登录</h2>
<p class="login-subtitle">请使用管理员账号登录运营后台</p>
</div>
<el-form
ref="usernameLoginForm"
:model="form"
:rules="rules"
class="form"
>
<el-form-item prop="username">
<el-input
v-model="form.username"
size="large" size="large"
:loading="loading" clearable
style="width: 100%" placeholder="请输入用户名"
@click="submitLogin" autocomplete="off"
> >
<span v-if="!loading">{{ $t("login") }}</span> <template #prefix>
<span v-else>{{ $t("logining") }}</span> <el-icon><User /></el-icon>
</el-button> </template>
</el-row> </el-input>
</el-row> </el-form-item>
<el-form-item prop="password">
<el-input
v-model="form.password"
type="password"
size="large"
show-password
placeholder="请输入密码"
autocomplete="off"
>
<template #prefix>
<el-icon><Lock /></el-icon>
</template>
</el-input>
</el-form-item>
</el-form>
<el-button
class="login-btn"
type="primary"
size="large"
:loading="loading"
@click="submitLogin"
>
<span v-if="!loading">{{ $t("login") }}</span>
<span v-else>{{ $t("logining") }}</span>
</el-button>
<verify <verify
ref="verify" ref="verify"
class="verify-con" class="verify-con"
@@ -60,8 +76,8 @@
@change="verifyChange" @change="verifyChange"
/> />
<Footer /> <Footer />
</el-col> </div>
</el-row> </div>
</div> </div>
</template> </template>
@@ -84,6 +100,7 @@ export default {
}, },
data() { data() {
return { return {
year: new Date().getFullYear(),
loading: false, loading: false,
form: { form: {
username: "", username: "",
@@ -152,62 +169,269 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.login { .login {
display: flex;
min-height: 100vh; min-height: 100vh;
width: 100%; width: 100%;
box-sizing: border-box; background: #fff;
background-color: #fff; }
background-image: url("../assets/background.png");
background-repeat: no-repeat; .login-brand {
background-position: center bottom; position: relative;
background-size: cover; flex: 0 0 46%;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 56px 64px;
color: #fff;
background: linear-gradient(160deg, #1b2a41 0%, #243a5c 52%, #1a2f4d 100%);
overflow: hidden;
&::before {
content: "";
position: absolute;
inset: 0;
background:
radial-gradient(circle at 18% 22%, rgba($theme_color, 0.22), transparent 36%),
radial-gradient(circle at 82% 78%, rgba(255, 255, 255, 0.08), transparent 30%);
pointer-events: none;
}
&::after {
content: "";
position: absolute;
left: 0;
top: 0;
width: 4px;
height: 100%;
background: linear-gradient(180deg, $theme_color 0%, $warning_color 100%);
}
.brand-inner {
position: relative;
z-index: 1;
max-width: 460px;
margin-top: 8vh;
}
.brand-name {
margin: 0 0 18px;
font-size: 14px;
font-weight: 600;
letter-spacing: 4px;
color: rgba(255, 255, 255, 0.72);
}
.brand-title {
margin: 0;
font-size: 34px;
line-height: 1.35;
font-weight: 600;
letter-spacing: 1px;
}
.brand-desc {
margin: 18px 0 0;
font-size: 15px;
line-height: 1.7;
color: rgba(255, 255, 255, 0.72);
}
.brand-features {
margin: 36px 0 0;
padding: 0;
list-style: none;
li {
position: relative;
padding-left: 18px;
margin-bottom: 14px;
font-size: 14px;
line-height: 1.6;
color: rgba(255, 255, 255, 0.86);
&::before {
content: "";
position: absolute;
left: 0;
top: 9px;
width: 6px;
height: 6px;
border-radius: 50%;
background: $theme_color;
}
}
}
.brand-copyright {
position: relative;
z-index: 1;
margin: 0;
font-size: 13px;
color: rgba(255, 255, 255, 0.45);
}
}
.login-panel {
flex: 1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 48px 32px;
background: #f7f9fc;
}
:deep(.el-input__wrapper) { .login-wrap {
background-color: #fff !important; position: relative;
box-shadow: 0 0 0 1px var(--el-border-color) inset !important; width: 400px;
padding: 40px 42px 32px;
background: #fff;
border: 1px solid #e8edf3;
border-radius: 12px;
box-shadow: 0 12px 32px rgba(31, 45, 61, 0.06);
}
&.is-focus { :deep(.header) {
box-shadow: 0 0 0 1px var(--el-border-color) inset !important; margin-bottom: 0;
} justify-content: flex-start !important;
}
:deep(.logo) {
width: 168px !important;
height: auto !important;
}
.login-intro {
margin: 28px 0 32px;
.login-title {
margin: 0;
font-size: 24px;
font-weight: 600;
color: #1f2329;
} }
:deep(.el-input__inner) { .login-subtitle {
background-color: transparent !important; margin: 10px 0 0;
font-size: 14px;
&:-webkit-autofill, color: #8a9199;
&:-webkit-autofill:hover,
&:-webkit-autofill:focus,
&:-webkit-autofill:active {
-webkit-box-shadow: 0 0 0 1000px #fff inset !important;
box-shadow: 0 0 0 1000px #fff inset !important;
-webkit-text-fill-color: #606266 !important;
caret-color: #606266;
transition: background-color 99999s ease-out;
}
}
.verify-con {
position: absolute;
top: 150px;
z-index: 10;
left: 20px;
}
.form {
padding-top: 1vh;
}
.login-btn {
background: linear-gradient(135deg, $theme_color 0%, $warning_color 100%);
height: 40px;
border: none;
}
.login-btn:hover {
opacity: 0.9;
} }
} }
.flex {
justify-content: center; :deep(.el-input__wrapper) {
background-color: #fff !important;
box-shadow: 0 0 0 1px #dce3eb inset !important;
border-radius: 8px;
padding: 4px 14px;
transition: box-shadow 0.2s ease;
&.is-focus {
box-shadow: 0 0 0 1px $theme_color inset,
0 0 0 3px rgba($theme_color, 0.12) !important;
}
}
:deep(.el-input__prefix) {
color: #a0a7b0;
}
:deep(.el-input__inner) {
background-color: transparent !important;
&:-webkit-autofill,
&:-webkit-autofill:hover,
&:-webkit-autofill:focus,
&:-webkit-autofill:active {
-webkit-box-shadow: 0 0 0 1000px #fff inset !important;
box-shadow: 0 0 0 1000px #fff inset !important;
-webkit-text-fill-color: #606266 !important;
caret-color: #606266;
transition: background-color 99999s ease-out;
}
}
:deep(.el-form-item) {
margin-bottom: 22px;
}
.verify-con {
position: absolute;
top: 150px;
z-index: 10;
left: 20px;
}
.form {
padding-top: 2px;
}
.login-btn {
width: 100%;
height: 44px;
margin-top: 4px;
border: none;
border-radius: 8px;
font-size: 15px;
letter-spacing: 2px;
background: $theme_color;
box-shadow: none;
transition: background-color 0.2s ease, opacity 0.2s ease;
&:hover {
background: darken($theme_color, 4%);
opacity: 1;
}
}
:deep(.foot) {
position: static;
width: 100%;
margin-top: 28px;
color: #9aa3ad;
}
:deep(.foot .item),
:deep(.foot .href) {
color: #9aa3ad !important;
}
:deep(.foot .item:hover) {
color: #6b7280 !important;
}
@media (max-width: 992px) {
.login {
flex-direction: column;
}
.login-brand {
flex: none;
padding: 36px 28px 28px;
.brand-inner {
margin-top: 0;
}
.brand-title {
font-size: 26px;
}
.brand-features {
margin-top: 24px;
}
.brand-copyright {
display: none;
}
}
.login-panel {
padding: 24px 20px 40px;
}
.login-wrap {
width: 100%;
max-width: 400px;
padding: 32px 24px 24px;
}
} }
</style> </style>

View File

@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<el-row class="header"> <el-row class="header">
<img :src="domainLogo" class="logo" width="220px" /> <img v-if="domainLogo" :src="domainLogo" class="logo" width="220px" />
</el-row> </el-row>
</div> </div>
</template> </template>
@@ -12,26 +12,12 @@ import { getBaseSite } from "@/api/common.js";
export default { export default {
data() { data() {
return { return {
domainLogo: require("@/assets/logo.png"), domainLogo: "",
}; };
}, },
methods: { methods: {
init() {
if (
!localStorage.getItem("icon") ||
!localStorage.getItem("title") ||
!localStorage.getItem("icontitle_expiration_time")
) {
this.getSite();
} else if (new Date() > localStorage.getItem("icontitle_expiration_time")) {
this.getSite();
} else {
this.domainLogo = localStorage.getItem("icon");
this.applyFavicon(localStorage.getItem("icon"));
window.document.title = localStorage.getItem("title") + " - 运营后台";
}
},
applyFavicon(href) { applyFavicon(href) {
if (!href) return;
let link = let link =
document.querySelector("link[rel*='icon']") || document.querySelector("link[rel*='icon']") ||
document.createElement("link"); document.createElement("link");
@@ -46,20 +32,22 @@ export default {
const { domainLogo, domainIcon, siteName } = JSON.parse( const { domainLogo, domainIcon, siteName } = JSON.parse(
res.result.settingValue res.result.settingValue
); );
this.domainLogo = domainLogo; this.domainLogo = domainLogo || "";
const expirationTime = new Date().setHours(new Date().getHours() + 1); const expirationTime = new Date().setHours(new Date().getHours() + 1);
localStorage.setItem("icontitle_expiration_time", expirationTime); localStorage.setItem("icontitle_expiration_time", expirationTime);
localStorage.setItem("icon", domainLogo); localStorage.setItem("icon", domainLogo || "");
localStorage.setItem("domainIcon", domainIcon); localStorage.setItem("domainIcon", domainIcon || "");
localStorage.setItem("title", siteName); localStorage.setItem("title", siteName || "");
this.applyFavicon(domainIcon || domainLogo); this.applyFavicon(domainIcon || domainLogo);
window.document.title = siteName + " - 运营后台"; if (siteName) {
window.document.title = siteName + " - 运营后台";
}
} }
}); });
}, },
}, },
mounted() { mounted() {
this.init(); this.getSite();
}, },
}; };
</script> </script>