|
@@ -1,4 +1,4 @@
|
|
|
-import {View, Image, Text} from '@tarojs/components';
|
|
|
|
|
|
|
+import {View, Image, Text, Button} from '@tarojs/components';
|
|
|
import face from '@assets/face.svg';
|
|
import face from '@assets/face.svg';
|
|
|
import classNames from 'classnames';
|
|
import classNames from 'classnames';
|
|
|
import {useStore} from 'zustand';
|
|
import {useStore} from 'zustand';
|
|
@@ -8,11 +8,22 @@ import {ORDER_PATH} from '@routes';
|
|
|
import {useNavigate} from '@hooks';
|
|
import {useNavigate} from '@hooks';
|
|
|
import {useBtnList} from './hooks';
|
|
import {useBtnList} from './hooks';
|
|
|
import {userStore} from '@stores';
|
|
import {userStore} from '@stores';
|
|
|
|
|
+import {showModal} from '@tarojs/taro';
|
|
|
|
|
|
|
|
export default function App() {
|
|
export default function App() {
|
|
|
|
|
+ const btnList = useBtnList();
|
|
|
const [visible, {toggle, setFalse}] = useBoolean();
|
|
const [visible, {toggle, setFalse}] = useBoolean();
|
|
|
const {navigateWithLogin, navigate} = useNavigate();
|
|
const {navigateWithLogin, navigate} = useNavigate();
|
|
|
- const {userName} = useStore(userStore);
|
|
|
|
|
|
|
+ const {userName, token, logout} = useStore(userStore);
|
|
|
|
|
+
|
|
|
|
|
+ function onLogout() {
|
|
|
|
|
+ showModal({
|
|
|
|
|
+ title: '你确定要退出登录吗?',
|
|
|
|
|
+ success({confirm}) {
|
|
|
|
|
+ confirm && logout();
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
function navigateTo(name, needLogin) {
|
|
function navigateTo(name, needLogin) {
|
|
|
return function () {
|
|
return function () {
|
|
@@ -20,8 +31,6 @@ export default function App() {
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const btnList = useBtnList();
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<View
|
|
<View
|
|
@@ -84,6 +93,15 @@ export default function App() {
|
|
|
</View>
|
|
</View>
|
|
|
);
|
|
);
|
|
|
})}
|
|
})}
|
|
|
|
|
+
|
|
|
|
|
+ {token ? (
|
|
|
|
|
+ <Button
|
|
|
|
|
+ onClick={onLogout}
|
|
|
|
|
+ className='mt-10 text-sm bg-primary h-10 text-white leading-10 rounded-full'
|
|
|
|
|
+ >
|
|
|
|
|
+ 退出登录
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ ) : null}
|
|
|
</View>
|
|
</View>
|
|
|
|
|
|
|
|
<Login visible={visible} onClose={setFalse} />
|
|
<Login visible={visible} onClose={setFalse} />
|