罗广聪

评价页面提交按钮

... ... @@ -23,6 +23,7 @@ import AIBegin from "./src/pages/Home/AISolution/Begin";
import AIQuestion from "./src/pages/Home/AISolution/Question";
import AISolution from "./src/pages/Home/AISolution/Solution";
import HealthQuestionnaire from "./src/pages/Home/healthQuestionnaire";
import Evaluate from "./src/pages/Mine/Evaluate";
// 底部导航栏配置,但也只是作为一个页面,加载到StackNavigator成为第一个页面
const MainTabBar = TabNavigator(
... ... @@ -133,6 +134,10 @@ const ProtectGod = StackNavigator(
HealthQuestionnaire: {
screen: HealthQuestionnaire,
navigationOptions: { headerTitle: "健康问卷" }
},
Evaluate: {
screen: Evaluate,
navigationOptions: { headerTitle: "评价" }
}
},
{
... ...
import React, { Component } from "react";
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
TouchableOpacity,
ScrollView,
ListView,
Dimensions,
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
import post from "../../utils/fetch";
export default class Home extends Component {
static navigationOptions = ({ navigation }) => {
const { state, setParams, navigate } = navigation;
return {
headerRight: (
<TouchableOpacity
style={{ marginRight: 13 }}
onPress={() => state.params.submit()}
>
<Text style={{fontSize: 16,color: "#0071E1"}}>提交</Text>
</TouchableOpacity>
)
};
};
constructor(props) {
super(props);
this.state = {};
}
componentWillMount() {}
componentDidMount() {
this.props.navigation.setParams({
submit: this.submit.bind(this)
});
}
//
submit() { console.log("提交成功") }
getListData() {
post("/test/insurance/article", {}, res => {}, err => {});
}
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<Text>评价页面</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "flex-start",
alignItems: "stretch",
backgroundColor: "#EFEFEF"
}
});
... ...
... ... @@ -315,7 +315,7 @@ export default class Mine extends Component {
{/* 评价和客服 */}
<View style={styles.midContainer}>
<TouchableOpacity style={styles.itemContainer}>
<TouchableOpacity style={styles.itemContainer} onPress={() => navigate('Evaluate')}>
<View style={styles.itemLeft}>
<Text style={styles.leftTitle}>评价我们</Text>
</View>
... ...
... ... @@ -11,6 +11,7 @@ import {
Dimensions,
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
import post from "../../utils/fetch";
export default class Home extends Component {
constructor(props) {
... ... @@ -22,40 +23,14 @@ export default class Home extends Component {
componentDidMount() {}
getListData() {
let that = this;
return fetch(`https://devpay.brae.co/test/insurance/topic`, {
method: "POST",
headers: {
Accept: "application/json",
"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.topic
});
console.log("首页列表", this.state.ListData);
}
});
post("/test/insurance/article", {}, res => {}, err => {});
}
render() {
// console.log("首页的this.props", this);
// console.log("render首页文章列表", this.state.ListData);
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<Text>智能问题</Text>
<Text>页面</Text>
</View>
);
}
... ... @@ -67,5 +42,5 @@ const styles = StyleSheet.create({
justifyContent: "flex-start",
alignItems: "stretch",
backgroundColor: "#EFEFEF"
},
}
});
... ...