罗广聪

开始处理客户管理的回调

@@ -81,7 +81,7 @@ @@ -81,7 +81,7 @@
81 </AdditionalOptions> 81 </AdditionalOptions>
82 </TestAction> 82 </TestAction>
83 <LaunchAction 83 <LaunchAction
84 - buildConfiguration = "Debug" 84 + buildConfiguration = "Release"
85 selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" 85 selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
86 selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" 86 selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
87 language = "" 87 language = ""
@@ -9,14 +9,18 @@ import { @@ -9,14 +9,18 @@ import {
9 ScrollView, 9 ScrollView,
10 ListView, 10 ListView,
11 Dimensions, 11 Dimensions,
12 - DatePickerIOS 12 + DatePickerIOS,
  13 + AsyncStorage
13 } from "react-native"; 14 } from "react-native";
14 import { StackNavigator, TabNavigator } from "react-navigation"; 15 import { StackNavigator, TabNavigator } from "react-navigation";
  16 +import post from "../../../utils/fetch";
15 17
16 export default class Home extends Component { 18 export default class Home extends Component {
17 constructor(props) { 19 constructor(props) {
18 super(props); 20 super(props);
19 this.state = { 21 this.state = {
  22 + IS_LOGIN: "",
  23 + USER_ID: "",
20 QuesList: [ 24 QuesList: [
21 { 25 {
22 title: "1.我该称呼您先生还是女士呢?", 26 title: "1.我该称呼您先生还是女士呢?",
@@ -59,7 +63,9 @@ export default class Home extends Component { @@ -59,7 +63,9 @@ export default class Home extends Component {
59 date: new Date() 63 date: new Date()
60 }; 64 };
61 } 65 }
62 - componentWillMount() {} 66 + componentWillMount() {
  67 + this.getAsyncStorage();
  68 + }
63 69
64 componentDidMount() {} 70 componentDidMount() {}
65 71
@@ -91,6 +97,19 @@ export default class Home extends Component { @@ -91,6 +97,19 @@ export default class Home extends Component {
91 }); 97 });
92 } 98 }
93 99
  100 + getAsyncStorage() {
  101 + const that = this;
  102 + AsyncStorage.multiGet(["IS_LOGIN", "USER_ID"], (err, result) => {
  103 + if (err) {
  104 + console.error(err);
  105 + }
  106 + that.setState({
  107 + IS_LOGIN: result[0][1],
  108 + USER_ID: result[1][1] != null ? result[1][1] : ""
  109 + });
  110 + });
  111 + }
  112 +
94 _renderQuestion() { 113 _renderQuestion() {
95 return this.state.QuesList.map((item, index) => { 114 return this.state.QuesList.map((item, index) => {
96 return ( 115 return (
@@ -155,6 +174,7 @@ export default class Home extends Component { @@ -155,6 +174,7 @@ export default class Home extends Component {
155 174
156 submit() { 175 submit() {
157 const that = this; 176 const that = this;
  177 + const { answerList,USER_ID } = this.state;
158 const { navigate } = this.props.navigation; 178 const { navigate } = this.props.navigation;
159 let Temp = this.state.QuesList.map(item => item.answers[item.selected]); 179 let Temp = this.state.QuesList.map(item => item.answers[item.selected]);
160 console.log(Temp); 180 console.log(Temp);
@@ -164,7 +184,21 @@ export default class Home extends Component { @@ -164,7 +184,21 @@ export default class Home extends Component {
164 answerList: Temp 184 answerList: Temp
165 }, 185 },
166 () => { 186 () => {
167 - navigate("AISolution", { answerList: that.state.answerList }); 187 + post(
  188 + `/test/insurance/advice`,
  189 + {
  190 + userid: USER_ID,
  191 + // result: answerList
  192 + },
  193 + res => {
  194 + Alert.alert("导入成功,点击“OK”查看结果", null, () => {
  195 + navigate("AISolution", { answerList: that.state.answerList });
  196 + });
  197 + },
  198 + err => {
  199 + console.log(err);
  200 + }
  201 + );
168 } 202 }
169 ); 203 );
170 } 204 }