|
|
@@ -1,4 +1,4 @@
|
|
|
-import {View, Image, Text, Navigator} from '@tarojs/components';
|
|
|
+import {View, Image, Text} from '@tarojs/components';
|
|
|
import classNames from 'classnames';
|
|
|
import sendIcon from '@assets/sending.svg';
|
|
|
import complateIcon from '@assets/complate.svg';
|
|
|
@@ -7,6 +7,9 @@ import face from '@assets/face.svg';
|
|
|
import Login from './login';
|
|
|
import {useBoolean} from 'ahooks';
|
|
|
import {DELIVER_GOODS_PATH, ORDER_PATH, RECEIVE_GOODS_PATH} from '@routes';
|
|
|
+import {useNavigate} from '@hooks';
|
|
|
+import {useStore} from 'zustand';
|
|
|
+import {userStore} from '@stores';
|
|
|
|
|
|
const btnList = [
|
|
|
{
|
|
|
@@ -24,6 +27,15 @@ const btnList = [
|
|
|
|
|
|
export default function App() {
|
|
|
const [visible, {toggle, setFalse}] = useBoolean();
|
|
|
+ const {navigateWithLogin, navigate} = useNavigate();
|
|
|
+
|
|
|
+ function navigateTo(name, needLogin) {
|
|
|
+ return function () {
|
|
|
+ needLogin ? navigateWithLogin(name) : navigate(name);
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ const userName = useStore(userStore, state => state.userName);
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
@@ -33,7 +45,10 @@ export default function App() {
|
|
|
'bg-gradient-to-br from-[#DEF6FE] to-[#F4F6F8]',
|
|
|
)}
|
|
|
>
|
|
|
- <View className='flex items-center' onClick={toggle}>
|
|
|
+ <View
|
|
|
+ className='flex items-center'
|
|
|
+ onClick={userName ? void 0 : toggle}
|
|
|
+ >
|
|
|
<Image
|
|
|
className='w-14 h-14 rounded-full'
|
|
|
src={face}
|
|
|
@@ -41,7 +56,9 @@ export default function App() {
|
|
|
/>
|
|
|
|
|
|
<View className='flex-1 ps-4'>
|
|
|
- <Text className='block text-base text-[#333]'>登录</Text>
|
|
|
+ <Text className='block text-base text-[#333]'>
|
|
|
+ {userName ? userName : '登录'}
|
|
|
+ </Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
|
|
|
@@ -61,7 +78,10 @@ export default function App() {
|
|
|
<View className='mt-3 grid grid-cols-4 grid-rows-1 gap-4'>
|
|
|
{el.children.map(function (item) {
|
|
|
return (
|
|
|
- <Navigator url={item.url} key={item.title}>
|
|
|
+ <View
|
|
|
+ onClick={navigateTo(item.url, item.url === ORDER_PATH)}
|
|
|
+ key={item.title}
|
|
|
+ >
|
|
|
<Image
|
|
|
src={item.icon}
|
|
|
className='w-8 h-8 mx-auto'
|
|
|
@@ -70,7 +90,7 @@ export default function App() {
|
|
|
<Text className='block text-center text-sm mt-2 text-[#666]'>
|
|
|
{item.title}
|
|
|
</Text>
|
|
|
- </Navigator>
|
|
|
+ </View>
|
|
|
);
|
|
|
})}
|
|
|
</View>
|