index.vue 4.2 KB

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