罗广聪

处理好本地通信录数据

... ... @@ -14,6 +14,7 @@ import InsuranceChurch from "./src/pages/InsuranceChurch/index";
import Mine from "./src/pages/Mine/index";
import Customer from "./src/pages/Customer/index";
import CustomerEdit from "./src/pages/Customer/edit";
import CustomerImport from "./src/pages/Customer/Import";
import Login from "./src/pages/Login";
import AllProduct from "./src/pages/Home/allProduct";
import ProductTemplate from "./src/Components/ProductTemplate";
... ... @@ -112,6 +113,10 @@ const ProtectGod = StackNavigator(
screen: CustomerEdit,
navigationOptions: { headerTitle: "客户信息" }
},
CustomerImport: {
screen: CustomerImport,
navigationOptions: { headerTitle: "导入客户" }
},
AllProduct: {
screen: AllProduct,
navigationOptions: { headerTitle: "全部产品" }
... ...
import React, { Component } from "react";
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
TouchableOpacity,
ScrollView,
ListView,
Dimensions,
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
import post from "../../utils/fetch";
export default class Import extends Component {
constructor(props) {
super(props);
this.state = {};
}
componentWillMount() {}
componentDidMount() {
console.log("导入客户",this.props.navigation.state.params);
}
getListData() {
post("/test/insurance/article", {}, res => {}, err => {});
}
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<Text>导入客户</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "flex-start",
alignItems: "stretch",
backgroundColor: "#EFEFEF"
}
});
... ...
... ... @@ -14,7 +14,7 @@ import {
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
import post from "../../utils/fetch";
import Contacts from 'react-native-contacts';
import Contacts from "react-native-contacts";
export default class Customer extends Component {
constructor(props) {
... ... @@ -56,26 +56,21 @@ export default class Customer extends Component {
post("/test/insurance/article", {}, res => {}, err => {});
}
getAllPhone() {
const { navigate } = this.props.navigation;
Contacts.getAll((err, contacts) => {
if (err && err.type === "permissionDenied") {
} else {
// let phones = [];
// contacts.forEach((item, index) => {
// item.phoneNumbers.forEach((phone, i) => {
// phones.push(phone.number);
// });
// });
console.log("通信录",contacts)
// post(
// "/spreader/rank/friends/contact",
// { contact: phones },
// res => {
// this.getRankData();
// },
// resErr => {
// Toast.show(resErr.cnmsg, Toast.error);
// }
// );
let customersList = [];
contacts.forEach((item, index) => {
customersList.push({
name: item.familyName + item.givenName,
phone: item.phoneNumbers.map((phone, index2) => {
return phone.number;
})
});
});
console.log("通信录", customersList);
navigate("CustomerImport", { customersList: customersList });
}
});
}
... ... @@ -126,8 +121,7 @@ export default class Customer extends Component {
Alert.alert("请先登录账号");
} else {
{
/* navigate("CustomerEdit"); */
this.getAllPhone()
this.getAllPhone();
}
}
}}
... ...