Forráskód Böngészése

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

Xiao_123 10 hónapja
szülő
commit
dca5826926

+ 0 - 1
src/layout/personal/navBar.vue

@@ -154,7 +154,6 @@ const toEnterprise = async (enterpriseId) => {
   // 获取企业账号令牌以及企业用户个人信息
   await userStore.changeRole(enterpriseId)
   router.push({ path: '/recruit/enterprise' })
-  localStorage.setItem('loginType', 'enterprise')
 }
 
 // 查看用户是否有在申请中的数据

+ 8 - 0
src/router/modules/common.js

@@ -43,6 +43,14 @@ const common = [
     },
     component: () => import('@/views/recruit/enterprise/systemManagement/groupAccount/inviteConfirm.vue')
   },
+  {
+    path: '/enterpriseInvite',
+    name: 'enterpriseInvite',
+    meta: {
+      title: '成员邀请'
+    },
+    component: () => import('@/views/recruit/enterprise/systemManagement/groupAccount/inviteConfirmEnt.vue')
+  },
 ]
 
 export default common

+ 5 - 5
src/store/user.js

@@ -12,7 +12,7 @@ import { getBaseInfoDictOfName } from '@/utils/getText'
 export const useUserStore = defineStore('user',
   {
     state: () => ({
-      loginType: null, // 登录类型 // 330为企业登录
+      // loginType: null, // 登录类型 // 330为企业登录
       accountInfo: {}, // 登录返回的信息
       userInfo: {}, // 当前登录账号信息
       baseInfo: {}, // 人才信息
@@ -25,7 +25,7 @@ export const useUserStore = defineStore('user',
         return new Promise((resolve, reject) => {
           const loginApi = data.loginType === 330 ? smsLoginOfEnterprise : smsLogin
           loginApi(data).then(res => {
-            this.loginType = data.loginType
+            // this.loginType = data.loginType
             setToken(res.accessToken)
             setRefreshToken(res.refreshToken)
             this.accountInfo = res
@@ -33,7 +33,7 @@ export const useUserStore = defineStore('user',
             localStorage.setItem('expiresTime', res.expiresTime) // token过期时间
             localStorage.setItem('loginType', 'personal')
             this.getUserInfos()
-            if (!this.loginType) this.getUserBaseInfos()
+            this.getUserBaseInfos()
             resolve()
           }).catch(err => { reject(err) })
         })
@@ -43,7 +43,6 @@ export const useUserStore = defineStore('user',
         return new Promise((resolve, reject) => {
           const loginApi = data.loginType === 330 ? passwordLoginOfEnterprise : passwordLogin
           loginApi(data).then(res => {
-            this.loginType = data.loginType
             setToken(res.accessToken)
             setRefreshToken(res.refreshToken)
             this.accountInfo = res
@@ -51,7 +50,7 @@ export const useUserStore = defineStore('user',
             localStorage.setItem('expiresTime', res.expiresTime) // token过期时间
             localStorage.setItem('loginType', 'personal')
             this.getUserInfos()
-            if (!this.loginType) this.getUserBaseInfos()
+            this.getUserBaseInfos()
             resolve()
           }).catch(err => { reject(err) })
         })
@@ -116,6 +115,7 @@ export const useUserStore = defineStore('user',
         const data = await switchLoginOfEnterprise({ enterpriseId })
         setToken(data.accessToken)
         setRefreshToken(data.refreshToken)
+        localStorage.setItem('loginType', 'enterprise')
         localStorage.setItem('accountInfo', JSON.stringify(data))
         localStorage.setItem('expiresTime', data.expiresTime)
         localStorage.setItem('currentRole', 'enterprise')

+ 13 - 3
src/views/login/components/companySelect.vue

@@ -10,15 +10,25 @@
 import { ref } from 'vue'
 import autocompleteUI from '@/components/FormUI/autocomplete'
 defineOptions({ name: 'enterpriseLogin-companySelect' })
-const props = defineProps({ modelValue: String })
+const props = defineProps({
+  modelValue: String,
+  defaultSelect: {
+    type: Boolean,
+    default: false
+  },
+  list: {
+    type: Array,
+    default: () => []
+  }
+})
 const emit = defineEmits(['update:modelValue'])
 
 const value = ref(props.modelValue)
 
 // 企业登录
 // const companyList = JSON.parse(localStorage.getItem('companyInfo'))
-const companyList = []
-if (companyList?.length) {
+const companyList = props.list?.length ? [...props.list] : []
+if (props.defaultSelect && companyList?.length) {
   const id = companyList[0].enterpriseId
   value.value = id
   emit('update:modelValue', id)

+ 1 - 1
src/views/login/index.vue

@@ -180,7 +180,7 @@ const switchToPersonalLogin = () => {
   position: relative;
   width: 100%;
   height: 100%;
-  background-image: url('https://www.menduner.com/images/userfiles/92d7e4a755e2428b94aab3636d5047f3/images/recruitment/adImages/2018/11/1920x940.jpg');
+  background-image: url('https://www.mendunerhr.com/images/userfiles/92d7e4a755e2428b94aab3636d5047f3/images/recruitment/adImages/2018/11/1920x940.jpg');
   background-size: cover;
 }
 .login-content {

+ 6 - 4
src/views/recruit/enterprise/systemManagement/groupAccount/components/link.vue

@@ -1,7 +1,7 @@
 <!-- 发起邀请 -->
 <template>
   <div style="font-size: 14px;">
-    <div class="mt-5 color-777">将下面的公共邀请链接通过微信、00等任何方式发给同事,即可点击加入公司。请注意,用户同意后将自动加入到团队中,您需确保添加到的同事为同一公司招聘人员</div>
+    <div class="mt-5 color-777">将下面的公共邀请链接通过微信、QQ等任何方式发给同事,即可点击加入公司。请注意,用户同意后将自动加入到团队中,您需确保添加到的同事为同一公司招聘人员</div>
     <div class="mt-5 d-flex align-center">
       <div class="mr-5 shareUrlTxtBox">
         <span v-if="code">{{ shareUrlTxt }}</span>
@@ -25,16 +25,18 @@ import { computed, ref } from 'vue'
 defineOptions({name: 'groupAccount-component-invite'})
 const props = defineProps({
   inviteType: {
-    type: String,
-    default: '0' // 类型 (0 邀请同事 | 1 邀请子公司),示例值(2)
+    type: [Number, String],
+    default: 0 // 类型 (0 邀请同事 | 1 邀请子公司),示例值(2)
   }
 })
+const inviteType = props.inviteType - 0
 
 const day = 30
 const code = ref('')
 const accessUrl = import.meta.env.VITE_ACCESS_BASE_URL
 const shareUrlTxt = computed(() => {
-  return accessUrl + '/invite?code=' + code.value
+  const url = inviteType ? 'enterpriseInvite' : 'invite'
+  return accessUrl + `/${url}?code=${code.value}`
 })
 
 // 基本逻辑:是否已有邀请码?->

+ 1 - 1
src/views/recruit/enterprise/systemManagement/groupAccount/invite.vue

@@ -26,7 +26,7 @@ import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
 import { useRouter } from 'vue-router'; const router = useRouter()
 import { ref } from 'vue'
 defineOptions({name: 'groupAccount-invite'})
-const inviteType = ref(+router.currentRoute.value?.params?.type || 0) // 类型(0 邀请同事 | 1 邀请子公司)
+const inviteType = ref(+router.currentRoute.value?.params?.type - 0 || 0) // 类型(0 邀请同事 | 1 邀请子公司)
 const tabList = [
   { label: t('enterprise.userManagement.initiateInvitation'), value: 1 },
   { label: t('enterprise.userManagement.invitationRecord'), value: 2 },

+ 3 - 3
src/views/recruit/enterprise/systemManagement/groupAccount/inviteConfirm.vue

@@ -4,7 +4,7 @@
       <div class="invite-title">
         <!-- 门墩儿直聘用户史迪奇,邀请你加入【门墩儿科技有限公司】的招聘团 -->
         <!-- 【门墩儿直聘邀请】 -->
-        <div style="color: var(--v-primary-base);" class="mb-3">【门墩儿直聘】</div>
+        <div style="color: var(--v-primary-base);" class="mb-3">【门墩儿直聘企业邀请】</div>
         <div style="font-size: 24px">
           <span class="color-333">{{ enterpriseInfo.name }}</span>
           <span class="color-333"> 邀请您加入 </span>
@@ -59,6 +59,7 @@ const handleLogin = async () => {
     const params = { ...phoneRef.value.loginData } // 只能验证码登录
     await userStore.handleSmsLogin(params)
     await enterpriseInviteRecordConsent(code)
+    joinSuccess.value = true
     Snackbar.success('加入成功')
   } catch (error) {
     Snackbar.error('加入失败')
@@ -68,13 +69,12 @@ const handleLogin = async () => {
 }
 
 const enterpriseInfo = ref({})
-// 根据邀请码获取邀请用户信息
+// 根据邀请码获取企业信息
 const getEnterpriseInfo = async () => {
   try {
     const data = await getEnterpriseInfoByCode({ code })
     enterpriseInfo.value = data
   } catch (error) {
-    console.error('error', error)
     Snackbar.error('链接失效')
   }
 }

+ 153 - 0
src/views/recruit/enterprise/systemManagement/groupAccount/inviteConfirmEnt.vue

@@ -0,0 +1,153 @@
+<template>
+  <div style="background-color: #f0f0f0;">
+    <div class="inviteView text-center" :style="{'width': isMobile ? '100%' : '750px'}">
+      <div class="invite-title">
+        <div style="color: var(--v-primary-base);" class="mb-3">【门墩儿直聘集团邀请】</div>
+        <div style="font-size: 24px">
+          <span class="color-333">{{ enterpriseInfo.name }}</span>
+          <span class="color-333"> 邀请您加入 </span>
+          <span class="color-333">{{ enterpriseInfo.enterpriseName }}</span>
+        </div>
+      </div>
+      <div class="mt-10 d-flex flex-column align-center">
+        <template v-if="joinSuccess">
+          <div>加入成功!</div>
+          <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" @handleEnter="handleClick()" :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' }">
+              {{ $t('common.confirmJoin') }}
+            </v-btn>
+            <div class="mt-3" style="font-size: 13px;text-align: center;">
+              <div>注:请使用已经申请好的企业账户加入集团</div>
+            </div>
+          </div>
+        </template>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script setup>
+defineOptions({ name: 'inviteConfirmEnt'})
+import { ref, onMounted, reactive } 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 } from '@/api/personal/user'
+import companySelect from '@/views/login/components/companySelect.vue'
+import phoneFrom from '@/components/VerificationCode'
+import { setToken } from '@/utils/auth'
+import { smsLogin, logout, switchLoginOfEnterprise } from '@/api/common'
+
+const joinSuccess = ref(false)
+const code = route.query?.code || ''
+
+// 组件挂载后添加事件监听器  
+const isMobile = ref(false)
+onMounted(() => {
+  const userAgent = navigator.userAgent
+  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 handleConfirmJoin = async () => {
+  phoneParams = { ...phoneRef.value.loginData }
+  const { valid } = await phoneRef.value.phoneForm.validate()
+  if (!valid) return
+  loginLoading.value = true
+  try {
+    const res = await smsLogin(phoneParams)
+    setToken(res.accessToken)
+    getEnterpriseList()
+  } catch (error) {
+    Snackbar.error('查询用户数据失败')
+  } finally {
+    loginLoading.value = false
+  }
+}
+
+const companySelectRef = ref()
+const enterpriseList = ref([])
+const getEnterpriseList = async() => {
+  try {
+    loginLoading.value = true
+    enterpriseList.value = []
+    const data = await getUserBindEnterpriseList() // 申请通过才有数据,否则空数组
+    if (!data?.length) return Snackbar.warning('未查询到该用户下存在企业')
+    if (data.length > 1) {
+      showCompanySelect.value = true
+      enterpriseList.value = data
+    } else {
+      join(data[0].enterpriseId)
+    }
+  } catch (error) {
+    Snackbar.error('查询用户企业失败')
+  } finally {
+    loginLoading.value = false
+  }
+}
+
+// 执行加入操作
+const join = async (enterpriseId) => {
+  if (!enterpriseId) return Snackbar.warning('请选择要加入的企业')
+  if (enterpriseInfo.value?.id === enterpriseId) return Snackbar.error('您在尝试加入自己的企业邀请,此操作不被允许!')
+  try {
+    loginLoading.value = true
+    await logout() // changeRole // 先退出个人登录
+    const data = await switchLoginOfEnterprise({ enterpriseId })
+    setToken(data.accessToken)
+    localStorage.setItem('currentRole', 'enterprise')
+    await enterpriseInviteRecordConsent(code)
+    Snackbar.success('加入成功')
+    joinSuccess.value = true
+  } catch (error) {
+    Snackbar.error('加入失败! ' + error)
+  } finally {
+    loginLoading.value = false
+  }
+}
+
+const enterpriseInfo = ref({})
+// 根据邀请码获取企业信息
+const getEnterpriseInfo = async () => {
+  try {
+    const data = await getEnterpriseInfoByCode({ code })
+    enterpriseInfo.value = data
+  } catch (error) {
+    console.error('error', error)
+    Snackbar.error('链接失效')
+  }
+}
+getEnterpriseInfo()
+
+</script>
+
+<style scoped lang="scss">
+.inviteView {
+  min-height: 100vh;
+  display: block;
+  overflow: hidden;
+  margin: 0 auto;
+  padding: 45px;
+  background-color: #fff;
+}
+.invite-title {
+  font-size: 20px;
+  font-weight: 700;
+  color: var(--color-333);
+}
+</style>