PayOrderScreen.jsx 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /* eslint-disable react/jsx-props-no-spreading */
  2. /* eslint-disable no-underscore-dangle */
  3. import * as WebBrowser from 'expo-web-browser';
  4. import * as React from 'react';
  5. import {
  6. StyleSheet,
  7. View,
  8. Clipboard,
  9. Dimensions,
  10. Animated,
  11. PanResponder,
  12. findNodeHandle,
  13. UIManager,
  14. TouchableOpacity,
  15. RefreshControl,
  16. } from 'react-native';
  17. import { Div, Button, Image, Text } from 'react-native-magnus';
  18. import { Appbar, Menu } from 'react-native-paper';
  19. import Constants from 'expo-constants';
  20. import { Flex } from '@ant-design/react-native';
  21. import { ScrollView } from 'react-native-gesture-handler';
  22. import { useRequest, useCreation, useMount } from '@umijs/hooks';
  23. import { useTranslation } from 'react-i18next';
  24. import { useRoute } from '@react-navigation/native';
  25. import { useAnimation } from 'react-native-animation-hooks';
  26. import useModel from 'flooks';
  27. import Toast from '../../flooks/Toast';
  28. import Header from '../Order/Header'; // 头部
  29. import PayCom from './PayCom';
  30. import OrderModel from '../Order/model';
  31. import { connectKefu } from '../../Utils/TotastUtils';
  32. import {
  33. merchantStatusMap,
  34. orderStatusMap,
  35. RiderStatusMap,
  36. payMap,
  37. reasonMap,
  38. } from '../../Utils/OrderUtils';
  39. import Time from '../../Utils/TimeUtils';
  40. import MapScreen from '../Map/MapScreen';
  41. export default function PayOrderScreen({ navigation }) {
  42. const { t } = useTranslation();
  43. const [orderInfo, setorderInfo] = React.useState({
  44. merchant: {},
  45. orderGoodsSpecs: [],
  46. });
  47. const { payOrder } = useModel(OrderModel, []);
  48. const { loading, success, warnning, clearLoading } = useModel(Toast, []);
  49. const route = useRoute();
  50. const { params } = route;
  51. const { orderId } = params || 0;
  52. const orderRequest = useRequest(`/orderInfo/get/${orderId}`, {
  53. refreshDeps: [orderId],
  54. onSuccess: (result) => {
  55. setorderInfo(result);
  56. },
  57. });
  58. const { merchant, orderGoodsSpecs } = orderInfo;
  59. return (
  60. <Div bg="gray200" w="100%" flex={1}>
  61. <Header title="收银台" orderId={orderId} />
  62. <ScrollView
  63. contentContainerStyle={{ flexGrow: 1, backgroundColor: '#eee' }}
  64. refreshControl={
  65. <RefreshControl
  66. refreshing={orderRequest.loading}
  67. onRefresh={orderRequest.run}
  68. />
  69. }
  70. >
  71. <Div pt={10} pb={10} px={15}>
  72. <View style={[styles.card]}>
  73. <Text fontSize="xl">
  74. {t('yu-ji')}
  75. {new Time(
  76. orderInfo.timeOfArrival,
  77. 'yyyy-MM-DD HH:mm:ss'
  78. ).getFormat('HH:mm')}
  79. {t('song-da')}
  80. </Text>
  81. </View>
  82. <View style={[styles.card]}>
  83. <Div row pb={10}>
  84. <Text fontSize="xl" fontWeight="bold">
  85. {orderInfo.merShowName}
  86. </Text>
  87. </Div>
  88. <Div>
  89. {orderGoodsSpecs.map((item) => {
  90. return (
  91. <GoodsItem info={item} goods={item.goods} key={item.id} />
  92. );
  93. })}
  94. </Div>
  95. <Flex style={styles.info}>
  96. <Flex.Item>
  97. <Flex>
  98. <Text fontSize="xs" color="gray300" textAlign="left">
  99. {t('bao-zhuang-fei')}
  100. </Text>
  101. <Text fontSize="xs" color="gray300" textAlign="left">
  102. {t('can-he')}
  103. </Text>
  104. </Flex>
  105. </Flex.Item>
  106. <Text fontSize="xs" color="gray300" textAlign="left">
  107. ¥{orderInfo.packingPrice}
  108. </Text>
  109. </Flex>
  110. <Flex style={styles.info}>
  111. <Flex.Item>
  112. <Text fontSize="xs" color="gray300" textAlign="left">
  113. {t('pei-song-fei-ding-dong-zhuan-song')}
  114. </Text>
  115. </Flex.Item>
  116. <Text fontSize="xs" color="gray300" textAlign="left">
  117. ¥{orderInfo.deliveryAmount}
  118. </Text>
  119. </Flex>
  120. <Flex style={styles.info}>
  121. <Flex.Item>
  122. <Text fontSize="xs" color="gray300" textAlign="left">
  123. {t('man-jian')}
  124. </Text>
  125. </Flex.Item>
  126. <Text fontSize="xs" color="red500" textAlign="left">
  127. -¥{orderInfo.fullReduction}
  128. </Text>
  129. </Flex>
  130. {!!orderInfo.firstBuy && (
  131. <Flex style={styles.info}>
  132. <Flex.Item>
  133. <Text fontSize="xs" color="gray300" textAlign="left">
  134. {t('shou-dan')}
  135. </Text>
  136. </Flex.Item>
  137. <Text fontSize="xs" color="red500" textAlign="left">
  138. ¥{orderInfo.firstBuy}
  139. </Text>
  140. </Flex>
  141. )}
  142. <Flex style={styles.info}>
  143. <Flex.Item>
  144. <Text fontSize="xs" color="gray300" textAlign="left">
  145. {t('hong-bao')}
  146. </Text>
  147. </Flex.Item>
  148. <Text fontSize="xs" color="red500" textAlign="left">
  149. -¥{orderInfo.redBag || 0}
  150. </Text>
  151. </Flex>
  152. <Flex style={styles.total} justify="end">
  153. <Text size="s1">
  154. {t('xiao-ji')} ¥{orderInfo.realAmount}
  155. </Text>
  156. </Flex>
  157. </View>
  158. </Div>
  159. <Div pt={10} pb={10} px={15}>
  160. <Div bg="white" p={15}>
  161. <PayCom />
  162. </Div>
  163. <Button
  164. block
  165. bg="brand500"
  166. mt={20}
  167. onPress={() => {
  168. payOrder(orderId).then(() => {
  169. navigation.replace('OrderDetail', { orderId });
  170. });
  171. }}
  172. >
  173. 立即支付
  174. </Button>
  175. </Div>
  176. </ScrollView>
  177. </Div>
  178. );
  179. }
  180. const GoodsItem = ({ info, goods }) => {
  181. return (
  182. <Div row>
  183. <Image w={33} h={33} rounded={3} source={{ uri: goods.img }} />
  184. <Div flex={1} ml={10}>
  185. <Div row>
  186. <Text fontSize="sm" flex={1}>
  187. {goods.name}
  188. </Text>
  189. <Text fontSize="sm">X {info.num}</Text>
  190. <Text ml={10}>¥{info.goodsRealPrice}</Text>
  191. </Div>
  192. <Text fontSize="xs" color="gray400">
  193. {info.specification}
  194. </Text>
  195. </Div>
  196. </Div>
  197. );
  198. };
  199. const styles = StyleSheet.create({
  200. scroll: {
  201. flexGrow: 1,
  202. },
  203. card: {
  204. borderRadius: 3,
  205. backgroundColor: '#fff',
  206. marginBottom: 5,
  207. padding: 15,
  208. },
  209. item: {
  210. paddingVertical: 5,
  211. },
  212. icon: {
  213. width: 33,
  214. height: 33,
  215. borderRadius: 3,
  216. },
  217. goodsMain: {
  218. marginLeft: 10,
  219. },
  220. type: {
  221. // marginTop:3,
  222. },
  223. main: {
  224. marginTop: 10,
  225. paddingVertical: 5,
  226. borderColor: '#E5E5E5',
  227. borderTopWidth: 1,
  228. },
  229. info: {
  230. marginTop: 10,
  231. },
  232. total: {
  233. paddingTop: 10,
  234. marginTop: 10,
  235. borderColor: '#E5E5E5',
  236. borderTopWidth: 1,
  237. },
  238. address: {
  239. minWidth: 50,
  240. marginRight: 30,
  241. },
  242. info2: {
  243. marginTop: 10,
  244. },
  245. });