UserLogin.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <!-- 智能仓储管理系统登录页面 -->
  2. <template>
  3. <div class="login-container">
  4. <!-- 背景装饰 -->
  5. <div class="background-decoration" />
  6. <!-- 主内容区域 -->
  7. <div class="login-content">
  8. <!-- 左侧信息区 -->
  9. <div class="login-left">
  10. <div class="system-info">
  11. <h1 class="system-title">智能仓储管理系统</h1>
  12. <div class="feature-list">
  13. <div class="feature-item">
  14. <i class="fas fa-check-circle" />
  15. <span>高效的库存管理</span>
  16. </div>
  17. <div class="feature-item">
  18. <i class="fas fa-check-circle" />
  19. <span>智能化物料追踪</span>
  20. </div>
  21. <div class="feature-item">
  22. <i class="fas fa-check-circle" />
  23. <span>实时数据分析</span>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <!-- 右侧登录表单 -->
  29. <div class="login-right">
  30. <div class="login-form-wrapper">
  31. <div class="form-header">
  32. <h2 class="form-title">欢迎登录</h2>
  33. <p class="form-subtitle">请输入您的账号信息</p>
  34. </div>
  35. <div class="form-content">
  36. <!-- 用户名输入框 -->
  37. <div class="form-item">
  38. <a-input v-model:value="username" placeholder="请输入用户名" size="large" @keyup.enter="handleLogin">
  39. <template #prefix>
  40. <UserOutlined class="input-icon" />
  41. </template>
  42. </a-input>
  43. </div>
  44. <!-- 密码输入框 -->
  45. <div class="form-item">
  46. <a-input-password v-model:value="password" placeholder="请输入密码" size="large" @keyup.enter="handleLogin">
  47. <template #prefix>
  48. <LockOutlined class="input-icon" />
  49. </template>
  50. </a-input-password>
  51. </div>
  52. <!-- 登录按钮 -->
  53. <a-button type="primary" block size="large" class="login-button" :loading="loading" @click="handleLogin">
  54. 登录
  55. </a-button>
  56. <!-- 忘记密码链接 -->
  57. <div class="form-footer">
  58. <a href="#" class="forgot-link" @click.prevent="handleForgotPassword">
  59. 忘记密码?
  60. </a>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <!-- 底部版权信息 -->
  67. <!-- <footer class="login-footer">
  68. © 2023 智能仓储管理系统. 保留所有权利.
  69. </footer> -->
  70. </div>
  71. </template>
  72. <script setup>
  73. import { ref } from 'vue';
  74. import { useRouter } from 'vue-router';
  75. import { message } from 'ant-design-vue';
  76. import { loginApi } from '../api/login.js';
  77. import { getFormattedDateTime } from '../common/Common.js';
  78. import { UserOutlined, LockOutlined } from '@ant-design/icons-vue';
  79. const router = useRouter();
  80. // 表单数据
  81. const username = ref('');
  82. const password = ref('');
  83. const loading = ref(false);
  84. // 登录处理函数
  85. const handleLogin = async () => {
  86. if (!username.value || !password.value) {
  87. message.error('请输入完整的登录信息');
  88. return;
  89. }
  90. loading.value = true;
  91. try {
  92. const params = {
  93. username: username.value,
  94. password: password.value,
  95. accountDateTime: getFormattedDateTime(),
  96. languageId: 'zh-CN',
  97. };
  98. const formData = new FormData();
  99. formData.append('userName', params.username);
  100. formData.append('password', params.password);
  101. formData.append('accountDateTime', params.accountDateTime);
  102. formData.append('languageId', params.languageId);
  103. const res = await loginApi(formData);
  104. if (res.errorCode === 0) {
  105. if (res.data) {
  106. localStorage.setItem('#token', res.data.token);
  107. localStorage.setItem('#accountId', res.data.accountId);
  108. localStorage.setItem('#LoginInfo', JSON.stringify(res.data));
  109. }
  110. message.success('欢迎登录,' + res.data.userName);
  111. const redirectUrl = window.location.href.split('redirectUrl=')[1];
  112. if (redirectUrl) {
  113. window.location = decodeURIComponent(redirectUrl);
  114. } else {
  115. router.push('/home');
  116. }
  117. } else {
  118. message.warning(res.errorMessage);
  119. }
  120. } catch (error) {
  121. message.error('登录失败');
  122. } finally {
  123. loading.value = false;
  124. }
  125. };
  126. // 忘记密码处理函数
  127. const handleForgotPassword = () => {
  128. message.info('请联系管理员重置密码');
  129. };
  130. </script>
  131. <style scoped>
  132. /* 登录容器 */
  133. .login-container {
  134. min-height: 100vh;
  135. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  136. position: relative;
  137. overflow: hidden;
  138. display: flex;
  139. flex-direction: column;
  140. }
  141. /* 背景装饰 */
  142. .background-decoration {
  143. position: absolute;
  144. top: 0;
  145. left: 0;
  146. width: 100%;
  147. height: 100%;
  148. /* background-image: url('./background.svg'); */
  149. background-repeat: no-repeat;
  150. background-position: center;
  151. background-size: cover;
  152. opacity: 0.1;
  153. pointer-events: none;
  154. }
  155. /* 主内容区域 */
  156. .login-content {
  157. flex: 1;
  158. display: flex;
  159. align-items: center;
  160. justify-content: center;
  161. padding: 40px 20px;
  162. position: relative;
  163. z-index: 1;
  164. }
  165. /* 左侧信息区 */
  166. .login-left {
  167. flex: 1;
  168. max-width: 500px;
  169. padding: 0 40px;
  170. color: white;
  171. }
  172. .system-info {
  173. animation: fadeInLeft 0.8s ease-out;
  174. }
  175. .system-title {
  176. font-size: 42px;
  177. font-weight: 700;
  178. margin-bottom: 16px;
  179. line-height: 1.2;
  180. color: #fff
  181. }
  182. .system-subtitle {
  183. font-size: 18px;
  184. opacity: 0.9;
  185. margin-bottom: 40px;
  186. font-weight: 300;
  187. }
  188. .feature-list {
  189. display: flex;
  190. flex-direction: column;
  191. gap: 20px;
  192. }
  193. .feature-item {
  194. display: flex;
  195. align-items: center;
  196. gap: 12px;
  197. font-size: 16px;
  198. opacity: 0.95;
  199. }
  200. .feature-item i {
  201. font-size: 20px;
  202. color: #4ade80;
  203. }
  204. /* 右侧登录表单 */
  205. .login-right {
  206. flex: 0 0 450px;
  207. padding: 0 20px;
  208. }
  209. .login-form-wrapper {
  210. background: white;
  211. border-radius: 16px;
  212. padding: 48px 40px;
  213. box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  214. animation: fadeInRight 0.8s ease-out;
  215. }
  216. .form-header {
  217. text-align: center;
  218. margin-bottom: 32px;
  219. }
  220. .form-title {
  221. font-size: 28px;
  222. font-weight: 700;
  223. color: #1f2937;
  224. margin-bottom: 8px;
  225. }
  226. .form-subtitle {
  227. font-size: 14px;
  228. color: #6b7280;
  229. }
  230. .form-content {
  231. display: flex;
  232. flex-direction: column;
  233. gap: 20px;
  234. }
  235. .form-item {
  236. margin-bottom: 4px;
  237. }
  238. .input-icon {
  239. color: #667eea;
  240. font-size: 16px;
  241. }
  242. .login-button {
  243. height: 48px;
  244. font-size: 16px;
  245. font-weight: 600;
  246. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  247. border: none;
  248. border-radius: 8px;
  249. margin-top: 8px;
  250. transition: all 0.3s ease;
  251. }
  252. .login-button:hover {
  253. transform: translateY(-2px);
  254. box-shadow: 0 8px 16px rgba(102, 126, 234, 0.4);
  255. }
  256. .form-footer {
  257. text-align: center;
  258. margin-top: 8px;
  259. }
  260. .forgot-link {
  261. color: #667eea;
  262. font-size: 14px;
  263. text-decoration: none;
  264. transition: color 0.3s ease;
  265. }
  266. .forgot-link:hover {
  267. color: #764ba2;
  268. text-decoration: underline;
  269. }
  270. /* 底部版权 */
  271. .login-footer {
  272. text-align: center;
  273. padding: 20px;
  274. color: white;
  275. font-size: 14px;
  276. opacity: 0.8;
  277. position: relative;
  278. z-index: 1;
  279. }
  280. /* 动画效果 */
  281. @keyframes fadeInLeft {
  282. from {
  283. opacity: 0;
  284. transform: translateX(-30px);
  285. }
  286. to {
  287. opacity: 1;
  288. transform: translateX(0);
  289. }
  290. }
  291. @keyframes fadeInRight {
  292. from {
  293. opacity: 0;
  294. transform: translateX(30px);
  295. }
  296. to {
  297. opacity: 1;
  298. transform: translateX(0);
  299. }
  300. }
  301. /* 响应式设计 */
  302. @media (max-width: 1024px) {
  303. .login-left {
  304. display: none;
  305. }
  306. .login-right {
  307. flex: 0 0 100%;
  308. max-width: 450px;
  309. }
  310. }
  311. @media (max-width: 640px) {
  312. .login-form-wrapper {
  313. padding: 32px 24px;
  314. }
  315. .form-title {
  316. font-size: 24px;
  317. }
  318. .login-right {
  319. padding: 0 16px;
  320. }
  321. }
  322. /* Ant Design 样式覆盖 */
  323. :deep(.ant-input-affix-wrapper) {
  324. border-radius: 8px;
  325. border: 1px solid #e5e7eb;
  326. padding: 12px 16px;
  327. }
  328. :deep(.ant-input-affix-wrapper:focus),
  329. :deep(.ant-input-affix-wrapper-focused) {
  330. border-color: #667eea;
  331. box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
  332. }
  333. :deep(.ant-input) {
  334. font-size: 15px;
  335. }
  336. :deep(.ant-input-password) {
  337. border-radius: 8px;
  338. }
  339. </style>