feat;提交管理端和城市合伙人端

This commit is contained in:
ljy
2026-07-05 23:48:20 +08:00
parent fecfc61ec5
commit 569becedaa
73 changed files with 10150 additions and 80 deletions
+76
View File
@@ -0,0 +1,76 @@
import { useEffect, useState } from 'react';
import { View, Text } from '@tarojs/components';
import HqHeader from '../../components/HqHeader';
import { request } from '../../lib/api';
import { useHqSession } from '../../lib/session';
import { ORDER_STATUS_LABELS } from '../../lib/constants';
import './index.css';
type Stats = {
usersTotal: number;
guestUsers: number;
verifiedUsers: number;
ordersToday: number;
storesTotal: number;
partnersTotal: number;
redeemToday: number;
deliveriesTotal: number;
mergedUsers: number;
ordersByStatus: Array<{ status: string; count: number }>;
};
export default function ReportsPage() {
useHqSession();
const [stats, setStats] = useState<Stats | null>(null);
useEffect(() => {
request<Stats>('/admin/dashboard/stats').then(setStats).catch(() => undefined);
}, []);
const dist = stats?.ordersByStatus ?? [];
const max = Math.max(1, ...dist.map((d) => d.count));
return (
<View className="hq-page">
<HqHeader title="数据报表" back />
<Text className="hq-section-title"></Text>
<View className="hq-stat-grid">
<View className="hq-stat">
<Text className="hq-stat__label"></Text>
<Text className="hq-stat__value">{stats?.usersTotal ?? 0}</Text>
<Text className="hq-stat__sub"> {stats?.verifiedUsers ?? 0}</Text>
</View>
<View className="hq-stat">
<Text className="hq-stat__label"></Text>
<Text className="hq-stat__value">{stats?.ordersToday ?? 0}</Text>
<Text className="hq-stat__sub"> {stats?.redeemToday ?? 0}</Text>
</View>
<View className="hq-stat">
<Text className="hq-stat__label"> / </Text>
<Text className="hq-stat__value">{stats?.storesTotal ?? 0}/{stats?.partnersTotal ?? 0}</Text>
<Text className="hq-stat__sub"> {stats?.deliveriesTotal ?? 0}</Text>
</View>
<View className="hq-stat">
<Text className="hq-stat__label">访</Text>
<Text className="hq-stat__value">{stats?.guestUsers ?? 0}</Text>
<Text className="hq-stat__sub"> {stats?.mergedUsers ?? 0}</Text>
</View>
</View>
<Text className="hq-section-title"></Text>
<View className="hq-card">
{dist.length === 0 && <Text className="hq-muted"></Text>}
{dist.map((d) => (
<View key={d.status} className="report-bar-row">
<Text className="report-bar-label">{ORDER_STATUS_LABELS[d.status] || d.status}</Text>
<View className="report-bar-track">
<View className="report-bar-fill" style={`width:${(d.count / max) * 100}%`} />
</View>
<Text className="report-bar-count">{d.count}</Text>
</View>
))}
</View>
</View>
);
}