login.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. const name = ref('')
  4. const roomID = ref('')
  5. defineProps<{ err: string }>()
  6. const emit = defineEmits<{(evt: 'loginBack', value: { name: string, roomID: string }): void }>()
  7. function login() {
  8. if (name.value && roomID.value) emit('loginBack', { name: name.value, roomID: roomID.value })
  9. }
  10. </script>
  11. <template>
  12. <div class="login">
  13. <div class="login-content">
  14. <div class="login-content-left" />
  15. <div class="login-content-right">
  16. <p>Hello, 欢迎登录</p>
  17. <div>
  18. <Icon
  19. name="username"
  20. :size="25"
  21. />
  22. <input
  23. v-model="roomID"
  24. type="text"
  25. placeholder="请输入房间"
  26. maxlength="20"
  27. >
  28. </div>
  29. <div>
  30. <Icon
  31. name="password"
  32. :size="25"
  33. />
  34. <input
  35. v-model="name"
  36. type="text"
  37. placeholder="请输入名称"
  38. maxlength="20"
  39. >
  40. </div>
  41. <div>
  42. <button
  43. :disabled="!name && !roomID"
  44. :class="{ resetStyle: name && roomID }"
  45. @click="login"
  46. >
  47. 加入
  48. </button>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <style scoped lang="less">
  55. .login {
  56. width: 100%;
  57. height: 100%;
  58. font-size: 0.15rem;
  59. display: flex;
  60. justify-content: center;
  61. align-items: center;
  62. background: url(../assets/img/bg.png) center center no-repeat;
  63. background-size: 100% 100%;
  64. &-content {
  65. width: 8rem;
  66. height: 4rem;
  67. background: white;
  68. border-radius: 0.2rem;
  69. display: flex;
  70. overflow: hidden;
  71. &-left {
  72. width: 5rem;
  73. background: url(../assets/img/login-left.png) center center no-repeat;
  74. background-size: 100% 100%;
  75. }
  76. &-right {
  77. flex: 1;
  78. padding: 0 0.3rem;
  79. &>p {
  80. font-size: 0.3rem;
  81. color: #5970C6;
  82. text-align: left;
  83. font-weight: 400;
  84. text-align: center;
  85. margin-top: 0.5rem;
  86. margin-bottom: 0.5rem;
  87. }
  88. &>div {
  89. padding: 0.1rem 0;
  90. display: flex;
  91. align-items: center;
  92. margin: 0.1rem 0;
  93. &:not(:last-child) {
  94. border-bottom: solid 1px #D2D6E7;
  95. }
  96. input {
  97. border: none;
  98. margin-left: 0.05rem;
  99. outline: none;
  100. width: 100%;
  101. font-size: 0.15rem;
  102. color: #333;
  103. &::placeholder {
  104. color: #9DA1A8;
  105. font-size: 0.15rem;
  106. }
  107. }
  108. button {
  109. background: #79b8fa;
  110. border: none;
  111. outline: none;
  112. color: white;
  113. font-size: 0.16rem;
  114. font-weight: 500;
  115. border-radius: 1rem;
  116. margin-top: 0.5rem;
  117. margin-left: auto;
  118. line-height: 0.35rem;
  119. padding: 0 0.35rem;
  120. cursor: not-allowed;
  121. }
  122. }
  123. .resetStyle {
  124. background: #2d8cf0;
  125. cursor: pointer;
  126. }
  127. }
  128. }
  129. }
  130. </style>