import { Images } from '@/constants/images'; import { GoodsItem } from '@/services/mall'; import { Image } from 'expo-image'; import React from 'react'; import { Dimensions, ImageBackground, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; const { width: SCREEN_WIDTH } = Dimensions.get('window'); // 小程序: width = (screenWidth - 18) / 2, height = 504rpx = 252pt const CARD_WIDTH = (SCREEN_WIDTH - 18) / 2; const CARD_HEIGHT = 252; // 图片区域: 340rpx = 170pt, 356rpx = 178pt const IMG_BOX_WIDTH = 170; const IMG_BOX_HEIGHT = 178; interface GoodsCardProps { data: GoodsItem; onPress?: (item: GoodsItem) => void; } export function GoodsCard({ data, onPress }: GoodsCardProps) { return ( onPress?.(data)}> {/* 图片边框装饰 */} {data.name} ¥ {data.price} {data.sellType === 2 && ( 预售 )} ); } const styles = StyleSheet.create({ cell: { height: CARD_HEIGHT, marginBottom: 12, }, content: { overflow: 'hidden', borderRadius: 8, }, imgBox: { width: IMG_BOX_WIDTH, height: IMG_BOX_HEIGHT, borderRadius: 7, overflow: 'hidden', paddingHorizontal: 6, alignSelf: 'center', }, image: { width: '100%', height: '100%', }, imgBoxBorder: { position: 'absolute', left: 0, top: 0, width: '100%', height: '100%', }, textBox: { paddingHorizontal: 9, marginTop: 6, }, name: { fontSize: 12, color: '#fff', }, priceRow: { flexDirection: 'row', alignItems: 'baseline', marginTop: 3, }, currency: { fontSize: 10, color: '#fff', }, price: { fontSize: 16, fontWeight: 'bold', color: '#fff', }, presellTag: { width: 64, height: 22, lineHeight: 22, borderRadius: 11, marginLeft: 8, justifyContent: 'center', alignItems: 'center', backgroundColor: 'rgba(255,255,255,0.2)', }, presellText: { fontSize: 12, color: '#fff', textAlign: 'center', }, });