import React, { useState, useEffect } from 'react' import { View, Text, ScrollView, Image } from '@tarojs/components' import Taro from '@tarojs/taro' import { listShopStore } from '@/api/shop/shopStore' import type { ShopStore } from '@/api/shop/shopStore/model' import EmptyState from '@/components/common/EmptyState' import { useScrollHeight } from '@/hooks/useScrollHeight' definePageConfig({ navigationBarTitleText: '门店列表', }) const StoreListPage: React.FC = () => { const [stores, setStores] = useState([]) const [loading, setLoading] = useState(true) const scrollHeight = useScrollHeight(44) useEffect(() => { fetchStores() }, []) const fetchStores = async () => { try { const data = await listShopStore({ status: 1 }) setStores(data || []) } catch (e) { console.error('获取门店列表失败:', e) } finally { setLoading(false) } } const handleCallStore = (phone: string) => { Taro.makePhoneCall({ phoneNumber: phone, fail: () => { Taro.showToast({ title: '拨打失败', icon: 'none' }) }, }) } const handleOpenMap = (store: ShopStore) => { if (store.latitude && store.longitude) { Taro.openLocation({ latitude: parseFloat(store.latitude), longitude: parseFloat(store.longitude), name: store.name || '', address: store.address || '', }) } else { Taro.showToast({ title: '暂无位置信息', icon: 'none' }) } } const handleBooking = (storeId: number) => { Taro.navigateTo({ url: `/pages/store/booking?storeId=${storeId}` }) } return ( {loading ? ( 加载中... ) : stores.length === 0 ? ( ) : ( {stores.map(store => ( {store.name} {store.distance && ( {store.distance < 1 ? `${Math.round(store.distance * 1000)}m` : `${store.distance.toFixed(1)}km`} )} 📍 {store.address} {store.businessHours && ( 🕐 {store.businessHours} )} handleCallStore(store.phone || '')} > 📞 拨打电话 handleOpenMap(store)} > 📍 导航到店 {/* handleBooking(store.id!)}*/} {/*>*/} {/* 📅 立即预约*/} {/**/} ))} )} ) } export default StoreListPage