RechargeDetailScreen.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /* eslint-disable camelcase */
  2. import * as WebBrowser from "expo-web-browser";
  3. import * as React from "react";
  4. import { StyleSheet, Image } from "react-native";
  5. import {
  6. Layout,
  7. useTheme,
  8. Icon,
  9. Divider,
  10. Text,
  11. } from "@ui-kitten/components";
  12. import { useModel } from "flooks";
  13. import { useFocusEffect, useRoute } from "@react-navigation/native";
  14. import moment from "moment";
  15. import NavHeaderBar from "../../components/NavHeaderBar";
  16. import ScrollPage from "../../components/ScrollPage";
  17. const styles = StyleSheet.create({
  18. top: {
  19. flexDirection: "row",
  20. alignItems: "center",
  21. paddingTop: 7,
  22. paddingLeft: 30,
  23. paddingRight: 56,
  24. },
  25. image: {
  26. width: 66,
  27. height: 66,
  28. flexShrink: 0,
  29. },
  30. icon: {
  31. width: 33,
  32. height: 33,
  33. flexShrink: 0,
  34. },
  35. line: {
  36. flex: 1,
  37. height: 2,
  38. },
  39. activeLine: {
  40. backgroundColor: "#FFC21C",
  41. },
  42. errorLine: {
  43. backgroundColor: "#F15A3C",
  44. },
  45. tips: {
  46. paddingBottom: 11,
  47. alignItems: "center",
  48. },
  49. form: {
  50. marginTop: 7,
  51. paddingVertical: 20,
  52. paddingHorizontal: 13,
  53. },
  54. item: {
  55. flexDirection: "row",
  56. justifyContent: "space-between",
  57. marginBottom: 10,
  58. },
  59. name: {
  60. color: "#787878",
  61. },
  62. });
  63. const img1=require("../../assets/images/logo_1.png")
  64. const img2=require("../../assets/images/apply2.png")
  65. export default function RechargeDetailScreen() {
  66. const theme = useTheme();
  67. const { changeBackground } = useModel("barModel");
  68. const {
  69. WITHDRAW,
  70. Apply_SUCCESS,
  71. Apply_PENDING,
  72. Apply_FAIL,
  73. rechargeTime,
  74. rechargeTitle2,
  75. rechargeTitle3,
  76. } = useModel("wordsModel");
  77. const { httpGet } = useModel("httpModel", true);
  78. // const { } = useModel("loadingModel");
  79. const [applyInfo, setApplyInfo] = React.useState({});
  80. const route = useRoute();
  81. const { amount, bankCard, status, withdrawTime } = applyInfo;
  82. const { bankName, cardNo } = bankCard || {};
  83. useFocusEffect(
  84. React.useCallback(() => {
  85. changeBackground(theme["color-primary-500"]);
  86. }, [])
  87. );
  88. const showTip = React.useMemo(() => {
  89. if (status === "SUCCESS") {
  90. return Apply_SUCCESS;
  91. } if (status === "FAIL") {
  92. return Apply_FAIL;
  93. }
  94. return Apply_PENDING;
  95. }, [Apply_SUCCESS, Apply_PENDING, Apply_FAIL]);
  96. const getTime = React.useMemo(() => {
  97. if (withdrawTime) {
  98. return moment(withdrawTime, "YYYY-MM-DD HH:mm:ss")
  99. .add(2, "hours")
  100. .format("YYYY-MM-DD HH:mm:ss");
  101. }
  102. return "";
  103. }, [withdrawTime]);
  104. const showBankInfo = React.useMemo(() => {
  105. if (bankName && cardNo) {
  106. return (
  107. `${bankName
  108. } (${
  109. cardNo.length > 5
  110. ? cardNo.substr(cardNo.length - 5, 4)
  111. : cardNo.substr(0, cardNo.length)
  112. })`
  113. );
  114. }
  115. return "";
  116. }, [bankName, cardNo]);
  117. function refreshEvent() {
  118. const { params } = route;
  119. const { id } = params || {};
  120. return httpGet(`/withdrawApply/get/${ id}`, {}, true).then(res => {
  121. setApplyInfo(res);
  122. });
  123. }
  124. return (
  125. <>
  126. <NavHeaderBar title={WITHDRAW} />
  127. <ScrollPage enabledFresh refreshEvent={refreshEvent}>
  128. <Layout style={styles.top}>
  129. <Image
  130. source={img1}
  131. style={styles.image}
  132. />
  133. <Divider style={[styles.line, styles.activeLine]} />
  134. <Image
  135. source={img2}
  136. style={styles.icon}
  137. />
  138. {status === "SUCCESS" ? (
  139. <Divider style={[styles.line, styles.activeLine]} />
  140. ) : status === "FAIL" ? (
  141. <Divider style={[styles.line, styles.errorLine]} />
  142. ) : (
  143. <Divider style={[styles.line]} />
  144. )}
  145. {status === "SUCCESS" ? (
  146. <Icon
  147. fill='#FFC21C'
  148. name='checkmark-circle-2'
  149. style={styles.icon}
  150. />
  151. ) : status === "FAIL" ? (
  152. <Icon
  153. fill='#F15A3C'
  154. name='checkmark-circle-2'
  155. style={styles.icon}
  156. />
  157. ) : (
  158. <Icon
  159. fill='#EEEEEE'
  160. name='checkmark-circle-2'
  161. style={styles.icon}
  162. />
  163. )}
  164. </Layout>
  165. <Layout style={styles.tips}>
  166. <Text>{showTip}</Text>
  167. </Layout>
  168. <Layout style={styles.form}>
  169. {getTime !== "" && (
  170. <Layout style={styles.item}>
  171. <Text style={styles.name}>{rechargeTime}</Text>
  172. <Text>{getTime}</Text>
  173. </Layout>
  174. )}
  175. <Layout style={styles.item}>
  176. <Text style={styles.name}>{rechargeTitle2}</Text>
  177. <Text>{showBankInfo}</Text>
  178. </Layout>
  179. <Layout style={styles.item}>
  180. <Text style={styles.name}>{rechargeTitle3}</Text>
  181. <Text>
  182. ¥
  183. {amount}
  184. </Text>
  185. </Layout>
  186. </Layout>
  187. </ScrollPage>
  188. </>
  189. );
  190. }