You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.8 KiB

1 month ago
1 month ago
1 month ago
3 weeks ago
1 month ago
3 weeks ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
4 weeks ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <div class="login-container">
  3. <div class="login-card">
  4. <form @submit.prevent="handleLogin">
  5. <div class="form-group">
  6. <input type="password" id="password" v-model="password" placeholder="请输入密码" />
  7. </div>
  8. <button type="submit" class="login-button">进入抽奖</button>
  9. </form>
  10. </div>
  11. </div>
  12. </template>
  13. <script setup>
  14. import { ref } from 'vue';
  15. import { useRouter } from 'vue-router';
  16. import { useAuthStore } from '../../stores/auth';
  17. const password = ref('');
  18. const router = useRouter();
  19. const authStore = useAuthStore();
  20. const handleLogin = () => {
  21. if (password.value === '') {
  22. alert('请输入密码');
  23. return;
  24. }
  25. if (password.value == '000000') {
  26. authStore.login();
  27. router.push('/hxlCj');
  28. } else {
  29. if (password.value === '123456') {
  30. // 添加登录状态存储
  31. authStore.login(); // 使用Pinia登录方法
  32. router.push('/choujiang');
  33. } else {
  34. alert('密码错误,请重试');
  35. }
  36. }
  37. };
  38. // 登录逻辑处理
  39. console.log('登录信息:', {
  40. password: password.value,
  41. });
  42. // 这里可以添加实际的登录API调用
  43. </script>
  44. <style scoped>
  45. .login-container {
  46. background-image: url('../../assets/登录背景.png');
  47. /* 确保路径正确 */
  48. background-position: center;
  49. background-size: cover;
  50. height: 100vh;
  51. /* 确保背景图片覆盖整个视口高度 */
  52. width: 100vw;
  53. /* 确保背景图片覆盖整个视口宽度 */
  54. position: fixed;
  55. /* 使用fixed定位确保背景图片覆盖整个页面 */
  56. top: 0;
  57. left: 0;
  58. /* z-index: -1; 确保背景图片在其他内容下方 */
  59. }
  60. .login-card {
  61. position: absolute;
  62. top: 55%;
  63. left: 50%;
  64. transform: translate(-50%, -50%);
  65. width: 450px;
  66. /* 增加卡片宽度 */
  67. height: 285px;
  68. padding: 2.5rem;
  69. /* 增加内边距 */
  70. background: rgba(255, 255, 255, 0.3);
  71. /* 调整背景颜色为半透明白色 */
  72. border-radius: 8px;
  73. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  74. box-sizing: border-box;
  75. z-index: 1;
  76. /* 确保卡片在背景图片上方 */
  77. }
  78. input {
  79. width: 100%;
  80. padding: 1.2rem;
  81. border: 1px solid #ddd;
  82. border-radius: 4px;
  83. font-size: 1.3rem;
  84. /* 增大字体大小 */
  85. margin-bottom: 2.5rem;
  86. /* 增加底部间距 */
  87. box-sizing: border-box
  88. }
  89. .login-button {
  90. width: 100%;
  91. padding: 1.2rem;
  92. /* 增加按钮内边距 */
  93. background-color: #e92821a3;
  94. color: white;
  95. border: none;
  96. border-radius: 4px;
  97. font-size: 1.3rem;
  98. /* 增大字体大小 */
  99. cursor: pointer;
  100. transition: background-color 0.3s;
  101. box-sizing: border-box
  102. }
  103. .login-button:hover {
  104. transform: scale(1.03);
  105. }
  106. </style>