大空间消毒机
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.

165 lines
3.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="login_modal">
  3. <img :src="showPassword ? Open : Eye" class="eye" @click="handleEye" />
  4. <p class="tips">{{ tip }}</p>
  5. <input
  6. type="text"
  7. v-model="username"
  8. class="username"
  9. @focus="handleFocus(1)"
  10. placeholder="请输入用户名"
  11. />
  12. <input
  13. :type="showPassword ? 'text' : 'password'"
  14. class="password"
  15. v-model="password"
  16. @focus="handleFocus(2)"
  17. id="txtPassword"
  18. placeholder="请输入设备密码"
  19. />
  20. <div class="login_btn" @click="handleLogin"></div>
  21. </div>
  22. </template>
  23. <script setup>
  24. import Eye from '@/assets/img/login/eye.png'
  25. import Open from '@/assets/img/login/open.png'
  26. import { useWebSocketStore, useUserStore } from '@/store'
  27. import { ref, watch } from 'vue'
  28. import { useRouter } from 'vue-router'
  29. import { loginJSON } from '@/mock/command'
  30. const props = defineProps({
  31. handleShowKey: {
  32. type: Function,
  33. },
  34. handleHideKey: {
  35. type: Function,
  36. },
  37. clearInput: {
  38. type: Function,
  39. },
  40. input: {
  41. type: String,
  42. },
  43. })
  44. const activeInput = ref(1)
  45. const handleFocus = flag => {
  46. props.handleShowKey()
  47. props.clearInput()
  48. activeInput.value = flag
  49. }
  50. const router = useRouter()
  51. const userStore = useUserStore()
  52. const webSocketStore = useWebSocketStore()
  53. const showPassword = ref(false)
  54. const username = ref('')
  55. const password = ref('')
  56. const tip = ref('')
  57. const handleEye = () => {
  58. showPassword.value = !showPassword.value
  59. }
  60. watch(() => {
  61. // 需要有个逻辑判断
  62. if (activeInput.value == 1) {
  63. username.value = props.input
  64. } else {
  65. password.value = props.input
  66. }
  67. })
  68. const handleLogin = () => {
  69. props.handleHideKey()
  70. if (username.value == '') {
  71. tip.value = '用户名不能为空'
  72. return
  73. }
  74. if (password.value == '') {
  75. tip.value = '密码不能为空'
  76. return
  77. }
  78. tip.value = ''
  79. webSocketStore?.sendCommandMsg(loginJSON(username.value, password.value))
  80. // 前端自己校验
  81. console.log(userStore.allUserList)
  82. let flag = false
  83. userStore.allUserList?.map(item => {
  84. if (item.uid == username.value && password.value == item.passwd) {
  85. // 登陆成功
  86. flag = true
  87. userStore.updatePermission(item.permission_level)
  88. userStore.updateLoginUser(item.uid)
  89. window.location.href = 'http://127.0.0.1/'
  90. }
  91. })
  92. if (!flag) {
  93. tip.value = '账号或密码错误'
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .login_modal {
  99. width: 476px;
  100. height: 414px;
  101. border-radius: 16px;
  102. overflow: hidden;
  103. background: url(../assets/img/login/login.png) no-repeat;
  104. background-size: 100% 100%;
  105. box-sizing: border-box;
  106. position: relative;
  107. .eye {
  108. width: 16px;
  109. height: 13px;
  110. position: absolute;
  111. right: 78.04px;
  112. top: 211px;
  113. }
  114. .tips {
  115. font-family: Source Han Sans CN;
  116. font-size: 12px;
  117. font-weight: 350;
  118. letter-spacing: 0.06em;
  119. color: #fa1c1c;
  120. position: absolute;
  121. left: 73px;
  122. bottom: 143px;
  123. }
  124. .username {
  125. border: none;
  126. outline: none;
  127. width: 253px;
  128. height: 17px;
  129. position: absolute;
  130. left: 120px;
  131. top: 142px;
  132. font-family: Source Han Sans CN;
  133. font-size: 18px;
  134. font-weight: 350;
  135. letter-spacing: 0.06em;
  136. }
  137. .password {
  138. border: none;
  139. outline: none;
  140. width: 253px;
  141. height: 17px;
  142. position: absolute;
  143. left: 120px;
  144. top: 209px;
  145. font-family: Source Han Sans CN;
  146. font-size: 18px;
  147. font-weight: 350;
  148. letter-spacing: 0.06em;
  149. }
  150. .login_btn {
  151. position: absolute;
  152. width: 340px;
  153. height: 68px;
  154. left: 68px;
  155. bottom: 62px;
  156. }
  157. }
  158. </style>