import * as WebBrowser from 'expo-web-browser'; import * as React from 'react'; import { StyleSheet, View } from 'react-native'; import { Div, Text, Image, Tag } from 'react-native-magnus'; import { Flex, SwipeAction } from '@ant-design/react-native'; import { TouchableRipple } from 'react-native-paper'; import { useTranslation } from 'react-i18next'; import useModel from 'flooks'; import { useCreation } from '@umijs/hooks'; import { useNavigation } from '@react-navigation/native'; import Chip from '../../../components/Chip'; import Icon from '../../../components/SvgIcon'; import DetailModel from '../../Detail/model'; import { getColor } from '../../../Utils/ColorUtils'; // 首页商家组件 export default function MerchantCom(props) { const { info, isCollection, CollectionId, freash, isNew } = props; const navigation = useNavigation(); const { delLike } = useModel(DetailModel, []); const { t } = useTranslation(); const { showName, logo, distance, category, merchantNature, startingAmount, monthSales, goodNum, badNum, preparationTime, mid, } = info || { showName: '' }; 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) { return `${(distance / 1000).toFixed(2)}km`; } else { return false; } }, [distance]); const right = [ { text: t('shan-chu'), onPress: () => { console.log('删除'); delLike(CollectionId).then(() => freash()); }, style: { backgroundColor: 'red', color: 'white' }, }, ]; return (
{ navigation.navigate('MerchantDetail', { merchantId: isCollection || isNew ? info.id : mid, }); }} >
{logo ? ( ) : (
)}
{showName} {tags.length > 0 && (
{tags.map((item, index) => { return ( {item.name} ); })}
)} {goodNum || 0} {badNum || 0} {t('yue-shou')} {monthSales} {t('qi-song')}${startingAmount || 0} {t('pei-song')}$ 10 {preparationTime || 60} {t('fen-zhong')} {!!long && ( {long} )} {/* {t( 'xi-huan-nin-lai-jin-gong-men-xi-huan-nin-lai-jin-gong-men' )} “喜欢您来金拱门喜欢您来金拱门” */} 12{t('jian')}5
); } const styles = StyleSheet.create({ image: { width: 67, height: 67, borderRadius: 3, }, text: { marginLeft: 6, }, label2: { marginTop: 4, overflow: 'hidden', }, main: { marginLeft: 10, borderBottomWidth: 1, borderBottomColor: '#C9C9C9', paddingBottom: 4, }, merchant: { paddingTop: 10, }, });