import { useEffect, useMemo, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import AppImage from '@dukang/shared-ui/AppImage'; import ProductCarousel from '../components/ProductCarousel'; import AppToast from '../components/AppToast'; import { request } from '../lib/api'; import { track } from '../lib/analytics'; import { handleShareButtonClick } from '../lib/wechat-share'; import { STITCH_STORE_MAP, getStoreGalleryImages } from '../lib/store-images'; type StoreMedia = { url: string; mediaType?: string; sortOrder?: number }; type StoreDetail = { id: string; name: string; phone: string; province: string; cityName?: string; city?: string; district: string; address: string; intro?: string | null; coverUrl?: string | null; status: string; openTime?: string | null; closeTime?: string | null; openTime2?: string | null; closeTime2?: string | null; avgPrice?: number | null; category?: { name: string } | null; media?: StoreMedia[]; }; const SERVICES = [ { icon: 'wifi', label: 'WiFi' }, { icon: 'local_parking', label: '免费停车' }, { icon: 'meeting_room', label: '独立包间' }, { icon: 'table_restaurant', label: '宴会大厅' }, ] as const; const MOCK_DISTANCES = ['800m', '1.2km', '2.4km', '3.5km']; const DEFAULT_INTRO = '作为本地优质餐饮合作伙伴,门店融合地域饮食文化与高端社交场景,设有杜康文化体验区,让宾客在用餐之余领略中华酒祖的千年传承。主打精品地方菜与创意融合菜,氛围庄重而不失亲和力,是商务宴请、亲友小聚以及文化交流的理想场所。'; function formatHours(store: StoreDetail) { const parts: string[] = []; if (store.openTime && store.closeTime) parts.push(`${store.openTime}-${store.closeTime}`); if (store.openTime2 && store.closeTime2) parts.push(`${store.openTime2}-${store.closeTime2}`); return parts.length ? parts.join(',') : '09:30-22:00'; } function fullAddress(store: StoreDetail) { const city = store.cityName || store.city || ''; return `${store.province}${city}${store.district}${store.address}`; } export default function StoreDetailPage() { const { id } = useParams(); const navigate = useNavigate(); const [store, setStore] = useState(null); const [benefitBalance, setBenefitBalance] = useState(0); const [headerSolid, setHeaderSolid] = useState(false); const [toast, setToast] = useState(''); useEffect(() => { if (id) { request('USER_H5', `/stores/${id}`).then(setStore); track('store_detail_view', { refType: 'STORE', refId: id, storeId: id }); } }, [id]); useEffect(() => { request>('USER_H5', '/benefit/coupons') .then((list) => { const balance = list.reduce((sum, c) => { if (c.status === 'ACTIVE') return sum + Number(c.balance || 0); return sum; }, 0); setBenefitBalance(balance); }) .catch(() => {}); }, []); useEffect(() => { function onScroll() { setHeaderSolid(window.scrollY > 80); } window.addEventListener('scroll', onScroll, { passive: true }); return () => window.removeEventListener('scroll', onScroll); }, []); const galleryImages = useMemo(() => { if (!store) return []; return getStoreGalleryImages(store.coverUrl, store.media); }, [store]); const distance = MOCK_DISTANCES[Number(id || 0) % MOCK_DISTANCES.length]; const isOpen = store?.status === 'OPEN'; if (!store) { return
加载中...
; } function callStore() { if (store?.phone) window.location.href = `tel:${store.phone}`; } function openMap() { window.alert('preV1:导航功能即将开放'); } return (

门店详情

{store.name}

营业时间:{formatHours(store)}

{store.avgPrice != null && Number(store.avgPrice) > 0 ? (

人均约 ¥{Number(store.avgPrice).toFixed(0)}

) : null} {store.category?.name && ( {store.category.name} )}
{isOpen && } {isOpen ? '营业中' : '休息中'}
info

温馨提示:为保证服务品质,如用餐规模超过2桌,请提前电话联系门店确认可用性。

{fullAddress(store)}

near_me 距离您 {distance}

设施服务

{SERVICES.map((s) => (
{s.icon} {s.label}
))}

门店介绍

{store.intro || DEFAULT_INTRO}

已有 1.2w 人到店体验
); }