Login.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <script setup lang="ts">
  2. import { appName, openRegisration } from "@/env";
  3. import { ref, computed, onMounted } from "vue";
  4. import { useMainStore } from "@/stores/main";
  5. import { useDisplay } from "vuetify";
  6. import { storeToRefs } from "pinia";
  7. import { useI18n } from "vue-i18n";
  8. import Navbar from "@/components/Navbar.vue";
  9. const mainStore = useMainStore();
  10. const mainStoreRef = storeToRefs(mainStore);
  11. // variable
  12. const email = ref("");
  13. const password = ref("");
  14. const { name } = useDisplay();
  15. const { t } = useI18n();
  16. let showPassword = ref(false);
  17. // getter
  18. const loginError = mainStoreRef.readLoginError;
  19. const width = computed(() => {
  20. // name is reactive and
  21. // must use .value
  22. switch (name.value) {
  23. case "xs":
  24. return 12;
  25. case "sm":
  26. return 12;
  27. // case "md":
  28. // return 6;
  29. }
  30. return 6;
  31. });
  32. // action
  33. function submit() {
  34. mainStore.logIn(email.value, password.value);
  35. }
  36. // lifecycle
  37. onMounted(() => {});
  38. </script>
  39. <template>
  40. <Navbar />
  41. <v-container fluid class="pa-0">
  42. <v-row align="center" no-gutters class="overflow-hidden">
  43. <v-col :cols="width">
  44. <section class="overflow-hidden banner-item">
  45. <img src="../assets/img/banner.png" alt="" />
  46. <h2>
  47. {{ t("describe_1") }}
  48. <br />
  49. {{ t("describe_2") }}
  50. </h2>
  51. </section>
  52. </v-col>
  53. <v-col :cols="width" class="px-6 my-8 my-md-0">
  54. <div class="form-title">
  55. <h3>{{ t("login") }}</h3>
  56. <span></span>
  57. </div>
  58. <v-form ref="form" class="login-form" lazy-validation>
  59. <v-text-field
  60. v-model="email"
  61. name="email"
  62. prepend-icon="person"
  63. :rules="[(v) => !!v || '請輸入您的帳號']"
  64. :label="$t('emailAddress')"
  65. required
  66. ></v-text-field>
  67. <v-text-field
  68. v-model="password"
  69. name="password"
  70. id="password"
  71. prepend-icon="key"
  72. :append-icon="showPassword ? 'visibility' : 'visibility_off'"
  73. :rules="[(v) => !!v || '請輸入您的密碼']"
  74. :type="showPassword ? 'text' : 'password'"
  75. :label="$t('password')"
  76. hint="4-12 位數密碼"
  77. @click:append="showPassword = !showPassword"
  78. required
  79. ></v-text-field>
  80. <p class="text-center">
  81. <<<<<<< HEAD
  82. 還沒有帳號?
  83. <router-link to="/signup">註冊</router-link> / <router-link
  84. to="/recover-password"
  85. >忘記密碼</router-link
  86. >
  87. =======
  88. {{ t("haventAccount") }}
  89. <router-link to="/signup">{{ t("register") }}</router-link
  90. > / <router-link to="/recover-password">{{
  91. t("forgotPsd")
  92. }}</router-link>
  93. >>>>>>> choozmo/front-dev
  94. </p>
  95. <v-btn
  96. rounded="pill"
  97. color="primary"
  98. @click.prevent="submit"
  99. class="login-btn"
  100. >
  101. {{ t("loginLink") }}
  102. </v-btn>
  103. </v-form>
  104. </v-col>
  105. </v-row>
  106. </v-container>
  107. <<<<<<< HEAD
  108. =======
  109. >>>>>>> choozmo/front-dev
  110. </template>