login.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div class="login">
  3. <div v-if="!appStore.globalConfig?.taskTitle" class="sys-disabled">
  4. <div class="text-center">
  5. <NoData>
  6. <template #img>
  7. <img src="../assets/imgs/sys_disabled.png" />
  8. </template>
  9. <template #title>{{ appStore.globalConfig?.orgTitle }}</template>
  10. 当前预约系统未开放</NoData
  11. >
  12. <div class="cus-btn" @click="exit">退出</div>
  13. </div>
  14. </div>
  15. <template v-else>
  16. <div class="title">{{ appStore.globalConfig?.orgTitle }}</div>
  17. <div class="sub-title">{{ appStore.globalConfig?.taskTitle }}</div>
  18. <van-form @submit="onSubmit" class="login-form">
  19. <van-cell-group inset>
  20. <van-field
  21. v-model="account"
  22. name="学号"
  23. label=""
  24. placeholder="请输入学号"
  25. clearable
  26. label-width="0px"
  27. :rules="[{ required: true, message: '请输入学号' }]"
  28. />
  29. <van-field
  30. v-model="password"
  31. :type="passwordShow ? 'text' : 'password'"
  32. name="密码"
  33. label=""
  34. placeholder="请输入证件号后六位"
  35. :right-icon="passwordShow ? 'closed-eye' : 'eye-o'"
  36. @click-right-icon="passwordShow = !passwordShow"
  37. label-width="0px"
  38. :rules="[{ required: true, message: '请输入证件号后六位' }]"
  39. />
  40. <div style="margin: 16px">
  41. <van-button block type="success" native-type="submit">
  42. 提交
  43. </van-button>
  44. </div>
  45. </van-cell-group>
  46. </van-form>
  47. </template>
  48. </div>
  49. </template>
  50. <script name="Login" setup>
  51. import { ref } from "vue";
  52. import { login } from "@/api/user";
  53. import { useRouter } from "vue-router";
  54. import { useUserStore, useAppStore } from "@/store";
  55. const router = useRouter();
  56. const appStore = useAppStore();
  57. const userStore = useUserStore();
  58. const account = ref("1509000120002");
  59. const password = ref("123456");
  60. const passwordShow = ref(false);
  61. const onSubmit = () => {
  62. login({ account: account.value, password: password.value }).then((res) => {
  63. if (res?.id) {
  64. userStore.setLoginInfo(res);
  65. router.push("/index");
  66. }
  67. });
  68. };
  69. const exit = () => {
  70. window.location.href = "about:blank";
  71. window.close();
  72. };
  73. </script>
  74. <style lang="less" scoped>
  75. .login {
  76. background-color: #fff !important;
  77. height: 100vh;
  78. .sys-disabled {
  79. height: 100%;
  80. display: flex;
  81. justify-content: center;
  82. align-items: center;
  83. background: #f0f0f0;
  84. }
  85. .title {
  86. font-size: 24px;
  87. font-weight: 600;
  88. color: #262626;
  89. padding-left: 24px;
  90. padding-top: 48px;
  91. }
  92. .sub-title {
  93. font-size: 16px;
  94. color: #8c8c8c;
  95. margin-top: 8px;
  96. padding-left: 24px;
  97. }
  98. .login-form {
  99. margin-top: 24px;
  100. }
  101. }
  102. </style>