OrderCom.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. import * as React from 'react';
  2. import { Div, Button, Image, Text, Avatar } from 'react-native-magnus';
  3. import { useTranslation } from 'react-i18next';
  4. import { RiderStatusMap } from '../utils/RiderInfoUtils';
  5. export default function OrderCom({
  6. info,
  7. type,
  8. goDetail,
  9. receiverOrder,
  10. goMap,
  11. changeStatus,
  12. sign,
  13. }) {
  14. const {
  15. user,
  16. userAddress,
  17. merchant,
  18. riderStatus,
  19. timeOfArrival,
  20. deliveryAmount,
  21. merShowName,
  22. merAddress,
  23. } = info;
  24. const { t } = useTranslation();
  25. const orderStatusInfo = RiderStatusMap.get(riderStatus);
  26. return (
  27. <Button bg="white" p={0} block mb={15} onPress={goDetail}>
  28. <Div flex={1}>
  29. <Div px={10} py={15}>
  30. <Div row alignItems="center">
  31. <Text fontSize="xl" color="red500" fontWeight="bold">
  32. 43分钟内
  33. </Text>
  34. <Text fontSize="xl">{t('song-da')}</Text>
  35. <Text
  36. fontSize="xl"
  37. color="red500"
  38. fontWeight="bold"
  39. flex={1}
  40. textAlign="right"
  41. >
  42. {deliveryAmount}
  43. </Text>
  44. </Div>
  45. {orderStatusInfo.type === 'merchant' && (
  46. <Text fontSize="xl" color="black" fontWeight="bold" pt={2}>
  47. {t('liu-shui-hao')}:{info.id}
  48. </Text>
  49. )}
  50. <Div row mt={10}>
  51. <Text
  52. fontSize={orderStatusInfo.type === 'merchant' ? 'xl' : 'sm'}
  53. color={orderStatusInfo.type === 'merchant' ? 'black' : 'gray500'}
  54. fontWeight={
  55. orderStatusInfo.type === 'merchant' ? 'bold' : 'normal'
  56. }
  57. >
  58. 1.5Km
  59. </Text>
  60. <Div flex={1} ml={12}>
  61. <Text
  62. fontSize={orderStatusInfo.type === 'merchant' ? 'xl' : 'sm'}
  63. color={
  64. orderStatusInfo.type === 'merchant' ? 'black' : 'gray600'
  65. }
  66. fontWeight={
  67. orderStatusInfo.type === 'merchant' ? 'bold' : 'normal'
  68. }
  69. pb={3}
  70. >
  71. {merShowName}
  72. </Text>
  73. <Text
  74. fontSize={orderStatusInfo.type === 'merchant' ? 'lg' : 'xs'}
  75. color={
  76. orderStatusInfo.type === 'merchant' ? 'black' : 'gray600'
  77. }
  78. fontWeight={
  79. orderStatusInfo.type === 'merchant' ? 'bold' : 'normal'
  80. }
  81. >
  82. {merAddress}
  83. </Text>
  84. </Div>
  85. </Div>
  86. <Div row mt={10}>
  87. <Text
  88. fontSize={orderStatusInfo.type === 'user' ? 'xl' : 'sm'}
  89. color={orderStatusInfo.type === 'user' ? 'black' : 'gray500'}
  90. fontWeight={orderStatusInfo.type === 'user' ? 'bold' : 'normal'}
  91. >
  92. 1.5Km
  93. </Text>
  94. <Div flex={1} ml={12}>
  95. {user.nickName && (
  96. <Text
  97. fontSize={orderStatusInfo.type === 'user' ? 'xl' : 'sm'}
  98. color={orderStatusInfo.type === 'user' ? 'black' : 'gray500'}
  99. fontWeight={
  100. orderStatusInfo.type === 'user' ? 'bold' : 'normal'
  101. }
  102. pb={5}
  103. >
  104. {user.nickName}
  105. </Text>
  106. )}
  107. <Text
  108. fontSize={orderStatusInfo.type === 'user' ? 'lg' : 'xs'}
  109. color={orderStatusInfo.type === 'user' ? 'black' : 'gray500'}
  110. fontWeight={orderStatusInfo.type === 'user' ? 'bold' : 'normal'}
  111. >
  112. {userAddress}
  113. </Text>
  114. </Div>
  115. </Div>
  116. </Div>
  117. {riderStatus === 'NOT_RECEIVED' && (
  118. <Button
  119. block
  120. mx={15}
  121. mb={20}
  122. bg={sign ? 'yellow500' : 'gray500'}
  123. disabled={!sign}
  124. onPress={receiverOrder}
  125. >
  126. {t('jie-dan')}
  127. </Button>
  128. )}
  129. {riderStatus != 'NOT_RECEIVED' && (
  130. <Div row mx={15} mb={20}>
  131. <Button
  132. flex={1}
  133. color="black"
  134. bg="white"
  135. borderColor="yellow500"
  136. borderWidth={1}
  137. onPress={goMap}
  138. >
  139. {t('cha-kan-dao-hang')}
  140. </Button>
  141. {riderStatus === 'RECEIVED' && (
  142. <Button ml={20} flex={1} bg="yellow500" onPress={changeStatus}>
  143. {t('wo-yi-dao-dian')}
  144. </Button>
  145. )}
  146. {riderStatus === 'ARRIVE' && (
  147. <Button ml={20} flex={1} bg="yellow500" onPress={goDetail}>
  148. {t('pai-zhao-qu-huo')}
  149. </Button>
  150. )}
  151. {riderStatus === 'TAKE_MEAL' && (
  152. <Button ml={20} flex={1} bg="yellow500" onPress={changeStatus}>
  153. {t('que-ren-song-da')}
  154. </Button>
  155. )}
  156. </Div>
  157. )}
  158. </Div>
  159. </Button>
  160. );
  161. }