罗广聪

change

... ... @@ -23,36 +23,36 @@ export default class ArticleTemplate extends Component {
};
}
componentWillMount() {
console.log("will 的ID",this.state.id)
console.log("will 的ID", this.state.id);
this.getArticles();
}
getArticles() {
let that = this,
id = this.state.id;
return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
})
.then(resp => {
if (resp.status === 200) {
return resp.json();
} else {
console.error("something went wrong!");
}
})
.then(respJson => {
if (respJson.enmsg != "ok") {
alert(respJson.cnmsg);
} else {
that.setState({
articleData: respJson.data.articleData
id = this.state.id;
return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
})
.then(resp => {
if (resp.status === 200) {
return resp.json();
} else {
console.error("something went wrong!");
}
})
console.log("详情页的文章",respJson.data.articleData)
}
});
.then(respJson => {
if (respJson.enmsg != "ok") {
alert(respJson.cnmsg);
} else {
that.setState({
articleData: respJson.data.articleData
});
console.log("详情页的文章", respJson.data.articleData);
}
});
}
render() {
const { articleData } = this.state;
... ... @@ -74,7 +74,11 @@ return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, {
<Text style={styles.paragraphTitle}>{item.title}</Text>
) : null}
{item.image ? (
<Image style={styles.paragraphImage} resizeMode="contain" source={{uri: item.image}} />
<Image
style={[styles.paragraphImage,{width: 320,height: 178}]}
resizeMode="contain"
source={{ uri: item.image }}
/>
) : null}
<Text style={styles.paragraphContent}>{item.content}</Text>
</View>
... ... @@ -128,19 +132,19 @@ const styles = StyleSheet.create({
alignSelf: "center",
color: "#1B9341",
fontSize: 15,
marginBottom: 15,
marginBottom: 15
// backgroundColor: "red",
},
paragraphImage: {
width: Dimensions.get("window").width - 30,
height: 140,
// backgroundColor: "blue",
marginBottom: 20,
marginBottom: 20
},
paragraphContent: {
color: "#555555",
fontSize: 15,
lineHeight: 22,
lineHeight: 22
// backgroundColor: "yellow",
}
});
... ...
... ... @@ -17,12 +17,8 @@ import Swiper from "react-native-swiper";
import CommonWebView from "../../Components/CommonWebView";
export default class Home extends Component {
// static navigationOptions = {
// title: "首页"
// };
constructor(props) {
super(props);
this._renderMap = this._renderMap.bind(this);
this._swiper = this._swiper.bind(this);
this.state = {
... ... @@ -45,7 +41,7 @@ export default class Home extends Component {
}
componentWillMount() {
this.getListData();
this.getBannar();
// this.getBannar();
}
componentDidMount() {}
getListData() {
... ... @@ -71,6 +67,7 @@ export default class Home extends Component {
that.setState({
ListData: respJson.data.topic
})
console.log("首页列表",this.state.ListData)
}
});
}
... ...
... ... @@ -6,7 +6,8 @@ import {
View,
ScrollView,
TouchableOpacity,
Image
Image,
ListView
} from "react-native";
import { StackNavigator, TabNavigator } from 'react-navigation';
import CommonWebView from "../../Components/CommonWebView";
... ... @@ -17,40 +18,8 @@ export default class InsuranceChurch extends Component {
// };
constructor(props) {
super(props);
// this._renderMap = this._renderMap.bind(this);
this.state = {
ListData: [
// {
// title: "凶猛台风来袭!与伤亡相关的保险知识你需要了解!",
// time: "刚刚",
// url: "http://mp.weixin.qq.com/s/_lGAz9sSxuulbdPGZ020cQ",
// imgurl: require("../../assets/church/1.png")
// },
// {
// title: "17世纪伦敦火灾频发,牛掰的保险公司有高招!",
// time: "3小时前",
// url: "http://mp.weixin.qq.com/s/cJ7oHQ__GBiBxBGZ1SCgDg",
// imgurl: require("../../assets/church/2.png")
// },
// {
// title: "这两个国家为何会有这些天气保险呢?原来是这样.....",
// time: "昨天",
// url: "http://mp.weixin.qq.com/s/EimQbKC0ziqN0o8_S1ACFQ",
// imgurl: require("../../assets/church/3.png")
// },
// {
// title: "车险小白必须知道的不计免赔险",
// time: "9月10日",
// url: "http://mp.weixin.qq.com/s/W9uR5G6ZlTb7HLLX-DZzSQ",
// imgurl: require("../../assets/church/4.png")
// },
// {
// title: "“五险一金”进了嘻哈歌词,有关社保和商业保险的知识你了解吗?",
// time: "9月9日",
// url: "http://mp.weixin.qq.com/s/0I7p2vaM23CsDiI41hHNOQ",
// imgurl: require("../../assets/church/5.png")
// },
]
ListData: []
};
}
componentWillMount() {
... ... @@ -77,29 +46,31 @@ export default class InsuranceChurch extends Component {
alert(respJson.cnmsg);
} else {
that.setState({
ListData: respJson.data
ListData: respJson.data.story
})
console.log("保堂列表",respJson.data)
console.log("保堂列表",respJson.data.story)
}
});
}
render() {
const { navigate } = this.props.navigation;
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
const dataSource = ds.cloneWithRows(this.state.ListData);
return (
<View style={styles.container}>
<ScrollView
<ListView
style={styles.scrollViewContainer}
automaticallyAdjustContentInsets={false}
>
{this.state.ListData.map((item, index) => {
dataSource={dataSource}
enableEmptySections = {true}
renderRow={(item,index) => {
return (
<TouchableOpacity
style={styles.itemContainer}
key={index}
onPress={() => navigate("CommonWebView", { item: item })}
onPress={() => navigate("ArticleTemplate", { item: item })}
>
<Image style={styles.itemImgWrapper} source={item.imgurl} />
<Image style={styles.itemImgWrapper} source={{uri: item.imgurl}} />
<View style={styles.itemRightWrapper}>
<Text style={styles.itemTextTop} numberOfLines={2}>
{item.title}
... ... @@ -107,10 +78,10 @@ export default class InsuranceChurch extends Component {
<Text style={styles.itemTextBottom}>{item.time}</Text>
</View>
</TouchableOpacity>
);
})}
<Text style={styles.scrollViewText}>没有更多了</Text>
</ScrollView>
)
}}
/>
<Text style={styles.scrollViewText}>没有更多了</Text>
</View>
);
}
... ...