罗广聪

处理好本地通信录数据

@@ -14,6 +14,7 @@ import InsuranceChurch from "./src/pages/InsuranceChurch/index"; @@ -14,6 +14,7 @@ import InsuranceChurch from "./src/pages/InsuranceChurch/index";
14 import Mine from "./src/pages/Mine/index"; 14 import Mine from "./src/pages/Mine/index";
15 import Customer from "./src/pages/Customer/index"; 15 import Customer from "./src/pages/Customer/index";
16 import CustomerEdit from "./src/pages/Customer/edit"; 16 import CustomerEdit from "./src/pages/Customer/edit";
  17 +import CustomerImport from "./src/pages/Customer/Import";
17 import Login from "./src/pages/Login"; 18 import Login from "./src/pages/Login";
18 import AllProduct from "./src/pages/Home/allProduct"; 19 import AllProduct from "./src/pages/Home/allProduct";
19 import ProductTemplate from "./src/Components/ProductTemplate"; 20 import ProductTemplate from "./src/Components/ProductTemplate";
@@ -112,6 +113,10 @@ const ProtectGod = StackNavigator( @@ -112,6 +113,10 @@ const ProtectGod = StackNavigator(
112 screen: CustomerEdit, 113 screen: CustomerEdit,
113 navigationOptions: { headerTitle: "客户信息" } 114 navigationOptions: { headerTitle: "客户信息" }
114 }, 115 },
  116 + CustomerImport: {
  117 + screen: CustomerImport,
  118 + navigationOptions: { headerTitle: "导入客户" }
  119 + },
115 AllProduct: { 120 AllProduct: {
116 screen: AllProduct, 121 screen: AllProduct,
117 navigationOptions: { headerTitle: "全部产品" } 122 navigationOptions: { headerTitle: "全部产品" }
  1 +import React, { Component } from "react";
  2 +import {
  3 + AppRegistry,
  4 + StyleSheet,
  5 + Text,
  6 + View,
  7 + Image,
  8 + TouchableOpacity,
  9 + ScrollView,
  10 + ListView,
  11 + Dimensions,
  12 +} from "react-native";
  13 +import { StackNavigator, TabNavigator } from "react-navigation";
  14 +import post from "../../utils/fetch";
  15 +
  16 +export default class Import extends Component {
  17 + constructor(props) {
  18 + super(props);
  19 + this.state = {};
  20 + }
  21 + componentWillMount() {}
  22 +
  23 + componentDidMount() {
  24 + console.log("导入客户",this.props.navigation.state.params);
  25 + }
  26 +
  27 + getListData() {
  28 + post("/test/insurance/article", {}, res => {}, err => {});
  29 + }
  30 +
  31 + render() {
  32 + const { navigate } = this.props.navigation;
  33 + return (
  34 + <View style={styles.container}>
  35 + <Text>导入客户</Text>
  36 + </View>
  37 + );
  38 + }
  39 +}
  40 +
  41 +const styles = StyleSheet.create({
  42 + container: {
  43 + flex: 1,
  44 + justifyContent: "flex-start",
  45 + alignItems: "stretch",
  46 + backgroundColor: "#EFEFEF"
  47 + }
  48 +});
@@ -14,7 +14,7 @@ import { @@ -14,7 +14,7 @@ import {
14 } from "react-native"; 14 } from "react-native";
15 import { StackNavigator, TabNavigator } from "react-navigation"; 15 import { StackNavigator, TabNavigator } from "react-navigation";
16 import post from "../../utils/fetch"; 16 import post from "../../utils/fetch";
17 -import Contacts from 'react-native-contacts'; 17 +import Contacts from "react-native-contacts";
18 18
19 export default class Customer extends Component { 19 export default class Customer extends Component {
20 constructor(props) { 20 constructor(props) {
@@ -56,26 +56,21 @@ export default class Customer extends Component { @@ -56,26 +56,21 @@ export default class Customer extends Component {
56 post("/test/insurance/article", {}, res => {}, err => {}); 56 post("/test/insurance/article", {}, res => {}, err => {});
57 } 57 }
58 getAllPhone() { 58 getAllPhone() {
  59 + const { navigate } = this.props.navigation;
59 Contacts.getAll((err, contacts) => { 60 Contacts.getAll((err, contacts) => {
60 if (err && err.type === "permissionDenied") { 61 if (err && err.type === "permissionDenied") {
61 } else { 62 } else {
62 - // let phones = []; 63 + let customersList = [];
63 - // contacts.forEach((item, index) => { 64 + contacts.forEach((item, index) => {
64 - // item.phoneNumbers.forEach((phone, i) => { 65 + customersList.push({
65 - // phones.push(phone.number); 66 + name: item.familyName + item.givenName,
66 - // }); 67 + phone: item.phoneNumbers.map((phone, index2) => {
67 - // }); 68 + return phone.number;
68 - console.log("通信录",contacts) 69 + })
69 - // post( 70 + });
70 - // "/spreader/rank/friends/contact", 71 + });
71 - // { contact: phones }, 72 + console.log("通信录", customersList);
72 - // res => { 73 + navigate("CustomerImport", { customersList: customersList });
73 - // this.getRankData();  
74 - // },  
75 - // resErr => {  
76 - // Toast.show(resErr.cnmsg, Toast.error);  
77 - // }  
78 - // );  
79 } 74 }
80 }); 75 });
81 } 76 }
@@ -126,8 +121,7 @@ export default class Customer extends Component { @@ -126,8 +121,7 @@ export default class Customer extends Component {
126 Alert.alert("请先登录账号"); 121 Alert.alert("请先登录账号");
127 } else { 122 } else {
128 { 123 {
129 - /* navigate("CustomerEdit"); */ 124 + this.getAllPhone();
130 - this.getAllPhone()  
131 } 125 }
132 } 126 }
133 }} 127 }}