| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import { useState } from 'react';
- import { View, Text } from '@tarojs/components';
- import Taro, { useLoad } from '@tarojs/taro';
- import { Avatar, Cell, CellGroup, Button, Dialog } from '@nutui/nutui-react-taro';
- import { ArrowRight, User } from '@nutui/icons-react-taro';
- import { useUserStore } from '@/stores/user';
- import './index.less';
- interface UserInfo {
- name: string;
- avatar: string;
- }
- const userInfo: UserInfo = {
- name: '公司管理',
- avatar: '',
- };
- export default function Mine() {
- const [statusBarHeight, setStatusBarHeight] = useState<number | undefined>(0);
- const [showLogoutConfirm, setShowLogoutConfirm] = useState<boolean>(false);
- const [loading, setLoading] = useState<boolean>(false);
- useLoad(() => {
- const { statusBarHeight: sHeight } = Taro.getSystemInfoSync();
- setStatusBarHeight(sHeight);
- });
- const handleMenuClick = (value: string) => {
- console.log('Menu clicked:', value);
- };
- const handleLogout = () => {
- setShowLogoutConfirm(true);
- };
- function handleConfirmLogout() {
- try {
- setLoading(true);
- setShowLogoutConfirm(false);
- useUserStore.getState().logout();
- } finally {
- setLoading(false);
- }
- }
- return (
- <View className="mine">
- {/* 用户信息区域 */}
- <View
- className="user-section"
- style={{ paddingTop: `${statusBarHeight! + 30}px`, paddingBottom: '30px' }}
- >
- <View className="user-info">
- <Avatar
- size="large"
- icon={userInfo.avatar || <User width="50px" height="50px" />}
- className="user-avatar"
- />
- <View className="user-details">
- <Text className="user-name">{userInfo.name}</Text>
- <Text className="user-guide-no"></Text>
- </View>
- </View>
- </View>
- {/* 功能菜单区域 */}
- <View className="menu-section">
- <CellGroup title="系统设置" className="menu-group">
- {/* <Cell title="设置" onClick={() => handleMenuClick('settings')} extra={<ArrowRight />} /> */}
- <Cell title="关于" onClick={() => handleMenuClick('about')} extra={<ArrowRight />} />
- </CellGroup>
- </View>
- {/* 退出登录 */}
- <View className="logout-section">
- <Button
- fill="outline"
- size="large"
- type="danger"
- block
- className="logout-btn"
- onClick={handleLogout}
- disabled={loading}
- >
- 退出登录
- </Button>
- </View>
- <Dialog
- visible={showLogoutConfirm}
- title="确认退出登录"
- confirmText="确认"
- cancelText="取消"
- footerDirection="vertical"
- onConfirm={handleConfirmLogout}
- onCancel={() => setShowLogoutConfirm(false)}
- ></Dialog>
- </View>
- );
- }
|