罗广聪

删除

... ... @@ -13,6 +13,7 @@ import {
Modal,
Alert,
AlertIOS,
AsyncStorage,
TouchableHighlight
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
... ... @@ -23,6 +24,7 @@ export default class Edit extends Component {
super(props);
this.state = {
USER_ID: "",
IS_LOGIN: "",
customer_id: this.props.navigation.state.params.item.id,
name: "",
age: "",
... ... @@ -35,12 +37,28 @@ export default class Edit extends Component {
};
}
componentWillMount() {
this.getAsyncStorage();
console.log("customer_id", this.state.customer_id);
console.log("回调是啥?", this.props.navigation);
this.getItemInfo();
}
componentDidMount() {}
getAsyncStorage() {
const that = this;
const { USER_ID, customersList } = this.state;
AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => {
if (err) {
console.error(err);
}
that.setState({
IS_LOGIN: result[0][1],
USER_ID: result[1][1] != null ? result[1][1] : ""
});
});
}
getItemInfo() {
const that = this;
const { customer_id } = this.state;
... ... @@ -69,7 +87,7 @@ export default class Edit extends Component {
submit() {
const that = this;
const { customer_id } = this.state;
const { goBack } = this.props.navigation;
const { goBack, state } = this.props.navigation;
post(
`/test/insurance/contact/update/${customer_id}`,
{
... ... @@ -94,12 +112,15 @@ export default class Edit extends Component {
delete() {
const that = this;
const { customer_id } = this.state;
const { state,goBack } = this.props.navigation;
post(
`/test/insurance/contact/del/${customer_id}`,
{},
res => {
console.log("修改客户个人信息", res);
Alert.alert("删除成功", null, () => goBack());
Alert.alert("删除成功", null, () => {
goBack();
});
},
err => {
Alert.alert(err);
... ... @@ -135,7 +156,7 @@ export default class Edit extends Component {
});
});
}
render() {
const { navigate } = this.props.navigation;
return (
... ... @@ -299,7 +320,23 @@ export default class Edit extends Component {
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
this.delete();
Alert.alert(
"确认删除该客户?",
"",
[
{
text: "取消",
onPress: () => {}
},
{
text: "确认",
onPress: () => {
this.delete();
}
}
],
{ cancelable: false }
);
}}
style={styles.deleteBtn}
>
... ...
... ... @@ -33,9 +33,8 @@ export default class Customer extends Component {
this.getAsyncStorage();
}
componentDidMount() {
}
componentDidMount() {}
getAllPhone() {
const { navigate } = this.props.navigation;
Contacts.getAll((err, contacts) => {
... ... @@ -58,7 +57,7 @@ export default class Customer extends Component {
getAsyncStorage() {
const that = this;
const { USER_ID,customersList } = this.state;
const { USER_ID, customersList } = this.state;
AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => {
if (err) {
console.error(err);
... ... @@ -69,19 +68,19 @@ export default class Customer extends Component {
USER_ID: result[1][1] != null ? result[1][1] : ""
},
() => {
console.log(that.state.USER_ID)
console.log(that.state.USER_ID);
post(
`/test/insurance/contact/get/${that.state.USER_ID}`,
{},
res => {
console.log("通信录返回值", res);
that.setState({
hasCustomer: true,
customersList: res.data.contacts
})
});
},
err => {
console.log("通信录err", err);
Alert.alert(err);
}
);
}
... ... @@ -160,7 +159,11 @@ export default class Customer extends Component {
<TouchableOpacity
key={index}
style={styles.mainCustomerItem}
onPress={() => navigate("CustomerEdit",{item: item})}
onPress={() =>
navigate("CustomerEdit", {
item: item,
refreshCallback: this.getAsyncStorage
})}
>
<Text style={styles.mainCustomerItemText}>{item.name}</Text>
<Image
... ...