feat(customer): implement customer analysis page and drawer flow

This commit is contained in:
2026-03-03 16:45:22 +08:00
parent ccf7d403de
commit d450526204
28 changed files with 2880 additions and 3 deletions

View File

@@ -14,6 +14,7 @@ import {
export function useCustomerProfilePage() {
const route = useRoute();
const router = useRouter();
const PROFILE_ROUTE_PATH = '/customer/profile';
const stores = ref<StoreListItemDto[]>([]);
const selectedStoreId = ref('');
@@ -49,6 +50,10 @@ export function useCustomerProfilePage() {
});
async function syncRouteQuery(storeId: string, customerKey: string) {
if (route.path !== PROFILE_ROUTE_PATH) {
return;
}
const currentStoreId = parseRouteQueryValue(route.query.storeId);
const currentCustomerKey = parseRouteQueryValue(route.query.customerKey);
if (currentStoreId === storeId && currentCustomerKey === customerKey) {
@@ -56,7 +61,7 @@ export function useCustomerProfilePage() {
}
await router.replace({
path: '/customer/profile',
path: PROFILE_ROUTE_PATH,
query: buildRouteQuery(
route.query as Record<string, unknown>,
storeId,
@@ -75,6 +80,10 @@ export function useCustomerProfilePage() {
}
async function loadProfileByRoute() {
if (route.path !== PROFILE_ROUTE_PATH) {
return;
}
if (stores.value.length === 0) {
await loadStores();
}
@@ -110,15 +119,24 @@ export function useCustomerProfilePage() {
watch(
() => route.fullPath,
() => {
if (route.path !== PROFILE_ROUTE_PATH) {
return;
}
void loadProfileByRoute();
},
);
onMounted(() => {
void loadProfileByRoute();
if (route.path === PROFILE_ROUTE_PATH) {
void loadProfileByRoute();
}
});
onActivated(() => {
if (route.path !== PROFILE_ROUTE_PATH) {
return;
}
if (stores.value.length === 0) {
void loadProfileByRoute();
}