登录流程bug修改
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
export default {
|
||||
// baseUrl: 'http://39.98.44.136:8080', // 测试
|
||||
// baseUrl: 'https://www.xjksly.cn/api/ks', // 正式环境
|
||||
baseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 测试
|
||||
baseUrl: 'https://www.xjksly.cn/api/ks', // 正式环境
|
||||
// baseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 测试
|
||||
|
||||
// LCBaseUrl:'http://10.110.145.145:9100',//内网端口
|
||||
// LCBaseUrlInner:'http://10.110.145.145:10100',//招聘、培训、帮扶
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -388,6 +388,24 @@ const wxLogin = () => {
|
||||
});
|
||||
// 登录成功后返回上一页
|
||||
uni.navigateBack();
|
||||
}).catch((error) => {
|
||||
// 只有在非企业用户且确实需要简历信息时才显示错误
|
||||
// 企业用户可能没有简历信息,这是正常的
|
||||
if (userType.value !== 0) {
|
||||
uni.showToast({
|
||||
title: '获取用户信息失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
} else {
|
||||
console.log('企业用户登录成功,简历信息可能为空');
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -439,12 +457,24 @@ const testLogin = () => {
|
||||
});
|
||||
// 登录成功后返回上一页
|
||||
uni.navigateBack();
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '获取用户信息失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}).catch((error) => {
|
||||
// 只有在非企业用户且确实需要简历信息时才显示错误
|
||||
// 企业用户可能没有简历信息,这是正常的
|
||||
if (userType.value !== 0) {
|
||||
uni.showToast({
|
||||
title: '获取用户信息失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
} else {
|
||||
console.log('企业用户测试登录成功,简历信息可能为空');
|
||||
uni.showToast({
|
||||
title: '测试登录成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
}).catch((err) => {
|
||||
uni.hideLoading();
|
||||
|
||||
@@ -191,7 +191,11 @@ function close() {
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
useUserStore().logOut();
|
||||
useUserStore().logOut(false); // 不显示登录弹窗
|
||||
// 跳转到首页
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}
|
||||
|
||||
const isAbove90 = (percent) => parseFloat(percent) < 90;
|
||||
|
||||
@@ -96,7 +96,13 @@ const useUserStore = defineStore("user", () => {
|
||||
similarityJobs.setUserInfo(resume.data)
|
||||
setUserInfo(resume);
|
||||
reslove(resume)
|
||||
}).catch(() => reject());
|
||||
}).catch((error) => {
|
||||
// 对于企业用户,简历接口可能失败,但这不应该阻止登录流程
|
||||
// 记录错误但不reject,让登录流程继续
|
||||
console.warn('获取简历信息失败,可能是企业用户或无简历信息:', error);
|
||||
// 返回一个空的简历对象,让登录流程继续
|
||||
reslove({ data: {} });
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user