This commit is contained in:
hanguangpu01
2025-12-18 18:02:26 +08:00
parent 4e5fa2a39b
commit 38313ee63b

View File

@@ -153,9 +153,9 @@
async function thirdLogin(){ async function thirdLogin(needToast){
let form={} let form={}
if (uni.getStorageSync('userInfo').isCompanyUser=='1') { if (uni.getStorageSync('userInfo') && uni.getStorageSync('userInfo').isCompanyUser=='1') {
form={ form={
usertype: '1', usertype: '1',
idno: uni.getStorageSync('userInfo').idCard, idno: uni.getStorageSync('userInfo').idCard,
@@ -165,7 +165,7 @@
contactperson: "", contactperson: "",
contactphone: "", contactphone: "",
} }
}else if (uni.getStorageSync('userInfo').isCompanyUser=='0') { }else if (uni.getStorageSync('userInfo') && uni.getStorageSync('userInfo').isCompanyUser=='0') {
form={ form={
usertype: "2", usertype: "2",
enterprisecode: uni.getStorageSync('userInfo').idCard, enterprisecode: uni.getStorageSync('userInfo').idCard,
@@ -176,10 +176,12 @@
name: "" name: ""
} }
}else{ }else{
uni.showToast({ if(needToast){
icon: 'none', uni.showToast({
title: '请先登录' icon: 'none',
}) title: '请先登录'
})
}
return false; return false;
} }
var resLogin = await $api.myRequest('/auth/login2/ks',form,'post',10100); var resLogin = await $api.myRequest('/auth/login2/ks',form,'post',10100);
@@ -213,7 +215,7 @@
}; };
async function goDetail(jobFairId){ async function goDetail(jobFairId){
if(await thirdLogin()){ if(await thirdLogin('1')){
if(state.current != 3){ if(state.current != 3){
navTo('/packageA/pages/exhibitors/exhibitors?jobFairId=' + jobFairId) navTo('/packageA/pages/exhibitors/exhibitors?jobFairId=' + jobFairId)
}else{ }else{
@@ -256,23 +258,28 @@
state.current = currented; state.current = currented;
} }
function seemsg(index) { async function seemsg(index) {
state.current = index; state.current = index;
if (index != 3) { if (index != 3) {
getFair("refresh"); getFair("refresh");
} else { } else {
if (!isLogin.value) {
getHeart(); if(await thirdLogin('1')){
return; if (!isLogin.value) {
} getHeart();
// 确保获取到用户信息后再请求“我参与的”列表 return;
if (!userInfo.value?.info?.userId) { }
getUser().then(() => { // 确保获取到用户信息后再请求“我参与的”列表
if (!userInfo.value?.info?.userId) {
getUser().then(() => {
getMyFair("refresh");
});
} else {
getMyFair("refresh"); getMyFair("refresh");
}); }
} else {
getMyFair("refresh");
} }
} }
} }
@@ -290,15 +297,21 @@
} }
}; };
function getHeart() { async function getHeart() {
const raw = uni.getStorageSync("Padmin-Token"); const raw = uni.getStorageSync("Padmin-Token");
const token = typeof raw === "string" ? raw.trim() : ""; const token = typeof raw === "string" ? raw.trim() : "";
var isLogins = await thirdLogin();
const headers = token ? { const headers = token ? {
Authorization: raw.startsWith("Bearer ") ? raw : `Bearer ${token}` Authorization: raw.startsWith("Bearer ") ? raw : `Bearer ${token}`
} : {}; } : {};
$api.myRequest("/dashboard/auth/heart", {}, "POST", 10100, headers).then((resData) => { $api.myRequest("/dashboard/auth/heart", {}, "POST", 10100, headers).then((resData) => {
if (resData.code == 200) { if (isLogins) {
isLogin.value = true; isLogin.value = true;
getUser(); getUser();
} else { } else {