Showing
2 changed files
with
68 additions
and
13 deletions
| @@ -16,7 +16,9 @@ import post from "../../utils/fetch"; | @@ -16,7 +16,9 @@ import post from "../../utils/fetch"; | ||
| 16 | export default class Import extends Component { | 16 | export default class Import extends Component { |
| 17 | constructor(props) { | 17 | constructor(props) { |
| 18 | super(props); | 18 | super(props); |
| 19 | - this.state = {}; | 19 | + this.state = { |
| 20 | + customersList: this.props.navigation.state.params.customersList | ||
| 21 | + }; | ||
| 20 | } | 22 | } |
| 21 | componentWillMount() {} | 23 | componentWillMount() {} |
| 22 | 24 | ||
| @@ -28,13 +30,65 @@ export default class Import extends Component { | @@ -28,13 +30,65 @@ export default class Import extends Component { | ||
| 28 | post("/test/insurance/article", {}, res => {}, err => {}); | 30 | post("/test/insurance/article", {}, res => {}, err => {}); |
| 29 | } | 31 | } |
| 30 | 32 | ||
| 33 | + /* customersList: [ | ||
| 34 | + ...this.state.customersList.slice(0, index), | ||
| 35 | + { | ||
| 36 | + ...this.state.customersList[index], | ||
| 37 | + selected: !this.state.customersList[index].selected | ||
| 38 | + }, | ||
| 39 | + ...this.state.slice(index + 1) | ||
| 40 | + ] */ | ||
| 31 | render() { | 41 | render() { |
| 32 | const { navigate } = this.props.navigation; | 42 | const { navigate } = this.props.navigation; |
| 33 | - const customersList = this.props.navigation.state.params.customersList; | 43 | + const { customersList } = this.state; |
| 44 | + // const customersList = this.props.navigation.state.params.customersList; | ||
| 45 | + const ds = new ListView.DataSource({ | ||
| 46 | + rowHasChanged: (r1, r2) => r1 !== r2 | ||
| 47 | + }); | ||
| 48 | + const dataSource = ds.cloneWithRows(customersList); | ||
| 34 | return ( | 49 | return ( |
| 35 | <View style={styles.container}> | 50 | <View style={styles.container}> |
| 36 | - {/* <Text>导入客户</Text> */} | 51 | + <ListView |
| 37 | - <ScrollView style={styles.mainSvcContainer}> | 52 | + style={styles.mainSvcContainer} |
| 53 | + dataSource={dataSource} | ||
| 54 | + enableEmptySections={true} | ||
| 55 | + renderRow={(item,secid, index) => { | ||
| 56 | + return ( | ||
| 57 | + <TouchableOpacity | ||
| 58 | + key={index} | ||
| 59 | + style={styles.CustomerItemContaier} | ||
| 60 | + onPress={() => { | ||
| 61 | + let Temp = customersList; | ||
| 62 | + console.log(index); | ||
| 63 | + {/* return; */} | ||
| 64 | + Temp.splice(index, 1, { | ||
| 65 | + ...customersList[index], | ||
| 66 | + selected: !customersList[index].selected | ||
| 67 | + }); | ||
| 68 | + this.setState({ | ||
| 69 | + customersList: Temp | ||
| 70 | + }); | ||
| 71 | + }} | ||
| 72 | + > | ||
| 73 | + <View style={styles.itemSelectIconContainer}> | ||
| 74 | + {item.selected ? ( | ||
| 75 | + <Image | ||
| 76 | + style={styles.itemSelectIcon} | ||
| 77 | + source={require("../../assets/customer/ic1_s.png")} | ||
| 78 | + /> | ||
| 79 | + ) : ( | ||
| 80 | + <Image | ||
| 81 | + style={styles.itemSelectIcon} | ||
| 82 | + source={require("../../assets/customer/ic1_n.png")} | ||
| 83 | + /> | ||
| 84 | + )} | ||
| 85 | + </View> | ||
| 86 | + <Text style={styles.CustomerItemText}>{item.name}</Text> | ||
| 87 | + </TouchableOpacity> | ||
| 88 | + ); | ||
| 89 | + }} | ||
| 90 | + /> | ||
| 91 | + {/* <ScrollView style={styles.mainSvcContainer}> | ||
| 38 | {customersList.map((item, index) => { | 92 | {customersList.map((item, index) => { |
| 39 | return ( | 93 | return ( |
| 40 | <TouchableOpacity key={index} style={styles.CustomerItemContaier}> | 94 | <TouchableOpacity key={index} style={styles.CustomerItemContaier}> |
| @@ -45,7 +99,7 @@ export default class Import extends Component { | @@ -45,7 +99,7 @@ export default class Import extends Component { | ||
| 45 | </TouchableOpacity> | 99 | </TouchableOpacity> |
| 46 | ); | 100 | ); |
| 47 | })} | 101 | })} |
| 48 | - </ScrollView> | 102 | + </ScrollView> */} |
| 49 | <View style={styles.selectBtnContaier}> | 103 | <View style={styles.selectBtnContaier}> |
| 50 | <View style={styles.selectBtnContaierLeft}> | 104 | <View style={styles.selectBtnContaierLeft}> |
| 51 | <TouchableOpacity style={styles.selectAllContainer}> | 105 | <TouchableOpacity style={styles.selectAllContainer}> |
| @@ -93,11 +147,11 @@ const styles = StyleSheet.create({ | @@ -93,11 +147,11 @@ const styles = StyleSheet.create({ | ||
| 93 | itemSelectIconContainer: { | 147 | itemSelectIconContainer: { |
| 94 | justifyContent: "center", | 148 | justifyContent: "center", |
| 95 | alignItems: "center", | 149 | alignItems: "center", |
| 96 | - marginRight: 10, | 150 | + marginRight: 10 |
| 97 | }, | 151 | }, |
| 98 | itemSelectIcon: { | 152 | itemSelectIcon: { |
| 99 | width: 15, | 153 | width: 15, |
| 100 | - height: 15, | 154 | + height: 15 |
| 101 | }, | 155 | }, |
| 102 | CustomerItemText: { | 156 | CustomerItemText: { |
| 103 | fontSize: 16, | 157 | fontSize: 16, |
| @@ -118,25 +172,25 @@ const styles = StyleSheet.create({ | @@ -118,25 +172,25 @@ const styles = StyleSheet.create({ | ||
| 118 | borderTopWidth: 1 | 172 | borderTopWidth: 1 |
| 119 | }, | 173 | }, |
| 120 | selectBtnContaierLeft: { | 174 | selectBtnContaierLeft: { |
| 121 | - flexDirection: "row", | 175 | + flexDirection: "row" |
| 122 | }, | 176 | }, |
| 123 | selectAllContainer: { | 177 | selectAllContainer: { |
| 124 | - marginLeft: 20, | 178 | + marginLeft: 20 |
| 125 | }, | 179 | }, |
| 126 | selectAllText: {}, | 180 | selectAllText: {}, |
| 127 | selectedTextContaier: { | 181 | selectedTextContaier: { |
| 128 | flexDirection: "row", | 182 | flexDirection: "row", |
| 129 | - marginLeft: 20, | 183 | + marginLeft: 20 |
| 130 | }, | 184 | }, |
| 131 | importBtnContaier: { | 185 | importBtnContaier: { |
| 132 | width: 100, | 186 | width: 100, |
| 133 | height: 49, | 187 | height: 49, |
| 134 | backgroundColor: "#1B9341", | 188 | backgroundColor: "#1B9341", |
| 135 | justifyContent: "center", | 189 | justifyContent: "center", |
| 136 | - alignItems: "center", | 190 | + alignItems: "center" |
| 137 | }, | 191 | }, |
| 138 | importBtnText: { | 192 | importBtnText: { |
| 139 | color: "white", | 193 | color: "white", |
| 140 | - fontSize: 16, | 194 | + fontSize: 16 |
| 141 | } | 195 | } |
| 142 | }); | 196 | }); |
| @@ -64,7 +64,8 @@ export default class Customer extends Component { | @@ -64,7 +64,8 @@ export default class Customer extends Component { | ||
| 64 | contacts.forEach((item, index) => { | 64 | contacts.forEach((item, index) => { |
| 65 | customersList.push({ | 65 | customersList.push({ |
| 66 | name: item.familyName + item.givenName, | 66 | name: item.familyName + item.givenName, |
| 67 | - phone: item.phoneNumbers[0] ? item.phoneNumbers[0].number: '', | 67 | + phone: item.phoneNumbers[0] ? item.phoneNumbers[0].number : "", |
| 68 | + selected: false, | ||
| 68 | }); | 69 | }); |
| 69 | }); | 70 | }); |
| 70 | // console.log("通信录", contacts); | 71 | // console.log("通信录", contacts); |
-
Please register or login to post a comment