import { useEffect, useState } from 'react'; import { View, Text } from '@tarojs/components'; import { useDidShow } from '@tarojs/taro'; import HqHeader from '../../components/HqHeader'; import { request, type Paginated } from '../../lib/api'; import { useHqSession } from '../../lib/session'; import { CITY_STATUS_LABELS, badgeClass } from '../../lib/constants'; type CityRow = { id: string; code: string; name: string; province?: string; status: string; storeCount?: number; orderCount?: number; partner?: { companyName: string }; }; export default function CitiesPage() { useHqSession(); const [rows, setRows] = useState([]); const [loading, setLoading] = useState(true); function load() { setLoading(true); request>('/admin/cities?pageSize=100') .then((d) => setRows(d.items)) .catch(() => setRows([])) .finally(() => setLoading(false)); } useEffect(load, []); useDidShow(load); return ( 开城城市 共 {rows.length} 城 {loading && 加载中…} {!loading && rows.length === 0 && 暂无开城城市} {rows.map((c) => ( {c.name} · {c.code} {CITY_STATUS_LABELS[c.status] || c.status} {c.province || ''} · 合伙人:{c.partner?.companyName || '—'} 门店 {c.storeCount ?? 0} 订单 {c.orderCount ?? 0} ))} ); }