From e8c25009d5bfefbdc156b0de7571e473ebc5545d Mon Sep 17 00:00:00 2001 From: huxuejian Date: Mon, 11 May 2026 14:25:24 +0800 Subject: [PATCH 1/6] Update account.js --- store/account.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/store/account.js b/store/account.js index e567b5b..ef4fa29 100644 --- a/store/account.js +++ b/store/account.js @@ -141,7 +141,10 @@ export default defineStore("accountStore", () => { async function getExternalUserId(corpId) { const unionid = account.value?.unionid; const openid = account.value?.openid; - if (!(corpId && unionid && openid)) return; + if (!(corpId && unionid && openid)) { + externalUserId.value = ''; + return + }; const res = await api('getUnionidToExternalUserid', { unionid, openid, corpId }, false); const id = res && res.success && typeof res.data === 'string' && res.data.trim() ? res.data.trim() : ''; externalUserId.value = id; From 3e3b2a1fe82f12246e209c849a1bea7c7c94921b Mon Sep 17 00:00:00 2001 From: wangdongbo <> Date: Tue, 2 Jun 2026 10:36:41 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=BB=BA=E6=A1=A3=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=81=9A=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/login/login.vue | 23 +++++++++++- pages/login/redirect-page.vue | 70 ++++++++++++++++++++++++++++------- utils/api.js | 2 +- 3 files changed, 79 insertions(+), 16 deletions(-) diff --git a/pages/login/login.vue b/pages/login/login.vue index 23716f4..caac2c2 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -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() { const res = await api('bindWxappWithTeam', { appid, corpId: team.value.corpId, teamId: team.value.teamId, openid: account.value.openid }); if (!res || !res.success) { return toast("关联团队失败"); } + await syncExternalUserRelation(); const res1 = await api('getWxAppCustomerCount', { miniAppId: account.value.openid, corpId: team.value.corpId, teamId: team.value.teamId }); if (res1 && res1.data > 0) { toHome(); @@ -126,7 +147,7 @@ async function getPhoneNumber(e) { if (!res) return; } if (team.value) { - bindTeam(account.value) + bindTeam() } else if (redirectUrl.value) { await attempToPage(redirectUrl.value); } else { diff --git a/pages/login/redirect-page.vue b/pages/login/redirect-page.vue index 1c409a5..085e432 100644 --- a/pages/login/redirect-page.vue +++ b/pages/login/redirect-page.vue @@ -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; const res = await api("getTeamData", { teamId, corpId, withCorpName: true }); loading.value = false; @@ -39,16 +83,17 @@ async function changeTeam({ teamId, corpId, corpUserId, qrid, referenceCustomerI set('home-invite-team-info', { teamId: team.value.teamId, corpUserId: corpUserId || '', - corpUserId, + externalUserId: externalUserId || '', qrid, referenceCustomerId: referenceCustomerId || '' }); await login() if (account.value && account.value.mobile) { - bindTeam(corpUserId) + bindTeam({ corpUserId, externalUserId }) } else { set("invite-team-info", { corpUserId, + externalUserId, qrid, referenceCustomerId, 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 }); if (!res || !res.success) { 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 }); if (res1 && res1.data > 0) { uni.switchTab({ @@ -89,15 +139,7 @@ async function bindTeam(corpUserId) { onLoad((options) => { if (options.q) { opts.value = JSON.stringify(options) - const href = - 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); + changeTeam(parseInviteOptions(options)); } else if (options.type === 'archive') { changeTeam(options); } @@ -124,4 +166,4 @@ onLoad((options) => { opacity: 1; } } - \ No newline at end of file + diff --git a/utils/api.js b/utils/api.js index aeec03d..a2d56ed 100644 --- a/utils/api.js +++ b/utils/api.js @@ -58,6 +58,7 @@ const urlsConfig = { unbindMiniAppArchive: 'unbindMiniAppArchive', updateMedicalRecord: 'updateMedicalRecord', getUnionidToExternalUserid: 'getUnionidToExternalUserid', + syncWxappExternalUserRelation: 'syncWxappExternalUserRelation', getWxAppCustomerCount: "getWxAppCustomerCount", updateCustomer: 'update', getRefrencePeople: 'getRefrencePeople', @@ -115,4 +116,3 @@ export default async function api(urlId, data = {}, loading = true) { } }, loading) } - From f8838cc1f929eb6001097a50efc5f5f79c6045cc Mon Sep 17 00:00:00 2001 From: wangdongbo <> Date: Tue, 2 Jun 2026 14:29:17 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E6=97=B6=EF=BC=8C=20=E6=94=B9=E4=B8=BA=E4=B8=BB?= =?UTF-8?q?=E5=8A=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/archive/archive-result.vue | 2 +- pages/team/friend.vue | 4 ++-- pages/team/homepage.vue | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pages/archive/archive-result.vue b/pages/archive/archive-result.vue index b06a305..51edf7e 100644 --- a/pages/archive/archive-result.vue +++ b/pages/archive/archive-result.vue @@ -94,7 +94,7 @@ function toFriend(userid) { } async function getQrcode(userid) { - const res = await api('addContactWay', { corpUserId: userid, corpId: corpId.value, unionid: account.value?.openid }); + const res = await api('addContactWay', { corpUserId: userid, corpId: corpId.value, unionid: account.value?.openid, fetchType: 'realtime' }); if (res && res.data) { qrcode.value = res.data; } diff --git a/pages/team/friend.vue b/pages/team/friend.vue index 5681332..d69ca02 100644 --- a/pages/team/friend.vue +++ b/pages/team/friend.vue @@ -56,7 +56,7 @@ async function getMember() { } async function getQrcode() { - const res = await api('addContactWay', { corpUserId: userid.value, corpId: corpId.value, unionid: account.value?.openid }); + const res = await api('addContactWay', { corpUserId: userid.value, corpId: corpId.value, unionid: account.value?.openid, fetchType: 'realtime' }); if (res && res.data) { qrcode.value = res.data; } @@ -92,4 +92,4 @@ watch(member, n => { width: 560rpx; height: 560rpx; } - \ No newline at end of file + diff --git a/pages/team/homepage.vue b/pages/team/homepage.vue index 726913e..7e5c44d 100644 --- a/pages/team/homepage.vue +++ b/pages/team/homepage.vue @@ -137,7 +137,7 @@ async function getMember() { } async function getQrcode() { - const res = await api('addContactWay', { corpUserId: userid.value, corpId: corpId.value, unionid: account.value?.openid }); + const res = await api('addContactWay', { corpUserId: userid.value, corpId: corpId.value, unionid: account.value?.openid, fetchType: 'realtime' }); if (res && res.data) { qrcode.value = res.data; } @@ -192,4 +192,4 @@ page { width: 560rpx; height: 560rpx; } - \ No newline at end of file + From ba830dff60dbd109396fa65b5b2d6e39dd1ccff7 Mon Sep 17 00:00:00 2001 From: wangdongbo <> Date: Wed, 3 Jun 2026 09:24:44 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=A1=A3=E6=A1=88=E6=A8=A1=E7=89=88?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=89=AA=E8=81=94=E5=8A=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/form-template/index.vue | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/components/form-template/index.vue b/components/form-template/index.vue index 647901e..7b47c4f 100644 --- a/components/form-template/index.vue +++ b/components/form-template/index.vue @@ -1,13 +1,14 @@