Showing
1 changed file
with
36 additions
and
24 deletions
| @@ -12,6 +12,7 @@ import { | @@ -12,6 +12,7 @@ import { | ||
| 12 | } from "react-native"; | 12 | } from "react-native"; |
| 13 | import { StackNavigator, TabNavigator } from "react-navigation"; | 13 | import { StackNavigator, TabNavigator } from "react-navigation"; |
| 14 | import Details from "./details"; | 14 | import Details from "./details"; |
| 15 | +import post from "../../utils/fetch"; | ||
| 15 | 16 | ||
| 16 | export default class InsuranceCircle extends Component { | 17 | export default class InsuranceCircle extends Component { |
| 17 | static navigationOptions = ({ navigation }) => { | 18 | static navigationOptions = ({ navigation }) => { |
| @@ -38,7 +39,7 @@ export default class InsuranceCircle extends Component { | @@ -38,7 +39,7 @@ export default class InsuranceCircle extends Component { | ||
| 38 | USER_ID: "", | 39 | USER_ID: "", |
| 39 | NICKNAME: "", | 40 | NICKNAME: "", |
| 40 | PROFESSION: "", | 41 | PROFESSION: "", |
| 41 | - forGoBack: "", | 42 | + forGoBack: "" |
| 42 | }; | 43 | }; |
| 43 | } | 44 | } |
| 44 | componentWillMount() { | 45 | componentWillMount() { |
| @@ -71,11 +72,13 @@ export default class InsuranceCircle extends Component { | @@ -71,11 +72,13 @@ export default class InsuranceCircle extends Component { | ||
| 71 | }, | 72 | }, |
| 72 | () => { | 73 | () => { |
| 73 | if (this.state.IS_LOGIN == "yes") { | 74 | if (this.state.IS_LOGIN == "yes") { |
| 74 | - navigate("Release", { refreshCallback: data => { | 75 | + navigate("Release", { |
| 75 | - that.setState({ | 76 | + refreshCallback: data => { |
| 76 | - ListData: data | 77 | + that.setState({ |
| 77 | - }) | 78 | + ListData: data |
| 78 | - } }); | 79 | + }); |
| 80 | + } | ||
| 81 | + }); | ||
| 79 | } else { | 82 | } else { |
| 80 | Alert.alert("请先登录账号"); | 83 | Alert.alert("请先登录账号"); |
| 81 | } | 84 | } |
| @@ -107,6 +110,16 @@ export default class InsuranceCircle extends Component { | @@ -107,6 +110,16 @@ export default class InsuranceCircle extends Component { | ||
| 107 | getArticles() { | 110 | getArticles() { |
| 108 | var that = this; | 111 | var that = this; |
| 109 | // 请求文章数据 | 112 | // 请求文章数据 |
| 113 | + // post( | ||
| 114 | + // "/test/insurance/article", | ||
| 115 | + // {}, | ||
| 116 | + // res => { | ||
| 117 | + // console.log("post", res.data.data); | ||
| 118 | + // }, | ||
| 119 | + // err => { | ||
| 120 | + // console.log(err); | ||
| 121 | + // } | ||
| 122 | + // ); | ||
| 110 | return fetch(`https://devpay.brae.co/test/insurance/article`, { | 123 | return fetch(`https://devpay.brae.co/test/insurance/article`, { |
| 111 | method: "POST", | 124 | method: "POST", |
| 112 | headers: { | 125 | headers: { |
| @@ -114,24 +127,23 @@ export default class InsuranceCircle extends Component { | @@ -114,24 +127,23 @@ export default class InsuranceCircle extends Component { | ||
| 114 | "Content-Type": "application/json" | 127 | "Content-Type": "application/json" |
| 115 | } | 128 | } |
| 116 | }) | 129 | }) |
| 117 | - .then(resp => { | 130 | + .then(resp => { |
| 118 | - if (resp.status === 200) { | 131 | + if (resp.status === 200) { |
| 119 | - return resp.json(); | 132 | + return resp.json(); |
| 120 | - } else { | 133 | + } else { |
| 121 | - console.error("something went wrong!"); | 134 | + console.error("something went wrong!"); |
| 122 | - } | 135 | + } |
| 123 | - }) | 136 | + }) |
| 124 | - .then(respJson => { | 137 | + .then(respJson => { |
| 125 | - if (respJson.enmsg != "ok") { | 138 | + if (respJson.enmsg != "ok") { |
| 126 | - alert(respJson.cnmsg); | 139 | + alert(respJson.cnmsg); |
| 127 | - } else { | 140 | + } else { |
| 128 | - that.setState({ | 141 | + that.setState({ |
| 129 | - ListData: respJson.data.data | 142 | + ListData: respJson.data.data |
| 130 | - }); | 143 | + }); |
| 131 | - // console.log("state.ListData", this.state.ListData); | 144 | + } |
| 132 | - } | 145 | + }) |
| 133 | - }) | 146 | + .catch(err => console.error(err)); |
| 134 | - .catch(err => console.error(err)); | ||
| 135 | } | 147 | } |
| 136 | 148 | ||
| 137 | render() { | 149 | render() { |
-
Please register or login to post a comment