263 lines
5.3 KiB
Vue
263 lines
5.3 KiB
Vue
<template>
|
||
<div class="auth-page">
|
||
<div class="auth-background">
|
||
<div class="floating-flowers">
|
||
<span class="flower">🌸</span>
|
||
<span class="flower">🌺</span>
|
||
<span class="flower">🌻</span>
|
||
<span class="flower">🌷</span>
|
||
<span class="flower">🌹</span>
|
||
<span class="flower">🌼</span>
|
||
</div>
|
||
</div>
|
||
<el-card class="auth-card">
|
||
<div class="auth-header">
|
||
<div class="logo-icon">🌸</div>
|
||
<h2 class="auth-title">欢迎回来</h2>
|
||
<p class="auth-subtitle">登录植愈线上花店</p>
|
||
</div>
|
||
<el-form :model="form" class="auth-form">
|
||
<el-form-item>
|
||
<el-input
|
||
v-model="form.username"
|
||
placeholder="请输入账号"
|
||
prefix-icon="el-icon-user"
|
||
size="large"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item>
|
||
<el-input
|
||
v-model="form.password"
|
||
type="password"
|
||
placeholder="请输入密码"
|
||
prefix-icon="el-icon-lock"
|
||
size="large"
|
||
@keyup.enter.native="submit"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item class="form-actions">
|
||
<el-button
|
||
type="primary"
|
||
class="submit-btn"
|
||
:loading="loading"
|
||
@click="submit"
|
||
>
|
||
<i class="el-icon-right"></i>立即登录
|
||
</el-button>
|
||
</el-form-item>
|
||
</el-form>
|
||
<div class="auth-footer">
|
||
<p>还没有账号?</p>
|
||
<el-button type="text" class="link-btn" @click="$router.push('/register')">
|
||
立即注册 <i class="el-icon-arrow-right"></i>
|
||
</el-button>
|
||
</div>
|
||
</el-card>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import { login } from '../api/auth';
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
form: { username: '', password: '' },
|
||
loading: false
|
||
};
|
||
},
|
||
methods: {
|
||
submit() {
|
||
if (!this.form.username || !this.form.password) {
|
||
this.$message.warning('请填写完整信息');
|
||
return;
|
||
}
|
||
this.loading = true;
|
||
login(this.form).then((res) => {
|
||
if (!res || !res.data || res.data.code !== 0) {
|
||
this.loading = false;
|
||
return;
|
||
}
|
||
const data = res.data.data;
|
||
if (!data) {
|
||
this.loading = false;
|
||
return;
|
||
}
|
||
localStorage.setItem('token', data.token);
|
||
localStorage.setItem('user', JSON.stringify(data.user));
|
||
this.$message.success('登录成功,欢迎回来!');
|
||
this.$router.push('/');
|
||
}).catch(() => {
|
||
this.loading = false;
|
||
});
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style scoped>
|
||
.auth-page {
|
||
min-height: 100vh;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
position: relative;
|
||
padding: 20px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.auth-background {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
background: linear-gradient(135deg, #fdf6f0 0%, #f8e8e8 50%, #e8f4f0 100%);
|
||
z-index: -1;
|
||
}
|
||
|
||
.floating-flowers {
|
||
position: absolute;
|
||
width: 100%;
|
||
height: 100%;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.flower {
|
||
position: absolute;
|
||
font-size: 40px;
|
||
opacity: 0.3;
|
||
animation: float-up 15s ease-in-out infinite;
|
||
}
|
||
|
||
.flower:nth-child(1) { left: 10%; animation-delay: 0s; }
|
||
.flower:nth-child(2) { left: 25%; animation-delay: 2s; }
|
||
.flower:nth-child(3) { left: 45%; animation-delay: 4s; }
|
||
.flower:nth-child(4) { left: 65%; animation-delay: 1s; }
|
||
.flower:nth-child(5) { left: 80%; animation-delay: 3s; }
|
||
.flower:nth-child(6) { left: 90%; animation-delay: 5s; }
|
||
|
||
@keyframes float-up {
|
||
0%, 100% {
|
||
transform: translateY(100vh) rotate(0deg);
|
||
opacity: 0;
|
||
}
|
||
10% {
|
||
opacity: 0.3;
|
||
}
|
||
90% {
|
||
opacity: 0.3;
|
||
}
|
||
100% {
|
||
transform: translateY(-100px) rotate(360deg);
|
||
opacity: 0;
|
||
}
|
||
}
|
||
|
||
.auth-card {
|
||
width: 100%;
|
||
max-width: 420px;
|
||
border-radius: var(--radius-lg);
|
||
box-shadow: var(--shadow-lg);
|
||
border: none;
|
||
animation: fadeIn 0.6s ease-out;
|
||
}
|
||
|
||
.auth-header {
|
||
text-align: center;
|
||
margin-bottom: 32px;
|
||
}
|
||
|
||
.logo-icon {
|
||
font-size: 64px;
|
||
margin-bottom: 16px;
|
||
animation: float 3s ease-in-out infinite;
|
||
}
|
||
|
||
.auth-title {
|
||
font-size: 28px;
|
||
font-weight: 700;
|
||
color: var(--text-primary);
|
||
margin: 0 0 8px 0;
|
||
}
|
||
|
||
.auth-subtitle {
|
||
font-size: 15px;
|
||
color: var(--text-secondary);
|
||
margin: 0;
|
||
}
|
||
|
||
.auth-form >>> .el-input__inner {
|
||
border-radius: 25px;
|
||
padding-left: 45px;
|
||
height: 50px;
|
||
font-size: 15px;
|
||
}
|
||
|
||
.auth-form >>> .el-input__prefix {
|
||
left: 15px;
|
||
top: 50%;
|
||
transform: translateY(-50%);
|
||
}
|
||
|
||
.auth-form >>> .el-input__icon {
|
||
font-size: 18px;
|
||
color: var(--text-secondary);
|
||
}
|
||
|
||
.form-actions {
|
||
margin-top: 24px;
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
.submit-btn {
|
||
width: 100%;
|
||
height: 50px;
|
||
border-radius: 25px;
|
||
font-size: 16px;
|
||
font-weight: 600;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 8px;
|
||
}
|
||
|
||
.auth-footer {
|
||
text-align: center;
|
||
margin-top: 24px;
|
||
padding-top: 24px;
|
||
border-top: 1px solid #e8e8e8;
|
||
}
|
||
|
||
.auth-footer p {
|
||
margin: 0 0 8px 0;
|
||
color: var(--text-secondary);
|
||
font-size: 14px;
|
||
}
|
||
|
||
.link-btn {
|
||
font-size: 15px;
|
||
font-weight: 600;
|
||
color: var(--secondary-color);
|
||
}
|
||
|
||
.link-btn:hover {
|
||
color: var(--secondary-light);
|
||
}
|
||
|
||
/* 响应式 */
|
||
@media (max-width: 480px) {
|
||
.auth-card {
|
||
margin: 0 16px;
|
||
}
|
||
|
||
.auth-title {
|
||
font-size: 24px;
|
||
}
|
||
|
||
.logo-icon {
|
||
font-size: 48px;
|
||
}
|
||
}
|
||
</style>
|