罗广聪

test post

... ... @@ -12,6 +12,7 @@ import {
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
import Details from "./details";
import post from "../../utils/fetch";
export default class InsuranceCircle extends Component {
static navigationOptions = ({ navigation }) => {
... ... @@ -38,7 +39,7 @@ export default class InsuranceCircle extends Component {
USER_ID: "",
NICKNAME: "",
PROFESSION: "",
forGoBack: "",
forGoBack: ""
};
}
componentWillMount() {
... ... @@ -71,11 +72,13 @@ export default class InsuranceCircle extends Component {
},
() => {
if (this.state.IS_LOGIN == "yes") {
navigate("Release", { refreshCallback: data => {
that.setState({
ListData: data
})
} });
navigate("Release", {
refreshCallback: data => {
that.setState({
ListData: data
});
}
});
} else {
Alert.alert("请先登录账号");
}
... ... @@ -107,6 +110,16 @@ export default class InsuranceCircle extends Component {
getArticles() {
var that = this;
// 请求文章数据
// post(
// "/test/insurance/article",
// {},
// res => {
// console.log("post", res.data.data);
// },
// err => {
// console.log(err);
// }
// );
return fetch(`https://devpay.brae.co/test/insurance/article`, {
method: "POST",
headers: {
... ... @@ -114,24 +127,23 @@ export default class InsuranceCircle extends Component {
"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({
ListData: respJson.data.data
});
// console.log("state.ListData", this.state.ListData);
}
})
.catch(err => console.error(err));
.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({
ListData: respJson.data.data
});
}
})
.catch(err => console.error(err));
}
render() {
... ...