GoodsCard.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import React from "react";
  2. import { StyleSheet, View } from "react-native";
  3. import { Card, Text, Button, Avatar } from "@ui-kitten/components";
  4. import { useModel } from "flooks";
  5. const styles = StyleSheet.create({
  6. card: { marginTop: 10 },
  7. layout: {
  8. flexDirection: "row",
  9. height: 80,
  10. backgroundColor: "transparent",
  11. },
  12. avatar: {
  13. width: 80,
  14. height: 80,
  15. marginRight: 10,
  16. },
  17. main: {
  18. flex: 1,
  19. backgroundColor: "transparent",
  20. },
  21. flex1: {
  22. flex: 1,
  23. },
  24. butContent: {
  25. marginLeft: 6,
  26. },
  27. fontColor: {
  28. color: "#B5B5B5",
  29. },
  30. miniButton: {
  31. minWidth: 22,
  32. minHeight: 22,
  33. width: 22,
  34. height: 22,
  35. position: "absolute",
  36. right: 10,
  37. bottom: 5,
  38. maxWidth: 22,
  39. },
  40. status: {
  41. position: "absolute",
  42. left: 0,
  43. width: 80,
  44. paddingVertical: 4,
  45. backgroundColor: "#F0F0F0",
  46. bottom: 0,
  47. textAlign: "center",
  48. },
  49. });
  50. export default function GoodsCard(props) {
  51. const { add, remove, getWordsStr, EBBZOP, HBHXVO, YMCWXK } = useModel(
  52. "wordsModel"
  53. );
  54. const {
  55. info,
  56. changeInfo,
  57. type,
  58. removeEvent,
  59. addEvent,
  60. isAdd,
  61. appearance,
  62. style,
  63. canEdit,
  64. onPress,
  65. } = props;
  66. const {
  67. id,
  68. img,
  69. name,
  70. introduction,
  71. totalSales,
  72. discountAmount,
  73. amount,
  74. takeOff,
  75. status,
  76. } = info || {};
  77. const { takeOffInfo, ChangeTakeOff } = useModel("goodsModel", true);
  78. return (
  79. <Card
  80. style={[!appearance && styles.card, style]}
  81. appearance={appearance || "goodsCard"}
  82. disabled={!canEdit}
  83. onPress={onPress}
  84. >
  85. {id ? (
  86. <View style={styles.layout}>
  87. <Avatar
  88. style={styles.avatar}
  89. shape="rounded"
  90. source={{
  91. uri: img,
  92. }}
  93. />
  94. {status === "PENDING" && (
  95. <Text style={styles.status} category="h1">
  96. {EBBZOP}
  97. </Text>
  98. )}
  99. {status === "DENY" && (
  100. <Text style={styles.status} category="h1" status="danger">
  101. {HBHXVO}
  102. </Text>
  103. )}
  104. <View style={styles.main}>
  105. <Text category="s1" ellipsizeMode="tail" numberOfLines={1}>
  106. {name || ""}
  107. </Text>
  108. <Text
  109. category="c1"
  110. status="info"
  111. ellipsizeMode="tail"
  112. numberOfLines={1}
  113. >
  114. {introduction || ""}
  115. </Text>
  116. <Text category="c1" status="info">
  117. {YMCWXK} {totalSales || 0}
  118. </Text>
  119. <View style={styles.flex1} />
  120. <Text category="h6" status="danger">
  121. ¥{discountAmount}{" "}
  122. <Text
  123. category="h1"
  124. status="info"
  125. style={{ textDecorationLine: "line-through" }}
  126. >
  127. ¥{amount}
  128. </Text>
  129. </Text>
  130. </View>
  131. {appearance && type === "goodsList" && (
  132. <View style={styles.butContent}>
  133. <Button
  134. status="primary"
  135. size="small"
  136. appearance="outline"
  137. onPress={() => {
  138. if (!takeOff) {
  139. takeOffInfo(() => {
  140. ChangeTakeOff(info).then(res => {
  141. changeInfo(res);
  142. });
  143. });
  144. } else {
  145. ChangeTakeOff(info).then(res => {
  146. changeInfo(res);
  147. });
  148. }
  149. }}
  150. >
  151. {getWordsStr(takeOff ? "takeUp" : "takeOff")}
  152. </Button>
  153. </View>
  154. )}
  155. {!appearance && !isAdd && (
  156. <View style={styles.butContent}>
  157. <Button status="primary" size="tiny" onPress={addEvent}>
  158. {add}
  159. </Button>
  160. </View>
  161. )}
  162. {removeEvent && isAdd && (
  163. <View style={styles.butContent}>
  164. <Button status="danger" onPress={removeEvent} size="tiny">
  165. {remove}
  166. </Button>
  167. </View>
  168. )}
  169. {/* {props.appearance == "classification" &&
  170. props.type != "goodsList" && (
  171. <Button
  172. style={styles.miniButton}
  173. status='danger'
  174. onPress={props.removeEvent}
  175. accessoryLeft={StarIcon}
  176. />
  177. )} */}
  178. </View>
  179. ) : (
  180. <View style={styles.layout} />
  181. )}
  182. </Card>
  183. );
  184. }