罗广聪

通信录OK

... ... @@ -41,8 +41,6 @@ export default class Edit extends Component {
}
componentWillMount() {
this.getAsyncStorage();
console.log("customer_id", this.state.customer_id);
console.log("回调是啥?", this.props.navigation);
this.getItemInfo();
}
... ... @@ -117,8 +115,9 @@ export default class Edit extends Component {
const { USER_ID } = this.state;
const { goBack, state } = this.props.navigation;
post(
`/test/insurance/contact/update/${USER_ID}`,
`/test/insurance/contact/add`,
{
user: USER_ID,
name: this.state.name,
age: this.state.age,
phone: this.state.phone,
... ... @@ -129,7 +128,6 @@ export default class Edit extends Component {
has_children: this.state.has_children
},
res => {
// console.log("修改客户个人信息", res);
Alert.alert("提交成功", null, () => goBack());
},
err => {
... ... @@ -350,30 +348,32 @@ export default class Edit extends Component {
>
<Text style={styles.confirmBtnText}>确定</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
Alert.alert(
"确认删除该客户?",
"",
[
{
text: "取消",
onPress: () => {}
},
{
text: "确认",
onPress: () => {
this.delete();
{this.state.todo == "edit" ? (
<TouchableOpacity
onPress={() => {
Alert.alert(
"确认删除该客户?",
"",
[
{
text: "取消",
onPress: () => {}
},
{
text: "确认",
onPress: () => {
this.delete();
}
}
}
],
{ cancelable: false }
);
}}
style={styles.deleteBtn}
>
<Text style={styles.deleteText}>删除</Text>
</TouchableOpacity>
],
{ cancelable: false }
);
}}
style={styles.deleteBtn}
>
<Text style={styles.deleteText}>删除</Text>
</TouchableOpacity>
) : null}
</View>
</View>
);
... ...
... ... @@ -24,7 +24,6 @@ export default class Customer extends Component {
USER_ID: "",
NICKNAME: "",
PROFESSION: "",
hasCustomer: false,
customersList: []
};
this.getAllPhone = this.getAllPhone.bind(this);
... ... @@ -57,7 +56,7 @@ export default class Customer extends Component {
getAsyncStorage() {
const that = this;
const { USER_ID, customersList } = this.state;
const { IS_LOGIN, USER_ID, customersList } = this.state;
AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => {
if (err) {
console.error(err);
... ... @@ -69,22 +68,24 @@ export default class Customer extends Component {
},
() => {
console.log(that.state.USER_ID);
post(
`/test/insurance/contact/get/${that.state.USER_ID}`,
{},
res => {
if (res.data.contacts) {
that.setState({
hasCustomer: true,
customersList: res.data.contacts
});
if (that.state.IS_LOGIN == "yes") {
post(
`/test/insurance/contact/get/${that.state.USER_ID}`,
{},
res => {
console.log("我的通信录呢?",res)
if (res.data.contacts) {
that.setState({
customersList: res.data.contacts
});
}
},
err => {
console.log("通信录err", err);
Alert.alert(err);
}
},
err => {
console.log("通信录err", err);
Alert.alert(err);
}
);
);
}
}
);
});
... ... @@ -102,11 +103,24 @@ export default class Customer extends Component {
<TouchableOpacity
style={styles.beginBtnLeft}
onPress={() => {
if (this.state.IS_LOGIN != "yes") {
Alert.alert("请先登录账号");
} else {
navigate("CustomerEdit");
}
AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => {
if (err) {
console.error(err);
}
this.setState(
{
IS_LOGIN: result[0][1],
USER_ID: result[1][1] != null ? result[1][1] : ""
},
() => {
if (this.state.IS_LOGIN != "yes") {
Alert.alert("请先登录账号");
} else {
navigate("CustomerEdit",{ todo: "add",item: null });
}
}
);
});
}}
>
<Text style={styles.beginBtnLeftText}>手动添加</Text>
... ... @@ -114,13 +128,24 @@ export default class Customer extends Component {
<TouchableOpacity
style={styles.beginBtnRight}
onPress={() => {
if (this.state.IS_LOGIN != "yes") {
Alert.alert("请先登录账号");
} else {
{
this.getAllPhone();
AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => {
if (err) {
console.error(err);
}
}
this.setState(
{
IS_LOGIN: result[0][1],
USER_ID: result[1][1] != null ? result[1][1] : ""
},
() => {
if (this.state.IS_LOGIN != "yes") {
Alert.alert("请先登录账号");
} else {
this.getAllPhone();
}
}
);
});
}}
>
<Text style={styles.beginBtnRightText}>通信录导入</Text>
... ... @@ -138,7 +163,7 @@ export default class Customer extends Component {
<TouchableOpacity
style={styles.mainBtnContaierLeft}
onPress={() => {
navigate("CustomerEdit", { todo: "add" });
navigate("CustomerEdit", { todo: "add",item: null });
}}
>
<Image
... ... @@ -147,6 +172,9 @@ export default class Customer extends Component {
/>
<Text style={styles.mainBtnLeftText}>手动添加</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.getAsyncStorage()}>
<Image source={require('../../assets/customer/ic_add.png')} style={{width: 44,height: 44}} />
</TouchableOpacity>
<TouchableOpacity
style={styles.mainBtnContaierRight}
onPress={() => {
... ... @@ -188,10 +216,10 @@ export default class Customer extends Component {
render() {
const { navigate } = this.props.navigation;
const { IS_LOGIN, hasCustomer, customers } = this.state;
const { IS_LOGIN, customers } = this.state;
return (
<View style={styles.container}>
{hasCustomer ? this._renderMain() : this._renderBegin()}
{IS_LOGIN == "yes" ? this._renderMain() : this._renderBegin()}
</View>
);
}
... ...
... ... @@ -87,7 +87,7 @@ export default class InsuranceChurch extends Component {
);
}}
/>
<Text style={styles.scrollViewText}>没有更多了</Text>
{/* <Text style={styles.scrollViewText}>没有更多了</Text> */}
</View>
);
}
... ...