罗广聪

文章OK

... ... @@ -12,6 +12,11 @@ import { StackNavigator, TabNavigator } from "react-navigation";
export default class CommonImageView extends Component {
constructor(props) {
super(props);
this.state = {
products: [
]
}
}
render() {
console.log("Image index", this.props.navigation.state.params.index);
... ...
... ... @@ -17,19 +17,21 @@ export default class ArticleTemplate extends Component {
super(props);
this.state = {
id: this.props.navigation.state.params.item.id,
model: this.props.navigation.state.params.model,
articleData: {
paragraph: []
}
};
}
componentWillMount() {
console.log("will 的ID", this.state.id);
console.log("will model", this.state.model);
this.getArticles();
}
getArticles() {
let that = this,
id = this.state.id;
return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, {
id = this.state.id,
model = this.state.model;
return fetch(`https://devpay.brae.co/test/insurance/${model}/${id}`, {
method: "POST",
headers: {
Accept: "application/json",
... ... @@ -37,6 +39,7 @@ export default class ArticleTemplate extends Component {
}
})
.then(resp => {
console.log("大爷",resp);
if (resp.status === 200) {
return resp.json();
} else {
... ... @@ -48,9 +51,9 @@ export default class ArticleTemplate extends Component {
alert(respJson.cnmsg);
} else {
that.setState({
articleData: respJson.data.articleData
articleData: respJson.data.data.articleData
});
console.log("详情页的文章", respJson.data.articleData);
console.log("详情页的文章", respJson.data.data.articleData);
}
});
}
... ... @@ -75,7 +78,7 @@ export default class ArticleTemplate extends Component {
) : null}
{item.image ? (
<Image
style={[styles.paragraphImage,{width: 320,height: 178}]}
style={{width: item.width,height: item.height,alignSelf: "center",marginBottom: 20}}
resizeMode="contain"
source={{ uri: item.image }}
/>
... ... @@ -136,8 +139,8 @@ const styles = StyleSheet.create({
// backgroundColor: "red",
},
paragraphImage: {
width: Dimensions.get("window").width - 30,
height: 140,
// width: Dimensions.get("window").width - 30,
// height: 140,
// backgroundColor: "blue",
marginBottom: 20
},
... ...
... ... @@ -194,7 +194,7 @@ export default class Home extends Component {
return (
<TouchableOpacity
style={styles.itemContainer}
onPress={() => navigate("ArticleTemplate", { item: item })}
onPress={() => navigate("ArticleTemplate", { item: item, model: "topic" })}
>
<View style={styles.itemImgWrapper}>
<Image
... ...
... ... @@ -68,7 +68,7 @@ export default class InsuranceChurch extends Component {
<TouchableOpacity
style={styles.itemContainer}
key={index}
onPress={() => navigate("ArticleTemplate", { item: item })}
onPress={() => navigate("ArticleTemplate", { item: item, model: "story" })}
>
<Image style={styles.itemImgWrapper} source={{uri: item.imgurl}} />
<View style={styles.itemRightWrapper}>
... ...