LoginPage.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="contain" >
  3. <div class="login-card">
  4. <div class="login-title">
  5. <h3>系统登录</h3>
  6. <p>国有资产管理平台</p>
  7. </div>
  8. <div class="form-item">
  9. <input
  10. type="text"
  11. placeholder="请输入账号"
  12. v-model="user"
  13. >
  14. </div>
  15. <div class="form-item">
  16. <input
  17. type="password"
  18. placeholder="请输入密码"
  19. v-model="password"
  20. @keyup.enter="handleLogin"
  21. >
  22. </div>
  23. <button class="btn-login" @click="handleLogin">登录</button>
  24. </div>
  25. </div>
  26. </template>
  27. <script setup>
  28. import { showError, showWarning } from '@/utils/message'
  29. import { ref } from 'vue'
  30. import { initLogin } from '@/api/login';
  31. import { useRouter } from 'vue-router';
  32. import { useUserStore } from '@/store/user';
  33. import { useFilterStore } from '@/store/filter';
  34. const userStore = useUserStore()
  35. const router = useRouter()
  36. const filterStore = useFilterStore()
  37. const user = ref('')
  38. const password = ref('')
  39. const handleLogin = async () => {
  40. if (!user.value.trim() || !password.value.trim()) {
  41. showWarning('请输入账号和密码!')
  42. return
  43. }
  44. const loginParams = {
  45. userName: user.value,
  46. password: password.value,
  47. clientId: 1
  48. }
  49. try {
  50. const {data} = await initLogin(loginParams)
  51. if(data.code !== 200) {
  52. showError(data.message)
  53. return
  54. }
  55. userStore.setUserInfo(data)
  56. filterStore.resetFilter()
  57. router.push('/home')
  58. } catch (error) {
  59. console.error('登录失败:', error);
  60. showError(error.message)
  61. }
  62. }
  63. </script>
  64. <style scoped>
  65. .contain{
  66. width: 100vw;
  67. height: 100vh;
  68. background-image: url('@/assets/images/login-bg.png');
  69. background-size: cover;
  70. background-position: center;
  71. background-repeat: no-repeat;
  72. display: flex;
  73. justify-content: center;
  74. align-items: center;
  75. }
  76. .login-card{
  77. width: 420px;
  78. padding: 36px 32px;
  79. background: rgba(255, 255, 255, 0.92);
  80. backdrop-filter: blur(12px);
  81. -webkit-backdrop-filter: blur(12px);
  82. border-radius: 18px;
  83. box-shadow: 0 8px 32px rgba(12, 85, 232, 0.12), 0 2px 8px rgba(0,0,0,0.05);
  84. display: flex;
  85. flex-direction: column;
  86. gap: 22px;
  87. border: 1px solid rgba(255,255,255,0.6);
  88. }
  89. .login-title{
  90. text-align: center;
  91. margin-bottom: 8px;
  92. }
  93. .login-title h3{
  94. font-family: var(--font-semibold);
  95. font-size: 24px;
  96. font-weight: 600;
  97. color: #0f2855;
  98. margin:0 0 6px;
  99. }
  100. .login-title p{
  101. font-family: var(--font-regular);
  102. font-size:14px;
  103. font-weight: 400;
  104. color:#66789c;
  105. margin:0;
  106. }
  107. .form-item input{
  108. width: 100%;
  109. height: 46px;
  110. border-radius: 12px;
  111. border: 1px solid #e1e7f2;
  112. padding: 0 16px;
  113. outline: none;
  114. font-family: var(--font-regular);
  115. font-size:15px;
  116. font-weight: 400;
  117. color:#2c3e50;
  118. background:#fafcff;
  119. transition: all 0.28s ease;
  120. }
  121. .form-item input:hover{
  122. border-color:#9ab9f2;
  123. background:#fff;
  124. }
  125. .form-item input:focus{
  126. border-color: #0c55e8;
  127. box-shadow: 0 0 0 3px rgba(12, 85, 232, 0.12);
  128. background:#ffffff;
  129. }
  130. .form-item input::placeholder{
  131. color:#b0bcca;
  132. }
  133. .btn-login{
  134. width: 100%;
  135. height: 48px;
  136. background: linear-gradient(135deg,#0c55e8,#2370ff);
  137. color: white;
  138. border: none;
  139. border-radius: 12px;
  140. cursor: pointer;
  141. font-family: var(--font-medium);
  142. font-size:16px;
  143. font-weight:500;
  144. transition: all 0.25s ease;
  145. margin-top:4px;
  146. }
  147. .btn-login:hover{
  148. transform: translateY(-2px);
  149. box-shadow: 0 6px 16px rgba(12, 85, 232, 0.3);
  150. background: linear-gradient(135deg,#0949d2,#1966f5);
  151. }
  152. .btn-login:active{
  153. transform: translateY(0);
  154. box-shadow: 0 2px 8px rgba(12, 85, 232, 0.25);
  155. }
  156. </style>