|
|
@@ -6,19 +6,28 @@ import {Icon, Row, Col} from 'antd'
|
|
|
import {Query} from "react-apollo"
|
|
|
import gql from "graphql-tag"
|
|
|
import './index.css'
|
|
|
-import AddAddress from "./addaddress"
|
|
|
+import SingleAddress from "./singleaddress"
|
|
|
|
|
|
class Address extends Component {
|
|
|
constructor(props) {
|
|
|
super(props)
|
|
|
this.state = {
|
|
|
- add: false
|
|
|
+ single: false,
|
|
|
+ addressID: 'add',
|
|
|
+ addressChoosed: {id: 'add'}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
changePage = (bool) => {
|
|
|
this.setState({
|
|
|
- add: bool
|
|
|
+ single: bool
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ changeAddress = (address) => {
|
|
|
+ this.setState({
|
|
|
+ addressID: address.id,
|
|
|
+ addressChoosed: address
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -34,6 +43,7 @@ class Address extends Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
+ let {addressChoosed, addressID} = this.state
|
|
|
return (
|
|
|
<div>
|
|
|
<Query query={gql(userAddressbyprops)} variables={{user_id: "obR_j5GbxDfGlOolvSeTdZUwfpKA"}}>
|
|
|
@@ -55,10 +65,15 @@ class Address extends Component {
|
|
|
return (
|
|
|
<div>
|
|
|
{
|
|
|
- this.state.add ?
|
|
|
- <AddAddress changePage={this.changePage}/>
|
|
|
+ this.state.single ?
|
|
|
+ <SingleAddress addressID={addressID} addressChoosed={addressChoosed} changePage={this.changePage}/>
|
|
|
:
|
|
|
- <AddressRender defaultAddress={this.getDefaultAddress(data)} otherAddress={this.getOtherAddress(data)} changePage={this.changePage}/>
|
|
|
+ <AddressRender
|
|
|
+ defaultAddress={this.getDefaultAddress(data)}
|
|
|
+ otherAddress={this.getOtherAddress(data)}
|
|
|
+ changePage={this.changePage}
|
|
|
+ changeAddress={this.changeAddress}
|
|
|
+ />
|
|
|
}
|
|
|
</div>
|
|
|
)
|
|
|
@@ -79,9 +94,7 @@ class AddressRender extends Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- let {changePage, defaultAddress, otherAddress} = this.props
|
|
|
- console.log(defaultAddress)
|
|
|
- console.log(otherAddress)
|
|
|
+ let {changePage, changeAddress, defaultAddress, otherAddress} = this.props
|
|
|
return (
|
|
|
<div>
|
|
|
<div className='address-add' onClick={() => {
|
|
|
@@ -101,7 +114,16 @@ class AddressRender extends Component {
|
|
|
<Row>
|
|
|
<Col span={20}
|
|
|
className='address-address'>{defaultAddress.province + defaultAddress.city + defaultAddress.area + defaultAddress.address}</Col>
|
|
|
- <Col span={2} offset={2}><Icon type="edit" style={{fontSize: 14}}/></Col>
|
|
|
+ <Col span={2} offset={2}>
|
|
|
+ <Icon
|
|
|
+ type="edit"
|
|
|
+ style={{fontSize: 14}}
|
|
|
+ onClick={()=>{
|
|
|
+ changePage(true)
|
|
|
+ changeAddress(defaultAddress)
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Col>
|
|
|
</Row>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -115,9 +137,17 @@ class AddressRender extends Component {
|
|
|
<Col span={14} className='address-phone ellipsis'>{address.telephone}</Col>
|
|
|
</Row>
|
|
|
<Row>
|
|
|
- <Col span={20}
|
|
|
- className='address-address'>{address.province + address.city + address.area + address.address}</Col>
|
|
|
- <Col span={2} offset={2}><Icon type="edit" style={{fontSize: 14}}/></Col>
|
|
|
+ <Col span={20} className='address-address'>{address.province + address.city + address.area + address.address}</Col>
|
|
|
+ <Col span={2} offset={2}>
|
|
|
+ <Icon
|
|
|
+ type="edit"
|
|
|
+ style={{fontSize: 14}}
|
|
|
+ onClick={()=>{
|
|
|
+ changePage(true)
|
|
|
+ changeAddress(address)
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Col>
|
|
|
</Row>
|
|
|
</div>
|
|
|
)
|