SelectInvoice.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. View,
  5. Image,
  6. StatusBar,
  7. Text,
  8. TouchableOpacity,
  9. Dimensions,
  10. PixelRatio,
  11. ScrollView,
  12. } from 'react-native'
  13. import { connect } from 'react-redux'
  14. import Collapsible from 'react-native-collapsible'
  15. import Input from '../../components/input'
  16. import png from '../../static/images/defaultimg.jpg'
  17. import Icon from '../../components/Iconfont/Iconfont'
  18. import { NavigationActions } from '../../utils'
  19. import redblue from '../../static/images/ic-redblue.png'
  20. import { HeaderView } from '../common/HeaderView'
  21. const { width, height } = Dimensions.get('window')
  22. const data = [{ a: 1, b: [1, 2] }, { a: 2, b: [3] }, { a: 3, b: [1, 2, 3] }]
  23. const adress = ['曲美北京分公司', '曲美广东佛山分公司', '曲美上海分公司']
  24. @connect(({ theme, mine }) => ({ ...theme, ...mine }))
  25. class SelectInvoice extends Component {
  26. constructor(props) {
  27. super(props)
  28. this.state = {
  29. invoice: props.invoiceDefault,
  30. typeVal: this.props.invoiceDefault
  31. ? this.props.invoiceDefault.invoiceType
  32. : '',
  33. typeArr: [],
  34. key: '',
  35. }
  36. }
  37. componentDidMount() {
  38. this.setInvoice()
  39. }
  40. setInvoice() {
  41. let typeArr = [],
  42. index
  43. for (let val of this.props.invoiceData) {
  44. typeArr.push(val.invoiceType)
  45. }
  46. typeArr = Array.from(new Set(typeArr))
  47. if (this.props.invoiceData.indexOf(this.props.invoiceDefault) != -1) {
  48. index = this.props.invoiceData.indexOf(this.props.invoiceDefault)
  49. }
  50. this.setState({ key: index, typeArr: typeArr })
  51. }
  52. // 底部按钮
  53. bottomTouch() {
  54. let touchArr = [],
  55. touchAtt = [
  56. {
  57. touchName: '取消',
  58. background: '#FFF',
  59. textColor: '#666',
  60. onpress: () => this.props.dispatch(NavigationActions.back()),
  61. },
  62. {
  63. touchName: '确定',
  64. background: '#E14C46',
  65. textColor: '#FFF',
  66. onpress: () => {
  67. this.props.navigation.state.params(this.state.invoice)
  68. this.props.dispatch(NavigationActions.back())
  69. },
  70. },
  71. ]
  72. for (let i = 0; i < touchAtt.length; i++) {
  73. touchArr.push(
  74. <TouchableOpacity
  75. onPress={() => touchAtt[i].onpress()}
  76. key={i}
  77. style={{
  78. flex: 1,
  79. backgroundColor: touchAtt[i].background,
  80. justifyContent: 'center',
  81. borderRightColor: '#eee',
  82. borderRightWidth: 1 / PixelRatio.get(),
  83. }}
  84. >
  85. <Text
  86. style={{
  87. fontSize: 14,
  88. lineHeight: 20,
  89. color: touchAtt[i].textColor,
  90. alignSelf: 'center',
  91. }}
  92. >
  93. {touchAtt[i].touchName}
  94. </Text>
  95. </TouchableOpacity>
  96. )
  97. }
  98. return touchArr
  99. }
  100. touchTitle(item, key) {
  101. this.setState({ invoice: item, key: key, typeVal: item.invoiceType })
  102. }
  103. render() {
  104. const { appTheme, invoiceData } = this.props
  105. return (
  106. <View
  107. style={[
  108. styles.container,
  109. { backgroundColor: appTheme.backgroundColor },
  110. ]}
  111. >
  112. <StatusBar
  113. animated={true}
  114. barStyle={appTheme.barStyle}
  115. // barStyle={"dark-content"}
  116. backgroundColor={'transparent'}
  117. translucent={true}
  118. />
  119. {/* 头部 */}
  120. {HeaderView(this.props.dispatch, '选择发票')}
  121. {/* 主内容 */}
  122. <ScrollView style={{ flex: 1 }}>
  123. {/* 发票抬头 */}
  124. <View style={{ padding: 10, backgroundColor: '#FFF' }}>
  125. <Text style={{ fontSize: 14, lineHeight: 20, color: '#333' }}>
  126. 发票抬头
  127. </Text>
  128. <ScrollView
  129. showsHorizontalScrollIndicator={false}
  130. horizontal={true}
  131. style={{ flexDirection: 'row', paddingTop: 10, paddingBottom: 5 }}
  132. >
  133. {invoiceData &&
  134. invoiceData.map((item, key) => (
  135. <TouchableOpacity
  136. onPress={() => this.touchTitle(item, key)}
  137. key={key}
  138. style={{
  139. paddingHorizontal: 12,
  140. paddingVertical: 4,
  141. borderWidth: 1 / PixelRatio.get(),
  142. borderColor: this.state.key == key ? '#E14C46' : '#666',
  143. marginRight: 10,
  144. borderRadius: 2,
  145. }}
  146. >
  147. <Text
  148. style={{
  149. fontSize: 12,
  150. lineHeight: 17,
  151. color: this.state.key == key ? '#E14C46' : '#333',
  152. }}
  153. >
  154. {item.invoiceTitle}
  155. </Text>
  156. </TouchableOpacity>
  157. ))}
  158. </ScrollView>
  159. </View>
  160. {/* 发票类型 */}
  161. <View style={{ padding: 10, backgroundColor: '#FFF', marginTop: 10 }}>
  162. <Text style={{ fontSize: 14, lineHeight: 20, color: '#333' }}>
  163. 发票类型
  164. </Text>
  165. <ScrollView
  166. showsHorizontalScrollIndicator={false}
  167. horizontal={true}
  168. style={{ flexDirection: 'row', paddingTop: 10, paddingBottom: 5 }}
  169. >
  170. {this.state.typeArr &&
  171. this.state.typeArr.map((item, key) => (
  172. <View
  173. key={key}
  174. style={{
  175. paddingHorizontal: 12,
  176. paddingVertical: 4,
  177. borderWidth: 1 / PixelRatio.get(),
  178. borderColor:
  179. this.state.typeVal == item ? '#E14C46' : '#666',
  180. marginRight: 10,
  181. borderRadius: 2,
  182. }}
  183. >
  184. <Text
  185. style={{
  186. fontSize: 12,
  187. lineHeight: 17,
  188. color: this.state.typeVal == item ? '#E14C46' : '#333',
  189. }}
  190. >
  191. {item}
  192. </Text>
  193. </View>
  194. ))}
  195. </ScrollView>
  196. </View>
  197. {/* 发票内容 */}
  198. <View style={{ marginTop: 10, padding: 10, backgroundColor: '#FFF' }}>
  199. <Text style={{ fontSize: 13, lineHeight: 24, color: '#666' }}>
  200. 发票抬头:<Text style={{ color: '#333' }}>
  201. {this.state.invoice && this.state.invoice.invoiceTitle}
  202. </Text>
  203. </Text>
  204. <Text style={{ fontSize: 13, lineHeight: 24, color: '#666' }}>
  205. 发票内容:<Text style={{ color: '#333' }}>
  206. {this.state.invoice && this.state.invoice.invoiceContent}
  207. </Text>
  208. </Text>
  209. <Text style={{ fontSize: 13, lineHeight: 24, color: '#666' }}>
  210. 纳税人识别号:<Text style={{ color: '#333' }}>
  211. {this.state.invoice && this.state.invoice.invoiceTaxId}
  212. </Text>
  213. </Text>
  214. <Text style={{ fontSize: 13, lineHeight: 24, color: '#666' }}>
  215. 开户银行:<Text style={{ color: '#333' }}>
  216. {this.state.invoice && this.state.invoice.invoiceBank}
  217. </Text>
  218. </Text>
  219. <Text style={{ fontSize: 13, lineHeight: 24, color: '#666' }}>
  220. 支行名称:<Text style={{ color: '#333' }}>
  221. {this.state.invoice && this.state.invoice.invoiceSubBank}{' '}
  222. </Text>
  223. </Text>
  224. <Text style={{ fontSize: 13, lineHeight: 24, color: '#666' }}>
  225. 账号:<Text style={{ color: '#333' }}>
  226. {this.state.invoice && this.state.invoice.invoiceAccount}
  227. </Text>
  228. </Text>
  229. </View>
  230. </ScrollView>
  231. {/* 底部 */}
  232. <View
  233. style={{
  234. height: 45,
  235. backgroundColor: '#FFF',
  236. flexDirection: 'row',
  237. }}
  238. >
  239. {this.bottomTouch()}
  240. </View>
  241. </View>
  242. )
  243. }
  244. }
  245. const styles = StyleSheet.create({
  246. container: {
  247. flex: 1,
  248. },
  249. text333: {
  250. fontSize: 14,
  251. lineHeight: 20,
  252. letterSpacing: 0.17,
  253. color: '#333',
  254. },
  255. text666: {
  256. fontSize: 12,
  257. lineHeight: 17,
  258. color: '#666',
  259. },
  260. text999: {
  261. fontSize: 12,
  262. lineHeight: 17,
  263. color: '#999',
  264. },
  265. })
  266. export default SelectInvoice