Credit.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. Text,
  6. SectionList,
  7. Dimensions,
  8. StatusBar,
  9. TouchableOpacity,
  10. PixelRatio,
  11. ActivityIndicator,
  12. } from 'react-native'
  13. import { connect } from 'react-redux'
  14. import Icon from '../../../components/Iconfont/Iconfont'
  15. import { NavigationActions, createAction } from '../../../utils'
  16. import Echarts from '../../../components/echarts/EchartsComponent'
  17. import { ScaleUtil } from '../../../utils/utils'
  18. import { isIphoneX } from '../../common/theme/config'
  19. import { HeaderView } from '../../common/HeaderView'
  20. const { width, height } = Dimensions.get('window')
  21. @connect(({ theme, mine_header }) => ({ ...theme, ...mine_header }))
  22. class Credit extends Component {
  23. constructor(props) {
  24. super(props)
  25. this.state = { data: [] }
  26. // console.disableYellowBox = true;
  27. }
  28. listHeader(section) {
  29. return (
  30. <View
  31. style={{
  32. marginTop: 10,
  33. padding: 10,
  34. backgroundColor: '#FAFAFA',
  35. borderBottomColor: '#DDD',
  36. flexDirection: 'row',
  37. justifyContent: 'space-between',
  38. borderBottomWidth: 1 / PixelRatio.get(),
  39. borderTopColor: '#DDD',
  40. borderTopWidth: 1 / PixelRatio.get(),
  41. }}
  42. >
  43. <Text style={{ fontSize: 15, lineHeight: 21, color: '#333' }}>
  44. {section.financialOrg}
  45. </Text>
  46. <Text style={{ fontSize: 15, lineHeight: 21, color: '#333' }}>
  47. {section.saleOrg}
  48. </Text>
  49. </View>
  50. )
  51. }
  52. listItemRender(item, index) {
  53. return (
  54. <View
  55. style={{
  56. paddingHorizontal: 10,
  57. paddingTop: 10,
  58. paddingBottom: 20,
  59. backgroundColor: '#FFF',
  60. borderBottomColor: '#EEE',
  61. borderBottomWidth: 1,
  62. }}
  63. >
  64. <Text style={{ fontSize: 14, lineHeight: 20, color: '#333' }}>
  65. {item.productGroupName}
  66. </Text>
  67. <View>
  68. <Echarts data={item} index={index} bottomText={'余额'} />
  69. </View>
  70. <View style={{ flexDirection: 'row' }}>
  71. <View style={{ flex: 1, alignItems: 'center' }}>
  72. <Text
  73. style={{
  74. fontSize: 13,
  75. lineHeight: 18,
  76. letterSpacing: 0.16,
  77. color: '#999',
  78. }}
  79. >
  80. 额度
  81. </Text>
  82. <Text
  83. style={{
  84. fontSize: 15,
  85. lineHeight: 21,
  86. letterSpacing: 0.18,
  87. color: '#333',
  88. marginTop: 7,
  89. }}
  90. >
  91. {CURRENCY.currencySign}
  92. {ScaleUtil(item.creditLimit, CURRENCY.currencyAmountScale)}
  93. </Text>
  94. </View>
  95. <View style={{ height: 30, width: 2, backgroundColor: '#EEE' }} />
  96. <View
  97. style={{
  98. flex: 1,
  99. alignItems: 'center',
  100. }}
  101. >
  102. <Text
  103. style={{
  104. fontSize: 13,
  105. lineHeight: 18,
  106. letterSpacing: 0.16,
  107. color: '#999',
  108. }}
  109. >
  110. 占用
  111. </Text>
  112. <Text
  113. style={{
  114. fontSize: 15,
  115. lineHeight: 21,
  116. letterSpacing: 0.18,
  117. color: '#333',
  118. marginTop: 7,
  119. }}
  120. >
  121. {/* 预占 */}
  122. {/* {CURRENCY.currencySign}{item.preoccupyLimit} */}
  123. {/* 占用 */}
  124. {CURRENCY.currencySign}
  125. {ScaleUtil(item.occupyLimit, CURRENCY.currencyAmountScale)}
  126. </Text>
  127. </View>
  128. </View>
  129. </View>
  130. )
  131. }
  132. render() {
  133. const { appTheme, creditData } = this.props
  134. return (
  135. <View
  136. style={[
  137. styles.container,
  138. { backgroundColor: appTheme.backgroundColor },
  139. ]}
  140. >
  141. <StatusBar
  142. animated={true}
  143. barStyle={appTheme.barStyle}
  144. // barStyle={"dark-content"}
  145. backgroundColor={'transparent'}
  146. translucent={true}
  147. />
  148. {HeaderView(this.props.dispatch, '信用余额')}
  149. {creditData ? (
  150. <SectionList
  151. keyExtractor={(item, index) => index}
  152. stickySectionHeadersEnabled={true}
  153. renderSectionHeader={({ section }) => this.listHeader(section)}
  154. renderItem={({ item, index }) => this.listItemRender(item, index)}
  155. style={{ marginTop: -10 }}
  156. sections={creditData}
  157. />
  158. ) : (
  159. <View
  160. style={{ flex: 1, alignSelf: 'center', justifyContent: 'center' }}
  161. >
  162. <ActivityIndicator />
  163. </View>
  164. )}
  165. <View
  166. style={{
  167. height: 10,
  168. width: width,
  169. position: 'absolute',
  170. top: isIphoneX() ? 74 : 50,
  171. backgroundColor: '#FFF',
  172. }}
  173. />
  174. </View>
  175. )
  176. }
  177. }
  178. const styles = StyleSheet.create({
  179. container: {
  180. flex: 1,
  181. },
  182. })
  183. export default Credit