Phecda

添加eslint

@@ -17,6 +17,7 @@ import AllProduct from "./src/pages/Home/allProduct"; @@ -17,6 +17,7 @@ import AllProduct from "./src/pages/Home/allProduct";
17 import ProductTemplate from "./src/Components/ProductTemplate"; 17 import ProductTemplate from "./src/Components/ProductTemplate";
18 import ArticleTemplate from "./src/Components/articleTemplate"; 18 import ArticleTemplate from "./src/Components/articleTemplate";
19 import Details from "./src/pages/InsuranceCircle/details"; 19 import Details from "./src/pages/InsuranceCircle/details";
  20 +import Release from "./src/pages/InsuranceCircle/release";
20 import Discover from "./src/pages/Discover/index"; 21 import Discover from "./src/pages/Discover/index";
21 import AIBegin from "./src/pages/Home/AISolution/Begin"; 22 import AIBegin from "./src/pages/Home/AISolution/Begin";
22 import AIQuestion from "./src/pages/Home/AISolution/Question"; 23 import AIQuestion from "./src/pages/Home/AISolution/Question";
@@ -112,6 +113,10 @@ const ProtectGod = StackNavigator( @@ -112,6 +113,10 @@ const ProtectGod = StackNavigator(
112 ProductTemplate: { screen: ProductTemplate }, 113 ProductTemplate: { screen: ProductTemplate },
113 ArticleTemplate: { screen: ArticleTemplate }, 114 ArticleTemplate: { screen: ArticleTemplate },
114 Details: { screen: Details }, 115 Details: { screen: Details },
  116 + Release: {
  117 + screen: Release,
  118 + navigationOptions: { headerTitle: "发布" }
  119 + },
115 Discover: { screen: Discover }, 120 Discover: { screen: Discover },
116 AIBegin: { 121 AIBegin: {
117 screen: AIBegin, 122 screen: AIBegin,
No preview for this file type
@@ -10,12 +10,43 @@ import { @@ -10,12 +10,43 @@ import {
10 ListView, 10 ListView,
11 Dimensions 11 Dimensions
12 } from "react-native"; 12 } from "react-native";
13 -import { StackNavigator, TabNavigator } from "react-navigation"; 13 +import { StackNavigator, TabNavigator, NavigationActions } from "react-navigation";
  14 +import { Col, Row, Grid } from "react-native-easy-grid";
14 15
15 export default class Home extends Component { 16 export default class Home extends Component {
16 constructor(props) { 17 constructor(props) {
17 super(props); 18 super(props);
18 - this.state = {}; 19 + this.state = {
  20 + gridData: {
  21 + title: ["角色", "建议产品", "建议保额", "保险年限", "缴费期限", "年缴保费"],
  22 + actor: "父亲",
  23 + age: "42岁",
  24 + products: [
  25 + {
  26 + name: "成人意外险",
  27 + price: "50W",
  28 + long: "1年",
  29 + year: "20年",
  30 + eachyear: "150元"
  31 + },
  32 + {
  33 + name: "成人意外险",
  34 + price: "50W",
  35 + long: "1年",
  36 + year: "20年",
  37 + eachyear: "150元"
  38 + },
  39 + {
  40 + name: "成人意外险",
  41 + price: "50W",
  42 + long: "1年",
  43 + year: "20年",
  44 + eachyear: "150元"
  45 + }
  46 + ],
  47 + count: "1200"
  48 + }
  49 + };
19 } 50 }
20 componentWillMount() {} 51 componentWillMount() {}
21 52
@@ -49,9 +80,21 @@ export default class Home extends Component { @@ -49,9 +80,21 @@ export default class Home extends Component {
49 }); 80 });
50 } 81 }
51 82
  83 + submit() {
  84 + this.props.navigation.dispatch(NavigationActions.reset({
  85 + index: 0,
  86 + actions: [
  87 + NavigationActions.navigate({
  88 + routeName: "MainTabBar"
  89 + })
  90 + ]
  91 + }))
  92 + }
  93 +
52 render() { 94 render() {
53 - console.log("solution", this.props.navigation.state.params.answerList); 95 + console.log("solution", this.props.navigation);
54 const { navigate } = this.props.navigation; 96 const { navigate } = this.props.navigation;
  97 + const { gridData } = this.state;
55 return ( 98 return (
56 <View style={styles.container}> 99 <View style={styles.container}>
57 <View style={styles.ownContaier}> 100 <View style={styles.ownContaier}>
@@ -84,20 +127,98 @@ export default class Home extends Component { @@ -84,20 +127,98 @@ export default class Home extends Component {
84 </View> 127 </View>
85 <View style={styles.adviceContainer}> 128 <View style={styles.adviceContainer}>
86 <Text style={styles.adviceText}> 129 <Text style={styles.adviceText}>
87 - 作为家庭的经济支柱,压力和责任重大,应优先进行保险配置,且应占家庭保险的中支出和总保额的大比重,建议依次配置以下产品,以保障家庭持续、高品质的运营 130 + 作为家庭的经济支柱,压力和责任重大,应优先进行保险配置,且应占家庭保险的中支出和总保额的大比重,建议依次配置以下产品,以保障家庭持续、高品质的运营
88 </Text> 131 </Text>
89 </View> 132 </View>
90 </View> 133 </View>
  134 +
91 <View style={styles.configureContaier}> 135 <View style={styles.configureContaier}>
92 <View style={styles.headerContainer}> 136 <View style={styles.headerContainer}>
93 <View style={styles.titleWrapper}> 137 <View style={styles.titleWrapper}>
94 <Text style={styles.headerTitle}>保险配置方案</Text> 138 <Text style={styles.headerTitle}>保险配置方案</Text>
95 </View> 139 </View>
96 </View> 140 </View>
97 - <View style={styles.tableContainer}> 141 + <ScrollView style={styles.tableContainer}>
98 - <Text>表格</Text> 142 + <Grid>
  143 + <Row>
  144 + {/* {gridData.title.map((item,index) => {
  145 + return (
  146 + <Col key={index} style={styles.gridtitleContaier}><Text style={styles.gridheaderText}>{item}</Text></Col>
  147 + )
  148 + })} */}
  149 + <Col size={1} style={styles.gridtitleContaier}>
  150 + <Text style={styles.gridheaderText}>角色</Text>
  151 + </Col>
  152 + <Col size={1.5} style={styles.gridtitleContaier}>
  153 + <Text style={styles.gridheaderText}>建议产品</Text>
  154 + </Col>
  155 + <Col size={1} style={styles.gridtitleContaier}>
  156 + <Text style={styles.gridheaderText}>建议保额</Text>
  157 + </Col>
  158 + <Col size={1} style={styles.gridtitleContaier}>
  159 + <Text style={styles.gridheaderText}>保险年限</Text>
  160 + </Col>
  161 + <Col size={1} style={styles.gridtitleContaier}>
  162 + <Text style={styles.gridheaderText}>缴费期限</Text>
  163 + </Col>
  164 + <Col size={1} style={styles.gridtitleContaier}>
  165 + <Text style={styles.gridheaderText}>年缴保费</Text>
  166 + </Col>
  167 + </Row>
  168 + <Row>
  169 + <Col style={styles.actor} size={1}>
  170 + <Text style={styles.contentText}>父亲</Text>
  171 + <Text style={styles.contentText}>42</Text>
  172 + </Col>
  173 + <Col size={5.5}>
  174 + {gridData.products.map((item, index) => {
  175 + return (
  176 + <Row key={index}>
  177 + <Col size={1.5} style={styles.contentCol}>
  178 + <Text style={styles.contentText}>{item.name}</Text>
  179 + </Col>
  180 + <Col size={1} style={styles.contentCol}>
  181 + <Text style={styles.contentText}>{item.price}</Text>
  182 + </Col>
  183 + <Col size={1} style={styles.contentCol}>
  184 + <Text style={styles.contentText}>{item.long}</Text>
  185 + </Col>
  186 + <Col size={1} style={styles.contentCol}>
  187 + <Text style={styles.contentText}>{item.year}</Text>
  188 + </Col>
  189 + <Col size={1} style={styles.contentCol}>
  190 + <Text style={styles.contentText}>
  191 + {item.eachyear}
  192 + </Text>
  193 + </Col>
  194 + </Row>
  195 + );
  196 + })}
  197 + <Row style={styles.countContainer}>
  198 + <Text style={styles.countText}>{gridData.count}</Text>
  199 + <Text style={styles.contentText}>/</Text>
  200 + </Row>
  201 + </Col>
  202 + </Row>
  203 + </Grid>
  204 + </ScrollView>
  205 + <View style={styles.tipsContainer}>
  206 + <Image
  207 + style={{ width: 16, height: 16 }}
  208 + source={require("../../../assets/home/ic_notice.png")}
  209 + />
  210 + <Text style={styles.tipsText}>保险配置预算仅供参考,实际缴费金额与投保时内容有关。</Text>
99 </View> 211 </View>
100 </View> 212 </View>
  213 +
  214 + <TouchableOpacity
  215 + onPress={() => {
  216 + this.submit();
  217 + }}
  218 + style={styles.confirmBtn}
  219 + >
  220 + <Text style={styles.confirmBtnText}>完成</Text>
  221 + </TouchableOpacity>
101 </View> 222 </View>
102 ); 223 );
103 } 224 }
@@ -136,7 +257,7 @@ const styles = StyleSheet.create({ @@ -136,7 +257,7 @@ const styles = StyleSheet.create({
136 borderColor: "#E8E8E8", 257 borderColor: "#E8E8E8",
137 borderTopWidth: 0.5, 258 borderTopWidth: 0.5,
138 flexDirection: "row", 259 flexDirection: "row",
139 - paddingVertical: 12, 260 + paddingVertical: 12
140 }, 261 },
141 leftInfoContaier: { 262 leftInfoContaier: {
142 flex: 1, 263 flex: 1,
@@ -150,10 +271,10 @@ const styles = StyleSheet.create({ @@ -150,10 +271,10 @@ const styles = StyleSheet.create({
150 }, 271 },
151 TInfoContaier: { 272 TInfoContaier: {
152 flexDirection: "row", 273 flexDirection: "row",
153 - marginBottom: 12, 274 + marginBottom: 12
154 }, 275 },
155 BInfoContaier: { 276 BInfoContaier: {
156 - flexDirection: "row", 277 + flexDirection: "row"
157 }, 278 },
158 adviceContainer: { 279 adviceContainer: {
159 marginLeft: 18, 280 marginLeft: 18,
@@ -161,15 +282,94 @@ const styles = StyleSheet.create({ @@ -161,15 +282,94 @@ const styles = StyleSheet.create({
161 borderStyle: "solid", 282 borderStyle: "solid",
162 borderColor: "#E8E8E8", 283 borderColor: "#E8E8E8",
163 borderTopWidth: 0.5, 284 borderTopWidth: 0.5,
164 - paddingVertical: 12, 285 + paddingVertical: 12
165 }, 286 },
166 adviceText: { 287 adviceText: {
167 fontSize: 13, 288 fontSize: 13,
168 lineHeight: 20, 289 lineHeight: 20,
169 - color: "#242424", 290 + color: "#242424"
170 }, 291 },
171 configureContaier: { 292 configureContaier: {
172 backgroundColor: "white", 293 backgroundColor: "white",
173 marginTop: 10 294 marginTop: 10
174 - } 295 + },
  296 + tableContainer: {
  297 + marginLeft: 18,
  298 + paddingRight: 18,
  299 + borderStyle: "solid",
  300 + borderColor: "#E8E8E8",
  301 + borderTopWidth: 1,
  302 + paddingVertical: 12
  303 + },
  304 + gridtitleContaier: {
  305 + justifyContent: "center",
  306 + alignItems: "center",
  307 + paddingVertical: 8,
  308 + backgroundColor: "#1B9341",
  309 + borderColor: "#E8E8E8",
  310 + borderStyle: "solid",
  311 + borderLeftWidth: 0.5
  312 + },
  313 + gridheaderText: {
  314 + fontSize: 11,
  315 + color: "white"
  316 + },
  317 + actor: {
  318 + justifyContent: "center",
  319 + alignItems: "center",
  320 + borderColor: "#ccc",
  321 + borderStyle: "solid",
  322 + borderWidth: 0.5
  323 + },
  324 + contentCol: {
  325 + justifyContent: "center",
  326 + alignItems: "center",
  327 + paddingVertical: 8,
  328 + borderColor: "#ccc",
  329 + borderStyle: "solid",
  330 + borderBottomWidth: 0.5,
  331 + borderRightWidth: 0.5
  332 + },
  333 + contentText: {
  334 + fontSize: 12,
  335 + lineHeight: 17
  336 + },
  337 + countContainer: {
  338 + justifyContent: "center",
  339 + alignItems: "center",
  340 + paddingVertical: 8,
  341 + borderColor: "#ccc",
  342 + borderStyle: "solid",
  343 + borderBottomWidth: 0.5,
  344 + borderRightWidth: 0.5
  345 + },
  346 + countText: {
  347 + fontSize: 18,
  348 + color: "#1B9341"
  349 + },
  350 + tipsContainer: {
  351 + flexDirection: "row",
  352 + alignItems: "center",
  353 + marginHorizontal: 24,
  354 + marginBottom: 10
  355 + },
  356 + tipsText: {
  357 + fontSize: 12,
  358 + color: "#7A7A7A",
  359 + lineHeight: 17,
  360 + marginLeft: 5
  361 + },
  362 + confirmBtn: {
  363 + marginVertical: 20,
  364 + marginHorizontal: 40,
  365 + justifyContent: "center",
  366 + alignItems: "center",
  367 + backgroundColor: "#1B9341",
  368 + height: 45,
  369 + borderRadius: 5
  370 + },
  371 + confirmBtnText: {
  372 + fontSize: 16,
  373 + color: "white"
  374 + },
175 }); 375 });
@@ -238,11 +238,7 @@ const styles = StyleSheet.create({ @@ -238,11 +238,7 @@ const styles = StyleSheet.create({
238 backgroundColor: "white" 238 backgroundColor: "white"
239 }, 239 },
240 KAVContainer: { 240 KAVContainer: {
241 - // flex: 1,  
242 justifyContent: "center" 241 justifyContent: "center"
243 - // paddingBottom: 52,  
244 - // paddingHorizontal: 20,  
245 - // paddingTop: 20,  
246 }, 242 },
247 scrollViewContainer: { 243 scrollViewContainer: {
248 flex: 1 244 flex: 1
@@ -7,21 +7,100 @@ import { @@ -7,21 +7,100 @@ import {
7 ScrollView, 7 ScrollView,
8 TouchableOpacity, 8 TouchableOpacity,
9 Image, 9 Image,
  10 + AsyncStorage,
  11 + Alert,
10 } from "react-native"; 12 } from "react-native";
11 import { StackNavigator, TabNavigator } from "react-navigation"; 13 import { StackNavigator, TabNavigator } from "react-navigation";
12 import Details from "./details"; 14 import Details from "./details";
13 15
14 export default class InsuranceCircle extends Component { 16 export default class InsuranceCircle extends Component {
  17 + static navigationOptions = ({ navigation }) => {
  18 + const { state, setParams, navigate } = navigation;
  19 + // console.log("保圈页面-发布", state);
  20 + return {
  21 + headerRight: (
  22 + <TouchableOpacity
  23 + style={{ marginRight: 13 }}
  24 + onPress={() => state.params.testLoginAndGo()}
  25 + >
  26 + <Image
  27 + source={require("../../assets/circle/ic_announce.png")}
  28 + style={{ width: 19, height: 19 }}
  29 + />
  30 + </TouchableOpacity>
  31 + )
  32 + };
  33 + };
15 constructor(props) { 34 constructor(props) {
16 super(props); 35 super(props);
17 this.state = { 36 this.state = {
18 ListData: [], 37 ListData: [],
  38 + IS_LOGIN: "",
  39 + USER_ID: "",
  40 + NICKNAME: "",
  41 + PROFESSION: ""
19 }; 42 };
20 } 43 }
21 -  
22 componentWillMount() { 44 componentWillMount() {
  45 + // this.getAsyncStorage();
23 this.getArticles(); 46 this.getArticles();
24 } 47 }
  48 + componentDidMount() {
  49 + this.props.navigation.setParams({
  50 + testLoginAndGo: this.testLoginAndGo.bind(this)
  51 + });
  52 + }
  53 + testLoginAndGo() {
  54 + const that = this;
  55 + const { navigate } = this.props.navigation;
  56 + console.log("为何是underfined?",this);
  57 + // this.getAsyncStorage();
  58 + AsyncStorage.multiGet(
  59 + ["IS_LOGIN", "USER_ID", "NICKNAME", "PROFESSION"],
  60 + (err, result) => {
  61 + if (err) {
  62 + console.error(err);
  63 + }
  64 + console.log("点击登录后的值", result);
  65 + that.setState({
  66 + IS_LOGIN: result[0][1],
  67 + USER_ID: result[1][1] != null ? result[1][1] : "",
  68 + NICKNAME: result[2][1] != null ? result[2][1] : "",
  69 + PROFESSION: result[3][1] != null ? result[3][1] : ""
  70 + },() => {
  71 + if (this.state.IS_LOGIN == 'yes') {
  72 + navigate("Release");
  73 + } else {
  74 + Alert.alert("请先登录账号");
  75 + }
  76 + });
  77 + }
  78 + );
  79 + // if (this.state.IS_LOGIN == 'yes') {
  80 + // navigate("Release");
  81 + // } else {
  82 + // Alert.alert("请先登录账号");
  83 + // }
  84 + }
  85 +
  86 + getAsyncStorage() {
  87 + const that = this;
  88 + AsyncStorage.multiGet(
  89 + ["IS_LOGIN", "USER_ID", "NICKNAME", "PROFESSION"],
  90 + (err, result) => {
  91 + if (err) {
  92 + console.error(err);
  93 + }
  94 + console.log("点击登录后的值", result);
  95 + that.setState({
  96 + IS_LOGIN: result[0][1],
  97 + USER_ID: result[1][1] != null ? result[1][1] : "",
  98 + NICKNAME: result[2][1] != null ? result[2][1] : "",
  99 + PROFESSION: result[3][1] != null ? result[3][1] : ""
  100 + });
  101 + }
  102 + );
  103 + }
25 104
26 getArticles() { 105 getArticles() {
27 var that = this; 106 var that = this;
@@ -45,7 +124,7 @@ export default class InsuranceCircle extends Component { @@ -45,7 +124,7 @@ export default class InsuranceCircle extends Component {
45 alert(respJson.cnmsg); 124 alert(respJson.cnmsg);
46 } else { 125 } else {
47 that.setState({ 126 that.setState({
48 - ListData: respJson.data.data, 127 + ListData: respJson.data.data
49 }); 128 });
50 console.log("state.ListData", this.state.ListData); 129 console.log("state.ListData", this.state.ListData);
51 } 130 }
  1 +import React, { Component } from "react";
  2 +import {
  3 + AppRegistry,
  4 + StyleSheet,
  5 + Text,
  6 + View,
  7 + Image,
  8 + TouchableOpacity,
  9 + ScrollView,
  10 + ListView,
  11 + Dimensions,
  12 +} from "react-native";
  13 +import { StackNavigator, TabNavigator } from "react-navigation";
  14 +
  15 +export default class Home extends Component {
  16 + constructor(props) {
  17 + super(props);
  18 + this.state = {};
  19 + }
  20 + componentWillMount() {}
  21 +
  22 + componentDidMount() {}
  23 +
  24 + getListData() {
  25 + let that = this;
  26 + return fetch(`https://devpay.brae.co/test/insurance/topic`, {
  27 + method: "POST",
  28 + headers: {
  29 + Accept: "application/json",
  30 + "Content-Type": "application/json"
  31 + }
  32 + })
  33 + .then(resp => {
  34 + if (resp.status === 200) {
  35 + return resp.json();
  36 + } else {
  37 + console.error("something went wrong!");
  38 + }
  39 + })
  40 + .then(respJson => {
  41 + if (respJson.enmsg != "ok") {
  42 + alert(respJson.cnmsg);
  43 + } else {
  44 + that.setState({
  45 + ListData: respJson.data.topic
  46 + });
  47 + console.log("首页列表", this.state.ListData);
  48 + }
  49 + });
  50 + }
  51 +
  52 + render() {
  53 + // console.log("首页的this.props", this);
  54 + // console.log("render首页文章列表", this.state.ListData);
  55 + const { navigate } = this.props.navigation;
  56 + return (
  57 + <View style={styles.container}>
  58 + <Text>发布</Text>
  59 + </View>
  60 + );
  61 + }
  62 +}
  63 +
  64 +const styles = StyleSheet.create({
  65 + container: {
  66 + flex: 1,
  67 + justifyContent: "flex-start",
  68 + alignItems: "stretch",
  69 + backgroundColor: "#EFEFEF"
  70 + },
  71 +});
@@ -256,7 +256,7 @@ export default class Login extends Component { @@ -256,7 +256,7 @@ export default class Login extends Component {
256 NICKNAME: nickname, 256 NICKNAME: nickname,
257 PROFESSION: profession, 257 PROFESSION: profession,
258 }); 258 });
259 - setTimeout(function () { 259 + setTimeout(function () {
260 that.props.navigation.goBack(); 260 that.props.navigation.goBack();
261 },0) 261 },0)
262 } 262 }
@@ -2605,7 +2605,7 @@ lodash@^3.5.0: @@ -2605,7 +2605,7 @@ lodash@^3.5.0:
2605 version "3.10.1" 2605 version "3.10.1"
2606 resolved "http://registry.npm.taobao.org/lodash/download/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" 2606 resolved "http://registry.npm.taobao.org/lodash/download/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
2607 2607
2608 -lodash@^4.14.0, lodash@^4.16.6, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.6.1: 2608 +lodash@^4.11.1, lodash@^4.14.0, lodash@^4.16.6, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.6.1:
2609 version "4.17.4" 2609 version "4.17.4"
2610 resolved "http://registry.npm.taobao.org/lodash/download/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" 2610 resolved "http://registry.npm.taobao.org/lodash/download/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
2611 2611
@@ -3251,6 +3251,12 @@ react-native-drawer-layout@1.3.2: @@ -3251,6 +3251,12 @@ react-native-drawer-layout@1.3.2:
3251 dependencies: 3251 dependencies:
3252 react-native-dismiss-keyboard "1.0.0" 3252 react-native-dismiss-keyboard "1.0.0"
3253 3253
  3254 +react-native-easy-grid@^0.1.15:
  3255 + version "0.1.15"
  3256 + resolved "http://registry.npm.taobao.org/react-native-easy-grid/download/react-native-easy-grid-0.1.15.tgz#02939ae032d74662b50c9540d902c79866ba638a"
  3257 + dependencies:
  3258 + lodash "^4.11.1"
  3259 +
3254 react-native-swiper@^1.5.11: 3260 react-native-swiper@^1.5.11:
3255 version "1.5.11" 3261 version "1.5.11"
3256 resolved "http://registry.npm.taobao.org/react-native-swiper/download/react-native-swiper-1.5.11.tgz#2d46ded43f383dbde4540d513cb4eaaa60eaed61" 3262 resolved "http://registry.npm.taobao.org/react-native-swiper/download/react-native-swiper-1.5.11.tgz#2d46ded43f383dbde4540d513cb4eaaa60eaed61"