|
@@ -4,9 +4,13 @@ import { List, InputItem, WhiteSpace ,Picker,PickerView, Button, WingBlank} from
|
|
|
import { createForm } from 'rc-form';
|
|
import { createForm } from 'rc-form';
|
|
|
import './FormAddress.css'
|
|
import './FormAddress.css'
|
|
|
|
|
|
|
|
|
|
+import {graphqls} from '../../api/graphql_request'
|
|
|
|
|
+import {getAddressById,updateAddress} from '../../api/graphql/address'
|
|
|
|
|
+
|
|
|
import { district} from 'antd-mobile-demo-data';
|
|
import { district} from 'antd-mobile-demo-data';
|
|
|
|
|
|
|
|
import config from '../../api/url_config'
|
|
import config from '../../api/url_config'
|
|
|
|
|
+import {successToast} from '../Common/Toast'
|
|
|
|
|
|
|
|
const APPID =config.APPID
|
|
const APPID =config.APPID
|
|
|
|
|
|
|
@@ -33,6 +37,26 @@ export default class FormAddress extends Component {
|
|
|
this.codeChange=this.codeChange.bind(this)
|
|
this.codeChange=this.codeChange.bind(this)
|
|
|
this.submit=this.submit.bind(this)
|
|
this.submit=this.submit.bind(this)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ componentWillMount(){
|
|
|
|
|
+ //console.log('from render------',this.props.address_id)
|
|
|
|
|
+ if(this.props.address_id){
|
|
|
|
|
+ graphqls(getAddressById,{id:this.props.address_id}).then((e)=>{
|
|
|
|
|
+ console.log('--------getAddressBYID------------',e.userAddressbyid)
|
|
|
|
|
+ let address=e.userAddressbyid
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ name:address.username,
|
|
|
|
|
+ phone:address.telephone,
|
|
|
|
|
+ detail:address.address,
|
|
|
|
|
+ code:address.postcode,
|
|
|
|
|
+ "area": address.area,
|
|
|
|
|
+ "city": address.city,
|
|
|
|
|
+ "province": address.province
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
nameChange(e){
|
|
nameChange(e){
|
|
|
console.log(e)
|
|
console.log(e)
|
|
|
this.setState({
|
|
this.setState({
|
|
@@ -98,6 +122,11 @@ export default class FormAddress extends Component {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ updateUserAddress(data){
|
|
|
|
|
+ graphqls(updateAddress,data).then(e=>{
|
|
|
|
|
+ successToast('更新地址成功',2)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
submit(){
|
|
submit(){
|
|
|
let data={
|
|
let data={
|
|
|
"address": this.state.detail,
|
|
"address": this.state.detail,
|
|
@@ -113,7 +142,12 @@ export default class FormAddress extends Component {
|
|
|
"username": this.state.name
|
|
"username": this.state.name
|
|
|
}
|
|
}
|
|
|
//console.log(this.props)
|
|
//console.log(this.props)
|
|
|
- this.props.createUserAddress(data)
|
|
|
|
|
|
|
+ if(this.props.address_id){
|
|
|
|
|
+ this.updateUserAddress(data)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.props.createUserAddress(data)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
trigger(){
|
|
trigger(){
|