管道式消毒机
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.

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