login.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div class="login">
  3. <div class="title">{{ appStore.globalConfig.orgTitle }}</div>
  4. <div class="sub-title">{{ appStore.globalConfig.taskTitle }}</div>
  5. <van-form @submit="onSubmit" class="login-form">
  6. <van-cell-group inset>
  7. <van-field
  8. v-model="account"
  9. name="学号"
  10. label=""
  11. placeholder="请输入学号"
  12. clearable
  13. label-width="0px"
  14. :rules="[{ required: true, message: '请输入学号' }]"
  15. />
  16. <van-field
  17. v-model="password"
  18. :type="passwordShow ? 'text' : 'password'"
  19. name="密码"
  20. label=""
  21. placeholder="请输入证件号后六位"
  22. :right-icon="passwordShow ? 'closed-eye' : 'eye-o'"
  23. @click-right-icon="passwordShow = !passwordShow"
  24. label-width="0px"
  25. :rules="[{ required: true, message: '请输入证件号后六位' }]"
  26. />
  27. <div style="margin: 16px">
  28. <van-button block type="success" native-type="submit">
  29. 提交
  30. </van-button>
  31. </div>
  32. </van-cell-group>
  33. </van-form>
  34. </div>
  35. </template>
  36. <script name="Login" setup>
  37. import { ref } from "vue";
  38. import { login } from "@/api/user";
  39. import { useRouter } from "vue-router";
  40. import { useUserStore, useAppStore } from "@/store";
  41. const router = useRouter();
  42. const appStore = useAppStore();
  43. const userStore = useUserStore();
  44. const account = ref("1509000120002");
  45. const password = ref("123456");
  46. const passwordShow = ref(false);
  47. const onSubmit = () => {
  48. login({ account: account.value, password: password.value }).then((res) => {
  49. if (res?.id) {
  50. userStore.setLoginInfo(res);
  51. router.push("/index");
  52. }
  53. });
  54. };
  55. </script>
  56. <style lang="less" scoped>
  57. .login {
  58. background-color: #fff !important;
  59. height: 100vh;
  60. padding-top: 48px;
  61. .title {
  62. font-size: 24px;
  63. font-weight: 600;
  64. color: #262626;
  65. padding-left: 24px;
  66. }
  67. .sub-title {
  68. font-size: 16px;
  69. color: #8c8c8c;
  70. margin-top: 8px;
  71. padding-left: 24px;
  72. }
  73. .login-form {
  74. margin-top: 24px;
  75. }
  76. }
  77. </style>