import { useEffect, useState } from 'react'; import { View, Text, Image, Button } from '@tarojs/components'; import Taro, { useRouter } from '@tarojs/taro'; import HqHeader from '../../components/HqHeader'; import { request, toast } from '../../lib/api'; import { STORE_STATUS_LABELS, badgeClass, fmtTime } from '../../lib/constants'; type StoreDetail = { id: string; name: string; phone: string; status: string; province?: string; cityName?: string; district?: string; address?: string; intro?: string | null; coverUrl?: string | null; redeemCount?: number; createdAt: string; partner?: { companyName: string }; account?: { name: string; phone: string }; }; const ACTIONS: Array<{ status: string; label: string }> = [ { status: 'OPEN', label: '通过 / 营业' }, { status: 'PAUSED', label: '暂停营业' }, { status: 'CLOSED', label: '关闭门店' }, ]; export default function StoreDetailPage() { const router = useRouter(); const id = router.params.id; const [store, setStore] = useState(null); const [saving, setSaving] = useState(false); function load() { if (!id) return; request(`/admin/stores/${id}`).then(setStore).catch(() => undefined); } useEffect(load, [id]); async function changeStatus(status: string) { if (!id || saving) return; setSaving(true); try { await request(`/admin/stores/${id}/status`, { method: 'PUT', data: { status } }); toast('状态已更新', 'success'); setStore((s) => (s ? { ...s, status } : s)); } catch (e) { toast(e instanceof Error ? e.message : '更新失败'); } finally { setSaving(false); } } return ( {!store && 加载中…} {store && ( <> {store.coverUrl ? ( ) : null} {store.name} {STORE_STATUS_LABELS[store.status] || store.status} {store.province || ''}{store.cityName || ''}{store.district || ''}{store.address || ''} 联系电话:{store.phone} {store.intro ? ( {store.intro} ) : null} 开城合伙人 {store.partner?.companyName || '—'} 店长 {store.account?.name || '—'} {store.account?.phone || ''} 累计核销 {store.redeemCount ?? 0} 笔 创建时间 {fmtTime(store.createdAt)} 审核操作 {ACTIONS.map((a) => ( ))} )} ); }