- 将顶部渐变背景由紫粉色改为绿色系,增强视觉统一性 - 用户信息卡片背景调整为毛玻璃效果,提升质感与层次感 - 用户名、ID及箭头等文字颜色改为白色及半透明白色,增强对比度 - 数据概览从三列扩展为四列,新增余额栏目,文字统一为白色 - VIP标识渐变色由粉红色改为金色,突显尊贵感 - 增加第三个装饰圆形,调整装饰元素大小和位置,更加协调 - 注释并暂时移除门店列表和其他页面中的“立即预约”按钮相关代码,避免用户误操作 - 修正首页门店信息跳转路径,指向正确页面
132 lines
4.4 KiB
TypeScript
132 lines
4.4 KiB
TypeScript
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<ShopStore[]>([])
|
|
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 (
|
|
<View className='min-h-screen bg-gray-50'>
|
|
<ScrollView scrollY style={{ height: scrollHeight }}>
|
|
{loading ? (
|
|
<View className='flex items-center justify-center py-10'>
|
|
<Text className='text-gray-400'>加载中...</Text>
|
|
</View>
|
|
) : stores.length === 0 ? (
|
|
<EmptyState text='暂无门店' />
|
|
) : (
|
|
<View className='p-3'>
|
|
{stores.map(store => (
|
|
<View key={store.id} className='bg-white rounded-lg p-3 mb-3'>
|
|
<View className='flex justify-between items-start mb-2'>
|
|
<Text className='text-base font-medium text-gray-800 flex-1'>
|
|
{store.name}
|
|
</Text>
|
|
{store.distance && (
|
|
<Text className='text-xs text-gray-400 ml-2'>
|
|
{store.distance < 1
|
|
? `${Math.round(store.distance * 1000)}m`
|
|
: `${store.distance.toFixed(1)}km`}
|
|
</Text>
|
|
)}
|
|
</View>
|
|
|
|
<View className='flex items-center mb-1'>
|
|
<Text className='text-xs text-gray-400 mr-2'>📍</Text>
|
|
<Text className='text-xs text-gray-600 flex-1'>
|
|
{store.address}
|
|
</Text>
|
|
</View>
|
|
|
|
{store.businessHours && (
|
|
<View className='flex items-center mb-2'>
|
|
<Text className='text-xs text-gray-400 mr-2'>🕐</Text>
|
|
<Text className='text-xs text-gray-600'>
|
|
{store.businessHours}
|
|
</Text>
|
|
</View>
|
|
)}
|
|
|
|
<View className='flex gap-2 mt-2'>
|
|
<View
|
|
className='flex-1 py-2 bg-blue-50 rounded-lg text-center'
|
|
onClick={() => handleCallStore(store.phone || '')}
|
|
>
|
|
<Text className='text-xs text-blue-500'>📞 拨打电话</Text>
|
|
</View>
|
|
<View
|
|
className='flex-1 py-2 bg-green-50 rounded-lg text-center'
|
|
onClick={() => handleOpenMap(store)}
|
|
>
|
|
<Text className='text-xs text-green-500'>📍 导航到店</Text>
|
|
</View>
|
|
{/*<View*/}
|
|
{/* className='flex-1 py-2 bg-orange-50 rounded-lg text-center'*/}
|
|
{/* onClick={() => handleBooking(store.id!)}*/}
|
|
{/*>*/}
|
|
{/* <Text className='text-xs text-orange-500'>📅 立即预约</Text>*/}
|
|
{/*</View>*/}
|
|
</View>
|
|
</View>
|
|
))}
|
|
</View>
|
|
)}
|
|
</ScrollView>
|
|
</View>
|
|
)
|
|
}
|
|
|
|
export default StoreListPage
|