|
|
@@ -1,23 +1,48 @@
|
|
|
import * as WebBrowser from 'expo-web-browser';
|
|
|
import * as React from 'react';
|
|
|
-import { StyleSheet, Animated, UIManager, findNodeHandle } from 'react-native';
|
|
|
-import Constants from 'expo-constants';
|
|
|
+import { Animated, Dimensions } from 'react-native';
|
|
|
import { Div, Button, Text, Icon } from 'react-native-magnus';
|
|
|
-import { Menu, Portal } from 'react-native-paper';
|
|
|
-import { useBoolean, useDebounceFn, useCreation } from '@umijs/hooks';
|
|
|
+import { useBoolean, useCreation } from '@umijs/hooks';
|
|
|
import { useAnimation } from 'react-native-animation-hooks';
|
|
|
import useModel from 'flooks';
|
|
|
-import MerchantCom from './MerchantCom';
|
|
|
import HomeModel from './model';
|
|
|
-import { popularTagMap } from '../../../Utils/MerchantUtils';
|
|
|
+import { sortMap, filterMap, tagMap } from '../../../Utils/MerchantUtils';
|
|
|
+import Filter from './Filter';
|
|
|
|
|
|
-export default function List({ animatedScrollYValue, topHeight }) {
|
|
|
- const firstSortMenu = useBoolean(false);
|
|
|
- const { popularTag, changeTag } = useModel(HomeModel, [
|
|
|
- 'loadingTop',
|
|
|
- 'popularTag',
|
|
|
+export default function List({
|
|
|
+ animatedScrollYValue,
|
|
|
+ topHeight,
|
|
|
+ setscrollEnabled,
|
|
|
+}) {
|
|
|
+ const SortMenu = useBoolean(false);
|
|
|
+ const filterMenu = useBoolean(false);
|
|
|
+ const {
|
|
|
+ sort,
|
|
|
+ changeSort,
|
|
|
+ merchantNatureList,
|
|
|
+ getNature,
|
|
|
+ clearFiliter,
|
|
|
+ ChangeFiliter,
|
|
|
+ filter,
|
|
|
+ tag,
|
|
|
+ natureId,
|
|
|
+ endAmount,
|
|
|
+ } = useModel(HomeModel, [
|
|
|
+ 'sort',
|
|
|
+ 'merchantNatureList',
|
|
|
+ 'filter',
|
|
|
+ 'tag',
|
|
|
+ 'natureId',
|
|
|
+ 'endAmount',
|
|
|
]);
|
|
|
|
|
|
+ React.useEffect(() => {
|
|
|
+ if (merchantNatureList.length === 0) {
|
|
|
+ getNature();
|
|
|
+ // setscrollEnabled(false);
|
|
|
+ }
|
|
|
+ }, [merchantNatureList]);
|
|
|
+
|
|
|
const top = useCreation(() => {
|
|
|
return topHeight ? topHeight + 56 : 200;
|
|
|
}, [topHeight]);
|
|
|
@@ -27,21 +52,19 @@ export default function List({ animatedScrollYValue, topHeight }) {
|
|
|
outputRange: [0, 0, 0, 1],
|
|
|
});
|
|
|
|
|
|
- const [selectHeight, setSelectHeight] = React.useState(0);
|
|
|
-
|
|
|
const soltType = useCreation(() => {
|
|
|
return 'first';
|
|
|
- }, [popularTag]);
|
|
|
+ }, [sort]);
|
|
|
|
|
|
- const popularInfo = useCreation(() => {
|
|
|
- return popularTagMap.get(popularTag);
|
|
|
- }, [popularTag]);
|
|
|
+ const sortInfo = useCreation(() => {
|
|
|
+ return sortMap.get(sort);
|
|
|
+ }, [sort]);
|
|
|
|
|
|
- const height = useAnimation({
|
|
|
+ const SortHeight = useAnimation({
|
|
|
type: 'timing',
|
|
|
initialValue: 0,
|
|
|
duration: 100,
|
|
|
- toValue: firstSortMenu.state ? 230 : 0,
|
|
|
+ toValue: SortMenu.state ? 230 : 0,
|
|
|
});
|
|
|
|
|
|
return (
|
|
|
@@ -55,7 +78,7 @@ export default function List({ animatedScrollYValue, topHeight }) {
|
|
|
>
|
|
|
<Div row bg="white">
|
|
|
<Button
|
|
|
- onPress={firstSortMenu.setTrue}
|
|
|
+ onPress={SortMenu.setTrue}
|
|
|
bg="hide"
|
|
|
fontSize="xl"
|
|
|
px={10}
|
|
|
@@ -76,41 +99,89 @@ export default function List({ animatedScrollYValue, topHeight }) {
|
|
|
</Button>
|
|
|
</Div>
|
|
|
<Div row bg="white" alignItems="center">
|
|
|
- <Button onPress={() => firstSortMenu.toggle()} bg="hide" px={10}>
|
|
|
+ <Button
|
|
|
+ onPress={() => {
|
|
|
+ SortMenu.toggle();
|
|
|
+ filterMenu.setFalse();
|
|
|
+ }}
|
|
|
+ bg="hide"
|
|
|
+ px={10}
|
|
|
+ >
|
|
|
<Text
|
|
|
fontSize="xs"
|
|
|
color={
|
|
|
- popularTag && popularInfo.showType !== 'top'
|
|
|
- ? 'brand500'
|
|
|
- : 'gray600'
|
|
|
+ sort && sortInfo.showType !== 'top' ? 'brand500' : 'gray600'
|
|
|
}
|
|
|
>
|
|
|
- {popularInfo.name}
|
|
|
+ {sortInfo.showType !== 'top'
|
|
|
+ ? sortInfo.name
|
|
|
+ : sortMap.get('').name}
|
|
|
</Text>
|
|
|
<Icon
|
|
|
name="down"
|
|
|
fontSize="xs"
|
|
|
color={
|
|
|
- popularTag && popularInfo.showType !== 'top'
|
|
|
- ? 'brand500'
|
|
|
- : 'gray600'
|
|
|
+ sort && sortInfo.showType !== 'top' ? 'brand500' : 'gray600'
|
|
|
}
|
|
|
/>
|
|
|
</Button>
|
|
|
|
|
|
- <Button fontSize="xs" bg="hide" color="gray600" px={10}>
|
|
|
+ <Button
|
|
|
+ fontSize="xs"
|
|
|
+ bg="hide"
|
|
|
+ color={sort === '7' ? 'brand500' : 'gray600'}
|
|
|
+ px={10}
|
|
|
+ onPress={() => {
|
|
|
+ changeSort('7');
|
|
|
+ SortMenu.setFalse();
|
|
|
+ filterMenu.setFalse();
|
|
|
+ }}
|
|
|
+ >
|
|
|
距离
|
|
|
</Button>
|
|
|
- <Button fontSize="xs" bg="hide" color="gray600" px={10}>
|
|
|
+ <Button
|
|
|
+ fontSize="xs"
|
|
|
+ bg="hide"
|
|
|
+ color={sort === '8' ? 'brand500' : 'gray600'}
|
|
|
+ px={10}
|
|
|
+ onPress={() => {
|
|
|
+ changeSort('8');
|
|
|
+ SortMenu.setFalse();
|
|
|
+ filterMenu.setFalse();
|
|
|
+ }}
|
|
|
+ >
|
|
|
销量
|
|
|
</Button>
|
|
|
+ <Div flex={1} />
|
|
|
+ <Button
|
|
|
+ onPress={() => {
|
|
|
+ filterMenu.toggle();
|
|
|
+ SortMenu.setFalse();
|
|
|
+ }}
|
|
|
+ bg="hide"
|
|
|
+ px={10}
|
|
|
+ >
|
|
|
+ <Text fontSize="xs" color="gray600">
|
|
|
+ 筛选
|
|
|
+ </Text>
|
|
|
+ <Icon
|
|
|
+ name="down"
|
|
|
+ fontSize="xs"
|
|
|
+ color={
|
|
|
+ sort && sortInfo.showType !== 'top' ? 'brand500' : 'gray600'
|
|
|
+ }
|
|
|
+ />
|
|
|
+ </Button>
|
|
|
</Div>
|
|
|
-
|
|
|
<Animated.View
|
|
|
- style={{ height, overflow: 'hidden', backgroundColor: '#fff' }}
|
|
|
+ style={{
|
|
|
+ height: SortHeight,
|
|
|
+ overflow: 'hidden',
|
|
|
+ backgroundColor: '#fff',
|
|
|
+ }}
|
|
|
>
|
|
|
- {[...popularTagMap.keys()].map((item, index) => {
|
|
|
- const info = popularTagMap.get(item);
|
|
|
+ {[...sortMap.keys()].map((item, index) => {
|
|
|
+ const info = sortMap.get(item);
|
|
|
return info.showType !== 'top' ? (
|
|
|
<Button
|
|
|
key={index}
|
|
|
@@ -118,14 +189,14 @@ export default function List({ animatedScrollYValue, topHeight }) {
|
|
|
bg="white"
|
|
|
rounded="none"
|
|
|
onPress={() => {
|
|
|
- firstSortMenu.setFalse();
|
|
|
- changeTag(item);
|
|
|
+ SortMenu.setFalse();
|
|
|
+ changeSort(item);
|
|
|
}}
|
|
|
>
|
|
|
<Text
|
|
|
fontSize="xs"
|
|
|
flex={1}
|
|
|
- color={popularTag === item ? 'brand500' : 'gray600'}
|
|
|
+ color={sort === item ? 'brand500' : 'gray600'}
|
|
|
>
|
|
|
{info.name}
|
|
|
</Text>
|
|
|
@@ -135,8 +206,23 @@ export default function List({ animatedScrollYValue, topHeight }) {
|
|
|
);
|
|
|
})}
|
|
|
</Animated.View>
|
|
|
+ <Filter
|
|
|
+ show={filterMenu.state}
|
|
|
+ merchantNatureList={merchantNatureList}
|
|
|
+ filters={filter}
|
|
|
+ tags={tag}
|
|
|
+ natureId={natureId}
|
|
|
+ endAmount={endAmount}
|
|
|
+ clear={() => {
|
|
|
+ filterMenu.setFalse();
|
|
|
+ clearFiliter();
|
|
|
+ }}
|
|
|
+ submit={(filter, tag, natureId, endAmount) => {
|
|
|
+ filterMenu.setFalse();
|
|
|
+ }}
|
|
|
+ />
|
|
|
</Animated.View>
|
|
|
- {firstSortMenu.state && (
|
|
|
+ {(SortMenu.state || filterMenu.state) && (
|
|
|
<Button
|
|
|
bg="black600"
|
|
|
position="absolute"
|
|
|
@@ -145,7 +231,10 @@ export default function List({ animatedScrollYValue, topHeight }) {
|
|
|
right={0}
|
|
|
bottom={0}
|
|
|
zIndex={2}
|
|
|
- onPress={firstSortMenu.setFalse}
|
|
|
+ onPress={() => {
|
|
|
+ SortMenu.setFalse();
|
|
|
+ filterMenu.setFalse();
|
|
|
+ }}
|
|
|
/>
|
|
|
)}
|
|
|
</>
|