微信小程序上传
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { View, Text, Button } from '@tarojs/components';
|
||||
import Taro, { useDidShow } from '@tarojs/taro';
|
||||
import TabMainHeader from '../../components/TabMainHeader';
|
||||
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
||||
import { isLoggedIn, logout, request, toast, type UserProfile } from '../../lib/api';
|
||||
|
||||
export default function MinePage() {
|
||||
const [profile, setProfile] = useState<UserProfile | null>(null);
|
||||
const loggedIn = isLoggedIn();
|
||||
|
||||
useDidShow(() => {
|
||||
syncTabBarSelected(3);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!loggedIn) return;
|
||||
request<UserProfile>('/auth/me')
|
||||
.then(setProfile)
|
||||
.catch((e) => toast(e instanceof Error ? e.message : '加载失败'));
|
||||
}, [loggedIn]);
|
||||
|
||||
return (
|
||||
<View className="u-page u-page--tab">
|
||||
<TabMainHeader title="我的" />
|
||||
<View className="u-card">
|
||||
{loggedIn ? (
|
||||
<View>
|
||||
<Text className="u-title" style={{ marginBottom: 4 }}>
|
||||
{profile?.nickname || '用户'}
|
||||
</Text>
|
||||
<Text className="u-muted" style={{ display: 'block', marginBottom: 16 }}>
|
||||
{profile?.phone || '未绑定手机'}
|
||||
</Text>
|
||||
<Text className="u-muted" style={{ display: 'block', marginBottom: 16 }}>
|
||||
订单 / 地址 / 核销码等页面后续从 h5-user 迁移
|
||||
</Text>
|
||||
<Button className="u-btn u-btn--block" onClick={() => logout()}>
|
||||
退出登录
|
||||
</Button>
|
||||
</View>
|
||||
) : (
|
||||
<View>
|
||||
<View className="u-empty">登录后管理订单与个人信息</View>
|
||||
<Button
|
||||
className="u-btn u-btn--block"
|
||||
onClick={() => Taro.navigateTo({ url: '/pages/login/index' })}
|
||||
>
|
||||
去登录
|
||||
</Button>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
{shouldRenderPageTabBar() ? <UserTabBar selected={3} /> : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user