From d036d756f4c8132fc3247d39b8b7d22f622eeed9 Mon Sep 17 00:00:00 2001 From: Timi Date: Fri, 11 Sep 2026 18:47:14 +0800 Subject: [PATCH] add customer age chart --- src/api/StoreChartAPI.ts | 10 +- src/pages/store/StoreDataCharts.vue | 41 ++++- .../store/component/StoreCustomerAgeChart.vue | 143 ++++++++++++++++++ .../StoreCustomerDiseaseWordCloudChart.vue | 2 +- .../component/StoreCustomerGenderChart.vue | 8 +- .../component/StoreCustomerGrowthChart.vue | 4 +- src/types/Customer.ts | 5 + 7 files changed, 198 insertions(+), 15 deletions(-) create mode 100644 src/pages/store/component/StoreCustomerAgeChart.vue diff --git a/src/api/StoreChartAPI.ts b/src/api/StoreChartAPI.ts index 4d543e8..58941a9 100644 --- a/src/api/StoreChartAPI.ts +++ b/src/api/StoreChartAPI.ts @@ -1,7 +1,7 @@ import { axios } from "timi-web-api"; import EventAPI from "@/api/EventAPI"; import StoreAPI from "@/api/StoreAPI"; -import type { CustomerDailyStatView, CustomerGenderStatView } from "@/types/Customer"; +import type { CustomerAgeStatView, CustomerDailyStatView, CustomerGenderStatView } from "@/types/Customer"; import type { EventItem } from "@/types/EventItem"; import type { StoreBusinessDay, StoreChartReq, StoreEventRecordCalendarView, StoreEventRecordDailyStatView, StoreEventRecordNumberValueDailyStatView } from "@/types/Store"; import { getStoreChartCache } from "@/utils/storeChartCache"; @@ -21,6 +21,13 @@ async function customerGenderStat(): Promise { })); } +async function customerAgeStat(): Promise { + const storeId = getCurrentStoreId(); + return await getStoreChartCache(`customer-age:${storeId}`, async () => await axios.post(`${BASE_URI}/customer/age`, undefined, { + params: { storeId } + })); +} + async function eventRecordDailyStat(req: StoreChartReq): Promise { const request = withCurrentStoreId(req); return await getStoreChartCache(`event-record-daily:${JSON.stringify(request)}`, async () => await axios.post(`${BASE_URI}/event/record/daily`, request)); @@ -48,6 +55,7 @@ async function businessDayCalendar(storeId: string, beginDateValue: number, endD export default { customerDailyStat, customerGenderStat, + customerAgeStat, eventRecordDailyStat, eventRecordNumberValueDailyStat, eventRecordCalendar, diff --git a/src/pages/store/StoreDataCharts.vue b/src/pages/store/StoreDataCharts.vue index c5c1721..1c12a33 100644 --- a/src/pages/store/StoreDataCharts.vue +++ b/src/pages/store/StoreDataCharts.vue @@ -1,19 +1,32 @@ + + diff --git a/src/pages/store/component/StoreCustomerDiseaseWordCloudChart.vue b/src/pages/store/component/StoreCustomerDiseaseWordCloudChart.vue index c6b40a3..9deeb4c 100644 --- a/src/pages/store/component/StoreCustomerDiseaseWordCloudChart.vue +++ b/src/pages/store/component/StoreCustomerDiseaseWordCloudChart.vue @@ -1,6 +1,6 @@