|
|
@@ -2,50 +2,93 @@ import * as WebBrowser from 'expo-web-browser';
|
|
|
import * as React from 'react';
|
|
|
import { StyleSheet, View, Image } from 'react-native';
|
|
|
import { Flex, WhiteSpace, WingBlank, Badge } from '@ant-design/react-native';
|
|
|
+import { useCreation } from '@umijs/hooks';
|
|
|
import Text from '../../../components/Text';
|
|
|
import Chip from '../../../components/Chip';
|
|
|
import Icon from '../../../components/SvgIcon';
|
|
|
|
|
|
// 首页商家组件
|
|
|
|
|
|
-export default function MerchantCom() {
|
|
|
+export default function MerchantCom(props) {
|
|
|
+ const { info } = props;
|
|
|
+
|
|
|
+ const {
|
|
|
+ showName,
|
|
|
+ logo,
|
|
|
+ distance,
|
|
|
+ firstOrder,
|
|
|
+ category,
|
|
|
+ merchantNature,
|
|
|
+ startingAmount,
|
|
|
+ monthSales,
|
|
|
+ goodNum,
|
|
|
+ badNum,
|
|
|
+ } = info;
|
|
|
+
|
|
|
+ const tags = useCreation(() => {
|
|
|
+ let list = [];
|
|
|
+ if (merchantNature) {
|
|
|
+ list.push({
|
|
|
+ name: merchantNature.name,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (category) {
|
|
|
+ list = list.concat(
|
|
|
+ category.map((item) => {
|
|
|
+ return { name: item.name };
|
|
|
+ })
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }, [category, merchantNature]);
|
|
|
+
|
|
|
+ const long = useCreation(() => {
|
|
|
+ if (distance < 1000) {
|
|
|
+ return `${distance}米`;
|
|
|
+ } else {
|
|
|
+ return `${(distance / 1000).toFixed(1)}km`;
|
|
|
+ }
|
|
|
+ }, [distance]);
|
|
|
+
|
|
|
return (
|
|
|
<Flex align="start" style={styles.merchant}>
|
|
|
- <Image
|
|
|
- style={styles.image}
|
|
|
- resizeMode="cover"
|
|
|
- source={{ uri: 'https://picsum.photos/700' }}
|
|
|
- />
|
|
|
+ <Image style={styles.image} resizeMode="cover" source={{ uri: logo }} />
|
|
|
<Flex.Item style={styles.main}>
|
|
|
<Text size="s1" bold>
|
|
|
- 111
|
|
|
+ {showName}
|
|
|
</Text>
|
|
|
- <Flex>
|
|
|
- <Chip>连锁品牌</Chip>
|
|
|
- <Chip>百年老店</Chip>
|
|
|
- </Flex>
|
|
|
+ {tags.length > 0 && (
|
|
|
+ <Flex>
|
|
|
+ {tags.map((item, index) => {
|
|
|
+ return <Chip key={index}>{item.name}</Chip>;
|
|
|
+ })}
|
|
|
+ </Flex>
|
|
|
+ )}
|
|
|
+
|
|
|
<Flex>
|
|
|
<Flex>
|
|
|
<Icon name="zan" type="primary" width={18} height={18} />
|
|
|
<Text size="c1" type="primary">
|
|
|
- 9999+
|
|
|
+ {goodNum || 0}
|
|
|
</Text>
|
|
|
</Flex>
|
|
|
<Flex style={styles.text}>
|
|
|
<Icon name="zan" Flip color="#000" width={18} height={18} />
|
|
|
<Text size="c1" type="info">
|
|
|
- 9999+
|
|
|
+ {badNum || 0}
|
|
|
</Text>
|
|
|
</Flex>
|
|
|
<Flex style={styles.text}>
|
|
|
<Text size="c1" type="info">
|
|
|
- 月售9999+
|
|
|
+ 月售
|
|
|
+ {monthSales}
|
|
|
</Text>
|
|
|
</Flex>
|
|
|
</Flex>
|
|
|
<Flex>
|
|
|
<Text size="c1" type="info">
|
|
|
- 起送$ 10
|
|
|
+ 起送$
|
|
|
+ {startingAmount || 0}
|
|
|
</Text>
|
|
|
<Flex.Item style={styles.text}>
|
|
|
<Text size="c1" type="info">
|
|
|
@@ -57,7 +100,7 @@ export default function MerchantCom() {
|
|
|
</Text>
|
|
|
<View style={styles.text}>
|
|
|
<Text size="c1" type="info">
|
|
|
- 4.2km
|
|
|
+ {long}
|
|
|
</Text>
|
|
|
</View>
|
|
|
</Flex>
|