建档流程做优化
This commit is contained in:
parent
6de95f5b47
commit
3e3b2a1fe8
@ -105,12 +105,33 @@ function toHome() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function syncExternalUserRelation() {
|
||||||
|
const currentTeam = team.value || {};
|
||||||
|
const currentAccount = account.value || {};
|
||||||
|
if (!(currentTeam.corpId && currentTeam.externalUserId && currentAccount.openid)) return;
|
||||||
|
try {
|
||||||
|
const res = await api('syncWxappExternalUserRelation', {
|
||||||
|
corpId: currentTeam.corpId,
|
||||||
|
externalUserId: currentTeam.externalUserId,
|
||||||
|
unionid: currentAccount.unionid || '',
|
||||||
|
openid: currentAccount.openid,
|
||||||
|
corpUserId: currentTeam.corpUserId || '',
|
||||||
|
}, false);
|
||||||
|
if (!res || !res.success) {
|
||||||
|
console.warn('关联 externalUserId 失败:', res && res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('关联 externalUserId 异常:', error && error.message ? error.message : error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async function bindTeam() {
|
async function bindTeam() {
|
||||||
const res = await api('bindWxappWithTeam', { appid, corpId: team.value.corpId, teamId: team.value.teamId, openid: account.value.openid });
|
const res = await api('bindWxappWithTeam', { appid, corpId: team.value.corpId, teamId: team.value.teamId, openid: account.value.openid });
|
||||||
if (!res || !res.success) {
|
if (!res || !res.success) {
|
||||||
return toast("关联团队失败");
|
return toast("关联团队失败");
|
||||||
}
|
}
|
||||||
|
await syncExternalUserRelation();
|
||||||
const res1 = await api('getWxAppCustomerCount', { miniAppId: account.value.openid, corpId: team.value.corpId, teamId: team.value.teamId });
|
const res1 = await api('getWxAppCustomerCount', { miniAppId: account.value.openid, corpId: team.value.corpId, teamId: team.value.teamId });
|
||||||
if (res1 && res1.data > 0) {
|
if (res1 && res1.data > 0) {
|
||||||
toHome();
|
toHome();
|
||||||
@ -126,7 +147,7 @@ async function getPhoneNumber(e) {
|
|||||||
if (!res) return;
|
if (!res) return;
|
||||||
}
|
}
|
||||||
if (team.value) {
|
if (team.value) {
|
||||||
bindTeam(account.value)
|
bindTeam()
|
||||||
} else if (redirectUrl.value) {
|
} else if (redirectUrl.value) {
|
||||||
await attempToPage(redirectUrl.value);
|
await attempToPage(redirectUrl.value);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -29,7 +29,51 @@ function copy() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeTeam({ teamId, corpId, corpUserId, qrid, referenceCustomerId }) {
|
function safeDecode(value) {
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(value);
|
||||||
|
} catch (error) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseInviteOptions(options = {}) {
|
||||||
|
const href =
|
||||||
|
typeof options.q === "string" ? safeDecode(options.q) : "";
|
||||||
|
const [, url = ""] = href.split("?");
|
||||||
|
const data = url.split("&").reduce((acc, cur) => {
|
||||||
|
if (!cur) return acc;
|
||||||
|
const [key, ...valueParts] = cur.split("=");
|
||||||
|
if (!key) return acc;
|
||||||
|
acc[key] = safeDecode(valueParts.join("=") || "");
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
return {
|
||||||
|
...options,
|
||||||
|
...data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function syncExternalUserRelation({ corpId, externalUserId, corpUserId }) {
|
||||||
|
const currentAccount = account.value || {};
|
||||||
|
if (!(corpId && externalUserId && currentAccount.openid)) return;
|
||||||
|
try {
|
||||||
|
const res = await api('syncWxappExternalUserRelation', {
|
||||||
|
corpId,
|
||||||
|
externalUserId,
|
||||||
|
unionid: currentAccount.unionid || '',
|
||||||
|
openid: currentAccount.openid,
|
||||||
|
corpUserId: corpUserId || '',
|
||||||
|
}, false);
|
||||||
|
if (!res || !res.success) {
|
||||||
|
console.warn('关联 externalUserId 失败:', res && res.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('关联 externalUserId 异常:', error && error.message ? error.message : error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function changeTeam({ teamId, corpId, corpUserId, externalUserId, qrid, referenceCustomerId }) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const res = await api("getTeamData", { teamId, corpId, withCorpName: true });
|
const res = await api("getTeamData", { teamId, corpId, withCorpName: true });
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@ -39,16 +83,17 @@ async function changeTeam({ teamId, corpId, corpUserId, qrid, referenceCustomerI
|
|||||||
set('home-invite-team-info', {
|
set('home-invite-team-info', {
|
||||||
teamId: team.value.teamId,
|
teamId: team.value.teamId,
|
||||||
corpUserId: corpUserId || '',
|
corpUserId: corpUserId || '',
|
||||||
corpUserId,
|
externalUserId: externalUserId || '',
|
||||||
qrid,
|
qrid,
|
||||||
referenceCustomerId: referenceCustomerId || ''
|
referenceCustomerId: referenceCustomerId || ''
|
||||||
});
|
});
|
||||||
await login()
|
await login()
|
||||||
if (account.value && account.value.mobile) {
|
if (account.value && account.value.mobile) {
|
||||||
bindTeam(corpUserId)
|
bindTeam({ corpUserId, externalUserId })
|
||||||
} else {
|
} else {
|
||||||
set("invite-team-info", {
|
set("invite-team-info", {
|
||||||
corpUserId,
|
corpUserId,
|
||||||
|
externalUserId,
|
||||||
qrid,
|
qrid,
|
||||||
referenceCustomerId,
|
referenceCustomerId,
|
||||||
corpId: team.value.corpId,
|
corpId: team.value.corpId,
|
||||||
@ -69,11 +114,16 @@ async function changeTeam({ teamId, corpId, corpUserId, qrid, referenceCustomerI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bindTeam(corpUserId) {
|
async function bindTeam({ corpUserId, externalUserId }) {
|
||||||
const res = await api('bindWxappWithTeam', { appid, corpId: team.value.corpId, teamId: team.value.teamId, openid: account.value.openid });
|
const res = await api('bindWxappWithTeam', { appid, corpId: team.value.corpId, teamId: team.value.teamId, openid: account.value.openid });
|
||||||
if (!res || !res.success) {
|
if (!res || !res.success) {
|
||||||
return toast("关联团队失败");
|
return toast("关联团队失败");
|
||||||
}
|
}
|
||||||
|
await syncExternalUserRelation({
|
||||||
|
corpId: team.value.corpId,
|
||||||
|
externalUserId,
|
||||||
|
corpUserId,
|
||||||
|
});
|
||||||
const res1 = await api('getWxAppCustomerCount', { miniAppId: account.value.openid, corpId: team.value.corpId, teamId: team.value.teamId });
|
const res1 = await api('getWxAppCustomerCount', { miniAppId: account.value.openid, corpId: team.value.corpId, teamId: team.value.teamId });
|
||||||
if (res1 && res1.data > 0) {
|
if (res1 && res1.data > 0) {
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
@ -89,15 +139,7 @@ async function bindTeam(corpUserId) {
|
|||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
if (options.q) {
|
if (options.q) {
|
||||||
opts.value = JSON.stringify(options)
|
opts.value = JSON.stringify(options)
|
||||||
const href =
|
changeTeam(parseInviteOptions(options));
|
||||||
typeof options.q === "string" ? decodeURIComponent(options.q) : "";
|
|
||||||
const [, url = ""] = href.split("?");
|
|
||||||
const data = url.split("&").reduce((acc, cur) => {
|
|
||||||
const [key, value] = cur.split("=");
|
|
||||||
acc[key] = value;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
changeTeam(data);
|
|
||||||
} else if (options.type === 'archive') {
|
} else if (options.type === 'archive') {
|
||||||
changeTeam(options);
|
changeTeam(options);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,7 @@ const urlsConfig = {
|
|||||||
unbindMiniAppArchive: 'unbindMiniAppArchive',
|
unbindMiniAppArchive: 'unbindMiniAppArchive',
|
||||||
updateMedicalRecord: 'updateMedicalRecord',
|
updateMedicalRecord: 'updateMedicalRecord',
|
||||||
getUnionidToExternalUserid: 'getUnionidToExternalUserid',
|
getUnionidToExternalUserid: 'getUnionidToExternalUserid',
|
||||||
|
syncWxappExternalUserRelation: 'syncWxappExternalUserRelation',
|
||||||
getWxAppCustomerCount: "getWxAppCustomerCount",
|
getWxAppCustomerCount: "getWxAppCustomerCount",
|
||||||
updateCustomer: 'update',
|
updateCustomer: 'update',
|
||||||
getRefrencePeople: 'getRefrencePeople',
|
getRefrencePeople: 'getRefrencePeople',
|
||||||
@ -115,4 +116,3 @@ export default async function api(urlId, data = {}, loading = true) {
|
|||||||
}
|
}
|
||||||
}, loading)
|
}, loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user