DeliverySign.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. Image,
  6. StatusBar,
  7. Dimensions,
  8. PixelRatio,
  9. TouchableOpacity,
  10. Text,
  11. FlatList,
  12. ScrollView,
  13. ImageBackground,
  14. RefreshControl,
  15. ActivityIndicator,
  16. } from 'react-native'
  17. import { connect } from 'react-redux'
  18. import png from '../../../../static/images/defaultimg.jpg'
  19. import Icon from '../../../../components/Iconfont/Iconfont'
  20. import { NavigationActions, createAction } from '../../../../utils'
  21. import { ReturnDate } from '../../../../utils/utils'
  22. import signPng from '../../../../static/images/signed.png'
  23. import EmptyOrder from '../../../../static/images/Empty-order.png'
  24. import { ImageBaseUrl } from '../../../../utils/fetch/Fetchx'
  25. const { width, height } = Dimensions.get('window')
  26. @connect(({ theme, ordersign }) => ({ ...theme, ...ordersign }))
  27. class DeliverySign extends Component {
  28. constructor() {
  29. super()
  30. this.state = {
  31. activeSection: 'suibianshuru',
  32. setButton: 0,
  33. isRefreshing: false,
  34. Loading: false,
  35. SubmitLoad: false,
  36. }
  37. this.page = 0
  38. this.size = 5
  39. }
  40. componentDidMount = () => {
  41. this.onRefresh()
  42. }
  43. onRefresh() {
  44. this.props.dispatch(
  45. createAction('ordersign/getSignList')({
  46. signData: [],
  47. pageInfo: { page: 0, size: this.size },
  48. searchInfo: {
  49. search_EQ_customerId: CUSTOMERINFO.id,
  50. },
  51. })
  52. )
  53. this.page = 0
  54. }
  55. gotoDetail = () => {
  56. this.props.dispatch(NavigationActions.navigate({ routeName: 'Detail' }))
  57. }
  58. _toggle(key) {
  59. if (this.state.activeSection == key) {
  60. this.setState({ activeSection: key + 'asd' })
  61. } else {
  62. this.setState({ activeSection: key })
  63. }
  64. }
  65. async submitSign(data) {
  66. this.props.dispatch(
  67. createAction('ordersign/getSignDetail')({
  68. saleOutOrderId: data.id,
  69. confirmCb: () => this.onRefresh(),
  70. })
  71. )
  72. // this.setState({ SubmitLoad: true });
  73. // data.saleOutOrderItemInfoDtos.map(item => {
  74. // item.signNum = item.mainNum;
  75. // item.persistStatus = "upd";
  76. // });
  77. // const result = await authService.confirmSign(data.saleOutOrderItemInfoDtos);
  78. // if (result && result.status == "200") {
  79. // this.onRefresh();
  80. // }
  81. // this.setState({ SubmitLoad: false });
  82. }
  83. // 订单列表Render
  84. topOrderRender(item, index) {
  85. let imageArr = [],
  86. imalength = item.goodsImgs.length,
  87. signState = false
  88. if (
  89. item.saleOutOrderItemInfoDtos.some(
  90. data => !data.signNum || (data.signNum && data.signNum <= 0)
  91. )
  92. ) {
  93. signState = true
  94. }
  95. if (imalength.length > 3) {
  96. imalength = 3
  97. }
  98. for (let i = 0; i < imalength; i++) {
  99. imageArr.push(
  100. <Image
  101. key={i}
  102. style={{ width: 60, height: 60, marginRight: 10 }}
  103. source={
  104. item.goodsImgs[i] ? { uri: ImageBaseUrl + item.goodsImgs[i] } : png
  105. }
  106. />
  107. )
  108. }
  109. return (
  110. <View style={{ marginTop: 10, backgroundColor: '#fff' }}>
  111. <View
  112. // activeOpacity={item && item.c == "unsigned" ? 0 : 1}
  113. // onPress={() => {
  114. // item && item.c == "unsigned"
  115. // ?
  116. // : null;
  117. // }}
  118. style={{
  119. paddingHorizontal: 10,
  120. }}
  121. >
  122. {/* 订单信息栏 */}
  123. <View
  124. style={{
  125. paddingVertical: 6,
  126. flexDirection: 'row',
  127. justifyContent: 'space-between',
  128. backgroundColor: '#fafafa',
  129. }}
  130. >
  131. <Text style={styles.CardText666}>发货编号:{item.billCode}</Text>
  132. <Text
  133. style={{
  134. fontSize: 12,
  135. lineHeight: 17,
  136. letterSpacing: 0.14,
  137. color: '#666',
  138. }}
  139. >
  140. {ReturnDate(item.billDate)}
  141. </Text>
  142. </View>
  143. <View
  144. style={{
  145. paddingVertical: 10,
  146. borderBottomColor: '#EEE',
  147. borderBottomWidth: 1 / PixelRatio.get(),
  148. flexDirection: 'row',
  149. }}
  150. >
  151. <View
  152. style={{
  153. flex: 6,
  154. flexDirection: 'row',
  155. }}
  156. >
  157. {imageArr}
  158. {/* {imageArr.length > 3 ? imageArr.slice(0, 3) : imageArr} */}
  159. {imalength > 3 ? (
  160. <Text style={[styles.CardText999, { alignSelf: 'center' }]}>
  161. ......
  162. </Text>
  163. ) : null}
  164. </View>
  165. <View
  166. style={{
  167. flex: 2,
  168. paddingRight: 7,
  169. }}
  170. >
  171. <View style={{ flex: 1, justifyContent: 'center' }}>
  172. <Text style={[styles.CardTextPrice, { alignSelf: 'flex-end' }]}>
  173. {item.totalAssistNum}
  174. {/* <Text
  175. style={{
  176. fontSize: 12,
  177. lineHeight: 22,
  178. letterSpacing: 0.19,
  179. color: "#151515"
  180. }}
  181. >
  182. </Text> */}
  183. </Text>
  184. </View>
  185. {signState ? null : (
  186. // {item.billStatusCode == "unsigned" ? null : (
  187. <View
  188. style={{
  189. position: 'absolute',
  190. left: 0,
  191. top: 10,
  192. }}
  193. >
  194. <Image
  195. resizeMode={'contain'}
  196. source={signPng}
  197. style={{
  198. width: 55,
  199. height: 45,
  200. }}
  201. />
  202. </View>
  203. )}
  204. </View>
  205. </View>
  206. </View>
  207. {/* 签收栏 */}
  208. {signState ? (
  209. // {item.billStatusCode == "unsigned" ? (
  210. <View
  211. style={{
  212. padding: 10,
  213. flexDirection: 'row',
  214. justifyContent: 'space-between',
  215. borderTopColor: '#EEE',
  216. borderTopWidth: 1,
  217. }}
  218. >
  219. <Text style={[styles.CardText333, { alignSelf: 'center' }]}>
  220. {signState ? '未签收' : '已签收'}
  221. {/* {item.billStatusName} */}
  222. </Text>
  223. <TouchableOpacity
  224. onPress={() => this.submitSign(item)}
  225. style={{
  226. paddingHorizontal: 18,
  227. paddingVertical: 4,
  228. backgroundColor: '#E14C46',
  229. borderRadius: 100,
  230. }}
  231. >
  232. <Text style={styles.CardTextFFF}>签收</Text>
  233. </TouchableOpacity>
  234. </View>
  235. ) : null}
  236. </View>
  237. )
  238. }
  239. setTouch(index) {
  240. this.setState({ setButton: index })
  241. }
  242. // 订单按钮组
  243. setList() {
  244. let textColor = ['#999', '#E14C46']
  245. let border = ['transparent', '#E14C46']
  246. setArr = []
  247. const setAtt = [
  248. { touchName: '全部' },
  249. { touchName: '未签收' },
  250. { touchName: '已签收' },
  251. ]
  252. for (let j = 0; j < setAtt.length; j++) {
  253. setArr.push(
  254. <TouchableOpacity
  255. onPress={() => {
  256. this.setTouch(j)
  257. }}
  258. key={j}
  259. style={{ justifyContent: 'center' }}
  260. >
  261. <Text
  262. style={{
  263. fontSize: 13,
  264. lineHeight: 18,
  265. color: this.state.setButton == j ? textColor[1] : textColor[0],
  266. }}
  267. >
  268. {setAtt[j].touchName}
  269. </Text>
  270. <View
  271. style={{
  272. height: 2,
  273. backgroundColor:
  274. this.state.setButton == j ? border[1] : border[0],
  275. marginTop: 3,
  276. }}
  277. />
  278. </TouchableOpacity>
  279. )
  280. }
  281. return setArr
  282. }
  283. // 底部
  284. footerCom() {
  285. if (this.props.showFoot == 0) {
  286. return <View />
  287. } else if (this.props.showFoot == 1) {
  288. return (
  289. <View style={styles.footer}>
  290. <Text
  291. style={{
  292. fontSize: 14,
  293. lineHeight: 20,
  294. letterSpacing: 0.17,
  295. color: '#999',
  296. }}
  297. >
  298. 没有更多数据
  299. </Text>
  300. </View>
  301. )
  302. } else if (this.props.showFoot == 2) {
  303. return (
  304. <View style={styles.footer}>
  305. <ActivityIndicator />
  306. <Text>正在加载更多数据...</Text>
  307. </View>
  308. )
  309. }
  310. }
  311. render() {
  312. const { signData, totalPages } = this.props
  313. return (
  314. <View tabLabel={this.props.tabLabel} style={styles.container}>
  315. {/* <View
  316. style={{
  317. height: 35,
  318. backgroundColor: "#FFF",
  319. flexDirection: "row",
  320. justifyContent: "space-around"
  321. }}
  322. >
  323. {this.setList()}
  324. </View> */}
  325. {signData && signData.length > 0 ? (
  326. this.state.Loading ? (
  327. <View style={styles.footer}>
  328. <ActivityIndicator />
  329. </View>
  330. ) : (
  331. <FlatList
  332. keyExtractor={(item, index) => index}
  333. data={signData}
  334. extraData={this.state}
  335. renderItem={({ item, index }) => this.topOrderRender(item, index)}
  336. ListFooterComponent={this.footerCom.bind(this)}
  337. // initialNumToRender={5}
  338. onEndReachedThreshold={0.1}
  339. onEndReached={e => {
  340. if (this.props.showFoot != 0) {
  341. return
  342. }
  343. if (this.page != 1 && this.page >= totalPages) {
  344. return
  345. } else {
  346. this.page++
  347. }
  348. this.props.dispatch(
  349. createAction('ordersign/getSignList')({
  350. signData: signData,
  351. pageInfo: { page: this.page, size: this.size },
  352. forUse: 'slipOn',
  353. searchInfo: {
  354. search_EQ_customerId: CUSTOMERINFO.id,
  355. },
  356. })
  357. )
  358. }}
  359. refreshControl={
  360. <RefreshControl
  361. refreshing={this.props.isRefreshing}
  362. onRefresh={this.onRefresh.bind(this)} //(()=>this.onRefresh)或者通过bind来绑定this引用来调用方法
  363. tintColor="red"
  364. title={this.props.isRefreshing ? '刷新中....' : '下拉刷新'}
  365. />
  366. }
  367. />
  368. )
  369. ) : (
  370. <ScrollView
  371. showsHorizontalScrollIndicator={false}
  372. style={{ flex: 1 }}
  373. refreshControl={
  374. <RefreshControl
  375. refreshing={this.props.isRefreshing}
  376. onRefresh={this.onRefresh.bind(this)} //(()=>this.onRefresh)或者通过bind来绑定this引用来调用方法
  377. tintColor="red"
  378. title={this.props.isRefreshing ? '刷新中....' : '下拉刷新'}
  379. />
  380. }
  381. >
  382. <ImageBackground
  383. resizeMode="contain"
  384. source={EmptyOrder}
  385. style={{
  386. width: width - 80,
  387. height: height / 1.5,
  388. alignSelf: 'center',
  389. }}
  390. >
  391. <View
  392. style={{
  393. position: 'absolute',
  394. bottom: '15%',
  395. alignSelf: 'center',
  396. }}
  397. >
  398. <Text
  399. style={{
  400. fontSize: 14,
  401. lineHeight: 20,
  402. letterSpacing: 0.17,
  403. color: '#999',
  404. }}
  405. >
  406. 您还没有相关订单~
  407. </Text>
  408. </View>
  409. </ImageBackground>
  410. </ScrollView>
  411. )}
  412. </View>
  413. )
  414. }
  415. }
  416. const styles = StyleSheet.create({
  417. container: {
  418. flex: 1,
  419. backgroundColor: '#f5f5f5',
  420. },
  421. CardText999: {
  422. fontSize: 13,
  423. lineHeight: 17,
  424. letterSpacing: 0.14,
  425. color: '#999',
  426. },
  427. CardText333: {
  428. fontSize: 13,
  429. lineHeight: 17,
  430. letterSpacing: 0.14,
  431. color: '#333',
  432. },
  433. CardText666: {
  434. fontSize: 13,
  435. lineHeight: 17,
  436. letterSpacing: 0.14,
  437. color: '#666',
  438. },
  439. CardTextFFF: {
  440. fontSize: 13,
  441. lineHeight: 17,
  442. letterSpacing: 0.14,
  443. color: '#FFF',
  444. },
  445. CardTextPrice: {
  446. fontSize: 17,
  447. lineHeight: 22,
  448. letterSpacing: 0.19,
  449. color: '#E14C46',
  450. },
  451. footer: {
  452. flex: 1,
  453. flexDirection: 'row',
  454. height: 24,
  455. justifyContent: 'center',
  456. alignItems: 'center',
  457. marginBottom: 10,
  458. marginTop: 10,
  459. },
  460. })
  461. export default DeliverySign