Showing
3 changed files
with
87 additions
and
59 deletions
| @@ -41,8 +41,6 @@ export default class Edit extends Component { | @@ -41,8 +41,6 @@ export default class Edit extends Component { | ||
| 41 | } | 41 | } |
| 42 | componentWillMount() { | 42 | componentWillMount() { |
| 43 | this.getAsyncStorage(); | 43 | this.getAsyncStorage(); |
| 44 | - console.log("customer_id", this.state.customer_id); | ||
| 45 | - console.log("回调是啥?", this.props.navigation); | ||
| 46 | this.getItemInfo(); | 44 | this.getItemInfo(); |
| 47 | } | 45 | } |
| 48 | 46 | ||
| @@ -117,8 +115,9 @@ export default class Edit extends Component { | @@ -117,8 +115,9 @@ export default class Edit extends Component { | ||
| 117 | const { USER_ID } = this.state; | 115 | const { USER_ID } = this.state; |
| 118 | const { goBack, state } = this.props.navigation; | 116 | const { goBack, state } = this.props.navigation; |
| 119 | post( | 117 | post( |
| 120 | - `/test/insurance/contact/update/${USER_ID}`, | 118 | + `/test/insurance/contact/add`, |
| 121 | { | 119 | { |
| 120 | + user: USER_ID, | ||
| 122 | name: this.state.name, | 121 | name: this.state.name, |
| 123 | age: this.state.age, | 122 | age: this.state.age, |
| 124 | phone: this.state.phone, | 123 | phone: this.state.phone, |
| @@ -129,7 +128,6 @@ export default class Edit extends Component { | @@ -129,7 +128,6 @@ export default class Edit extends Component { | ||
| 129 | has_children: this.state.has_children | 128 | has_children: this.state.has_children |
| 130 | }, | 129 | }, |
| 131 | res => { | 130 | res => { |
| 132 | - // console.log("修改客户个人信息", res); | ||
| 133 | Alert.alert("提交成功", null, () => goBack()); | 131 | Alert.alert("提交成功", null, () => goBack()); |
| 134 | }, | 132 | }, |
| 135 | err => { | 133 | err => { |
| @@ -350,30 +348,32 @@ export default class Edit extends Component { | @@ -350,30 +348,32 @@ export default class Edit extends Component { | ||
| 350 | > | 348 | > |
| 351 | <Text style={styles.confirmBtnText}>确定</Text> | 349 | <Text style={styles.confirmBtnText}>确定</Text> |
| 352 | </TouchableOpacity> | 350 | </TouchableOpacity> |
| 353 | - <TouchableOpacity | 351 | + {this.state.todo == "edit" ? ( |
| 354 | - onPress={() => { | 352 | + <TouchableOpacity |
| 355 | - Alert.alert( | 353 | + onPress={() => { |
| 356 | - "确认删除该客户?", | 354 | + Alert.alert( |
| 357 | - "", | 355 | + "确认删除该客户?", |
| 358 | - [ | 356 | + "", |
| 359 | - { | 357 | + [ |
| 360 | - text: "取消", | 358 | + { |
| 361 | - onPress: () => {} | 359 | + text: "取消", |
| 362 | - }, | 360 | + onPress: () => {} |
| 363 | - { | 361 | + }, |
| 364 | - text: "确认", | 362 | + { |
| 365 | - onPress: () => { | 363 | + text: "确认", |
| 366 | - this.delete(); | 364 | + onPress: () => { |
| 365 | + this.delete(); | ||
| 366 | + } | ||
| 367 | } | 367 | } |
| 368 | - } | 368 | + ], |
| 369 | - ], | 369 | + { cancelable: false } |
| 370 | - { cancelable: false } | 370 | + ); |
| 371 | - ); | 371 | + }} |
| 372 | - }} | 372 | + style={styles.deleteBtn} |
| 373 | - style={styles.deleteBtn} | 373 | + > |
| 374 | - > | 374 | + <Text style={styles.deleteText}>删除</Text> |
| 375 | - <Text style={styles.deleteText}>删除</Text> | 375 | + </TouchableOpacity> |
| 376 | - </TouchableOpacity> | 376 | + ) : null} |
| 377 | </View> | 377 | </View> |
| 378 | </View> | 378 | </View> |
| 379 | ); | 379 | ); |
| @@ -24,7 +24,6 @@ export default class Customer extends Component { | @@ -24,7 +24,6 @@ export default class Customer extends Component { | ||
| 24 | USER_ID: "", | 24 | USER_ID: "", |
| 25 | NICKNAME: "", | 25 | NICKNAME: "", |
| 26 | PROFESSION: "", | 26 | PROFESSION: "", |
| 27 | - hasCustomer: false, | ||
| 28 | customersList: [] | 27 | customersList: [] |
| 29 | }; | 28 | }; |
| 30 | this.getAllPhone = this.getAllPhone.bind(this); | 29 | this.getAllPhone = this.getAllPhone.bind(this); |
| @@ -57,7 +56,7 @@ export default class Customer extends Component { | @@ -57,7 +56,7 @@ export default class Customer extends Component { | ||
| 57 | 56 | ||
| 58 | getAsyncStorage() { | 57 | getAsyncStorage() { |
| 59 | const that = this; | 58 | const that = this; |
| 60 | - const { USER_ID, customersList } = this.state; | 59 | + const { IS_LOGIN, USER_ID, customersList } = this.state; |
| 61 | AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => { | 60 | AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => { |
| 62 | if (err) { | 61 | if (err) { |
| 63 | console.error(err); | 62 | console.error(err); |
| @@ -69,22 +68,24 @@ export default class Customer extends Component { | @@ -69,22 +68,24 @@ export default class Customer extends Component { | ||
| 69 | }, | 68 | }, |
| 70 | () => { | 69 | () => { |
| 71 | console.log(that.state.USER_ID); | 70 | console.log(that.state.USER_ID); |
| 72 | - post( | 71 | + if (that.state.IS_LOGIN == "yes") { |
| 73 | - `/test/insurance/contact/get/${that.state.USER_ID}`, | 72 | + post( |
| 74 | - {}, | 73 | + `/test/insurance/contact/get/${that.state.USER_ID}`, |
| 75 | - res => { | 74 | + {}, |
| 76 | - if (res.data.contacts) { | 75 | + res => { |
| 77 | - that.setState({ | 76 | + console.log("我的通信录呢?",res) |
| 78 | - hasCustomer: true, | 77 | + if (res.data.contacts) { |
| 79 | - customersList: res.data.contacts | 78 | + that.setState({ |
| 80 | - }); | 79 | + customersList: res.data.contacts |
| 80 | + }); | ||
| 81 | + } | ||
| 82 | + }, | ||
| 83 | + err => { | ||
| 84 | + console.log("通信录err", err); | ||
| 85 | + Alert.alert(err); | ||
| 81 | } | 86 | } |
| 82 | - }, | 87 | + ); |
| 83 | - err => { | 88 | + } |
| 84 | - console.log("通信录err", err); | ||
| 85 | - Alert.alert(err); | ||
| 86 | - } | ||
| 87 | - ); | ||
| 88 | } | 89 | } |
| 89 | ); | 90 | ); |
| 90 | }); | 91 | }); |
| @@ -102,11 +103,24 @@ export default class Customer extends Component { | @@ -102,11 +103,24 @@ export default class Customer extends Component { | ||
| 102 | <TouchableOpacity | 103 | <TouchableOpacity |
| 103 | style={styles.beginBtnLeft} | 104 | style={styles.beginBtnLeft} |
| 104 | onPress={() => { | 105 | onPress={() => { |
| 105 | - if (this.state.IS_LOGIN != "yes") { | 106 | + AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => { |
| 106 | - Alert.alert("请先登录账号"); | 107 | + if (err) { |
| 107 | - } else { | 108 | + console.error(err); |
| 108 | - navigate("CustomerEdit"); | 109 | + } |
| 109 | - } | 110 | + this.setState( |
| 111 | + { | ||
| 112 | + IS_LOGIN: result[0][1], | ||
| 113 | + USER_ID: result[1][1] != null ? result[1][1] : "" | ||
| 114 | + }, | ||
| 115 | + () => { | ||
| 116 | + if (this.state.IS_LOGIN != "yes") { | ||
| 117 | + Alert.alert("请先登录账号"); | ||
| 118 | + } else { | ||
| 119 | + navigate("CustomerEdit",{ todo: "add",item: null }); | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + ); | ||
| 123 | + }); | ||
| 110 | }} | 124 | }} |
| 111 | > | 125 | > |
| 112 | <Text style={styles.beginBtnLeftText}>手动添加</Text> | 126 | <Text style={styles.beginBtnLeftText}>手动添加</Text> |
| @@ -114,13 +128,24 @@ export default class Customer extends Component { | @@ -114,13 +128,24 @@ export default class Customer extends Component { | ||
| 114 | <TouchableOpacity | 128 | <TouchableOpacity |
| 115 | style={styles.beginBtnRight} | 129 | style={styles.beginBtnRight} |
| 116 | onPress={() => { | 130 | onPress={() => { |
| 117 | - if (this.state.IS_LOGIN != "yes") { | 131 | + AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => { |
| 118 | - Alert.alert("请先登录账号"); | 132 | + if (err) { |
| 119 | - } else { | 133 | + console.error(err); |
| 120 | - { | ||
| 121 | - this.getAllPhone(); | ||
| 122 | } | 134 | } |
| 123 | - } | 135 | + this.setState( |
| 136 | + { | ||
| 137 | + IS_LOGIN: result[0][1], | ||
| 138 | + USER_ID: result[1][1] != null ? result[1][1] : "" | ||
| 139 | + }, | ||
| 140 | + () => { | ||
| 141 | + if (this.state.IS_LOGIN != "yes") { | ||
| 142 | + Alert.alert("请先登录账号"); | ||
| 143 | + } else { | ||
| 144 | + this.getAllPhone(); | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + ); | ||
| 148 | + }); | ||
| 124 | }} | 149 | }} |
| 125 | > | 150 | > |
| 126 | <Text style={styles.beginBtnRightText}>通信录导入</Text> | 151 | <Text style={styles.beginBtnRightText}>通信录导入</Text> |
| @@ -138,7 +163,7 @@ export default class Customer extends Component { | @@ -138,7 +163,7 @@ export default class Customer extends Component { | ||
| 138 | <TouchableOpacity | 163 | <TouchableOpacity |
| 139 | style={styles.mainBtnContaierLeft} | 164 | style={styles.mainBtnContaierLeft} |
| 140 | onPress={() => { | 165 | onPress={() => { |
| 141 | - navigate("CustomerEdit", { todo: "add" }); | 166 | + navigate("CustomerEdit", { todo: "add",item: null }); |
| 142 | }} | 167 | }} |
| 143 | > | 168 | > |
| 144 | <Image | 169 | <Image |
| @@ -147,6 +172,9 @@ export default class Customer extends Component { | @@ -147,6 +172,9 @@ export default class Customer extends Component { | ||
| 147 | /> | 172 | /> |
| 148 | <Text style={styles.mainBtnLeftText}>手动添加</Text> | 173 | <Text style={styles.mainBtnLeftText}>手动添加</Text> |
| 149 | </TouchableOpacity> | 174 | </TouchableOpacity> |
| 175 | + <TouchableOpacity onPress={() => this.getAsyncStorage()}> | ||
| 176 | + <Image source={require('../../assets/customer/ic_add.png')} style={{width: 44,height: 44}} /> | ||
| 177 | + </TouchableOpacity> | ||
| 150 | <TouchableOpacity | 178 | <TouchableOpacity |
| 151 | style={styles.mainBtnContaierRight} | 179 | style={styles.mainBtnContaierRight} |
| 152 | onPress={() => { | 180 | onPress={() => { |
| @@ -188,10 +216,10 @@ export default class Customer extends Component { | @@ -188,10 +216,10 @@ export default class Customer extends Component { | ||
| 188 | 216 | ||
| 189 | render() { | 217 | render() { |
| 190 | const { navigate } = this.props.navigation; | 218 | const { navigate } = this.props.navigation; |
| 191 | - const { IS_LOGIN, hasCustomer, customers } = this.state; | 219 | + const { IS_LOGIN, customers } = this.state; |
| 192 | return ( | 220 | return ( |
| 193 | <View style={styles.container}> | 221 | <View style={styles.container}> |
| 194 | - {hasCustomer ? this._renderMain() : this._renderBegin()} | 222 | + {IS_LOGIN == "yes" ? this._renderMain() : this._renderBegin()} |
| 195 | </View> | 223 | </View> |
| 196 | ); | 224 | ); |
| 197 | } | 225 | } |
| @@ -87,7 +87,7 @@ export default class InsuranceChurch extends Component { | @@ -87,7 +87,7 @@ export default class InsuranceChurch extends Component { | ||
| 87 | ); | 87 | ); |
| 88 | }} | 88 | }} |
| 89 | /> | 89 | /> |
| 90 | - <Text style={styles.scrollViewText}>没有更多了</Text> | 90 | + {/* <Text style={styles.scrollViewText}>没有更多了</Text> */} |
| 91 | </View> | 91 | </View> |
| 92 | ); | 92 | ); |
| 93 | } | 93 | } |
-
Please register or login to post a comment