罗广聪

准备接入通信录接口

@@ -9,7 +9,8 @@ import { @@ -9,7 +9,8 @@ import {
9 ScrollView, 9 ScrollView,
10 ListView, 10 ListView,
11 Dimensions, 11 Dimensions,
12 - AsyncStorage 12 + AsyncStorage,
  13 + Alert
13 } from "react-native"; 14 } from "react-native";
14 import { StackNavigator, TabNavigator } from "react-navigation"; 15 import { StackNavigator, TabNavigator } from "react-navigation";
15 import post from "../../utils/fetch"; 16 import post from "../../utils/fetch";
@@ -22,11 +23,26 @@ export default class Customer extends Component { @@ -22,11 +23,26 @@ export default class Customer extends Component {
22 USER_ID: "", 23 USER_ID: "",
23 NICKNAME: "", 24 NICKNAME: "",
24 PROFESSION: "", 25 PROFESSION: "",
25 - hasCustomer: true, 26 + hasCustomer: false,
26 - customersList: ["张某某", "周某某", "林某某", "李某某"] 27 + customersList: ["张某某", "周某某", "林某某", "李某某"],
  28 + customersList2: [{
  29 + name: "Tina",
  30 + id: "",
  31 + phone: "",
  32 + },{
  33 + name: "aaaa",
  34 + id: "",
  35 + phone: "",
  36 + },{
  37 + name: "dddd",
  38 + id: "",
  39 + phone: "",
  40 + }]
27 }; 41 };
28 } 42 }
29 - componentWillMount() {} 43 + componentWillMount() {
  44 + this.getAsyncStorage();
  45 + }
30 46
31 componentDidMount() {} 47 componentDidMount() {}
32 48
@@ -84,10 +100,28 @@ export default class Customer extends Component { @@ -84,10 +100,28 @@ export default class Customer extends Component {
84 style={styles.beginPic} 100 style={styles.beginPic}
85 /> 101 />
86 <View style={styles.beginBtnContaier}> 102 <View style={styles.beginBtnContaier}>
87 - <TouchableOpacity style={styles.beginBtnLeft} onPress={() => {navigate("CustomerEdit")}}> 103 + <TouchableOpacity
88 - <Text style={styles.beginBtnLeftText}>手动选择</Text> 104 + style={styles.beginBtnLeft}
  105 + onPress={() => {
  106 + if (this.state.IS_LOGIN != "yes") {
  107 + Alert.alert("请先登录账号");
  108 + } else {
  109 + navigate("CustomerEdit");
  110 + }
  111 + }}
  112 + >
  113 + <Text style={styles.beginBtnLeftText}>手动添加</Text>
89 </TouchableOpacity> 114 </TouchableOpacity>
90 - <TouchableOpacity style={styles.beginBtnRight}> 115 + <TouchableOpacity
  116 + style={styles.beginBtnRight}
  117 + onPress={() => {
  118 + if (this.state.IS_LOGIN != "yes") {
  119 + Alert.alert("请先登录账号");
  120 + } else {
  121 + {/* navigate("CustomerEdit"); */}
  122 + }
  123 + }}
  124 + >
91 <Text style={styles.beginBtnRightText}>通信录导入</Text> 125 <Text style={styles.beginBtnRightText}>通信录导入</Text>
92 </TouchableOpacity> 126 </TouchableOpacity>
93 </View> 127 </View>
@@ -100,7 +134,12 @@ export default class Customer extends Component { @@ -100,7 +134,12 @@ export default class Customer extends Component {
100 return ( 134 return (
101 <View style={styles.mainContaier}> 135 <View style={styles.mainContaier}>
102 <View style={styles.mainBtnContaier}> 136 <View style={styles.mainBtnContaier}>
103 - <TouchableOpacity style={styles.mainBtnContaierLeft} onPress={() => {navigate("CustomerEdit")}}> 137 + <TouchableOpacity
  138 + style={styles.mainBtnContaierLeft}
  139 + onPress={() => {
  140 + navigate("CustomerEdit");
  141 + }}
  142 + >
104 <Image 143 <Image
105 style={styles.mainBtnLeftImg} 144 style={styles.mainBtnLeftImg}
106 source={require("../../assets/customer/ic_add.png")} 145 source={require("../../assets/customer/ic_add.png")}
@@ -138,14 +177,10 @@ export default class Customer extends Component { @@ -138,14 +177,10 @@ export default class Customer extends Component {
138 177
139 render() { 178 render() {
140 const { navigate } = this.props.navigation; 179 const { navigate } = this.props.navigation;
141 - const { IS_LOGIN,hasCustomer, customers } = this.state; 180 + const { IS_LOGIN, hasCustomer, customers } = this.state;
142 return ( 181 return (
143 <View style={styles.container}> 182 <View style={styles.container}>
144 - {hasCustomer ? ( 183 + {hasCustomer ? this._renderMain() : this._renderBegin()}
145 - this._renderMain()  
146 - ) : (  
147 - this._renderBegin()  
148 - )}  
149 </View> 184 </View>
150 ); 185 );
151 } 186 }