登录流程bug修改
This commit is contained in:
@@ -68,8 +68,11 @@
|
||||
<script setup>
|
||||
import { ref, inject, computed, onMounted, onUnmounted } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import useUserStore from '@/stores/useUserStore';
|
||||
import { tabbarManager } from '@/utils/tabbarManager';
|
||||
|
||||
const { $api } = inject('globalFunction');
|
||||
const userStore = useUserStore();
|
||||
|
||||
// 从页面参数获取数据
|
||||
const phone = ref('');
|
||||
@@ -333,32 +336,51 @@ const submitVerification = async () => {
|
||||
const res = await $api.createRequest('/app/appLoginPhone', requestParams, 'post');
|
||||
|
||||
if (res.token && res.code === 200) {
|
||||
// 检查idCard是否为null,如果是则跳转到个人信息不全页面
|
||||
if (res.idCard) {
|
||||
uni.showToast({ title: '个人信息不全,请完善信息', icon: 'none' });
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({ url: '/pages/personal-info/incomplete' });
|
||||
}, 1500);
|
||||
return;
|
||||
}
|
||||
|
||||
// 登录成功,存储token
|
||||
const userStore = useUserStore();
|
||||
await userStore.loginSetToken(res.token);
|
||||
|
||||
// 更新用户类型到缓存
|
||||
if (res.isCompanyUser !== undefined) {
|
||||
const userInfo = uni.getStorageSync('userInfo') || {};
|
||||
userInfo.isCompanyUser = res.isCompanyUser ? 0 : 1;
|
||||
uni.setStorageSync('userInfo', userInfo);
|
||||
}
|
||||
|
||||
uni.showToast({ title: '登录成功', icon: 'success' });
|
||||
|
||||
// 返回上一页或跳转到首页
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({ delta: 2 }); // 返回两页(跳过登录页面)
|
||||
}, 1500);
|
||||
await userStore.loginSetToken(res.token).then((resume) => {
|
||||
// 更新用户类型到缓存
|
||||
if (res.isCompanyUser !== undefined) {
|
||||
const userInfo = uni.getStorageSync('userInfo') || {};
|
||||
userInfo.isCompanyUser = Number(res.isCompanyUser); // 0-企业用户,1-求职者
|
||||
uni.setStorageSync('userInfo', userInfo);
|
||||
}
|
||||
|
||||
uni.showToast({ title: '登录成功', icon: 'success' });
|
||||
|
||||
// 刷新tabbar以显示正确的用户类型
|
||||
tabbarManager.refreshTabBar();
|
||||
console.log(userType.value , res.isCompanyUser);
|
||||
console.log('用户登录成功,简历信息:', resume);
|
||||
if (!resume?.data?.jobTitleId) {
|
||||
if (!res.idCard) {
|
||||
if (userType.value === '1') {
|
||||
// 求职者跳转到个人信息补全页面
|
||||
uni.reLaunch({
|
||||
url: '/packageA/pages/complete-info/complete-info?step=1'
|
||||
});
|
||||
} else if (userType.value === '0') {
|
||||
// 招聘者跳转到企业信息补全页面
|
||||
uni.reLaunch({
|
||||
url: '/packageA/pages/complete-info/company-info'
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('用户登录成功,有简历信息');
|
||||
// 跳转到首页
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
// 只有在非企业用户且确实需要简历信息时才显示错误
|
||||
// 企业用户可能没有简历信息,这是正常的
|
||||
if (userType.value !== '0') {
|
||||
uni.showToast({ title: '获取用户信息失败', icon: 'none' });
|
||||
} else {
|
||||
console.log('企业用户登录成功,简历信息可能为空');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '验证失败', icon: 'none' });
|
||||
}
|
||||
@@ -379,8 +401,7 @@ onUnmounted(() => {
|
||||
clearInterval(timer.value);
|
||||
});
|
||||
|
||||
// 需要导入useUserStore
|
||||
import useUserStore from '@/stores/useUserStore';
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
|
||||
Reference in New Issue
Block a user