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.

102 lines
2.7 KiB

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