罗广聪

jjj

@@ -16,7 +16,6 @@ import Details from "./details"; @@ -16,7 +16,6 @@ import Details from "./details";
16 export default class InsuranceCircle extends Component { 16 export default class InsuranceCircle extends Component {
17 static navigationOptions = ({ navigation }) => { 17 static navigationOptions = ({ navigation }) => {
18 const { state, setParams, navigate } = navigation; 18 const { state, setParams, navigate } = navigation;
19 - // console.log("保圈页面-发布", state);  
20 return { 19 return {
21 headerRight: ( 20 headerRight: (
22 <TouchableOpacity 21 <TouchableOpacity
@@ -9,18 +9,48 @@ import { @@ -9,18 +9,48 @@ import {
9 ScrollView, 9 ScrollView,
10 ListView, 10 ListView,
11 Dimensions, 11 Dimensions,
  12 + TextInput,
  13 + AsyncStorage,
  14 + Alert
12 } from "react-native"; 15 } from "react-native";
13 import { StackNavigator, TabNavigator } from "react-navigation"; 16 import { StackNavigator, TabNavigator } from "react-navigation";
14 17
15 export default class Home extends Component { 18 export default class Home extends Component {
16 constructor(props) { 19 constructor(props) {
17 super(props); 20 super(props);
18 - this.state = {}; 21 + this.state = {
  22 + title: "",
  23 + content: "",
  24 + IS_LOGIN: "",
  25 + USER_ID: "",
  26 + NICKNAME: "",
  27 + PROFESSION: ""
  28 + };
  29 + }
  30 + componentWillMount() {
  31 + this.getAsyncStorage();
19 } 32 }
20 - componentWillMount() {}  
21 33
22 componentDidMount() {} 34 componentDidMount() {}
23 35
  36 + getAsyncStorage() {
  37 + const that = this;
  38 + AsyncStorage.multiGet(
  39 + ["IS_LOGIN", "USER_ID", "NICKNAME", "PROFESSION"],
  40 + (err, result) => {
  41 + if (err) {
  42 + console.error(err);
  43 + }
  44 + console.log("点击登录后的值", result);
  45 + that.setState({
  46 + IS_LOGIN: result[0][1],
  47 + USER_ID: result[1][1] != null ? result[1][1] : "",
  48 + NICKNAME: result[2][1] != null ? result[2][1] : "",
  49 + PROFESSION: result[3][1] != null ? result[3][1] : ""
  50 + });
  51 + }
  52 + );
  53 + }
24 getListData() { 54 getListData() {
25 let that = this; 55 let that = this;
26 return fetch(`https://devpay.brae.co/test/insurance/topic`, { 56 return fetch(`https://devpay.brae.co/test/insurance/topic`, {
@@ -48,14 +78,65 @@ export default class Home extends Component { @@ -48,14 +78,65 @@ export default class Home extends Component {
48 } 78 }
49 }); 79 });
50 } 80 }
51 - 81 + submit() {
  82 + if (!this.state.title) {
  83 + Alert.alert("请填写标题");
  84 + return false;
  85 + }
  86 + if (!this.state.content) {
  87 + Alert.alert("请填写内容");
  88 + return false;
  89 + }
  90 + console.log("title和content",this.state.title,this.state.content);
  91 + }
52 render() { 92 render() {
53 - // console.log("首页的this.props", this);  
54 - // console.log("render首页文章列表", this.state.ListData);  
55 const { navigate } = this.props.navigation; 93 const { navigate } = this.props.navigation;
56 return ( 94 return (
57 <View style={styles.container}> 95 <View style={styles.container}>
58 - <Text>发布</Text> 96 + <View style={styles.inputContaier}>
  97 + <TextInput
  98 + style={styles.titleInput}
  99 + placeholder="文章标题"
  100 + onChangeText={title => this.setState({ title })}
  101 + value={this.state.title}
  102 + autoCapitalize="none"
  103 + selectionColor="#1B9341"
  104 + numberOfLines={1}
  105 + clearButtonMode="always"
  106 + keyboardType="default"
  107 + enablesReturnKeyAutomatically={true}
  108 + returnKeyType="send"
  109 + onSubmitEditing={() => {
  110 + Keyboard.dismiss();
  111 + }}
  112 + />
  113 + </View>
  114 + <View style={styles.inputContaier}>
  115 + <TextInput
  116 + style={styles.contentInput}
  117 + placeholder="填写发布内容"
  118 + onChangeText={content => this.setState({ content })}
  119 + value={this.state.content}
  120 + autoCapitalize="none"
  121 + multiline={true}
  122 + selectionColor="#1B9341"
  123 + clearButtonMode="always"
  124 + keyboardType="default"
  125 + enablesReturnKeyAutomatically={true}
  126 + returnKeyType="send"
  127 + onSubmitEditing={() => {
  128 + Keyboard.dismiss();
  129 + }}
  130 + />
  131 + </View>
  132 + <TouchableOpacity
  133 + onPress={() => {
  134 + this.submit();
  135 + }}
  136 + style={styles.confirmBtn}
  137 + >
  138 + <Text style={styles.confirmBtnText}>发布</Text>
  139 + </TouchableOpacity>
59 </View> 140 </View>
60 ); 141 );
61 } 142 }
@@ -68,4 +149,36 @@ const styles = StyleSheet.create({ @@ -68,4 +149,36 @@ const styles = StyleSheet.create({
68 alignItems: "stretch", 149 alignItems: "stretch",
69 backgroundColor: "#EFEFEF" 150 backgroundColor: "#EFEFEF"
70 }, 151 },
  152 + inputContaier: {
  153 + backgroundColor: "white",
  154 + paddingHorizontal: 15,
  155 + paddingVertical: 10,
  156 + borderStyle: "solid",
  157 + borderColor: "#EFEFEF",
  158 + borderTopWidth: 1
  159 + },
  160 + titleInput: {
  161 + fontSize: 15,
  162 + paddingTop: 8,
  163 + paddingBottom: 7
  164 + },
  165 + contentInput: {
  166 + fontSize: 15,
  167 + paddingTop: 8,
  168 + paddingBottom: 7,
  169 + height: 200
  170 + },
  171 + confirmBtn: {
  172 + marginVertical: 20,
  173 + marginHorizontal: 40,
  174 + justifyContent: "center",
  175 + alignItems: "center",
  176 + backgroundColor: "#1B9341",
  177 + height: 45,
  178 + borderRadius: 5
  179 + },
  180 + confirmBtnText: {
  181 + fontSize: 16,
  182 + color: "white"
  183 + }
71 }); 184 });