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

129 lines
2.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
  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. placeholder="请输入用户名"
  10. />
  11. <input
  12. :type="showPassword ? 'text' : 'password'"
  13. class="password"
  14. v-model="password"
  15. placeholder="请输入设备密码"
  16. />
  17. <div class="login_btn" @click="handleLogin"></div>
  18. </div>
  19. </template>
  20. <script setup>
  21. import Eye from '@/assets/img/login/eye.png'
  22. import Open from '@/assets/img/login/open.png'
  23. import { useWebSocketStore, useUserStore } from '@/store'
  24. import { ref } from 'vue'
  25. import { useRouter } from 'vue-router'
  26. import { loginJSON } from '@/mock/command'
  27. const router = useRouter()
  28. const userStore = useUserStore()
  29. const webSocketStore = useWebSocketStore()
  30. const showPassword = ref(false)
  31. const username = ref('')
  32. const password = ref('')
  33. const tip = ref('')
  34. const handleEye = () => {
  35. showPassword.value = !showPassword.value
  36. }
  37. const handleLogin = () => {
  38. if (username.value == '') {
  39. tip.value = '用户名不能为空'
  40. return
  41. }
  42. if (password.value == '') {
  43. tip.value = '密码不能为空'
  44. return
  45. }
  46. tip.value = ''
  47. webSocketStore?.sendCommandMsg(loginJSON(username.value, password.value))
  48. // 前端自己校验
  49. let flag = false
  50. userStore.allUserList?.map(item => {
  51. if (item.uid == username.value && password.value == item.passwd) {
  52. // 登陆成功
  53. flag = true
  54. userStore.updatePermission(item.permission_level)
  55. userStore.updateLoginUser(item.uid)
  56. }
  57. })
  58. if (flag) {
  59. router.push('/')
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .login_modal {
  65. width: 476px;
  66. height: 414px;
  67. border-radius: 16px;
  68. overflow: hidden;
  69. background: url(../assets/img/login/login.png) no-repeat;
  70. background-size: 100% 100%;
  71. box-sizing: border-box;
  72. position: relative;
  73. .eye {
  74. width: 16px;
  75. height: 13px;
  76. position: absolute;
  77. right: 78.04px;
  78. top: 211px;
  79. }
  80. .tips {
  81. font-family: Source Han Sans CN;
  82. font-size: 12px;
  83. font-weight: 350;
  84. letter-spacing: 0.06em;
  85. color: #fa1c1c;
  86. position: absolute;
  87. left: 73px;
  88. bottom: 143px;
  89. }
  90. .username {
  91. border: none;
  92. outline: none;
  93. width: 253px;
  94. height: 17px;
  95. position: absolute;
  96. left: 120px;
  97. top: 142px;
  98. font-family: Source Han Sans CN;
  99. font-size: 12px;
  100. font-weight: 350;
  101. letter-spacing: 0.06em;
  102. }
  103. .password {
  104. border: none;
  105. outline: none;
  106. width: 253px;
  107. height: 17px;
  108. position: absolute;
  109. left: 120px;
  110. top: 209px;
  111. font-family: Source Han Sans CN;
  112. font-size: 12px;
  113. font-weight: 350;
  114. letter-spacing: 0.06em;
  115. }
  116. .login_btn {
  117. position: absolute;
  118. width: 340px;
  119. height: 68px;
  120. left: 68px;
  121. bottom: 62px;
  122. }
  123. }
  124. </style>