import React, { Component } from 'react' import { StyleSheet, View, Image, StatusBar, Text, TouchableOpacity, PixelRatio, FlatList, } from 'react-native' import { connect } from 'react-redux' import Icon from '../../components/Iconfont/Iconfont' import { NavigationActions, createAction } from '../../utils' import { HeaderView } from '../common/HeaderView' @connect(({ theme, mine }) => ({ ...theme, ...mine })) class SelectAdress extends Component { constructor() { super() this.state = { adress: [], adressDefault: {} } } componentDidMount() { this.props.dispatch( createAction('mine/getAdress')({ customer: CUSTOMERINFO.id }) ) // this.setState({ adress: adress }); } setDefault(item, addressData) { let adress = addressData for (val of adress) { val.isDefault = 0 } adress[item.index].isDefault = 1 this.setState({ adress: adress, adressDefault: adress[item.index] }) } touchItem(item) { this.props.dispatch(NavigationActions.back()) this.props.navigation.state.params(item) } _renderItem(item, addressData) { return ( this.touchItem(item)} > {item.item.isDefault == 1 ? ( ) : null} {item.item.receiver} {item.item.receiverPhone} {item.item.isDefault == 1 ? ( 默认地址 ) : ( this.setDefault(item, addressData)} > 设为默认 )} {/* {item.item.receiverProvince + item.item.receiverCity + item.item.receiverDistrict + item.item.receiverTown + item.item.receiverAddress} */} {item.item.country+item.item.receiverAddress} ) } render() { const { appTheme, addressData } = this.props return ( {/* 头部 */} {HeaderView(this.props.dispatch, '选择地址')} {/* 内容 */} index} renderItem={(item, index) => this._renderItem(item, addressData)} /> ) } } 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 SelectAdress