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

179 lines
3.8 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
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 style-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, getAllUserJSON } 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. hideLoginModal: {
  44. type: Function,
  45. default: () => {},
  46. },
  47. modal: {
  48. type: Boolean,
  49. default: false,
  50. },
  51. changeTab: {
  52. type: Function,
  53. default: () => {},
  54. },
  55. })
  56. const activeInput = ref(1)
  57. const handleFocus = flag => {
  58. props.handleShowKey()
  59. props.clearInput()
  60. activeInput.value = flag
  61. }
  62. const router = useRouter()
  63. const userStore = useUserStore()
  64. const webSocketStore = useWebSocketStore()
  65. const showPassword = ref(false)
  66. const username = ref('')
  67. const password = ref('')
  68. const tip = ref('')
  69. const handleEye = () => {
  70. showPassword.value = !showPassword.value
  71. }
  72. watch(() => {
  73. // 需要有个逻辑判断
  74. if (activeInput.value == 1) {
  75. username.value = props.input
  76. } else {
  77. password.value = props.input
  78. }
  79. })
  80. const handleLogin = () => {
  81. props.handleHideKey()
  82. if (username.value == '') {
  83. tip.value = '用户名不能为空'
  84. return
  85. }
  86. if (password.value == '') {
  87. tip.value = '密码不能为空'
  88. return
  89. }
  90. tip.value = ''
  91. webSocketStore?.sendCommandMsg(loginJSON(username.value, password.value))
  92. // 前端自己校验
  93. setTimeout(() => {
  94. userStore.allUserList?.map(item => {
  95. if (item.uid == username.value && password.value == item.passwd) {
  96. // 登陆成功
  97. userStore.updatePermission(item.permission_level)
  98. userStore.updateLoginUser(item.uid)
  99. if (props.modal) {
  100. props.changeTab(5)
  101. props.hideLoginModal()
  102. // 判断是否在消毒中,如果在消毒中,将TAB切换到设置
  103. } else {
  104. window.location.href = 'http://127.0.0.1/'
  105. }
  106. }
  107. })
  108. })
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .login_modal {
  113. width: 476px;
  114. height: 414px;
  115. border-radius: 16px;
  116. overflow: hidden;
  117. background: url(../assets/img/login/login.png) no-repeat;
  118. background-size: 100% 100%;
  119. box-sizing: border-box;
  120. position: relative;
  121. .eye {
  122. width: 16px;
  123. height: 13px;
  124. position: absolute;
  125. right: 78.04px;
  126. top: 211px;
  127. }
  128. .tips {
  129. font-family: Source Han Sans CN;
  130. font-size: 12px;
  131. font-weight: 350;
  132. letter-spacing: 0.06em;
  133. color: #fa1c1c;
  134. position: absolute;
  135. left: 73px;
  136. bottom: 143px;
  137. }
  138. .username {
  139. border: none;
  140. outline: none;
  141. width: 253px;
  142. height: 20px;
  143. position: absolute;
  144. left: 120px;
  145. top: 142px;
  146. font-family: Source Han Sans CN;
  147. font-size: 22px;
  148. font-weight: 350;
  149. letter-spacing: 0.06em;
  150. }
  151. .password {
  152. border: none;
  153. outline: none;
  154. width: 253px;
  155. height: 17px;
  156. position: absolute;
  157. left: 120px;
  158. top: 209px;
  159. font-family: Source Han Sans CN;
  160. font-size: 18px;
  161. font-weight: 350;
  162. letter-spacing: 0.06em;
  163. }
  164. .login_btn {
  165. position: absolute;
  166. width: 340px;
  167. height: 68px;
  168. left: 68px;
  169. bottom: 62px;
  170. }
  171. }
  172. </style>