Showing
2 changed files
with
20 additions
and
11 deletions
| @@ -25,7 +25,9 @@ export default class Edit extends Component { | @@ -25,7 +25,9 @@ export default class Edit extends Component { | ||
| 25 | this.state = { | 25 | this.state = { |
| 26 | USER_ID: "", | 26 | USER_ID: "", |
| 27 | IS_LOGIN: "", | 27 | IS_LOGIN: "", |
| 28 | - customer_id: this.props.navigation.state.params.item.id, | 28 | + customer_id: this.props.navigation.state.params.item |
| 29 | + ? this.props.navigation.state.params.item.id | ||
| 30 | + : null, | ||
| 29 | todo: this.props.navigation.state.params.todo, | 31 | todo: this.props.navigation.state.params.todo, |
| 30 | name: "", | 32 | name: "", |
| 31 | age: "", | 33 | age: "", |
| @@ -138,7 +140,7 @@ export default class Edit extends Component { | @@ -138,7 +140,7 @@ export default class Edit extends Component { | ||
| 138 | delete() { | 140 | delete() { |
| 139 | const that = this; | 141 | const that = this; |
| 140 | const { customer_id } = this.state; | 142 | const { customer_id } = this.state; |
| 141 | - const { state,goBack } = this.props.navigation; | 143 | + const { state, goBack } = this.props.navigation; |
| 142 | post( | 144 | post( |
| 143 | `/test/insurance/contact/del/${customer_id}`, | 145 | `/test/insurance/contact/del/${customer_id}`, |
| 144 | {}, | 146 | {}, |
| @@ -338,7 +340,7 @@ export default class Edit extends Component { | @@ -338,7 +340,7 @@ export default class Edit extends Component { | ||
| 338 | <View style={styles.btnContainer}> | 340 | <View style={styles.btnContainer}> |
| 339 | <TouchableOpacity | 341 | <TouchableOpacity |
| 340 | onPress={() => { | 342 | onPress={() => { |
| 341 | - if(this.state.todo == 'edit') { | 343 | + if (this.state.todo == "edit") { |
| 342 | this.submit(); | 344 | this.submit(); |
| 343 | } else { | 345 | } else { |
| 344 | this.add(); | 346 | this.add(); |
| @@ -24,7 +24,7 @@ export default class Customer extends Component { | @@ -24,7 +24,7 @@ export default class Customer extends Component { | ||
| 24 | USER_ID: "", | 24 | USER_ID: "", |
| 25 | NICKNAME: "", | 25 | NICKNAME: "", |
| 26 | PROFESSION: "", | 26 | PROFESSION: "", |
| 27 | - hasCustomer: true, | 27 | + hasCustomer: false, |
| 28 | customersList: [] | 28 | customersList: [] |
| 29 | }; | 29 | }; |
| 30 | this.getAllPhone = this.getAllPhone.bind(this); | 30 | this.getAllPhone = this.getAllPhone.bind(this); |
| @@ -73,10 +73,12 @@ export default class Customer extends Component { | @@ -73,10 +73,12 @@ export default class Customer extends Component { | ||
| 73 | `/test/insurance/contact/get/${that.state.USER_ID}`, | 73 | `/test/insurance/contact/get/${that.state.USER_ID}`, |
| 74 | {}, | 74 | {}, |
| 75 | res => { | 75 | res => { |
| 76 | - that.setState({ | 76 | + if (res.data.contacts) { |
| 77 | - hasCustomer: true, | 77 | + that.setState({ |
| 78 | - customersList: res.data.contacts | 78 | + hasCustomer: true, |
| 79 | - }); | 79 | + customersList: res.data.contacts |
| 80 | + }); | ||
| 81 | + } | ||
| 80 | }, | 82 | }, |
| 81 | err => { | 83 | err => { |
| 82 | console.log("通信录err", err); | 84 | console.log("通信录err", err); |
| @@ -136,7 +138,7 @@ export default class Customer extends Component { | @@ -136,7 +138,7 @@ export default class Customer extends Component { | ||
| 136 | <TouchableOpacity | 138 | <TouchableOpacity |
| 137 | style={styles.mainBtnContaierLeft} | 139 | style={styles.mainBtnContaierLeft} |
| 138 | onPress={() => { | 140 | onPress={() => { |
| 139 | - navigate("CustomerEdit",{todo: 'add'}); | 141 | + navigate("CustomerEdit", { todo: "add" }); |
| 140 | }} | 142 | }} |
| 141 | > | 143 | > |
| 142 | <Image | 144 | <Image |
| @@ -145,7 +147,12 @@ export default class Customer extends Component { | @@ -145,7 +147,12 @@ export default class Customer extends Component { | ||
| 145 | /> | 147 | /> |
| 146 | <Text style={styles.mainBtnLeftText}>手动添加</Text> | 148 | <Text style={styles.mainBtnLeftText}>手动添加</Text> |
| 147 | </TouchableOpacity> | 149 | </TouchableOpacity> |
| 148 | - <TouchableOpacity style={styles.mainBtnContaierRight}> | 150 | + <TouchableOpacity |
| 151 | + style={styles.mainBtnContaierRight} | ||
| 152 | + onPress={() => { | ||
| 153 | + this.getAllPhone(); | ||
| 154 | + }} | ||
| 155 | + > | ||
| 149 | <Image | 156 | <Image |
| 150 | style={styles.mainBtnRightImg} | 157 | style={styles.mainBtnRightImg} |
| 151 | source={require("../../assets/customer/ic_message.png")} | 158 | source={require("../../assets/customer/ic_message.png")} |
| @@ -162,7 +169,7 @@ export default class Customer extends Component { | @@ -162,7 +169,7 @@ export default class Customer extends Component { | ||
| 162 | onPress={() => | 169 | onPress={() => |
| 163 | navigate("CustomerEdit", { | 170 | navigate("CustomerEdit", { |
| 164 | item: item, | 171 | item: item, |
| 165 | - todo: 'edit', | 172 | + todo: "edit", |
| 166 | refreshCallback: this.getAsyncStorage | 173 | refreshCallback: this.getAsyncStorage |
| 167 | })} | 174 | })} |
| 168 | > | 175 | > |
-
Please register or login to post a comment