进入页面bug修复
This commit is contained in:
parent
fe7583017d
commit
57803051e1
@ -87,7 +87,7 @@ function cacheCurrentTeam(currentTeam) {
|
|||||||
|
|
||||||
function isSameTeam(candidate, target = {}) {
|
function isSameTeam(candidate, target = {}) {
|
||||||
const targetTeamId = target.teamId || "";
|
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 || "");
|
const targetCorpId = normalizeCorpId(target.corpId || "");
|
||||||
if (!targetCorpId) return true;
|
if (!targetCorpId) return true;
|
||||||
@ -99,13 +99,13 @@ function isSameTeam(candidate, target = {}) {
|
|||||||
async function changeTeam({ teamId, corpId, corpName }) {
|
async function changeTeam({ teamId, corpId, corpName }) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const res = await api("getTeamData", { teamId, corpId });
|
const res = await api("getTeamData", { teamId, corpId, withCorpName: true });
|
||||||
if (res && res.data) {
|
if (res && res.data) {
|
||||||
team.value = {
|
team.value = {
|
||||||
...res.data,
|
...res.data,
|
||||||
corpId: normalizeCorpId(res.data.corpId || corpId),
|
corpId: normalizeCorpId(res.data.corpId || corpId),
|
||||||
};
|
};
|
||||||
team.value.corpName = corpName;
|
team.value.corpName = corpName || res.data.corpName || res.data.corp_name || "";
|
||||||
cacheCurrentTeam(team.value);
|
cacheCurrentTeam(team.value);
|
||||||
return team.value;
|
return team.value;
|
||||||
}
|
}
|
||||||
@ -168,23 +168,40 @@ function buildArchiveBindUrl(action) {
|
|||||||
].join("&");
|
].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() {
|
async function continuePendingAction() {
|
||||||
const action = pendingAction.value;
|
const action = pendingAction.value;
|
||||||
if (!action || !account.value?.openid || !team.value?.teamId) return;
|
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("未找到目标服务团队");
|
toast("未找到目标服务团队");
|
||||||
pendingAction.value = null;
|
pendingAction.value = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await syncPendingExternalUser(action);
|
||||||
|
|
||||||
const customerId = action.memberId || action.customerId;
|
const customerId = action.memberId || action.customerId;
|
||||||
const customerRes = await api(
|
const customerRes = await api(
|
||||||
"getCustomerByCustomerId",
|
"getCustomerByCustomerId",
|
||||||
{ corpId: action.corpId, customerId },
|
{ corpId: action.corpId, customerId },
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
const customer = customerRes?.success ? customerRes.data : null;
|
const customer = customerRes?.data || null;
|
||||||
if (!customer) {
|
if (!customer) {
|
||||||
toast(customerRes?.message || "目标档案不存在");
|
toast(customerRes?.message || "目标档案不存在");
|
||||||
pendingAction.value = null;
|
pendingAction.value = null;
|
||||||
@ -220,17 +237,33 @@ async function getMatchTeams(inviteTeam = null) {
|
|||||||
});
|
});
|
||||||
let validTeam = teams.value.find(i => isSameTeam(i, targetIdentity));
|
let validTeam = teams.value.find(i => isSameTeam(i, targetIdentity));
|
||||||
|
|
||||||
if (!validTeam && pendingAction.value && targetIdentity.teamId && account.value?.openid) {
|
if (pendingAction.value && targetIdentity.teamId && account.value?.openid) {
|
||||||
const bindRes = await api("bindWxappWithTeam", {
|
if (!validTeam) {
|
||||||
appid,
|
const bindRes = await api("bindWxappWithTeam", {
|
||||||
corpId: targetIdentity.corpId,
|
appid,
|
||||||
teamId: targetIdentity.teamId,
|
corpId: targetIdentity.corpId,
|
||||||
openid: account.value.openid,
|
teamId: targetIdentity.teamId,
|
||||||
});
|
openid: account.value.openid,
|
||||||
if (bindRes?.success) {
|
});
|
||||||
|
if (!bindRes?.success) {
|
||||||
|
toast(bindRes?.message || "关联医生团队失败");
|
||||||
|
team.value = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
teams.value = await getTeams();
|
teams.value = await getTeams();
|
||||||
validTeam = teams.value.find(i => isSameTeam(i, targetIdentity));
|
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];
|
const firstTeam = teams.value[0];
|
||||||
@ -252,7 +285,6 @@ async function getMatchTeams(inviteTeam = null) {
|
|||||||
|
|
||||||
onLoad((options = {}) => {
|
onLoad((options = {}) => {
|
||||||
pendingAction.value = parsePendingAction(options);
|
pendingAction.value = parsePendingAction(options);
|
||||||
if (!account.value) login();
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user