import React, { Component } from 'react'
import {
StyleSheet,
View,
Image,
StatusBar,
Text,
TouchableOpacity,
Dimensions,
PixelRatio,
ScrollView,
} from 'react-native'
import { connect } from 'react-redux'
import Collapsible from 'react-native-collapsible'
import Input from '../../components/input'
import png from '../../static/images/defaultimg.jpg'
import Icon from '../../components/Iconfont/Iconfont'
import { NavigationActions } from '../../utils'
import redblue from '../../static/images/ic-redblue.png'
import { HeaderView } from '../common/HeaderView'
const { width, height } = Dimensions.get('window')
const data = [{ a: 1, b: [1, 2] }, { a: 2, b: [3] }, { a: 3, b: [1, 2, 3] }]
const adress = ['曲美北京分公司', '曲美广东佛山分公司', '曲美上海分公司']
@connect(({ theme, mine }) => ({ ...theme, ...mine }))
class SelectInvoice extends Component {
constructor(props) {
super(props)
this.state = {
invoice: props.invoiceDefault,
typeVal: this.props.invoiceDefault
? this.props.invoiceDefault.invoiceType
: '',
typeArr: [],
key: '',
}
}
componentDidMount() {
this.setInvoice()
}
setInvoice() {
let typeArr = [],
index
for (let val of this.props.invoiceData) {
typeArr.push(val.invoiceType)
}
typeArr = Array.from(new Set(typeArr))
if (this.props.invoiceData.indexOf(this.props.invoiceDefault) != -1) {
index = this.props.invoiceData.indexOf(this.props.invoiceDefault)
}
this.setState({ key: index, typeArr: typeArr })
}
// 底部按钮
bottomTouch() {
let touchArr = [],
touchAtt = [
{
touchName: '取消',
background: '#FFF',
textColor: '#666',
onpress: () => this.props.dispatch(NavigationActions.back()),
},
{
touchName: '确定',
background: '#E14C46',
textColor: '#FFF',
onpress: () => {
this.props.navigation.state.params(this.state.invoice)
this.props.dispatch(NavigationActions.back())
},
},
]
for (let i = 0; i < touchAtt.length; i++) {
touchArr.push(
touchAtt[i].onpress()}
key={i}
style={{
flex: 1,
backgroundColor: touchAtt[i].background,
justifyContent: 'center',
borderRightColor: '#eee',
borderRightWidth: 1 / PixelRatio.get(),
}}
>
{touchAtt[i].touchName}
)
}
return touchArr
}
touchTitle(item, key) {
this.setState({ invoice: item, key: key, typeVal: item.invoiceType })
}
render() {
const { appTheme, invoiceData } = this.props
return (
{/* 头部 */}
{HeaderView(this.props.dispatch, '选择发票')}
{/* 主内容 */}
{/* 发票抬头 */}
发票抬头
{invoiceData &&
invoiceData.map((item, key) => (
this.touchTitle(item, key)}
key={key}
style={{
paddingHorizontal: 12,
paddingVertical: 4,
borderWidth: 1 / PixelRatio.get(),
borderColor: this.state.key == key ? '#E14C46' : '#666',
marginRight: 10,
borderRadius: 2,
}}
>
{item.invoiceTitle}
))}
{/* 发票类型 */}
发票类型
{this.state.typeArr &&
this.state.typeArr.map((item, key) => (
{item}
))}
{/* 发票内容 */}
发票抬头:
{this.state.invoice && this.state.invoice.invoiceTitle}
发票内容:
{this.state.invoice && this.state.invoice.invoiceContent}
纳税人识别号:
{this.state.invoice && this.state.invoice.invoiceTaxId}
开户银行:
{this.state.invoice && this.state.invoice.invoiceBank}
支行名称:
{this.state.invoice && this.state.invoice.invoiceSubBank}{' '}
账号:
{this.state.invoice && this.state.invoice.invoiceAccount}
{/* 底部 */}
{this.bottomTouch()}
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
text333: {
fontSize: 14,
lineHeight: 20,
letterSpacing: 0.17,
color: '#333',
},
text666: {
fontSize: 12,
lineHeight: 17,
color: '#666',
},
text999: {
fontSize: 12,
lineHeight: 17,
color: '#999',
},
})
export default SelectInvoice