| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- import React from "react";
- import { StyleSheet, View } from "react-native";
- import { Card, Text, Button, Avatar } from "@ui-kitten/components";
- import { useModel } from "flooks";
- const styles = StyleSheet.create({
- card: { marginTop: 10 },
- layout: {
- flexDirection: "row",
- height: 80,
- backgroundColor: "transparent",
- },
- avatar: {
- width: 80,
- height: 80,
- marginRight: 10,
- },
- main: {
- flex: 1,
- backgroundColor: "transparent",
- },
- flex1: {
- flex: 1,
- },
- butContent: {
- marginLeft: 6,
- },
- fontColor: {
- color: "#B5B5B5",
- },
- miniButton: {
- minWidth: 22,
- minHeight: 22,
- width: 22,
- height: 22,
- position: "absolute",
- right: 10,
- bottom: 5,
- maxWidth: 22,
- },
- status: {
- position: "absolute",
- left: 0,
- width: 80,
- paddingVertical: 4,
- backgroundColor: "#F0F0F0",
- bottom: 0,
- textAlign: "center",
- },
- });
- export default function GoodsCard(props) {
- const { add, remove, getWordsStr, EBBZOP, HBHXVO, YMCWXK } = useModel(
- "wordsModel"
- );
- const {
- info,
- changeInfo,
- type,
- removeEvent,
- addEvent,
- isAdd,
- appearance,
- style,
- canEdit,
- onPress,
- } = props;
- const {
- id,
- img,
- name,
- introduction,
- totalSales,
- discountAmount,
- amount,
- takeOff,
- status,
- } = info || {};
- const { takeOffInfo, ChangeTakeOff } = useModel("goodsModel", true);
- return (
- <Card
- style={[!appearance && styles.card, style]}
- appearance={appearance || "goodsCard"}
- disabled={!canEdit}
- onPress={onPress}
- >
- {id ? (
- <View style={styles.layout}>
- <Avatar
- style={styles.avatar}
- shape="rounded"
- source={{
- uri: img,
- }}
- />
- {status === "PENDING" && (
- <Text style={styles.status} category="h1">
- {EBBZOP}
- </Text>
- )}
- {status === "DENY" && (
- <Text style={styles.status} category="h1" status="danger">
- {HBHXVO}
- </Text>
- )}
- <View style={styles.main}>
- <Text category="s1" ellipsizeMode="tail" numberOfLines={1}>
- {name || ""}
- </Text>
- <Text
- category="c1"
- status="info"
- ellipsizeMode="tail"
- numberOfLines={1}
- >
- {introduction || ""}
- </Text>
- <Text category="c1" status="info">
- {YMCWXK} {totalSales || 0}
- </Text>
- <View style={styles.flex1} />
- <Text category="h6" status="danger">
- ¥{discountAmount}{" "}
- <Text
- category="h1"
- status="info"
- style={{ textDecorationLine: "line-through" }}
- >
- ¥{amount}
- </Text>
- </Text>
- </View>
- {appearance && type === "goodsList" && (
- <View style={styles.butContent}>
- <Button
- status="primary"
- size="small"
- appearance="outline"
- onPress={() => {
- if (!takeOff) {
- takeOffInfo(() => {
- ChangeTakeOff(info).then(res => {
- changeInfo(res);
- });
- });
- } else {
- ChangeTakeOff(info).then(res => {
- changeInfo(res);
- });
- }
- }}
- >
- {getWordsStr(takeOff ? "takeUp" : "takeOff")}
- </Button>
- </View>
- )}
- {!appearance && !isAdd && (
- <View style={styles.butContent}>
- <Button status="primary" size="tiny" onPress={addEvent}>
- {add}
- </Button>
- </View>
- )}
- {removeEvent && isAdd && (
- <View style={styles.butContent}>
- <Button status="danger" onPress={removeEvent} size="tiny">
- {remove}
- </Button>
- </View>
- )}
- {/* {props.appearance == "classification" &&
- props.type != "goodsList" && (
- <Button
- style={styles.miniButton}
- status='danger'
- onPress={props.removeEvent}
- accessoryLeft={StarIcon}
- />
- )} */}
- </View>
- ) : (
- <View style={styles.layout} />
- )}
- </Card>
- );
- }
|