FirstOrderScreen.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import * as WebBrowser from "expo-web-browser";
  2. import * as React from "react";
  3. import {
  4. Image,
  5. Platform,
  6. StyleSheet,
  7. TouchableOpacity,
  8. View,
  9. ImageBackground,
  10. } from "react-native";
  11. import { useModel } from "flooks";
  12. import {
  13. Layout,
  14. Tab,
  15. TabView,
  16. Text,
  17. useTheme,
  18. Button,
  19. Card,
  20. List,
  21. Input,
  22. Icon,
  23. } from "@ui-kitten/components";
  24. import EmptyComponent from "../../components/EmptyComponent";
  25. import FormInput from "../../components/FormInput";
  26. import { useFocusEffect } from "@react-navigation/native";
  27. import ScrollPage from "../../components/ScrollPage";
  28. import NavHeaderBar from "../../components/NavHeaderBar";
  29. export default function FirstOrderScreen({ navigation, route }) {
  30. const theme = useTheme();
  31. const { changeBackground } = useModel("barModel", true);
  32. const { httpGet, httpPost } = useModel("httpModel", true);
  33. const { success, warnning } = useModel("loadingModel", true);
  34. const { showDialog } = useModel("dialogModel");
  35. const {
  36. userTitle21,
  37. fullReduction2,
  38. fullReduction1,
  39. delText,
  40. editText,
  41. confirm,
  42. cancel,
  43. complete,
  44. successText,
  45. removeTips,
  46. } = useModel("wordsModel");
  47. const [money, changeMoney] = React.useState("");
  48. const [edit, changeEdit] = React.useState(false);
  49. useFocusEffect(
  50. React.useCallback(() => {
  51. changeBackground(theme["color-primary-500"]);
  52. }, [])
  53. );
  54. const { mid, firstOrder, updateMerchant } = useModel("userModel");
  55. React.useEffect(() => {
  56. if (!firstOrder) {
  57. changeEdit(true);
  58. } else {
  59. changeMoney(firstOrder.toString() || "");
  60. }
  61. }, [firstOrder]);
  62. return (
  63. <>
  64. <NavHeaderBar title='首单' />
  65. <ScrollPage
  66. style={styles.lay}
  67. enabledFresh={true}
  68. refreshEvent={() => {
  69. return Promise.resolve();
  70. }}
  71. >
  72. <Layout style={[styles.lay]}>
  73. <Layout style={styles.item}>
  74. <Layout style={[styles.text, styles.flexRow]}>
  75. <Text category='c2'>新用户立减</Text>
  76. {edit ? (
  77. <Input
  78. size='small'
  79. style={styles.input}
  80. value={money}
  81. keyboardType='numeric'
  82. onChangeText={changeMoney}
  83. />
  84. ) : (
  85. <Text category='c2'>{money}</Text>
  86. )}
  87. <Text category='c2'>元</Text>
  88. </Layout>
  89. {!edit ? (
  90. <>
  91. <Button
  92. size='small'
  93. appearance='outline'
  94. onPress={() => {
  95. changeEdit(true);
  96. }}
  97. >
  98. {editText}
  99. </Button>
  100. <Button
  101. size='small'
  102. appearance='outline'
  103. style={styles.buttonlast}
  104. onPress={() => {
  105. changeEdit(false);
  106. }}
  107. >
  108. {cancel}
  109. </Button>
  110. </>
  111. ) : (
  112. <>
  113. <Button
  114. size='small'
  115. onPress={() => {
  116. changeEdit(false);
  117. updateMerchant({
  118. firstOrder: money,
  119. }).then(() => {
  120. // success("保存成功");
  121. });
  122. }}
  123. >
  124. 保存
  125. </Button>
  126. {money != "" && (
  127. <Button
  128. size='small'
  129. status='danger'
  130. style={styles.buttonlast}
  131. onPress={() => {
  132. changeMoney("");
  133. changeEdit(true);
  134. updateMerchant({
  135. firstOrder: 0,
  136. }).then(() => {
  137. // success("删除成功");
  138. });
  139. }}
  140. >
  141. {delText}
  142. </Button>
  143. )}
  144. </>
  145. )}
  146. </Layout>
  147. </Layout>
  148. </ScrollPage>
  149. </>
  150. );
  151. }
  152. const PulsIcon = props => (
  153. <Icon
  154. {...props}
  155. style={[props.style, { width: 33, height: 33 }]}
  156. name='plus-circle'
  157. />
  158. );
  159. const styles = StyleSheet.create({
  160. lay: {
  161. backgroundColor: "#fff",
  162. },
  163. padBot: {
  164. paddingBottom: 100,
  165. },
  166. list: {
  167. paddingVertical: 10,
  168. paddingHorizontal: 15,
  169. backgroundColor: "transparent",
  170. flex: 0,
  171. },
  172. item: {
  173. flexDirection: "row",
  174. alignItems: "center",
  175. paddingVertical: 10,
  176. paddingHorizontal: 15,
  177. },
  178. input: {
  179. marginHorizontal: 5,
  180. minWidth: 49,
  181. },
  182. text: {
  183. flex: 1,
  184. },
  185. flexRow: {
  186. flexDirection: "row",
  187. alignItems: "center",
  188. },
  189. buttonlast: {
  190. marginLeft: 10,
  191. },
  192. button: {
  193. alignSelf: "flex-start",
  194. },
  195. });