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.

130 lines
2.4 KiB

4 weeks ago
  1. <template>
  2. <view class="login-container">
  3. <view class="login-box">
  4. <view class="title">宿舍管理系统</view>
  5. <view class="input-group">
  6. <view class="input-item">
  7. <input type="text" v-model="username" placeholder="请输入账号" />
  8. </view>
  9. <view class="input-item">
  10. <input type="password" v-model="password" placeholder="请输入密码" />
  11. </view>
  12. </view>
  13. <button class="login-btn" @click="handleLogin">
  14. <text>登录</text>
  15. </button>
  16. <view class="tips">
  17. <text>账号: 20030229</text>
  18. <text>密码: hahaha</text>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script setup>
  24. import { ref } from 'vue'
  25. const username = ref('')
  26. const password = ref('')
  27. const handleLogin = function() {
  28. if (!username.value & password.value) {
  29. uni.showToast({
  30. title: '请输入账号',
  31. icon:'none'
  32. })
  33. return
  34. }
  35. if (username.value & !password.value) {
  36. uni.showToast({
  37. title: '请输入密码',
  38. icon:'none'
  39. })
  40. return
  41. }
  42. if (!username.value & !password.value) {
  43. uni.showToast({
  44. title: '请输入账号和密码',
  45. icon:'none'
  46. })
  47. return
  48. }
  49. if (username.value === '20030229' && password.value === 'hahaha') {
  50. setTimeout(() => {
  51. uni.setStorageSync('isLogin', true)
  52. uni.switchTab({
  53. url: '/pages/index/index'
  54. })
  55. }, 1000)
  56. } else {
  57. uni.showToast({
  58. title: '账号或密码错误',
  59. icon:'none'
  60. })
  61. }
  62. }
  63. </script>
  64. <style scoped>
  65. .login-container {
  66. display: flex;
  67. align-items: center;
  68. justify-content: center;
  69. height: 100vh;
  70. background-color: #f5f5f5;
  71. }
  72. .login-box {
  73. width: 70vw;
  74. background-color: #fff;
  75. border-radius: 20rpx;
  76. padding: 60rpx 40rpx;
  77. box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
  78. }
  79. .title {
  80. text-align: center;
  81. font-size: 36rpx;
  82. font-weight: bold;
  83. color: #333;
  84. margin-bottom: 10vh;
  85. }
  86. .input-group {
  87. margin-bottom: 60rpx;
  88. }
  89. .input-item {
  90. display: flex;
  91. align-items: center;
  92. border-bottom: 1px solid #eee;
  93. padding: 20rpx 20rpx;
  94. }
  95. .login-btn {
  96. display: flex;
  97. align-items: center;
  98. justify-content: center;
  99. width: 40vw;
  100. height: 4vh;
  101. background-color: #36bffa;
  102. color: #fff;
  103. border-radius: 40rpx;
  104. font-size: 30rpx;
  105. }
  106. .tips {
  107. display: flex;
  108. flex-direction: column;
  109. align-items: center;
  110. margin-top: 5vh;
  111. color: #999;
  112. font-size: 24rpx;
  113. }
  114. .tips text {
  115. margin-top: 10rpx;
  116. }
  117. </style>