进入页面bug修复

This commit is contained in:
zhanchao 2026-08-18 18:13:39 +08:00
parent fe7583017d
commit 57803051e1

View File

@ -87,7 +87,7 @@ function cacheCurrentTeam(currentTeam) {
function isSameTeam(candidate, target = {}) {
const targetTeamId = target.teamId || "";
if (!candidate || !candidate.teamId || candidate.teamId !== targetTeamId) return false;
if (!candidate || !candidate.teamId || String(candidate.teamId) !== String(targetTeamId)) return false;
const targetCorpId = normalizeCorpId(target.corpId || "");
if (!targetCorpId) return true;
@ -99,13 +99,13 @@ function isSameTeam(candidate, target = {}) {
async function changeTeam({ teamId, corpId, corpName }) {
loading.value = true;
try {
const res = await api("getTeamData", { teamId, corpId });
const res = await api("getTeamData", { teamId, corpId, withCorpName: true });
if (res && res.data) {
team.value = {
...res.data,
corpId: normalizeCorpId(res.data.corpId || corpId),
};
team.value.corpName = corpName;
team.value.corpName = corpName || res.data.corpName || res.data.corp_name || "";
cacheCurrentTeam(team.value);
return team.value;
}
@ -168,23 +168,40 @@ function buildArchiveBindUrl(action) {
].join("&");
}
async function syncPendingExternalUser(action) {
if (!action?.externalUserId || !account.value?.openid || !action.corpId) return;
try {
await api("syncWxappExternalUserRelation", {
corpId: action.corpId,
externalUserId: action.externalUserId,
unionid: action.unionid || account.value.unionid || "",
openid: account.value.openid,
corpUserId: action.corpUserId || "",
}, false);
} catch (error) {
console.warn("同步外部联系人关系失败", error);
}
}
async function continuePendingAction() {
const action = pendingAction.value;
if (!action || !account.value?.openid || !team.value?.teamId) return;
if (action.teamId && action.teamId !== team.value.teamId) {
if (action.teamId && String(action.teamId) !== String(team.value.teamId)) {
toast("未找到目标服务团队");
pendingAction.value = null;
return;
}
await syncPendingExternalUser(action);
const customerId = action.memberId || action.customerId;
const customerRes = await api(
"getCustomerByCustomerId",
{ corpId: action.corpId, customerId },
false
);
const customer = customerRes?.success ? customerRes.data : null;
const customer = customerRes?.data || null;
if (!customer) {
toast(customerRes?.message || "目标档案不存在");
pendingAction.value = null;
@ -220,17 +237,33 @@ async function getMatchTeams(inviteTeam = null) {
});
let validTeam = teams.value.find(i => isSameTeam(i, targetIdentity));
if (!validTeam && pendingAction.value && targetIdentity.teamId && account.value?.openid) {
const bindRes = await api("bindWxappWithTeam", {
appid,
corpId: targetIdentity.corpId,
teamId: targetIdentity.teamId,
openid: account.value.openid,
});
if (bindRes?.success) {
if (pendingAction.value && targetIdentity.teamId && account.value?.openid) {
if (!validTeam) {
const bindRes = await api("bindWxappWithTeam", {
appid,
corpId: targetIdentity.corpId,
teamId: targetIdentity.teamId,
openid: account.value.openid,
});
if (!bindRes?.success) {
toast(bindRes?.message || "关联医生团队失败");
team.value = null;
return null;
}
teams.value = await getTeams();
validTeam = teams.value.find(i => isSameTeam(i, targetIdentity));
}
// 使
const targetTeam = await changeTeam({
...targetIdentity,
corpName: validTeam?.corpName || "",
});
if (targetTeam) {
teams.value = teams.value.length ? teams.value : [targetTeam];
return targetTeam;
}
return null;
}
const firstTeam = teams.value[0];
@ -252,7 +285,6 @@ async function getMatchTeams(inviteTeam = null) {
onLoad((options = {}) => {
pendingAction.value = parsePendingAction(options);
if (!account.value) login();
})
onShow(async () => {