lifanagju_citu 8 mesiacov pred
rodič
commit
57ba5d3574

+ 8 - 4
src/permission.js

@@ -18,16 +18,20 @@ router.beforeEach(async (to, from, next) => {
   start()
   // loadStart()
   if (to.path === '/enterpriseVerification') {
-    useUserStore().changeRole()
+    const res = JSON.parse(localStorage.getItem('emailLoginInfo') || "false")
+    const obj = res ? { ...res, type: 'emailLogin' } : {}
+    useUserStore().changeRole(obj)
     next()
   } else if (getToken(tokenIndex)) {
     // 企业信息完成度提示
     if (localStorage.getItem('checkEnterpriseBaseInfoFalseHref')) {
       const href = localStorage.getItem('checkEnterpriseBaseInfoFalseHref')
       localStorage.setItem('checkEnterpriseBaseInfoFalseHref', '')
-      Confirm('系统提示', '企业信息设置未完善,是否前往完善?').then(() => {
-        window.location.href = href
-      })
+      setTimeout(() => {
+        Confirm('系统提示', '企业信息设置未完善,是否前往完善?').then(() => {
+          window.location.href = href
+        })
+      }, 4000);
     }
     if (to.path === '/login') {
       next({ path: '/recruitHome' })

+ 7 - 5
src/store/user.js

@@ -56,8 +56,10 @@ export const useUserStore = defineStore('user',
           data.account = data.phone
           passwordLogin(data).then(res => {
             if (data.isEnterprise) { // 企业邮箱登录
-              this.changeRole('emailLogin', res)
+              localStorage.setItem('emailLoginInfo', JSON.stringify(res))
+              window.location.href = '/enterpriseVerification'
             } else {
+              // 个人手机号登录
               setToken(res.accessToken)
               setRefreshToken(res.refreshToken)
               this.accountInfo = res
@@ -122,9 +124,9 @@ export const useUserStore = defineStore('user',
         localStorage.clear()
       },
       // 切换为招聘者
-      async changeRole (type, res) {
+      async changeRole (res) {
         let data
-        if (type === 'emailLogin') {
+        if (res?.type === 'emailLogin') {
           data = res
         } else {
           // 先退出个人登录
@@ -140,9 +142,9 @@ export const useUserStore = defineStore('user',
         await this.getEnterpriseInfo()
         await this.getEnterpriseUserAccountInfo()
         updateEventList(false)
-        Snackbar.success('切换成功')
+        Snackbar.success(res?.type === 'emailLogin' ? '登录成功' : '切换成功')
         await this.checkEnterpriseBaseInfo() // 校验企业必填信息
-        window.location.href = '/enterprise'
+        setTimeout(() => { window.location.href = '/enterprise' }, 1000)
       },
       // 获取当前登录的企业用户信息
       async getEnterpriseInfo () {

+ 2 - 0
src/views/login/components/passwordPage.vue

@@ -72,6 +72,8 @@ const loginData = reactive({
 
 // 设置默认账号密码便于开发快捷登录
 if (window.location.hostname === 'localhost' || window.location.hostname === '192.168.3.152') {
+  // loginData.phone = '18400000022@qq.com'
+  // loginData.password = '12345678'
   loginData.phone = '13229740092'
   loginData.password = 'Citu123456'
 }

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

@@ -79,7 +79,7 @@ const handleLogin = async () => {
       const isEnterprise = pattern.test(params.phone)
       params.isEnterprise = isEnterprise
     }
-    if (params.isEnterprise) router.push({ path: '/enterpriseVerification' }) // 先跳转到会使用企业token的路由
+    // if (params.isEnterprise) router.push({ path: '/enterpriseVerification' }) // 先跳转到会使用企业token的路由
     await userStore[api](params)
     // 跳转
     if (params.isEnterprise) return // 企业邮箱登录