123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <template>
- <div class="login-box">
- <div class="login-content">
- <div class="text-end pr-5 pt-5">
- <span class="color-error cursor-pointer text-decoration-underline" @click="router.push('/register/selected')">还没有登录账户?去注册</span>
- </div>
- <div class="login-content-box mb-10">
- <div class="login-tab">
- <v-tabs v-model="tab" align-tabs="center" color="primary" class="mb-10">
- <v-tab :value="1">验证码</v-tab>
- <v-tab :value="2">账号</v-tab>
- <v-tab :value="3">二维码</v-tab>
- </v-tabs>
- <v-window v-model="tab">
- <!-- 验证码登录 -->
- <v-window-item :value="1">
- <phoneFrom ref="phoneRef" @handleEnter="handleLogin"></phoneFrom>
- </v-window-item>
- <!-- 账号密码登录 -->
- <v-window-item :value="2">
- <passwordFrom ref="passRef" @handleEnter="handleLogin"></passwordFrom>
- </v-window-item>
- <v-window-item :value="3">
- <div class="d-flex align-center flex-column">
- <span class="text-decoration-underline">微信扫描二维码进行登录</span>
- <v-img src="https://minio.citupro.com/dev/menduner/login-qrCode.png" width="150" height="150"></v-img>
- </div>
- </v-window-item>
- </v-window>
- </div>
- <div class="font-size-14 tips">
- <span class="float-left color-666 cursor-pointer" v-if="tab === 2" @click="router.push('/forgotPassword')">忘记密码</span>
- </div>
- <v-btn :loading="loginLoading" color="primary" class="white--text mt-5" min-width="350" @click="handleLogin">
- {{ $t('login.login') }}
- </v-btn>
- <div class="login-tips mt-3">
- {{ $t('login.agreeLogin') }}
- <span class="color" style="cursor: pointer;" @click="handleToUserAgreement"> [{{ $t('login.userAgreement') }}] </span>和
- <span class="color" style="cursor: pointer;" @click="handlePrivacyPolicy">[{{ $t('login.privacyPolicy') }}]</span>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { ref } from 'vue'
- import passwordFrom from './components/passwordPage.vue'
- import phoneFrom from '@/components/VerificationCode'
- import { useUserStore } from '@/store/user'
- import { useRouter } from 'vue-router'
- import { useI18n } from '@/hooks/web/useI18n'
- import Snackbar from '@/plugins/snackbar'
- defineOptions({ name: 'login-index' })
- const { t } = useI18n()
- const router = useRouter()
- const tab = ref(1)
- // 验证码登录
- const phoneRef = ref()
- const passRef = ref()
- const loginLoading = ref(false)
- const userStore = useUserStore()
- const handleLogin = async () => {
- const { valid } = tab.value === 1 ? await phoneRef.value.phoneForm.validate() : await passRef.value.passwordForm.validate()
- if (!valid) return
- loginLoading.value = true
- try {
- let params, api = {}
- if (tab.value === 1) { params = { ...phoneRef.value.loginData }; api = 'handleSmsLogin'}
- else { params = { ...passRef.value.loginData }; api = 'handlePasswordLogin'}
-
- // 邮箱为企业招聘, 手机号为个人求职
- if (tab.value === 2) {
- const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
- const isEnterprise = pattern.test(params.phone)
- params.isEnterprise = isEnterprise
- }
- // if (params.isEnterprise) router.push({ path: '/enterpriseVerification' }) // 先跳转到会使用企业token的路由
- await userStore[api](params)
- // 跳转
- if (params.isEnterprise) return // 企业邮箱登录
- Snackbar.success(t('login.loginSuccess'))
- router.push({ path: '/recruitHome' })
- }
- finally {
- loginLoading.value = false
- }
- }
- // 隐私、用户协议
- const handleToUserAgreement = () => {
- router.push({ path: '/userAgreement' })
- }
- const handlePrivacyPolicy = () => {
- router.push({ path: '/privacyPolicy' })
- }
- </script>
- <style lang="scss" scoped>
- .login-box {
- position: relative;
- width: 100%;
- height: 100%;
- background-image: url('https://www.mendunerhr.com/images/userfiles/92d7e4a755e2428b94aab3636d5047f3/images/recruitment/adImages/2018/11/1920x940.jpg');
- background-size: cover;
- }
- .login-content {
- position: absolute;
- top: 50%;
- left: 50%;
- translate: -50% -50%;
- width: 450px;
- background-color: #fff;
- border-radius: 10px;
- }
- .login-content-box {
- padding: 0 50px;
- }
- .left {
- display: flex;
- }
- .login-tips {
- width: 100%;
- font-size: 12px;
- text-align: center;
- }
- .tips {
- span:hover {
- text-decoration: underline;
- }
- }
- .color {
- color: var(--v-primary-base);
- }
- </style>
|