|
@@ -18,16 +18,18 @@
|
|
|
<v-btn class="mt-10" color="warning" to="/recruitHome">{{ $t('common.toHome') }}</v-btn>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
- <div v-if="showCompanySelect">
|
|
|
- <companySelect ref="companySelectRef" :list="enterpriseList" v-model="enterpriseId"></companySelect>
|
|
|
- <v-btn :loading="loginLoading" color="warning" class="white--text mt-3" min-width="350" @click="join(enterpriseId)" :style="{'width': isMobile ? '100%' : '350px' }">
|
|
|
- {{ $t('common.confirm') }}
|
|
|
- </v-btn>
|
|
|
- </div>
|
|
|
- <div v-show="!showCompanySelect">
|
|
|
- <phoneFrom ref="phoneRef" openVerify @verifySuccess="handleConfirmJoin" :style="{'width': isMobile ? '100%' : '350px' }"></phoneFrom>
|
|
|
- <v-btn :loading="loginLoading" color="warning" class="white--text mt-3" min-width="350" @click="handleConfirmJoin" :style="{'width': isMobile ? '100%' : '350px' }">
|
|
|
- {{ quickRegister ? $t('login.register') : $t('common.confirmJoin') }}
|
|
|
+ <div>
|
|
|
+ <div style="font-size: 13px;text-align: left;" class="mb-2"><span style="color: red;">*</span> 请输入要加入的企业邮箱及密码</div>
|
|
|
+ <passwordFrom
|
|
|
+ ref="entPassRef"
|
|
|
+ placeholder="请输入企业邮箱"
|
|
|
+ :isCounter="true"
|
|
|
+ :validEmail="true"
|
|
|
+ style="text-align: left;"
|
|
|
+ @handleEnter="handleLogin"
|
|
|
+ ></passwordFrom>
|
|
|
+ <v-btn :loading="loginLoading" color="warning" class="white--text mt-3" min-width="350" @click="handleLogin" :style="{'width': isMobile ? '100%' : '350px' }">
|
|
|
+ {{ $t('common.confirmJoin') }}
|
|
|
</v-btn>
|
|
|
<div class="mt-3" style="font-size: 13px;text-align: center;">
|
|
|
<div>注:请使用已经申请好的企业账户加入集团</div>
|
|
@@ -51,20 +53,30 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <Verify
|
|
|
+ ref="verify"
|
|
|
+ captchaType="blockPuzzle"
|
|
|
+ :imgSize="{ width: '400px', height: '200px' }"
|
|
|
+ mode="pop"
|
|
|
+ @success="verifySuccess"
|
|
|
+ />
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
defineOptions({ name: 'inviteConfirmEnt'})
|
|
|
import { useRouter } from 'vue-router'; const router = useRouter()
|
|
|
-import { ref, onMounted, reactive } from 'vue'
|
|
|
+import { ref, onMounted } from 'vue'
|
|
|
import { useRoute } from 'vue-router'; const route = useRoute()
|
|
|
import { enterpriseInviteRecordConsent, getEnterpriseInfoByCode } from '@/api/recruit/enterprise/enterpriseInvite.js'
|
|
|
import Snackbar from '@/plugins/snackbar'
|
|
|
-import { getUserBindEnterpriseList, getUserRegisterEnterpriseApply } from '@/api/personal/user'
|
|
|
-import companySelect from '@/views/login/components/companySelect.vue'
|
|
|
-import phoneFrom from '@/components/VerificationCode'
|
|
|
-import { getToken, setToken, setRefreshToken } from '@/utils/auth'
|
|
|
-import { smsLogin, logout, switchLoginOfEnterprise, logoutToken } from '@/api/common'
|
|
|
+import passwordFrom from '@/views/login/components/passwordPage.vue'
|
|
|
+import Verify from '@/components/Verifition'
|
|
|
+import { getToken } from '@/utils/auth'
|
|
|
+import { useUserStore } from '@/store/user'
|
|
|
+import {
|
|
|
+ logoutToken,
|
|
|
+ passwordLogin
|
|
|
+} from '@/api/common'
|
|
|
|
|
|
const joinSuccess = ref(false)
|
|
|
const code = route.query?.code || ''
|
|
@@ -76,85 +88,74 @@ onMounted(() => {
|
|
|
isMobile.value = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(userAgent)
|
|
|
})
|
|
|
|
|
|
-const phoneRef = ref()
|
|
|
-const loginLoading = ref(false)
|
|
|
-const showCompanySelect = ref(false)
|
|
|
-let phoneParams = reactive({})
|
|
|
-const enterpriseId = ref('')
|
|
|
+const entPassRef = ref()
|
|
|
+// 获取验证码
|
|
|
+const verify = ref()
|
|
|
+const getCode = async () => {
|
|
|
+ // 弹出验证码 // 已开启:则展示验证码;只有完成验证码的情况,才进行登录
|
|
|
+ verify.value.show()
|
|
|
+}
|
|
|
+const captchaStr = ref('')
|
|
|
+const verifySuccess = (params) => {
|
|
|
+ captchaStr.value = params.captchaVerification
|
|
|
+ handleLogin()
|
|
|
+}
|
|
|
|
|
|
-const handleConfirmJoin = async () => {
|
|
|
- phoneParams = { ...phoneRef.value.loginData }
|
|
|
- const { valid } = await phoneRef.value.phoneForm.validate()
|
|
|
+// const entBaseInfo = ref()
|
|
|
+// // 获取当前登录的企业用户信息
|
|
|
+// const getLoginEnterpriseInfo = async () => {
|
|
|
+// try {
|
|
|
+// const result = await getEnterprisingUserInfo()
|
|
|
+// entBaseInfo.value = result
|
|
|
+
|
|
|
+// // 是否为企业账号管理员
|
|
|
+// // const isAdmin = result.userType === '1'
|
|
|
+// } catch (error) {
|
|
|
+// console.error('error', error)
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+const loginLoading = ref(false)
|
|
|
+const handleLogin = async () => {
|
|
|
+ const { valid } = await entPassRef.value.passwordForm.validate()
|
|
|
if (!valid) return
|
|
|
- if (!phoneParams.captchaVerification) {
|
|
|
- phoneRef.value.getCode(true)
|
|
|
+ const params = {
|
|
|
+ ...entPassRef.value.loginData,
|
|
|
+ captchaVerification: captchaStr.value,
|
|
|
+ isEnterprise: true,
|
|
|
+ }
|
|
|
+ params.account = params.phone
|
|
|
+
|
|
|
+ if (!params.captchaVerification) {
|
|
|
+ getCode() // 验证码组件
|
|
|
return
|
|
|
}
|
|
|
loginLoading.value = true
|
|
|
try {
|
|
|
- const res = await smsLogin(phoneParams)
|
|
|
- setToken(res.accessToken)
|
|
|
- setRefreshToken(res.refreshToken)
|
|
|
- quickRegister.value ? getApplyInfo() : getEnterpriseList()
|
|
|
- } catch (error) {
|
|
|
- phoneRef.value && phoneRef.value.clearCaptcha()
|
|
|
- Snackbar.error(error?.msg || error)
|
|
|
- } finally {
|
|
|
- loginLoading.value = false
|
|
|
- }
|
|
|
-}
|
|
|
+ const res = await passwordLogin(params)
|
|
|
+ const obj = res ? { ...res, type: 'emailLogin', onlySetToken: true } : {}
|
|
|
+ await useUserStore().changeRole(obj)
|
|
|
+ await join()
|
|
|
|
|
|
-const companySelectRef = ref()
|
|
|
-const enterpriseList = ref([])
|
|
|
-const getEnterpriseList = async() => {
|
|
|
- try {
|
|
|
- loginLoading.value = true
|
|
|
- enterpriseList.value = []
|
|
|
- const data = await getUserBindEnterpriseList() // 申请通过才有数据,否则空数组
|
|
|
- if (!data?.length) {
|
|
|
- // Snackbar.warning('未查询到该用户下存在企业')
|
|
|
- getApplyInfo()
|
|
|
- return
|
|
|
- }
|
|
|
- if (data.length > 1) {
|
|
|
- showCompanySelect.value = true
|
|
|
- enterpriseList.value = data
|
|
|
- } else {
|
|
|
- join(data[0].enterpriseId)
|
|
|
- }
|
|
|
} catch (error) {
|
|
|
Snackbar.error(error?.msg || error)
|
|
|
- logoutFun()
|
|
|
} finally {
|
|
|
+ captchaStr.value = ''
|
|
|
loginLoading.value = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 查看用户是否有在申请中的数据
|
|
|
-const getApplyInfo = async () => {
|
|
|
- const data = await getUserRegisterEnterpriseApply()
|
|
|
- const bool = data && Object.keys(data).length // 已经有数据说明已经申请过了
|
|
|
- const path = bool ? '/recruit/entRegister/inReview' : '/recruit/entRegister'
|
|
|
- router.push({ path })
|
|
|
- if (!bool) Snackbar.warning('未查询到该用户下存在企业,请优先提交企业申请')
|
|
|
-}
|
|
|
-
|
|
|
// 执行加入操作
|
|
|
-const join = async (enterpriseId) => {
|
|
|
- if (!enterpriseId) return Snackbar.warning('请选择要加入的企业')
|
|
|
- if (enterpriseInfo.value?.id === enterpriseId) return Snackbar.error('您在尝试加入自己的企业邀请,此操作不被允许!')
|
|
|
+const join = async () => {
|
|
|
try {
|
|
|
loginLoading.value = true
|
|
|
- await logout() // changeRole // 先退出个人登录
|
|
|
- const data = await switchLoginOfEnterprise({ enterpriseId })
|
|
|
- setToken(data.accessToken)
|
|
|
- await enterpriseInviteRecordConsent(code)
|
|
|
+ await enterpriseInviteRecordConsent({ code })
|
|
|
Snackbar.success('加入成功')
|
|
|
joinSuccess.value = true
|
|
|
} catch (error) {
|
|
|
- phoneRef.value && phoneRef.value.clearCaptcha()
|
|
|
Snackbar.error(error?.msg || error)
|
|
|
} finally {
|
|
|
+ captchaStr.value = ''
|
|
|
loginLoading.value = false
|
|
|
logoutFun()
|
|
|
}
|
|
@@ -162,7 +163,7 @@ const join = async (enterpriseId) => {
|
|
|
|
|
|
const quickRegister = ref(false)
|
|
|
const handleRegister = () => {
|
|
|
- quickRegister.value = true
|
|
|
+ router.push('/register/selected')
|
|
|
}
|
|
|
|
|
|
const logoutFun = async () => {
|