From e23ab0f6d33d697c3bf842bfb5883914c7d7183b Mon Sep 17 00:00:00 2001 From: zhanchao Date: Wed, 12 Aug 2026 11:34:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E6=9E=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../select-rights-archive.vue | 71 ++++++++++--------- utils/api.js | 1 + 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/pages/experience-coupon/select-rights-archive.vue b/pages/experience-coupon/select-rights-archive.vue index 2198ac7..5bb8ff9 100644 --- a/pages/experience-coupon/select-rights-archive.vue +++ b/pages/experience-coupon/select-rights-archive.vue @@ -33,11 +33,12 @@ import { onLoad } from "@dcloudio/uni-app"; import { storeToRefs } from "pinia"; import useAccount from "@/store/account"; import api from "@/utils/api"; -import { set } from "@/utils/cache"; +import { get, set } from "@/utils/cache"; import { toast } from "@/utils/widget"; import { normalizeCorpId } from "@/utils/api-base-config"; import FullPage from "@/components/full-page.vue"; +const HOME_CURRENT_TEAM_CACHE_KEY = "home-current-team-info"; const RIGHTS_SELECTION_CACHE_KEY = "experience-coupon-rights-selection"; const { account } = storeToRefs(useAccount()); const { getTeams } = useAccount(); @@ -50,10 +51,6 @@ const currentCustomerId = ref(""); const mode = ref("back"); const target = ref(""); -function pickCorpName(team = {}) { - return team.licenseHospitalName || team.leaderCorp || team.corpName || "-"; -} - function maskMobile(mobile = "") { const value = String(mobile || "").trim(); if (!value) return ""; @@ -77,16 +74,6 @@ function buildMetaText(customer = {}) { return parts.length ? parts.join(",") : "暂无档案信息"; } -function dedupeByCorp(list = []) { - const map = new Map(); - list.forEach((team) => { - const corpId = normalizeCorpId(team.corpId); - if (!corpId || map.has(corpId)) return; - map.set(corpId, { ...team, corpId }); - }); - return Array.from(map.values()); -} - function buildTargetUrl(item) { const corp = encodeURIComponent(item.corpId || ""); const team = encodeURIComponent(item.teamId || ""); @@ -120,34 +107,48 @@ async function loadArchives() { loading.value = true; try { const teams = (await getTeams()) || []; - const corpTeams = dedupeByCorp(teams); - const responses = await Promise.all( - corpTeams.map(async (team) => { - try { - const res = await api("getMiniAppCustomers", { miniAppId, corpId: team.corpId }, false); - const customers = res?.success && Array.isArray(res.data) ? res.data : []; - return customers.map((customer) => ({ team, customer })); - } catch (e) { - console.warn(e); - return []; - } - }) + const currentTeam = get(HOME_CURRENT_TEAM_CACHE_KEY) || {}; + const selectedCorpId = normalizeCorpId(currentTeam.corpId || currentCorpId.value); + const selectedTeamId = currentTeam.teamId || currentTeamId.value; + const selectedTeam = teams.find( + (team) => + normalizeCorpId(team.corpId) === selectedCorpId && + (!selectedTeamId || team.teamId === selectedTeamId) ); - const list = responses - .flat() - .map(({ team, customer }) => ({ - key: `${team.corpId}_${customer._id}`, - corpId: team.corpId, - teamId: team.teamId || "", + if (!selectedCorpId || !selectedTeam) { + options.value = []; + return; + } + + const [corpRes, customerRes] = await Promise.all([ + api("getCorpInfo", { corpId: selectedCorpId }, false), + api( + "getTeamCustomers", + { + miniAppId, + corpId: selectedCorpId, + teamId: selectedTeam.teamId, + }, + false + ), + ]); + const corp = Array.isArray(corpRes?.data) ? corpRes.data[0] : null; + const archiveCorpName = corp?.corp_name || corp?.corpName || "-"; + const customers = customerRes?.success && Array.isArray(customerRes.data) ? customerRes.data : []; + const list = customers + .map((customer) => ({ + key: `${selectedCorpId}_${customer._id}`, + corpId: selectedCorpId, + teamId: selectedTeam.teamId || "", customerId: customer._id || "", name: customer.name || "", relationship: customer.relationship || "", metaText: buildMetaText(customer), idCardText: maskIdCard(customer.idCard), - corpName: pickCorpName(team), + corpName: archiveCorpName, })) - .filter((item) => item.corpId && item.customerId) + .filter((item) => item.customerId) .sort((a, b) => { const aScore = (a.corpId === currentCorpId.value ? 4 : 0) + diff --git a/utils/api.js b/utils/api.js index 3daa5fa..320eb1c 100644 --- a/utils/api.js +++ b/utils/api.js @@ -21,6 +21,7 @@ const urlsConfig = { recordBusinessCardBehavior: 'recordBusinessCardBehavior', getJoinedTeams: 'getJoinedTeams', getCorpBusinessCardStatus: 'getCorpBusinessCardStatus', + getCorpInfo: 'getCorpInfo', }, knowledgeBase: {