index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <!-- eslint-disable @typescript-eslint/ban-ts-comment -->
  2. <template>
  3. <div class="content">
  4. <div style="margin-top: -15vh;"><van-image :src="logoimg" /></div>
  5. <div style="font-size: 20px;font-weight: 600;margin-top:15px">文件管理系统</div>
  6. <div style="margin-top: 40px;">
  7. <div>
  8. <van-cell-group inset>
  9. <van-field v-model="loginForm.username" label="用户名" placeholder="请输入用户名" />
  10. </van-cell-group>
  11. </div>
  12. <div style="margin-top: 10px;">
  13. <van-cell-group inset>
  14. <van-field v-model="loginForm.password" label="密码" type="password" placeholder="请输入密码" />
  15. </van-cell-group>
  16. </div>
  17. <van-button style="margin-top: 40px;" type="primary" round size="large" @click="dologin">登录</van-button>
  18. </div>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import logoimg from '@/assets/logo/logo.png';
  23. import { useUserStore } from '@/store/modules/user';
  24. import { LoginData, TenantVO } from '@/api/types';
  25. import { to } from 'await-to-js';
  26. const userStore = useUserStore();
  27. const router = useRouter();
  28. const loginForm = ref<LoginData>({
  29. tenantId: '000000',
  30. username: 'admin',
  31. password: 'admin123',
  32. rememberMe: false,
  33. code: '',
  34. uuid: ''
  35. } as LoginData);
  36. const redirect = ref(undefined);
  37. watch(() => router.currentRoute.value, (newRoute: any) => {
  38. redirect.value = newRoute.query && newRoute.query.redirect;
  39. if ((redirect.value ?? "").indexOf("h5") == -1) {
  40. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  41. //@ts-ignore
  42. redirect.value = "/h5/project";
  43. }
  44. }, { immediate: true });
  45. const dologin = ()=>{
  46. to(userStore.login(loginForm.value)).then(res => {
  47. router.push({ path: redirect.value || '/h5/project' });
  48. }).catch((e) => {
  49. // console.log(e)
  50. })
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. .content{
  55. padding: 20px;
  56. text-align: center;
  57. display: flex;
  58. flex-direction: column;
  59. justify-content: center;
  60. position: relative;
  61. height: 100vh;
  62. background: #eff2f5;
  63. }
  64. </style>