diff --git a/src/apis/schemas.ts b/src/apis/schemas.ts index 1ec4e196..62acd9eb 100644 --- a/src/apis/schemas.ts +++ b/src/apis/schemas.ts @@ -157,6 +157,7 @@ export const enum PlanState { export interface Plan { cat?: Cat; + communityId?: string; coverUrl: string; createAt: number; description: string; diff --git a/src/pages/plan/helped-plans/HelpedCard.vue b/src/pages/plan/helped-plans/HelpedCard.vue index 2d3ebc9c..0f0e77a9 100644 --- a/src/pages/plan/helped-plans/HelpedCard.vue +++ b/src/pages/plan/helped-plans/HelpedCard.vue @@ -5,23 +5,29 @@ :src="props.donation.plan.coverUrl" class="image-cat" /> - 帮助{{ props.donation.plan?.cat?.name || "全体猫猫" }} {{ props.donation.plan.name }} - - {{ currentSchool }} - + + + {{ currentSchool }}-{{ currentCampus }} + + + + {{ currentSchool }} + - ×{{ props.donation.donateNum }} - {{ - displayTimeTotal(props.donation.donateTime) - }} + x{{ props.donation.donateNum }} + {{ + displayTimeTotal(props.donation.donateTime) + }} @@ -32,22 +38,12 @@ import { Donation, Community } from "@/apis/schemas"; import { displayTimeTotal } from "@/utils/time"; import { listCommunity } from "@/apis/community/community"; import { reactive, ref } from "vue"; -import { StorageKeys } from "@/utils/const"; -import BackgroundImage from "@/components/BackgroundImage.vue"; -let communityId = ref(""); let parentId = ref(""); const currentSchool = ref(""); const currentCampus = ref(""); -function init() { - communityId.value = uni.getStorageSync(StorageKeys.CommunityId); -} - -init(); const lists = reactive<{ data: Community[] }>({ data: [] }); -const campuses = reactive<{ data: Community[] }>({ data: [] }); - const props = defineProps<{ donation: Donation; community: Community; @@ -57,31 +53,22 @@ const onClick = () => { url: `${Pages.PlanDetails}?id=${props.donation.plan.id}` }); }; - async function schoolList() { lists.data = (await listCommunity({})).communities; } - -function getCampus() { - schoolList().then(async () => { - init(); - for (let i = 0; i < lists.data.length; i++) { - if (lists.data[i].id === communityId.value) { - currentCampus.value = lists.data[i].name; - parentId.value = lists.data[i].parentId; - } +async function getCampus() { + await schoolList(); + for (const data of lists.data) { + if (data.id === props.donation.plan.communityId) { + currentCampus.value = data.name; + parentId.value = data.parentId || ""; } - for (let j = 0; j < lists.data.length; j++) { - if (lists.data[j].id === parentId.value) { - currentSchool.value = lists.data[j].name; - } + } + for (const data of lists.data) { + if (data.id === parentId.value) { + currentSchool.value = data.name; } - campuses.data = ( - await listCommunity({ - parentId: parentId.value - }) - ).communities; - }); + } } getCampus(); @@ -89,12 +76,13 @@ getCampus();