Showing
2 changed files
with
237 additions
and
17 deletions
| 1 | - | 1 | +import React, { Component } from "react"; |
| 2 | -import React, { Component } from 'react'; | ||
| 3 | import { | 2 | import { |
| 4 | AppRegistry, | 3 | AppRegistry, |
| 5 | StyleSheet, | 4 | StyleSheet, |
| @@ -7,19 +6,74 @@ import { | @@ -7,19 +6,74 @@ import { | ||
| 7 | View, | 6 | View, |
| 8 | ScrollView, | 7 | ScrollView, |
| 9 | TouchableOpacity, | 8 | TouchableOpacity, |
| 10 | - Image, | 9 | + Image |
| 11 | -} from 'react-native'; | 10 | +} from "react-native"; |
| 12 | 11 | ||
| 13 | export default class Details extends Component { | 12 | export default class Details extends Component { |
| 14 | constructor(props) { | 13 | constructor(props) { |
| 15 | super(props); | 14 | super(props); |
| 16 | - this.state = {} | 15 | + this.state = { |
| 16 | + data: this.props.data | ||
| 17 | + }; | ||
| 18 | + } | ||
| 19 | + componentWillMount() { | ||
| 20 | + console.log("详情页", this); | ||
| 17 | } | 21 | } |
| 18 | 22 | ||
| 19 | render() { | 23 | render() { |
| 24 | + const { data } = this.state; | ||
| 20 | return ( | 25 | return ( |
| 21 | <View style={styles.container}> | 26 | <View style={styles.container}> |
| 22 | - <Text>我是详情页</Text> | 27 | + <ScrollView automaticallyAdjustContentInsets={false}> |
| 28 | + <Text style={styles.titleText} numberOfLines={3}> | ||
| 29 | + {data.title} | ||
| 30 | + </Text> | ||
| 31 | + {/* 个人信息 */} | ||
| 32 | + <View style={styles.personContainer}> | ||
| 33 | + <Image style={styles.personImg} source={data.image} /> | ||
| 34 | + <View style={styles.personRightContainer}> | ||
| 35 | + <View style={styles.personRTContainer}> | ||
| 36 | + <Text style={styles.personRTName}>{data.name}</Text> | ||
| 37 | + <Text style={styles.personRTIdentity}>{data.identity}</Text> | ||
| 38 | + </View> | ||
| 39 | + <Text style={styles.personRB}>{data.time}</Text> | ||
| 40 | + </View> | ||
| 41 | + </View> | ||
| 42 | + {/* 正文 */} | ||
| 43 | + <Text style={styles.content}>{data.content}</Text> | ||
| 44 | + <Text style={styles.copyright}>本文版权归 {data.name} 所有</Text> | ||
| 45 | + {/* 评论 */} | ||
| 46 | + <View style={styles.commentsContainer}> | ||
| 47 | + <View style={styles.commentsHeader}> | ||
| 48 | + <Text style={styles.commentsHeaderL}>评论</Text> | ||
| 49 | + <Text style={styles.commentsHeaderR}> | ||
| 50 | + ( {data.comments.length} ) | ||
| 51 | + </Text> | ||
| 52 | + </View> | ||
| 53 | + {data.comments.map((item, index) => { | ||
| 54 | + return ( | ||
| 55 | + <View style={styles.itemContainer} key={index}> | ||
| 56 | + <Image style={styles.itemIcon} source={item.replayicon} /> | ||
| 57 | + <View style={styles.itemRightContainer}> | ||
| 58 | + <View style={styles.itemRightTop}> | ||
| 59 | + <View style={styles.itemRightTopLeft}> | ||
| 60 | + <Text style={styles.itemReplyer}>{item.replyer}</Text> | ||
| 61 | + <Text style={styles.itemWord}>回复</Text> | ||
| 62 | + <Text style={styles.itemBeenreplyer}>{item.beenreplyer}</Text> | ||
| 63 | + <Text style={styles.itemTime}>{item.time}</Text> | ||
| 64 | + </View> | ||
| 65 | + <Image | ||
| 66 | + style={styles.itemRightTopRight} | ||
| 67 | + source={require("../../assets/tabbar/ic_circle_n.png")} | ||
| 68 | + /> | ||
| 69 | + </View> | ||
| 70 | + <Text style={styles.itemRightBottom}>{item.content}</Text> | ||
| 71 | + </View> | ||
| 72 | + </View> | ||
| 73 | + ); | ||
| 74 | + })} | ||
| 75 | + </View> | ||
| 76 | + </ScrollView> | ||
| 23 | </View> | 77 | </View> |
| 24 | ); | 78 | ); |
| 25 | } | 79 | } |
| @@ -30,8 +84,114 @@ const styles = StyleSheet.create({ | @@ -30,8 +84,114 @@ const styles = StyleSheet.create({ | ||
| 30 | flex: 1, | 84 | flex: 1, |
| 31 | justifyContent: "flex-start", | 85 | justifyContent: "flex-start", |
| 32 | alignItems: "stretch", | 86 | alignItems: "stretch", |
| 33 | - backgroundColor: "#EFEFEF", | 87 | + backgroundColor: "white", |
| 34 | - paddingTop: 74, | 88 | + paddingTop: 64 |
| 35 | }, | 89 | }, |
| 36 | -}) | 90 | + titleText: { |
| 37 | - | 91 | + marginTop: 21, |
| 92 | + marginLeft: 20, | ||
| 93 | + marginRight: 20, | ||
| 94 | + fontSize: 24, | ||
| 95 | + lineHeight: 30 | ||
| 96 | + }, | ||
| 97 | + personContainer: { | ||
| 98 | + marginTop: 16, | ||
| 99 | + marginLeft: 20, | ||
| 100 | + marginRight: 20, | ||
| 101 | + flexDirection: "row", | ||
| 102 | + justifyContent: "flex-start", | ||
| 103 | + alignItems: "center" | ||
| 104 | + }, | ||
| 105 | + personImg: { | ||
| 106 | + width: 42, | ||
| 107 | + height: 42 | ||
| 108 | + }, | ||
| 109 | + personRightContainer: { | ||
| 110 | + marginLeft: 10 | ||
| 111 | + }, | ||
| 112 | + personRTContainer: { | ||
| 113 | + flexDirection: "row", | ||
| 114 | + justifyContent: "flex-start", | ||
| 115 | + alignItems: "center" | ||
| 116 | + }, | ||
| 117 | + personRTName: { | ||
| 118 | + fontSize: 16, | ||
| 119 | + color: "#242424" | ||
| 120 | + }, | ||
| 121 | + personRTIdentity: { | ||
| 122 | + fontSize: 14, | ||
| 123 | + color: "#3F3F3F", | ||
| 124 | + marginLeft: 5 | ||
| 125 | + }, | ||
| 126 | + personRB: { | ||
| 127 | + fontSize: 13, | ||
| 128 | + color: "#999999" | ||
| 129 | + }, | ||
| 130 | + content: { | ||
| 131 | + marginLeft: 25, | ||
| 132 | + marginRight: 25, | ||
| 133 | + marginTop: 35, | ||
| 134 | + marginBottom: 25, | ||
| 135 | + fontSize: 15, | ||
| 136 | + lineHeight: 22, | ||
| 137 | + color: "#555555" | ||
| 138 | + }, | ||
| 139 | + copyright: { | ||
| 140 | + textAlign: "center", | ||
| 141 | + fontSize: 12, | ||
| 142 | + color: "#999999", | ||
| 143 | + marginBottom: 20 | ||
| 144 | + }, | ||
| 145 | + commentsContainer: { | ||
| 146 | + borderTopWidth: 10, | ||
| 147 | + borderColor: "#EFEFEF", | ||
| 148 | + borderStyle: "solid", | ||
| 149 | + paddingLeft: 13, | ||
| 150 | + paddingRight: 13 | ||
| 151 | + }, | ||
| 152 | + commentsHeader: { | ||
| 153 | + flexDirection: "row", | ||
| 154 | + justifyContent: "flex-start", | ||
| 155 | + alignItems: "center", | ||
| 156 | + height: 45 | ||
| 157 | + }, | ||
| 158 | + commentsHeaderL: { | ||
| 159 | + fontSize: 15, | ||
| 160 | + color: "#242424", | ||
| 161 | + marginRight: 5 | ||
| 162 | + }, | ||
| 163 | + commentsHeaderR: { | ||
| 164 | + fontSize: 15, | ||
| 165 | + color: "#242424" | ||
| 166 | + }, | ||
| 167 | + itemContainer: { | ||
| 168 | + paddingTop: 16, | ||
| 169 | + paddingBottom: 16, | ||
| 170 | + flexDirection: "row", | ||
| 171 | + justifyContent: "flex-start", | ||
| 172 | + }, | ||
| 173 | + itemIcon: { | ||
| 174 | + width: 32, | ||
| 175 | + height: 32, | ||
| 176 | + }, | ||
| 177 | + itemRightContainer: { | ||
| 178 | + flex: 1, | ||
| 179 | + marginLeft: 10 | ||
| 180 | + }, | ||
| 181 | + itemRightTop: { | ||
| 182 | + flexDirection: "row", | ||
| 183 | + justifyContent: "space-between", | ||
| 184 | + marginBottom: 7, | ||
| 185 | + }, | ||
| 186 | + itemRightTopLeft: { | ||
| 187 | + flexDirection: "row", | ||
| 188 | + justifyContent: "flex-start", | ||
| 189 | + alignItems: "center", | ||
| 190 | + }, | ||
| 191 | + itemRightTopRight: {}, | ||
| 192 | + itemRightBottom: { | ||
| 193 | + fontSize: 15, | ||
| 194 | + lineHeight: 21, | ||
| 195 | + color: "#242424", | ||
| 196 | + }, | ||
| 197 | +}); |
| @@ -20,18 +20,40 @@ export default class InsuranceCircle extends Component { | @@ -20,18 +20,40 @@ export default class InsuranceCircle extends Component { | ||
| 20 | title: "家庭经济越差越应该买保险,因为你病不起,输不起,也折腾不起…", | 20 | title: "家庭经济越差越应该买保险,因为你病不起,输不起,也折腾不起…", |
| 21 | content: | 21 | content: |
| 22 | "现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…", | 22 | "现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…", |
| 23 | - name: "jack", | 23 | + name: "嘿嘿嘿", |
| 24 | - image: require("../../assets/circle/newspic.png"), | 24 | + identity: "保险代理人", |
| 25 | + image: require("../../assets/Mine/iconpic1.png"), | ||
| 25 | num: "30", | 26 | num: "30", |
| 26 | - comments: [] | 27 | + time: "2017-8-15", |
| 28 | + comments: [{ | ||
| 29 | + replyer: "噢噢噢", | ||
| 30 | + replayicon: require("../../assets/Mine/iconpic1.png"), | ||
| 31 | + beenreplyer: "嘿嘿嘿", | ||
| 32 | + content: "生活就是如此矛是如此此生活就是如此矛盾现实生活就是如此矛盾现", | ||
| 33 | + time: "两小时前", | ||
| 34 | + },{ | ||
| 35 | + replyer: "哦哦哦", | ||
| 36 | + replayicon: require("../../assets/Mine/iconpic1.png"), | ||
| 37 | + beenreplyer: "哈哈哈", | ||
| 38 | + content: "生活就是如此矛是如此此生活就是如此矛盾现实生活就是如此矛盾现", | ||
| 39 | + time: "两小时前", | ||
| 40 | + },{ | ||
| 41 | + replyer: "洛洛洛", | ||
| 42 | + replayicon: require("../../assets/Mine/iconpic1.png"), | ||
| 43 | + beenreplyer: "额额额", | ||
| 44 | + content: "生活就是如此矛是如此此生活就是如此矛盾现实生活就是如此矛盾现", | ||
| 45 | + time: "两小时前", | ||
| 46 | + }], | ||
| 27 | }, | 47 | }, |
| 28 | { | 48 | { |
| 29 | title: "家庭经济越差越应该买保险,因为你病不起,输不起,也折腾不起…", | 49 | title: "家庭经济越差越应该买保险,因为你病不起,输不起,也折腾不起…", |
| 30 | content: | 50 | content: |
| 31 | "现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…", | 51 | "现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…", |
| 32 | - name: "mike", | 52 | + name: "嘿嘿嘿", |
| 53 | + identity: "保险代理人", | ||
| 33 | image: require("../../assets/circle/newspic.png"), | 54 | image: require("../../assets/circle/newspic.png"), |
| 34 | num: "29", | 55 | num: "29", |
| 56 | + time: "2017-8-15", | ||
| 35 | comments: [] | 57 | comments: [] |
| 36 | }, | 58 | }, |
| 37 | { | 59 | { |
| @@ -39,14 +61,49 @@ export default class InsuranceCircle extends Component { | @@ -39,14 +61,49 @@ export default class InsuranceCircle extends Component { | ||
| 39 | content: | 61 | content: |
| 40 | "现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…", | 62 | "现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…", |
| 41 | name: "luosf", | 63 | name: "luosf", |
| 64 | + identity: "保险代理人", | ||
| 42 | image: require("../../assets/circle/newspic.png"), | 65 | image: require("../../assets/circle/newspic.png"), |
| 43 | num: "10", | 66 | num: "10", |
| 67 | + time: "2017-8-15", | ||
| 44 | comments: [] | 68 | comments: [] |
| 45 | } | 69 | } |
| 46 | - ] | 70 | + ], |
| 71 | + testData: [], | ||
| 47 | }; | 72 | }; |
| 48 | } | 73 | } |
| 49 | 74 | ||
| 75 | + componentWillMount() { | ||
| 76 | + var that = this; | ||
| 77 | + return fetch(`https://mpay.brae.co/test/insurance/article`,{ | ||
| 78 | + method: "POST", | ||
| 79 | + headers: { | ||
| 80 | + 'Accept': 'application/json', | ||
| 81 | + 'Content-Type': 'application/json', | ||
| 82 | + }, | ||
| 83 | + }) | ||
| 84 | + .then((resp) => { | ||
| 85 | + console.log("测试接口",resp); | ||
| 86 | + // return false; | ||
| 87 | + if (resp.status === 200) { | ||
| 88 | + return resp.json(); | ||
| 89 | + } else { | ||
| 90 | + console.error("something went wrong!"); | ||
| 91 | + } | ||
| 92 | + }) | ||
| 93 | + .then((respJson) => { | ||
| 94 | + if (respJson.enmsg != 'ok') { | ||
| 95 | + console.error(err); | ||
| 96 | + alert(respJson.cnmsg); | ||
| 97 | + } else { | ||
| 98 | + that.setState({ | ||
| 99 | + testData: respJson.data | ||
| 100 | + }); | ||
| 101 | + console.log('state.testData',that.state.testData); | ||
| 102 | + } | ||
| 103 | + }) | ||
| 104 | + .catch((err) => console.error(err)) | ||
| 105 | + } | ||
| 106 | + | ||
| 50 | render() { | 107 | render() { |
| 51 | return ( | 108 | return ( |
| 52 | <View style={styles.container}> | 109 | <View style={styles.container}> |
| @@ -62,7 +119,10 @@ export default class InsuranceCircle extends Component { | @@ -62,7 +119,10 @@ export default class InsuranceCircle extends Component { | ||
| 62 | onPress={() => { | 119 | onPress={() => { |
| 63 | this.props.navigator.push({ | 120 | this.props.navigator.push({ |
| 64 | component: Details, | 121 | component: Details, |
| 65 | - passProps: {} | 122 | + title: "哈哈哈", |
| 123 | + passProps: { | ||
| 124 | + data: {...item}, | ||
| 125 | + }, | ||
| 66 | }); | 126 | }); |
| 67 | }} | 127 | }} |
| 68 | > | 128 | > |
| @@ -101,7 +161,7 @@ const styles = StyleSheet.create({ | @@ -101,7 +161,7 @@ const styles = StyleSheet.create({ | ||
| 101 | paddingTop: 74 | 161 | paddingTop: 74 |
| 102 | }, | 162 | }, |
| 103 | scrollViewContainer: { | 163 | scrollViewContainer: { |
| 104 | - height: 300 | 164 | + // height: 300 |
| 105 | }, | 165 | }, |
| 106 | scrollViewText: { | 166 | scrollViewText: { |
| 107 | color: "#7A7A7A", | 167 | color: "#7A7A7A", |
-
Please register or login to post a comment