index.js
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, { Component } from "react";
import {
StyleSheet,
WebView,
View,
Image,
Dimensions,
ScrollView,
Text,
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
export default class Discover extends Component {
constructor(props) {
super(props);
this.state = {
image: "",
};
}
componentWillMount() {
this.getImages();
}
getImages() {
let that = this,
id = this.state.id,
model = this.state.model;
return fetch(`https://devpay.brae.co/test/insurance/wallpaper`, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
})
.then(resp => {
console.log("大爷",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({
image: respJson.data.image
});
console.log("图片文章", respJson.data);
}
});
}
render() {
const { image } = this.state;
return (
<View style={styles.container}>
{/* <Text>图片首页</Text> */}
<Image
style={styles.image}
source={{uri: image}}
resizeMode="contain"
>
<Text>中央文案</Text>
</Image>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "white"
},
image: {
width: Dimensions.get("window").width,
height: Dimensions.get("window").height,
justifyContent: "center",
alignItems: "center",
}
});