RechargeHome.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. FlatList,
  6. Text,
  7. StatusBar,
  8. TouchableOpacity,
  9. PixelRatio,
  10. Dimensions,
  11. ScrollView,
  12. ActivityIndicator,
  13. RefreshControl,
  14. } from 'react-native'
  15. import { connect } from 'react-redux'
  16. import Icon from '../../../../components/Iconfont/Iconfont'
  17. import Input from '../../../../components/input/index'
  18. import SelectTimeCom from '../../../../components/selectTime/selectTime'
  19. import { NavigationActions, createAction } from '../../../../utils'
  20. import { ReturnDate, ScaleUtil } from '../../../../utils/utils'
  21. import { _AliPay } from '../../../../utils/payUtil'
  22. import Toast from 'react-native-root-toast'
  23. // @withHeader
  24. // Save(1,"保存","保存态收款单,尚未提交"),
  25. // Send(2,"提交","已提交收款单,尚未审批"),
  26. // Audit(3,"审批通过","已审批收款单"),
  27. // Auditing(4,"审批中","审批中收款单,正在审批"),
  28. // UnSend(5,"收回","已收回收款单,尚未提交"),
  29. // UnApprove(6,"审批不过","收款单审批未通过");
  30. const status = ['', '保存', '提交', '审批通过', '审批中', '收回', '审批不过']
  31. const { width, height } = Dimensions.get('window')
  32. @connect(({ theme, payRegister, rechargeModels }) => ({
  33. ...theme,
  34. ...payRegister,
  35. ...rechargeModels,
  36. }))
  37. class RechargeHome extends Component {
  38. constructor(props) {
  39. super(props)
  40. this.state = {
  41. // 从外部传来的要货单code
  42. searchPayListInfo:
  43. props.navigation.state.params &&
  44. props.navigation.state.params.searchPayListInfo
  45. ? props.navigation.state.params.searchPayListInfo
  46. : '',
  47. setButton: 0,
  48. startTime: '',
  49. endTime: '',
  50. searchVal: '',
  51. code: '',
  52. }
  53. this.page = 0
  54. this.size = 5
  55. }
  56. // 跳转
  57. NavigateToOthers(routeName, params) {
  58. this.props.dispatch(
  59. NavigationActions.navigate({ routeName: routeName, params: params })
  60. )
  61. }
  62. componentDidMount = () => {
  63. this.props.dispatch(createAction('rechargeModels/PaywaysSagas')())
  64. this.onRefresh()
  65. }
  66. onRefresh() {
  67. this.props.dispatch(
  68. createAction('rechargeModels/PayBillList')({
  69. pageInfo: { page: 0, size: this.size },
  70. payBillAction: [],
  71. searchInfo: this.searchFN(),
  72. })
  73. )
  74. }
  75. goBackCb() {
  76. this.onRefresh()
  77. this.page = 0
  78. }
  79. searchFN() {
  80. const searchReturn = {
  81. search_EQ_customer: CUSTOMERINFO.id,
  82. }
  83. if (
  84. this.state.searchPayListInfo &&
  85. this.state.searchPayListInfo.length > 0
  86. ) {
  87. searchReturn.search_EQ_srcBillCode = this.state.searchPayListInfo
  88. }
  89. // 时间
  90. if (this.state.startTime) {
  91. searchReturn.search_GTE_creationTime_date = new Date(
  92. this.state.startTime
  93. ).getTime()
  94. }
  95. if (this.state.endTime) {
  96. searchReturn.search_LT_creationTime_date = new Date(
  97. this.state.endTime
  98. ).getTime()
  99. }
  100. // 关键字
  101. if (this.state.searchVal) {
  102. searchReturn.search_LIKE_paybillCode = '%' + this.state.searchVal + '%'
  103. }
  104. // 编码Tab
  105. if (this.state.code) {
  106. searchReturn.search_EQ_paymentMode = this.state.code
  107. }
  108. return searchReturn
  109. }
  110. // 头部
  111. header() {
  112. return (
  113. <View
  114. style={{
  115. height: HEADERSTYLE.height,
  116. paddingTop: HEADERSTYLE.paddingTop + 5,
  117. backgroundColor: '#fff',
  118. borderBottomColor: '#eee',
  119. borderBottomWidth: 1 / PixelRatio.get(),
  120. }}
  121. >
  122. <View
  123. style={{
  124. flex: 1,
  125. justifyContent: 'center',
  126. }}
  127. >
  128. <TouchableOpacity
  129. style={{ position: 'absolute', left: 10, flexDirection: 'row' }}
  130. onPress={() => this.props.dispatch(NavigationActions.back())}
  131. >
  132. <Icon
  133. name="icon-icon-fanhui"
  134. size={20}
  135. color={'#666'}
  136. style={{ marginTop: 4 }}
  137. />
  138. <Text
  139. style={{
  140. fontSize: 14,
  141. lineHeight: 20,
  142. color: '#666',
  143. alignSelf: 'center',
  144. }}
  145. >
  146. 返回
  147. </Text>
  148. </TouchableOpacity>
  149. {this.state.showSearch ? (
  150. <Input
  151. autoFocus={this.state.showSearch}
  152. style={{
  153. marginLeft: 25,
  154. marginTop: 8,
  155. height: 28,
  156. width: width / 1.6,
  157. borderRadius: width / 2,
  158. alignSelf: 'center',
  159. marginBottom: 8,
  160. paddingLeft: 14,
  161. }}
  162. textStyle={{
  163. paddingLeft: 10,
  164. height: 32,
  165. fontSize: 11,
  166. padding: 0,
  167. }}
  168. iconSize={14}
  169. blurOnSubmit={true}
  170. textInputBacg={'#F5F5F5'}
  171. iconColor={'#CCC'}
  172. placeholderTextColor={'#CCC'}
  173. placeholder="请输入付款银行账户/编号或收款银行账户"
  174. placeholderSize={8}
  175. onchangeFn={e => {
  176. this.state.searchVal = e
  177. this.setState({ searchVal: e, activeSection: true })
  178. this.onRefresh()
  179. this.page = 0
  180. }}
  181. />
  182. ) : (
  183. <Text
  184. style={{
  185. alignSelf: 'center',
  186. fontSize: 18,
  187. lineHeight: 25,
  188. letterSpacing: 0.19,
  189. color: '#333',
  190. }}
  191. >
  192. 支付单
  193. </Text>
  194. )}
  195. {this.state.showSearch ? (
  196. <TouchableOpacity
  197. onPress={() =>
  198. this.setState({ showSearch: false, activeSection: true })
  199. }
  200. style={{
  201. position: 'absolute',
  202. right: 10,
  203. flexDirection: 'row',
  204. }}
  205. >
  206. <Text style={{ fontSize: 14, lineHeight: 20, color: '#666' }}>
  207. 取消
  208. </Text>
  209. </TouchableOpacity>
  210. ) : (
  211. <View
  212. style={{
  213. position: 'absolute',
  214. right: 10,
  215. flexDirection: 'row',
  216. }}
  217. >
  218. <TouchableOpacity
  219. style={{ marginRight: 10 }}
  220. onPress={() =>
  221. this.setState({
  222. showSearch: true,
  223. activeSection: true,
  224. dateActive: true,
  225. })
  226. }
  227. >
  228. <Icon name="icon-icon-sousuo" size={24} color={'#333'} />
  229. </TouchableOpacity>
  230. <TouchableOpacity
  231. onPress={() =>
  232. this.setState({
  233. dateActive: !this.state.dateActive,
  234. activeSection: true,
  235. })
  236. }
  237. >
  238. <Icon name="icon-icon-rili" size={24} color={'#333'} />
  239. </TouchableOpacity>
  240. </View>
  241. )}
  242. </View>
  243. </View>
  244. )
  245. }
  246. // 订单按钮组
  247. setList(list) {
  248. if (!list || (list && list.length < 1)) return null
  249. const data = [{ id: '', name: '全部', code: '' }, ...list]
  250. const textColor = ['#333', '#E14C46'],
  251. border = ['transparent', '#E14C46'],
  252. len = data.length,
  253. setArr = []
  254. for (let j = 0; j < len; j++) {
  255. setArr.push(
  256. <TouchableOpacity
  257. onPress={() => {
  258. this.setTouch(j, data[j].name, data[j].code)
  259. }}
  260. key={j}
  261. style={{
  262. width: len >= 5 ? width / 5 : width / len,
  263. alignSelf: 'center',
  264. alignItems: 'center',
  265. }}
  266. >
  267. <Text
  268. style={{
  269. fontSize: 14,
  270. lineHeight: 18,
  271. color: this.state.setButton == j ? textColor[1] : textColor[0],
  272. }}
  273. >
  274. {data[j].name}
  275. </Text>
  276. <View
  277. style={{
  278. height: 2,
  279. backgroundColor:
  280. this.state.setButton == j ? border[1] : border[0],
  281. marginTop: 3,
  282. width: data[j].name.length > 2 ? 45 : 30,
  283. }}
  284. />
  285. </TouchableOpacity>
  286. )
  287. }
  288. return setArr
  289. }
  290. setTouch(index, touchName, code) {
  291. this.state.code = code
  292. this.setState({ setButton: index, touchName: touchName, code: code })
  293. this.onRefresh()
  294. this.page = 0
  295. }
  296. dateCbFn(data) {
  297. if (data.fn && data.fn == 'cancel') {
  298. this.setState({ dateActive: true })
  299. } else {
  300. this.state.startTime = data.startTime
  301. this.state.endTime = data.endTime
  302. this.setState({
  303. dateActive: true,
  304. })
  305. this.onRefresh()
  306. this.page = 0
  307. }
  308. }
  309. paymentList(item) {
  310. return (
  311. <View style={{ padding: 10, backgroundColor: '#FFF', marginBottom: 10 }}>
  312. <View
  313. style={{
  314. paddingBottom: 10,
  315. flexDirection: 'row',
  316. justifyContent: 'space-between',
  317. borderBottomColor: '#DDD',
  318. borderBottomWidth: 1 / PixelRatio.get(),
  319. }}
  320. >
  321. <View style={{ flexDirection: 'row', alignItems: 'center' }}>
  322. <Text style={[styles.Text13, { color: '#333' }]}>
  323. {item.paybillCode}
  324. </Text>
  325. </View>
  326. <Text style={[styles.Text12, { color: '#999' }]}>
  327. {ReturnDate(item.billDate, true)}
  328. </Text>
  329. </View>
  330. <View
  331. style={{
  332. paddingVertical: 10,
  333. }}
  334. >
  335. <View
  336. style={{
  337. flexDirection: 'row',
  338. justifyContent: 'space-between',
  339. marginBottom: 5,
  340. }}
  341. >
  342. <Text style={[styles.Text13, { color: '#333' }]}>
  343. {item.payeeName}
  344. </Text>
  345. <Text style={[styles.Text13, { color: '#333' }]}>
  346. {ScaleUtil(
  347. item.paymentAmount,
  348. item && item.currencyAmountScale
  349. ? item.currencyAmountScale
  350. : CURRENCY.currencyAmountScale
  351. )}
  352. </Text>
  353. </View>
  354. <View
  355. style={{
  356. flexDirection: 'row',
  357. justifyContent: 'space-between',
  358. marginTop: 5,
  359. }}
  360. >
  361. <Text style={[styles.Text13, { color: '#333' }]}>
  362. {item.paymentModeName}
  363. </Text>
  364. <TouchableOpacity
  365. onPress={() => {
  366. if (this.toast) {
  367. Toast.hide(this.toast)
  368. }
  369. if (item.paymentStatusName == '待支付') {
  370. switch (item.paymentModeName) {
  371. // 支付宝
  372. case '支付宝':
  373. _AliPay(
  374. item,
  375. // 成功后操作
  376. () => this.onRefresh(),
  377. // 验签失败操作
  378. () => {},
  379. // 取消支付
  380. () => {}
  381. )
  382. break
  383. // 微信
  384. case '微信':
  385. this.toast = Toast.show('微信支付,正在开发中', {
  386. position: toastHeight,
  387. })
  388. // _WechatPay();
  389. break
  390. // // 畅捷支付
  391. case '畅捷支付':
  392. this.toast = Toast.show('畅捷支付,正在开发中', {
  393. position: toastHeight,
  394. })
  395. break
  396. }
  397. }
  398. }}
  399. disabled={item.paymentStatusName == '待支付' ? false : true}
  400. style={{
  401. borderColor: '#EEE',
  402. borderWidth:
  403. item.paymentStatusName == '待支付' ? 1 / PixelRatio.get() : 0,
  404. paddingHorizontal: 8,
  405. paddingVertical: 3,
  406. borderRadius: 20,
  407. }}
  408. >
  409. <Text style={[styles.Text13, { color: '#E70013' }]}>
  410. {item.paymentStatusName}
  411. </Text>
  412. </TouchableOpacity>
  413. </View>
  414. </View>
  415. </View>
  416. )
  417. }
  418. // 底部
  419. footerCom() {
  420. if (this.props.showFoot == 0) {
  421. return <View />
  422. } else if (this.props.showFoot == 1) {
  423. return (
  424. <View style={styles.footer}>
  425. <Text
  426. style={{
  427. fontSize: 14,
  428. lineHeight: 20,
  429. letterSpacing: 0.17,
  430. color: '#999',
  431. }}
  432. >
  433. 没有更多数据
  434. </Text>
  435. </View>
  436. )
  437. } else if (this.props.showFoot == 2) {
  438. return (
  439. <View style={styles.footer}>
  440. <ActivityIndicator />
  441. <Text>正在加载更多数据...</Text>
  442. </View>
  443. )
  444. }
  445. }
  446. render() {
  447. const { appTheme, payBillList, totalPages, payWays } = this.props
  448. return (
  449. <View
  450. style={[
  451. styles.container,
  452. { backgroundColor: appTheme.backgroundColor },
  453. ]}
  454. >
  455. <StatusBar
  456. animated={true}
  457. barStyle={appTheme.barStyle}
  458. backgroundColor={'transparent'}
  459. translucent={true}
  460. />
  461. {/* 头部 */}
  462. {this.header()}
  463. {/* SetList 状态 */}
  464. <View
  465. style={{
  466. flexDirection: 'row',
  467. height: 35,
  468. backgroundColor: '#FFF',
  469. }}
  470. >
  471. <ScrollView
  472. showsHorizontalScrollIndicator={false}
  473. pagingEnabled={true}
  474. horizontal={true}
  475. overScrollMode={'auto'}
  476. style={{ flex: 1, height: 35 }}
  477. >
  478. {this.setList(payWays)}
  479. </ScrollView>
  480. </View>
  481. {/* {HeaderView(this.props.dispatch, "付款单登记")} */}
  482. {/* card列表 */}
  483. {this.state.Loading ? (
  484. <View style={styles.footer}>
  485. <ActivityIndicator />
  486. </View>
  487. ) : (
  488. <FlatList
  489. keyExtractor={(item, index) => index}
  490. data={payBillList}
  491. extraData={this.state}
  492. renderItem={({ item, index }) => this.paymentList(item)}
  493. // renderItem={({ item, index }) =>{ this.topOrderRender(item, index)}}
  494. style={{ marginTop: 10 }}
  495. ListFooterComponent={this.footerCom.bind(this)}
  496. // initialNumToRender={5}
  497. onEndReachedThreshold={0.1}
  498. onEndReached={e => {
  499. if (this.props.showFoot != 0) {
  500. return
  501. }
  502. if (this.page != 1 && this.page >= totalPages) {
  503. return
  504. } else {
  505. this.page++
  506. }
  507. this.props.dispatch(
  508. createAction('rechargeModels/PayBillList')({
  509. payBillAction: payBillList,
  510. pageInfo: { page: this.page, size: this.size },
  511. forUse: 'slipOn',
  512. searchInfo: this.searchFN(),
  513. })
  514. )
  515. }}
  516. refreshControl={
  517. <RefreshControl
  518. refreshing={this.props.isRefreshing}
  519. onRefresh={this.onRefresh.bind(this)} //(()=>this.onRefresh)或者通过bind来绑定this引用来调用方法
  520. tintColor="red"
  521. title={this.props.isRefreshing ? '刷新中....' : '下拉刷新'}
  522. />
  523. }
  524. />
  525. )}
  526. <SelectTimeCom
  527. dateActive={this.state.dateActive}
  528. dateCb={data => this.dateCbFn(data)}
  529. />
  530. <TouchableOpacity
  531. onPress={() => {
  532. this.NavigateToOthers('RechargeAdd', {
  533. goBackCb: () => {
  534. this.goBackCb()
  535. },
  536. })
  537. }}
  538. style={{
  539. position: 'absolute',
  540. bottom: 30,
  541. right: 30,
  542. width: 50,
  543. height: 50,
  544. borderRadius: 50,
  545. justifyContent: 'center',
  546. alignItems: 'center',
  547. backgroundColor: '#E14C46',
  548. paddingRight: 2,
  549. }}
  550. >
  551. <Icon
  552. name="icon-icon-guanbianniu"
  553. size={30}
  554. color={'#FFF'}
  555. style={{ transform: [{ rotate: '45deg' }] }}
  556. />
  557. </TouchableOpacity>
  558. </View>
  559. )
  560. }
  561. }
  562. const styles = StyleSheet.create({
  563. container: {
  564. flex: 1,
  565. },
  566. Text15: {
  567. fontSize: 15,
  568. lineHeight: 21,
  569. },
  570. Text14: {
  571. fontSize: 14,
  572. lineHeight: 20,
  573. },
  574. Text13: {
  575. fontSize: 13,
  576. lineHeight: 18,
  577. },
  578. Text12: {
  579. fontSize: 12,
  580. lineHeight: 17,
  581. },
  582. footer: {
  583. flex: 1,
  584. flexDirection: 'row',
  585. height: 24,
  586. justifyContent: 'center',
  587. alignItems: 'center',
  588. marginBottom: 10,
  589. marginTop: 10,
  590. },
  591. })
  592. export default RechargeHome