LoginView.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <script setup>
  2. import { ref, unref } from 'vue';
  3. import { useRouter } from 'vue-router';
  4. import { NButton } from 'naive-ui';
  5. import { SvgIcon } from '@/components';
  6. import { useUserStore } from '@/stores/modules/userStore';
  7. import { userApi } from '@/api/user';
  8. const router = useRouter();
  9. const userStore = useUserStore();
  10. const errorMsg = ref('');
  11. const loading = ref(false);
  12. const loginFormData = ref({
  13. username: '',
  14. password: ''
  15. })
  16. const handleSubmit = async () => {
  17. const { username, password } = unref(loginFormData);
  18. if (!username) {
  19. return errorMsg.value = '请输入用户名称'
  20. }
  21. if (!password) {
  22. return errorMsg.value = '请输入登录密码'
  23. }
  24. loading.value = true;
  25. setTimeout(() => {
  26. loading.value = false;
  27. if ( username !== 'admin' || password !== 'admin123' ) {
  28. return errorMsg.value = '账号或者密码输入有误'
  29. }
  30. errorMsg.value = '';
  31. router.push("/");
  32. localStorage.setItem("isLogin", new Date().getTime());
  33. }, 1 * 1000)
  34. // try {
  35. // loading.value = true;
  36. // const { token } = await userApi.postLogin({ username, password, type: 0 });
  37. // userStore.setUserInfo({ token });
  38. // const { user } = await userApi.getUserInfo();
  39. // errorMsg.value = '';
  40. // userStore.setUserInfo({ ...user });
  41. // router.push("/");
  42. // }
  43. // catch (error) {
  44. // errorMsg.value = error.msg;
  45. // }
  46. // finally {
  47. // loading.value = false;
  48. // }
  49. }
  50. </script>
  51. <template>
  52. <div class="login-viewport">
  53. <div class="tips-wrapper">
  54. <ul class="tips-inner">
  55. <li class="title">LibraAI 智能体运营平台<br />锡林浩特污水处理厂</li>
  56. <li class="sub-title">使命重在担当,实干铸就未来</li>
  57. </ul>
  58. </div>
  59. <div class="login-wrapper">
  60. <div class="login-form w-[442px] h-[454px]">
  61. <p class="title pl-[2px] mb-[30px] text-[28px] text-[#fff] leading-[40px] font-bold">欢迎登录</p>
  62. <div class="form-inner w-full">
  63. <ul class="form-inp-list">
  64. <li class="inp-item-inner">
  65. <input type="text" placeholder="请输入用户名称" v-model="loginFormData.username">
  66. </li>
  67. <li class="inp-item-inner">
  68. <input type="password" placeholder="请输入登录密码" v-model="loginFormData.password">
  69. </li>
  70. </ul>
  71. <div class="waring-feedback h-[32px] text-[12px] text-[#FF7152]">
  72. <p class="flex items-center justify-center h-full space-x-[8px] bg-[#FFF1F0]" v-show="errorMsg">
  73. <SvgIcon name="login-warning-tips"></SvgIcon>
  74. <span>{{ errorMsg }}</span>
  75. </p>
  76. </div>
  77. </div>
  78. <NButton block color="#2454FF" size="large" :loading="loading" @click="handleSubmit">登 录</NButton>
  79. </div>
  80. </div>
  81. </div>
  82. </template>
  83. <style scoped lang="scss">
  84. .login-viewport {
  85. position: relative;
  86. @include flex(x, center, between);
  87. height: 100vh;
  88. background: url("@/assets/images/login/bg-login-xlht2.png") center center no-repeat;
  89. background-size: cover;
  90. overflow: hidden;
  91. min-width: 1100px;
  92. .tips-wrapper {
  93. position: relative;
  94. width: 100%;
  95. height: 100%;
  96. .tips-inner {
  97. position: absolute;
  98. top: 102px;
  99. left: 74px;
  100. line-height: 46px;
  101. color: #fff;
  102. .title {
  103. font-size: 36px;
  104. font-family: AlimamaShuHeiTi;
  105. }
  106. .sub-title {
  107. font-size: 24px;
  108. }
  109. }
  110. }
  111. .login-wrapper {
  112. @include flex(x, center, center);
  113. width: 562px;
  114. height: 100%;
  115. flex-shrink: 0;
  116. background: rgba(20, 28, 36, 0.60);
  117. backdrop-filter: blur(12px);
  118. }
  119. .logo {
  120. @include flex(x, center, center);
  121. .text {
  122. font-size: 11px;
  123. font-family: AlimamaShuHeiTi;
  124. font-weight: bold;
  125. line-height: 12px;
  126. }
  127. }
  128. .login-form {
  129. @include flex(y, start, between);
  130. padding: 40px 40px;
  131. .form-inp-list {
  132. width: 100%;
  133. margin-bottom: 8px;
  134. .inp-item-inner {
  135. border-radius: 2px;
  136. overflow: hidden;
  137. input {
  138. width: 100%;
  139. padding: 16px 20px;
  140. background: #F2F4F9;
  141. font-size: 16px;
  142. line-height: 22px;
  143. color: #1A2029;
  144. outline: none;
  145. &::placeholder {
  146. color: #989EA7;
  147. }
  148. }
  149. &:nth-child(1) {
  150. margin-bottom: 18px;
  151. }
  152. }
  153. }
  154. }
  155. }
  156. .n-button {
  157. height: 54px;
  158. font-size: 18px;
  159. &:hover {
  160. background: #1d43cc;
  161. }
  162. }
  163. </style>