微信小程序上传
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import { useDidShow } from '@tarojs/taro';
|
||||
import TabMainHeader from '../../components/TabMainHeader';
|
||||
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
||||
import { request, toast } from '../../lib/api';
|
||||
|
||||
type Store = {
|
||||
id: string;
|
||||
name: string;
|
||||
address?: string;
|
||||
status?: string;
|
||||
};
|
||||
|
||||
export default function StoresPage() {
|
||||
const [stores, setStores] = useState<Store[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useDidShow(() => {
|
||||
syncTabBarSelected(1);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
request<Store[]>('/stores')
|
||||
.then((list) => setStores(Array.isArray(list) ? list : []))
|
||||
.catch((e) => toast(e instanceof Error ? e.message : '加载失败'))
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View className="u-page u-page--tab">
|
||||
<TabMainHeader title="门店" />
|
||||
<View className="u-card">
|
||||
{loading ? (
|
||||
<View className="u-empty">加载中…</View>
|
||||
) : stores.length === 0 ? (
|
||||
<View className="u-empty">暂无营业中门店</View>
|
||||
) : (
|
||||
stores.map((s) => (
|
||||
<View key={s.id} className="u-store-row">
|
||||
<View className="u-store-avatar" />
|
||||
<View style={{ flex: 1, minWidth: 0 }}>
|
||||
<Text className="u-store-name">{s.name}</Text>
|
||||
<Text className="u-muted" style={{ display: 'block', marginTop: '4px' }}>
|
||||
{s.address || '地址待完善'}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
))
|
||||
)}
|
||||
</View>
|
||||
{shouldRenderPageTabBar() ? <UserTabBar selected={1} /> : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user