386 lines
7.9 KiB
Vue
386 lines
7.9 KiB
Vue
<template>
|
|
<view class="login-page">
|
|
<!-- 背景装饰 -->
|
|
<view class="bg-decoration">
|
|
<view class="bg-circle bg-circle-1"></view>
|
|
<view class="bg-circle bg-circle-2"></view>
|
|
<view class="bg-circle bg-circle-3"></view>
|
|
</view>
|
|
|
|
<!-- 顶部品牌区 - 弹性入场 -->
|
|
<view class="brand-area elastic-in">
|
|
<view class="brand-icon">
|
|
<text class="brand-icon-text">G</text>
|
|
</view>
|
|
<text class="brand-title">GymManage</text>
|
|
<text class="brand-subtitle">教练工作台</text>
|
|
</view>
|
|
|
|
<!-- 登录卡片 - 延迟入场 -->
|
|
<view class="login-card fade-in-up" style="animation-delay:0.15s">
|
|
<view class="card-header">
|
|
<text class="card-title">教练登录</text>
|
|
<text class="card-desc">请输入您的账号信息</text>
|
|
</view>
|
|
|
|
<view class="form-group">
|
|
<text class="form-label">用户名</text>
|
|
<input
|
|
class="login-input"
|
|
:value="username"
|
|
@input="username = $event.detail.value"
|
|
type="text"
|
|
placeholder="请输入用户名"
|
|
:disabled="loading"
|
|
/>
|
|
</view>
|
|
|
|
<view class="form-group">
|
|
<text class="form-label">密码</text>
|
|
<input
|
|
class="login-input"
|
|
:value="password"
|
|
@input="password = $event.detail.value"
|
|
type="password"
|
|
placeholder="请输入密码"
|
|
:disabled="loading"
|
|
/>
|
|
</view>
|
|
|
|
<transition name="fade">
|
|
<view v-if="errorMsg" class="error-msg">
|
|
<text>{{ errorMsg }}</text>
|
|
</view>
|
|
</transition>
|
|
|
|
<button
|
|
class="btn-login"
|
|
:class="{ 'is-loading': loading }"
|
|
:disabled="loading"
|
|
@tap="handleLogin"
|
|
>
|
|
<view v-if="loading" class="btn-spinner"></view>
|
|
<text>{{ loading ? '登录中...' : '登 录' }}</text>
|
|
</button>
|
|
</view>
|
|
|
|
<!-- 底部提示 -->
|
|
<text class="footer-hint">GymManage 智能健身房管理系统 v1.0</text>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { useAuthStore } from '@/store/auth.js'
|
|
import { showToast } from '@/utils/index.js'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
username: '',
|
|
password: '',
|
|
loading: false,
|
|
errorMsg: ''
|
|
}
|
|
},
|
|
methods: {
|
|
async handleLogin() {
|
|
if (!this.username || !this.password) {
|
|
this.errorMsg = '请输入用户名和密码'
|
|
return
|
|
}
|
|
this.loading = true
|
|
this.errorMsg = ''
|
|
try {
|
|
const authStore = useAuthStore()
|
|
await authStore.login(this.username, this.password)
|
|
showToast('登录成功', 'success')
|
|
setTimeout(() => {
|
|
uni.reLaunch({ url: '/pages/index/index' })
|
|
}, 500)
|
|
} catch (e) {
|
|
console.error('登录失败:', e)
|
|
const msg = e?.data?.message || e?.message || '登录失败,请检查用户名和密码'
|
|
this.errorMsg = msg
|
|
} finally {
|
|
this.loading = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.login-page {
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background: linear-gradient(160deg, #f0f4ff 0%, #e8eef8 40%, #f6f8fc 100%);
|
|
padding: 32px 24px;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* ============================================
|
|
背景装饰圆
|
|
============================================ */
|
|
.bg-decoration {
|
|
position: absolute;
|
|
inset: 0;
|
|
pointer-events: none;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.bg-circle {
|
|
position: absolute;
|
|
border-radius: 50%;
|
|
opacity: 0.06;
|
|
}
|
|
|
|
.bg-circle-1 {
|
|
width: 300px;
|
|
height: 300px;
|
|
background: #4f7cff;
|
|
top: -80px;
|
|
right: -60px;
|
|
animation: bgFloat1 8s ease-in-out infinite;
|
|
}
|
|
|
|
.bg-circle-2 {
|
|
width: 200px;
|
|
height: 200px;
|
|
background: #10b981;
|
|
bottom: 10%;
|
|
left: -40px;
|
|
animation: bgFloat2 10s ease-in-out infinite;
|
|
}
|
|
|
|
.bg-circle-3 {
|
|
width: 150px;
|
|
height: 150px;
|
|
background: #f59e0b;
|
|
bottom: 30%;
|
|
right: -30px;
|
|
animation: bgFloat3 7s ease-in-out infinite;
|
|
}
|
|
|
|
@keyframes bgFloat1 {
|
|
0%, 100% { transform: translate(0, 0) rotate(0deg); }
|
|
50% { transform: translate(20px, -20px) rotate(10deg); }
|
|
}
|
|
|
|
@keyframes bgFloat2 {
|
|
0%, 100% { transform: translate(0, 0) rotate(0deg); }
|
|
50% { transform: translate(-15px, 15px) rotate(-8deg); }
|
|
}
|
|
|
|
@keyframes bgFloat3 {
|
|
0%, 100% { transform: translate(0, 0) rotate(0deg); }
|
|
50% { transform: translate(-10px, -15px) rotate(5deg); }
|
|
}
|
|
|
|
/* ============================================
|
|
品牌区
|
|
============================================ */
|
|
.brand-area {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
margin-bottom: 40px;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.brand-icon {
|
|
width: 64px;
|
|
height: 64px;
|
|
background: linear-gradient(145deg, #4f7cff, #3b5fd9);
|
|
border-radius: 18px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: 0 12px 28px rgba(79, 124, 255, 0.35);
|
|
margin-bottom: 16px;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
.brand-icon:active {
|
|
transform: scale(0.92) rotate(-5deg);
|
|
}
|
|
|
|
.brand-icon-text {
|
|
color: #ffffff;
|
|
font-size: 32px;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.brand-title {
|
|
font-size: 26px;
|
|
font-weight: 700;
|
|
color: #0b1a33;
|
|
letter-spacing: -0.5px;
|
|
}
|
|
|
|
.brand-subtitle {
|
|
font-size: 14px;
|
|
color: #6b7d94;
|
|
margin-top: 6px;
|
|
}
|
|
|
|
/* ============================================
|
|
登录卡片
|
|
============================================ */
|
|
.login-card {
|
|
width: 100%;
|
|
background: #ffffff;
|
|
border-radius: 20px;
|
|
padding: 32px 24px;
|
|
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
|
|
position: relative;
|
|
z-index: 1;
|
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
|
}
|
|
|
|
.login-card:focus-within {
|
|
box-shadow: 0 8px 40px rgba(79, 124, 255, 0.1);
|
|
}
|
|
|
|
.card-header {
|
|
margin-bottom: 28px;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
color: #1e293b;
|
|
display: block;
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.card-desc {
|
|
font-size: 13px;
|
|
color: #94a3b8;
|
|
}
|
|
|
|
/* ============================================
|
|
表单
|
|
============================================ */
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: #334155;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.login-input {
|
|
display: block;
|
|
width: 100%;
|
|
height: 48px;
|
|
min-height: 48px;
|
|
padding: 0 16px;
|
|
border: 1px solid #e2e8f0;
|
|
border-radius: 10px;
|
|
font-size: 16px;
|
|
color: #1e293b;
|
|
background: #f8fafc;
|
|
outline: none;
|
|
box-sizing: border-box;
|
|
line-height: 48px;
|
|
transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
|
|
}
|
|
|
|
.login-input:focus {
|
|
border-color: #4f7cff;
|
|
background: #ffffff;
|
|
box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.1);
|
|
}
|
|
|
|
/* ============================================
|
|
错误消息 - 抖动动画
|
|
============================================ */
|
|
.error-msg {
|
|
background: #fef2f2;
|
|
border: 1px solid #fecaca;
|
|
border-radius: 10px;
|
|
padding: 10px 14px;
|
|
margin-bottom: 16px;
|
|
animation: errorShake 0.4s ease-out;
|
|
}
|
|
|
|
@keyframes errorShake {
|
|
0%, 100% { transform: translateX(0); }
|
|
20% { transform: translateX(-6px); }
|
|
40% { transform: translateX(6px); }
|
|
60% { transform: translateX(-3px); }
|
|
80% { transform: translateX(3px); }
|
|
}
|
|
|
|
.error-msg text {
|
|
font-size: 13px;
|
|
color: #ef4444;
|
|
}
|
|
|
|
/* ============================================
|
|
登录按钮
|
|
============================================ */
|
|
.btn-login {
|
|
width: 100%;
|
|
height: 48px;
|
|
background: linear-gradient(145deg, #4f7cff, #3b5fd9);
|
|
color: #ffffff;
|
|
border: none;
|
|
border-radius: 12px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-top: 8px;
|
|
box-shadow: 0 6px 18px rgba(79, 124, 255, 0.3);
|
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.btn-login::after {
|
|
content: '';
|
|
position: absolute;
|
|
inset: 0;
|
|
background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
|
|
opacity: 0;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
.btn-login:active::after { opacity: 1; }
|
|
|
|
.btn-login:active {
|
|
transform: scale(0.97);
|
|
box-shadow: 0 3px 10px rgba(79, 124, 255, 0.25);
|
|
}
|
|
|
|
.btn-login.is-loading {
|
|
opacity: 0.8;
|
|
}
|
|
|
|
.btn-login .btn-spinner {
|
|
margin-right: 10px;
|
|
}
|
|
|
|
/* ============================================
|
|
底部提示
|
|
============================================ */
|
|
.footer-hint {
|
|
font-size: 12px;
|
|
color: #c0c8d4;
|
|
margin-top: 32px;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
</style>
|