Showing
3 changed files
with
31 additions
and
59 deletions
| @@ -23,19 +23,19 @@ export default class ArticleTemplate extends Component { | @@ -23,19 +23,19 @@ export default class ArticleTemplate extends Component { | ||
| 23 | }; | 23 | }; |
| 24 | } | 24 | } |
| 25 | componentWillMount() { | 25 | componentWillMount() { |
| 26 | - console.log("will 的ID",this.state.id) | 26 | + console.log("will 的ID", this.state.id); |
| 27 | this.getArticles(); | 27 | this.getArticles(); |
| 28 | } | 28 | } |
| 29 | getArticles() { | 29 | getArticles() { |
| 30 | let that = this, | 30 | let that = this, |
| 31 | id = this.state.id; | 31 | id = this.state.id; |
| 32 | -return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, { | 32 | + return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, { |
| 33 | method: "POST", | 33 | method: "POST", |
| 34 | headers: { | 34 | headers: { |
| 35 | Accept: "application/json", | 35 | Accept: "application/json", |
| 36 | "Content-Type": "application/json" | 36 | "Content-Type": "application/json" |
| 37 | } | 37 | } |
| 38 | -}) | 38 | + }) |
| 39 | .then(resp => { | 39 | .then(resp => { |
| 40 | if (resp.status === 200) { | 40 | if (resp.status === 200) { |
| 41 | return resp.json(); | 41 | return resp.json(); |
| @@ -49,8 +49,8 @@ return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, { | @@ -49,8 +49,8 @@ return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, { | ||
| 49 | } else { | 49 | } else { |
| 50 | that.setState({ | 50 | that.setState({ |
| 51 | articleData: respJson.data.articleData | 51 | articleData: respJson.data.articleData |
| 52 | - }) | 52 | + }); |
| 53 | - console.log("详情页的文章",respJson.data.articleData) | 53 | + console.log("详情页的文章", respJson.data.articleData); |
| 54 | } | 54 | } |
| 55 | }); | 55 | }); |
| 56 | } | 56 | } |
| @@ -74,7 +74,11 @@ return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, { | @@ -74,7 +74,11 @@ return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, { | ||
| 74 | <Text style={styles.paragraphTitle}>{item.title}</Text> | 74 | <Text style={styles.paragraphTitle}>{item.title}</Text> |
| 75 | ) : null} | 75 | ) : null} |
| 76 | {item.image ? ( | 76 | {item.image ? ( |
| 77 | - <Image style={styles.paragraphImage} resizeMode="contain" source={{uri: item.image}} /> | 77 | + <Image |
| 78 | + style={[styles.paragraphImage,{width: 320,height: 178}]} | ||
| 79 | + resizeMode="contain" | ||
| 80 | + source={{ uri: item.image }} | ||
| 81 | + /> | ||
| 78 | ) : null} | 82 | ) : null} |
| 79 | <Text style={styles.paragraphContent}>{item.content}</Text> | 83 | <Text style={styles.paragraphContent}>{item.content}</Text> |
| 80 | </View> | 84 | </View> |
| @@ -128,19 +132,19 @@ const styles = StyleSheet.create({ | @@ -128,19 +132,19 @@ const styles = StyleSheet.create({ | ||
| 128 | alignSelf: "center", | 132 | alignSelf: "center", |
| 129 | color: "#1B9341", | 133 | color: "#1B9341", |
| 130 | fontSize: 15, | 134 | fontSize: 15, |
| 131 | - marginBottom: 15, | 135 | + marginBottom: 15 |
| 132 | // backgroundColor: "red", | 136 | // backgroundColor: "red", |
| 133 | }, | 137 | }, |
| 134 | paragraphImage: { | 138 | paragraphImage: { |
| 135 | width: Dimensions.get("window").width - 30, | 139 | width: Dimensions.get("window").width - 30, |
| 136 | height: 140, | 140 | height: 140, |
| 137 | // backgroundColor: "blue", | 141 | // backgroundColor: "blue", |
| 138 | - marginBottom: 20, | 142 | + marginBottom: 20 |
| 139 | }, | 143 | }, |
| 140 | paragraphContent: { | 144 | paragraphContent: { |
| 141 | color: "#555555", | 145 | color: "#555555", |
| 142 | fontSize: 15, | 146 | fontSize: 15, |
| 143 | - lineHeight: 22, | 147 | + lineHeight: 22 |
| 144 | // backgroundColor: "yellow", | 148 | // backgroundColor: "yellow", |
| 145 | } | 149 | } |
| 146 | }); | 150 | }); |
| @@ -17,12 +17,8 @@ import Swiper from "react-native-swiper"; | @@ -17,12 +17,8 @@ import Swiper from "react-native-swiper"; | ||
| 17 | import CommonWebView from "../../Components/CommonWebView"; | 17 | import CommonWebView from "../../Components/CommonWebView"; |
| 18 | 18 | ||
| 19 | export default class Home extends Component { | 19 | export default class Home extends Component { |
| 20 | - // static navigationOptions = { | ||
| 21 | - // title: "首页" | ||
| 22 | - // }; | ||
| 23 | constructor(props) { | 20 | constructor(props) { |
| 24 | super(props); | 21 | super(props); |
| 25 | - | ||
| 26 | this._renderMap = this._renderMap.bind(this); | 22 | this._renderMap = this._renderMap.bind(this); |
| 27 | this._swiper = this._swiper.bind(this); | 23 | this._swiper = this._swiper.bind(this); |
| 28 | this.state = { | 24 | this.state = { |
| @@ -45,7 +41,7 @@ export default class Home extends Component { | @@ -45,7 +41,7 @@ export default class Home extends Component { | ||
| 45 | } | 41 | } |
| 46 | componentWillMount() { | 42 | componentWillMount() { |
| 47 | this.getListData(); | 43 | this.getListData(); |
| 48 | - this.getBannar(); | 44 | + // this.getBannar(); |
| 49 | } | 45 | } |
| 50 | componentDidMount() {} | 46 | componentDidMount() {} |
| 51 | getListData() { | 47 | getListData() { |
| @@ -71,6 +67,7 @@ export default class Home extends Component { | @@ -71,6 +67,7 @@ export default class Home extends Component { | ||
| 71 | that.setState({ | 67 | that.setState({ |
| 72 | ListData: respJson.data.topic | 68 | ListData: respJson.data.topic |
| 73 | }) | 69 | }) |
| 70 | + console.log("首页列表",this.state.ListData) | ||
| 74 | } | 71 | } |
| 75 | }); | 72 | }); |
| 76 | } | 73 | } |
| @@ -6,7 +6,8 @@ import { | @@ -6,7 +6,8 @@ import { | ||
| 6 | View, | 6 | View, |
| 7 | ScrollView, | 7 | ScrollView, |
| 8 | TouchableOpacity, | 8 | TouchableOpacity, |
| 9 | - Image | 9 | + Image, |
| 10 | + ListView | ||
| 10 | } from "react-native"; | 11 | } from "react-native"; |
| 11 | import { StackNavigator, TabNavigator } from 'react-navigation'; | 12 | import { StackNavigator, TabNavigator } from 'react-navigation'; |
| 12 | import CommonWebView from "../../Components/CommonWebView"; | 13 | import CommonWebView from "../../Components/CommonWebView"; |
| @@ -17,40 +18,8 @@ export default class InsuranceChurch extends Component { | @@ -17,40 +18,8 @@ export default class InsuranceChurch extends Component { | ||
| 17 | // }; | 18 | // }; |
| 18 | constructor(props) { | 19 | constructor(props) { |
| 19 | super(props); | 20 | super(props); |
| 20 | - // this._renderMap = this._renderMap.bind(this); | ||
| 21 | this.state = { | 21 | this.state = { |
| 22 | - ListData: [ | 22 | + ListData: [] |
| 23 | - // { | ||
| 24 | - // title: "凶猛台风来袭!与伤亡相关的保险知识你需要了解!", | ||
| 25 | - // time: "刚刚", | ||
| 26 | - // url: "http://mp.weixin.qq.com/s/_lGAz9sSxuulbdPGZ020cQ", | ||
| 27 | - // imgurl: require("../../assets/church/1.png") | ||
| 28 | - // }, | ||
| 29 | - // { | ||
| 30 | - // title: "17世纪伦敦火灾频发,牛掰的保险公司有高招!", | ||
| 31 | - // time: "3小时前", | ||
| 32 | - // url: "http://mp.weixin.qq.com/s/cJ7oHQ__GBiBxBGZ1SCgDg", | ||
| 33 | - // imgurl: require("../../assets/church/2.png") | ||
| 34 | - // }, | ||
| 35 | - // { | ||
| 36 | - // title: "这两个国家为何会有这些天气保险呢?原来是这样.....", | ||
| 37 | - // time: "昨天", | ||
| 38 | - // url: "http://mp.weixin.qq.com/s/EimQbKC0ziqN0o8_S1ACFQ", | ||
| 39 | - // imgurl: require("../../assets/church/3.png") | ||
| 40 | - // }, | ||
| 41 | - // { | ||
| 42 | - // title: "车险小白必须知道的不计免赔险", | ||
| 43 | - // time: "9月10日", | ||
| 44 | - // url: "http://mp.weixin.qq.com/s/W9uR5G6ZlTb7HLLX-DZzSQ", | ||
| 45 | - // imgurl: require("../../assets/church/4.png") | ||
| 46 | - // }, | ||
| 47 | - // { | ||
| 48 | - // title: "“五险一金”进了嘻哈歌词,有关社保和商业保险的知识你了解吗?", | ||
| 49 | - // time: "9月9日", | ||
| 50 | - // url: "http://mp.weixin.qq.com/s/0I7p2vaM23CsDiI41hHNOQ", | ||
| 51 | - // imgurl: require("../../assets/church/5.png") | ||
| 52 | - // }, | ||
| 53 | - ] | ||
| 54 | }; | 23 | }; |
| 55 | } | 24 | } |
| 56 | componentWillMount() { | 25 | componentWillMount() { |
| @@ -77,29 +46,31 @@ export default class InsuranceChurch extends Component { | @@ -77,29 +46,31 @@ export default class InsuranceChurch extends Component { | ||
| 77 | alert(respJson.cnmsg); | 46 | alert(respJson.cnmsg); |
| 78 | } else { | 47 | } else { |
| 79 | that.setState({ | 48 | that.setState({ |
| 80 | - ListData: respJson.data | 49 | + ListData: respJson.data.story |
| 81 | }) | 50 | }) |
| 82 | - console.log("保堂列表",respJson.data) | 51 | + console.log("保堂列表",respJson.data.story) |
| 83 | } | 52 | } |
| 84 | }); | 53 | }); |
| 85 | } | 54 | } |
| 86 | 55 | ||
| 87 | render() { | 56 | render() { |
| 88 | const { navigate } = this.props.navigation; | 57 | const { navigate } = this.props.navigation; |
| 58 | + const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); | ||
| 59 | + const dataSource = ds.cloneWithRows(this.state.ListData); | ||
| 89 | return ( | 60 | return ( |
| 90 | <View style={styles.container}> | 61 | <View style={styles.container}> |
| 91 | - <ScrollView | 62 | + <ListView |
| 92 | style={styles.scrollViewContainer} | 63 | style={styles.scrollViewContainer} |
| 93 | - automaticallyAdjustContentInsets={false} | 64 | + dataSource={dataSource} |
| 94 | - > | 65 | + enableEmptySections = {true} |
| 95 | - {this.state.ListData.map((item, index) => { | 66 | + renderRow={(item,index) => { |
| 96 | return ( | 67 | return ( |
| 97 | <TouchableOpacity | 68 | <TouchableOpacity |
| 98 | style={styles.itemContainer} | 69 | style={styles.itemContainer} |
| 99 | key={index} | 70 | key={index} |
| 100 | - onPress={() => navigate("CommonWebView", { item: item })} | 71 | + onPress={() => navigate("ArticleTemplate", { item: item })} |
| 101 | > | 72 | > |
| 102 | - <Image style={styles.itemImgWrapper} source={item.imgurl} /> | 73 | + <Image style={styles.itemImgWrapper} source={{uri: item.imgurl}} /> |
| 103 | <View style={styles.itemRightWrapper}> | 74 | <View style={styles.itemRightWrapper}> |
| 104 | <Text style={styles.itemTextTop} numberOfLines={2}> | 75 | <Text style={styles.itemTextTop} numberOfLines={2}> |
| 105 | {item.title} | 76 | {item.title} |
| @@ -107,10 +78,10 @@ export default class InsuranceChurch extends Component { | @@ -107,10 +78,10 @@ export default class InsuranceChurch extends Component { | ||
| 107 | <Text style={styles.itemTextBottom}>{item.time}</Text> | 78 | <Text style={styles.itemTextBottom}>{item.time}</Text> |
| 108 | </View> | 79 | </View> |
| 109 | </TouchableOpacity> | 80 | </TouchableOpacity> |
| 110 | - ); | 81 | + ) |
| 111 | - })} | 82 | + }} |
| 83 | + /> | ||
| 112 | <Text style={styles.scrollViewText}>没有更多了</Text> | 84 | <Text style={styles.scrollViewText}>没有更多了</Text> |
| 113 | - </ScrollView> | ||
| 114 | </View> | 85 | </View> |
| 115 | ); | 86 | ); |
| 116 | } | 87 | } |
-
Please register or login to post a comment