Showing
4 changed files
with
18 additions
and
10 deletions
| @@ -12,6 +12,11 @@ import { StackNavigator, TabNavigator } from "react-navigation"; | @@ -12,6 +12,11 @@ import { StackNavigator, TabNavigator } from "react-navigation"; | ||
| 12 | export default class CommonImageView extends Component { | 12 | export default class CommonImageView extends Component { |
| 13 | constructor(props) { | 13 | constructor(props) { |
| 14 | super(props); | 14 | super(props); |
| 15 | + this.state = { | ||
| 16 | + products: [ | ||
| 17 | + | ||
| 18 | + ] | ||
| 19 | + } | ||
| 15 | } | 20 | } |
| 16 | render() { | 21 | render() { |
| 17 | console.log("Image index", this.props.navigation.state.params.index); | 22 | console.log("Image index", this.props.navigation.state.params.index); |
| @@ -17,19 +17,21 @@ export default class ArticleTemplate extends Component { | @@ -17,19 +17,21 @@ export default class ArticleTemplate extends Component { | ||
| 17 | super(props); | 17 | super(props); |
| 18 | this.state = { | 18 | this.state = { |
| 19 | id: this.props.navigation.state.params.item.id, | 19 | id: this.props.navigation.state.params.item.id, |
| 20 | + model: this.props.navigation.state.params.model, | ||
| 20 | articleData: { | 21 | articleData: { |
| 21 | paragraph: [] | 22 | paragraph: [] |
| 22 | } | 23 | } |
| 23 | }; | 24 | }; |
| 24 | } | 25 | } |
| 25 | componentWillMount() { | 26 | componentWillMount() { |
| 26 | - console.log("will 的ID", this.state.id); | 27 | + console.log("will model", this.state.model); |
| 27 | this.getArticles(); | 28 | this.getArticles(); |
| 28 | } | 29 | } |
| 29 | getArticles() { | 30 | getArticles() { |
| 30 | let that = this, | 31 | let that = this, |
| 31 | - id = this.state.id; | 32 | + id = this.state.id, |
| 32 | - return fetch(`https://devpay.brae.co/test/insurance/topic/${id}`, { | 33 | + model = this.state.model; |
| 34 | + return fetch(`https://devpay.brae.co/test/insurance/${model}/${id}`, { | ||
| 33 | method: "POST", | 35 | method: "POST", |
| 34 | headers: { | 36 | headers: { |
| 35 | Accept: "application/json", | 37 | Accept: "application/json", |
| @@ -37,6 +39,7 @@ export default class ArticleTemplate extends Component { | @@ -37,6 +39,7 @@ export default class ArticleTemplate extends Component { | ||
| 37 | } | 39 | } |
| 38 | }) | 40 | }) |
| 39 | .then(resp => { | 41 | .then(resp => { |
| 42 | + console.log("大爷",resp); | ||
| 40 | if (resp.status === 200) { | 43 | if (resp.status === 200) { |
| 41 | return resp.json(); | 44 | return resp.json(); |
| 42 | } else { | 45 | } else { |
| @@ -48,9 +51,9 @@ export default class ArticleTemplate extends Component { | @@ -48,9 +51,9 @@ export default class ArticleTemplate extends Component { | ||
| 48 | alert(respJson.cnmsg); | 51 | alert(respJson.cnmsg); |
| 49 | } else { | 52 | } else { |
| 50 | that.setState({ | 53 | that.setState({ |
| 51 | - articleData: respJson.data.articleData | 54 | + articleData: respJson.data.data.articleData |
| 52 | }); | 55 | }); |
| 53 | - console.log("详情页的文章", respJson.data.articleData); | 56 | + console.log("详情页的文章", respJson.data.data.articleData); |
| 54 | } | 57 | } |
| 55 | }); | 58 | }); |
| 56 | } | 59 | } |
| @@ -75,7 +78,7 @@ export default class ArticleTemplate extends Component { | @@ -75,7 +78,7 @@ export default class ArticleTemplate extends Component { | ||
| 75 | ) : null} | 78 | ) : null} |
| 76 | {item.image ? ( | 79 | {item.image ? ( |
| 77 | <Image | 80 | <Image |
| 78 | - style={[styles.paragraphImage,{width: 320,height: 178}]} | 81 | + style={{width: item.width,height: item.height,alignSelf: "center",marginBottom: 20}} |
| 79 | resizeMode="contain" | 82 | resizeMode="contain" |
| 80 | source={{ uri: item.image }} | 83 | source={{ uri: item.image }} |
| 81 | /> | 84 | /> |
| @@ -136,8 +139,8 @@ const styles = StyleSheet.create({ | @@ -136,8 +139,8 @@ const styles = StyleSheet.create({ | ||
| 136 | // backgroundColor: "red", | 139 | // backgroundColor: "red", |
| 137 | }, | 140 | }, |
| 138 | paragraphImage: { | 141 | paragraphImage: { |
| 139 | - width: Dimensions.get("window").width - 30, | 142 | + // width: Dimensions.get("window").width - 30, |
| 140 | - height: 140, | 143 | + // height: 140, |
| 141 | // backgroundColor: "blue", | 144 | // backgroundColor: "blue", |
| 142 | marginBottom: 20 | 145 | marginBottom: 20 |
| 143 | }, | 146 | }, |
| @@ -194,7 +194,7 @@ export default class Home extends Component { | @@ -194,7 +194,7 @@ export default class Home extends Component { | ||
| 194 | return ( | 194 | return ( |
| 195 | <TouchableOpacity | 195 | <TouchableOpacity |
| 196 | style={styles.itemContainer} | 196 | style={styles.itemContainer} |
| 197 | - onPress={() => navigate("ArticleTemplate", { item: item })} | 197 | + onPress={() => navigate("ArticleTemplate", { item: item, model: "topic" })} |
| 198 | > | 198 | > |
| 199 | <View style={styles.itemImgWrapper}> | 199 | <View style={styles.itemImgWrapper}> |
| 200 | <Image | 200 | <Image |
| @@ -68,7 +68,7 @@ export default class InsuranceChurch extends Component { | @@ -68,7 +68,7 @@ export default class InsuranceChurch extends Component { | ||
| 68 | <TouchableOpacity | 68 | <TouchableOpacity |
| 69 | style={styles.itemContainer} | 69 | style={styles.itemContainer} |
| 70 | key={index} | 70 | key={index} |
| 71 | - onPress={() => navigate("ArticleTemplate", { item: item })} | 71 | + onPress={() => navigate("ArticleTemplate", { item: item, model: "story" })} |
| 72 | > | 72 | > |
| 73 | <Image style={styles.itemImgWrapper} source={{uri: item.imgurl}} /> | 73 | <Image style={styles.itemImgWrapper} source={{uri: item.imgurl}} /> |
| 74 | <View style={styles.itemRightWrapper}> | 74 | <View style={styles.itemRightWrapper}> |
-
Please register or login to post a comment