index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="login-box">
  3. <div class="login-content">
  4. <div class="text-end pr-5 pt-5">
  5. <span class="color-error cursor-pointer text-decoration-underline" @click="router.push('/register/selected')">还没有登录账户?去注册</span>
  6. </div>
  7. <div class="login-content-box mb-10">
  8. <div class="login-tab">
  9. <v-tabs v-model="tab" align-tabs="center" color="primary" class="mb-10">
  10. <v-tab :value="1">验证码</v-tab>
  11. <v-tab :value="2">账号</v-tab>
  12. <v-tab :value="3">二维码</v-tab>
  13. </v-tabs>
  14. <v-window v-model="tab">
  15. <!-- 验证码登录 -->
  16. <v-window-item :value="1">
  17. <phoneFrom ref="phoneRef" @handleEnter="handleLogin"></phoneFrom>
  18. </v-window-item>
  19. <!-- 账号密码登录 -->
  20. <v-window-item :value="2">
  21. <passwordFrom ref="passRef" @handleEnter="handleLogin"></passwordFrom>
  22. </v-window-item>
  23. <v-window-item :value="3">
  24. <div class="d-flex align-center flex-column">
  25. <span class="text-decoration-underline">微信扫描二维码进行登录</span>
  26. <v-img src="https://minio.citupro.com/dev/menduner/login-qrCode.png" width="150" height="150"></v-img>
  27. </div>
  28. </v-window-item>
  29. </v-window>
  30. </div>
  31. <div class="font-size-14 tips">
  32. <span class="float-left color-666 cursor-pointer" v-if="tab === 2" @click="router.push('/forgotPassword')">忘记密码</span>
  33. </div>
  34. <v-btn :loading="loginLoading" color="primary" class="white--text mt-5" min-width="350" @click="handleLogin">
  35. {{ $t('login.login') }}
  36. </v-btn>
  37. <div class="login-tips mt-3">
  38. {{ $t('login.agreeLogin') }}
  39. <span class="color" style="cursor: pointer;" @click="handleToUserAgreement"> [{{ $t('login.userAgreement') }}] </span>和
  40. <span class="color" style="cursor: pointer;" @click="handlePrivacyPolicy">[{{ $t('login.privacyPolicy') }}]</span>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script setup>
  47. import { ref } from 'vue'
  48. import passwordFrom from './components/passwordPage.vue'
  49. import phoneFrom from '@/components/VerificationCode'
  50. import { useUserStore } from '@/store/user'
  51. import { useRouter } from 'vue-router'
  52. import { useI18n } from '@/hooks/web/useI18n'
  53. import Snackbar from '@/plugins/snackbar'
  54. defineOptions({ name: 'login-index' })
  55. const { t } = useI18n()
  56. const router = useRouter()
  57. const tab = ref(1)
  58. // 验证码登录
  59. const phoneRef = ref()
  60. const passRef = ref()
  61. const loginLoading = ref(false)
  62. const userStore = useUserStore()
  63. const handleLogin = async () => {
  64. const { valid } = tab.value === 1 ? await phoneRef.value.phoneForm.validate() : await passRef.value.passwordForm.validate()
  65. if (!valid) return
  66. loginLoading.value = true
  67. try {
  68. let params, api = {}
  69. if (tab.value === 1) { params = { ...phoneRef.value.loginData }; api = 'handleSmsLogin'}
  70. else { params = { ...passRef.value.loginData }; api = 'handlePasswordLogin'}
  71. await userStore[api](params)
  72. Snackbar.success(t('login.loginSuccess'))
  73. router.push({ path: '/recruitHome' })
  74. }
  75. finally {
  76. loginLoading.value = false
  77. }
  78. }
  79. // 隐私、用户协议
  80. const handleToUserAgreement = () => {
  81. router.push({ path: '/userAgreement' })
  82. }
  83. const handlePrivacyPolicy = () => {
  84. router.push({ path: '/privacyPolicy' })
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .loginType {
  89. position: absolute;
  90. top: 16px;
  91. right: 0;
  92. color: #fff;
  93. padding: 4px 15px 4px 32px;
  94. border-radius: 8px 0 0 8px;
  95. background-color: #fa9c3e;
  96. font-size: 16px;
  97. }
  98. .login-box {
  99. position: relative;
  100. width: 100%;
  101. height: 100%;
  102. background-image: url('https://www.mendunerhr.com/images/userfiles/92d7e4a755e2428b94aab3636d5047f3/images/recruitment/adImages/2018/11/1920x940.jpg');
  103. background-size: cover;
  104. }
  105. .login-content {
  106. position: absolute;
  107. top: 50%;
  108. left: 50%;
  109. translate: -50% -50%;
  110. width: 450px;
  111. background-color: #fff;
  112. border-radius: 10px;
  113. }
  114. .login-content-box {
  115. padding: 0 50px;
  116. }
  117. .left {
  118. display: flex;
  119. }
  120. .login-tips {
  121. width: 100%;
  122. font-size: 12px;
  123. text-align: center;
  124. }
  125. .tips {
  126. span:hover {
  127. text-decoration: underline;
  128. }
  129. }
  130. .color {
  131. color: var(--v-primary-base);
  132. }
  133. </style>