Toggle navigation
Toggle navigation
This project
Loading...
Sign in
罗广聪
/
ProtectGod
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
罗广聪
2017-10-01 10:50:45 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
152fb73918564516bfaaaec80063dcb0750f49db
152fb739
1 parent
01b521b5
AI
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
70 deletions
src/pages/Home/AISolution/Question.js
src/pages/Home/AISolution/Solution.js
src/pages/Home/index.js
src/pages/Home/AISolution/Question.js
View file @
152fb73
...
...
@@ -10,7 +10,8 @@ import {
ListView
,
Dimensions
,
DatePickerIOS
,
AsyncStorage
AsyncStorage
,
Alert
}
from
"react-native"
;
import
{
StackNavigator
,
TabNavigator
}
from
"react-navigation"
;
import
post
from
"../../../utils/fetch"
;
...
...
@@ -69,34 +70,6 @@ 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
);
}
});
}
getAsyncStorage
()
{
const
that
=
this
;
AsyncStorage
.
multiGet
([
"IS_LOGIN"
,
"USER_ID"
],
(
err
,
result
)
=>
{
...
...
@@ -173,34 +146,33 @@ export default class Home extends Component {
}
submit
()
{
const
that
=
this
;
const
{
answerList
,
USER_ID
}
=
this
.
state
;
const
{
navigate
}
=
this
.
props
.
navigation
;
const
that
=
this
,
{
answerList
,
USER_ID
}
=
this
.
state
,
{
navigate
}
=
this
.
props
.
navigation
;
let
Temp
=
this
.
state
.
QuesList
.
map
(
item
=>
item
.
answers
[
item
.
selected
]);
console
.
log
(
Temp
);
Temp
.
splice
(
3
,
1
,
that
.
format
(
that
.
state
.
date
));
that
.
setState
(
{
answerList
:
Temp
}
,
()
=>
{
post
(
`/test/insurance/advice`
,
{
userid
:
USER_ID
,
// result: answerList
},
res
=>
{
Alert
.
alert
(
"导入成功,点击“OK”查看结果"
,
null
,
()
=>
{
navigate
(
"AISolution"
,
{
answerList
:
that
.
state
.
answerList
});
});
},
err
=>
{
console
.
log
(
err
);
}
);
}
);
let
Result
=
{
age
:
2017
-
parseInt
(
Temp
[
3
].
split
(
"-"
)[
0
]),
security
:
Temp
[
5
],
income
:
Temp
[
4
]
,
debt
:
Temp
[
2
]
};
console
.
log
(
"temp Result"
,
Temp
,
Result
);
if
(
this
.
state
.
IS_LOGIN
!=
"yes"
)
{
Alert
.
alert
(
"请先登录账号"
);
}
else
{
post
(
`/test/insurance/advice`
,
{
userid
:
this
.
state
.
USER_ID
,
result
:
Result
},
res
=>
{
navigate
(
"AISolution"
);
},
err
=>
{}
);
}
}
format
(
date
)
{
...
...
src/pages/Home/AISolution/Solution.js
View file @
152fb73
...
...
@@ -8,16 +8,25 @@ import {
TouchableOpacity
,
ScrollView
,
ListView
,
Dimensions
Dimensions
,
AsyncStorage
,
Alert
}
from
"react-native"
;
import
{
StackNavigator
,
TabNavigator
,
NavigationActions
}
from
"react-navigation"
;
import
{
StackNavigator
,
TabNavigator
,
NavigationActions
}
from
"react-navigation"
;
import
{
Col
,
Row
,
Grid
}
from
"react-native-easy-grid"
;
import
post
from
"../../../utils/fetch"
;
export
default
class
Home
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
gridData
:
{
IS_LOGIN
:
""
,
USER_ID
:
""
,
title
:
[
"角色"
,
"建议产品"
,
"建议保额"
,
"保险年限"
,
"缴费期限"
,
"年缴保费"
],
actor
:
"父亲"
,
age
:
"42岁"
,
...
...
@@ -48,10 +57,25 @@ export default class Home extends Component {
}
};
}
componentWillMount
()
{}
componentWillMount
()
{
this
.
getAsyncStorage
();
}
componentDidMount
()
{}
getAsyncStorage
()
{
const
that
=
this
;
AsyncStorage
.
multiGet
([
"IS_LOGIN"
,
"USER_ID"
],
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
err
);
}
that
.
setState
({
IS_LOGIN
:
result
[
0
][
1
],
USER_ID
:
result
[
1
][
1
]
!=
null
?
result
[
1
][
1
]
:
""
});
});
}
getListData
()
{
let
that
=
this
;
return
fetch
(
`https://devpay.brae.co/test/insurance/topic`
,
{
...
...
@@ -81,6 +105,32 @@ export default class Home extends Component {
}
submit
()
{
if
(
this
.
state
.
IS_LOGIN
!=
"yes"
)
{
Alert
.
alert
(
"请先登录账号"
);
}
else
{
post
(
`/test/insurance/advice`
,
{
userid
:
this
.
state
.
USER_ID
,
result
:
{}
},
res
=>
{
Alert
.
alert
(
"保存成功"
,
null
,
()
=>
{
this
.
props
.
navigation
.
dispatch
(
NavigationActions
.
reset
({
index
:
0
,
actions
:
[
NavigationActions
.
navigate
({
routeName
:
"MainTabBar"
})
]
})
);
});
},
err
=>
{}
);
}
this
.
props
.
navigation
.
dispatch
(
NavigationActions
.
reset
({
index
:
0
,
actions
:
[
...
...
@@ -91,6 +141,7 @@ export default class Home extends Component {
}))
}
render
()
{
console
.
log
(
"solution"
,
this
.
props
.
navigation
);
const
{
navigate
}
=
this
.
props
.
navigation
;
...
...
@@ -217,7 +268,16 @@ export default class Home extends Component {
}}
style
=
{
styles
.
confirmBtn
}
>
<
Text
style
=
{
styles
.
confirmBtnText
}
>
完成
<
/Text
>
<
Text
style
=
{
styles
.
confirmBtnText
}
>
返回
<
/Text
>
<
/TouchableOpacity
>
<
TouchableOpacity
onPress
=
{()
=>
{
{
/* this.testAgain(); */
}
navigate
(
"AIQuestion"
)
}}
style
=
{
styles
.
testAgainBtn
}
>
<
Text
style
=
{
styles
.
testAgainText
}
>
再测一次
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
);
...
...
@@ -328,7 +388,7 @@ const styles = StyleSheet.create({
borderColor
:
"#ccc"
,
borderStyle
:
"solid"
,
borderBottomWidth
:
1
,
borderRightWidth
:
1
,
borderRightWidth
:
1
},
contentText
:
{
fontSize
:
12
,
...
...
@@ -360,7 +420,8 @@ const styles = StyleSheet.create({
marginLeft
:
5
},
confirmBtn
:
{
marginVertical
:
20
,
// marginVertical: 20,
marginTop
:
20
,
marginHorizontal
:
40
,
justifyContent
:
"center"
,
alignItems
:
"center"
,
...
...
@@ -372,4 +433,14 @@ const styles = StyleSheet.create({
fontSize
:
16
,
color
:
"white"
},
testAgainBtn
:
{
marginHorizontal
:
40
,
justifyContent
:
"center"
,
alignItems
:
"center"
,
height
:
45
,
},
testAgainText
:
{
fontSize
:
14
,
color
:
"#1B9341"
},
});
...
...
src/pages/Home/index.js
View file @
152fb73
...
...
@@ -9,16 +9,23 @@ import {
ScrollView
,
FlatList
,
ListView
,
Dimensions
Dimensions
,
Alert
,
AsyncStorage
}
from
"react-native"
;
import
{
StackNavigator
,
TabNavigator
}
from
"react-navigation"
;
import
Swiper
from
"react-native-swiper"
;
import
post
from
"../../utils/fetch"
;
export
default
class
Home
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
_swiper
=
this
.
_swiper
.
bind
(
this
);
this
.
state
=
{
IS_LOGIN
:
""
,
USER_ID
:
""
,
result
:
null
,
tested
:
false
,
ListData
:
[],
swiperImgList
:
[
{
...
...
@@ -32,10 +39,49 @@ export default class Home extends Component {
}
componentWillMount
()
{
this
.
getListData
();
this
.
getAsyncStorage
();
}
gotoAISolution
()
{
const
{
navigate
}
=
this
.
props
.
navigation
;
post
(
`/test/insurance/advice`
,
{
userid
:
this
.
state
.
USER_ID
},
res
=>
{
console
.
log
(
'智能方案答案'
,
res
);
this
.
setState
({
tested
:
res
.
data
.
tested
,
result
:
res
.
data
.
tested
?
res
.
data
.
result
:
null
});
},
err
=>
{
console
.
log
(
err
);
}
);
}
componentDidMount
()
{}
getAsyncStorage
()
{
const
that
=
this
;
AsyncStorage
.
multiGet
([
"IS_LOGIN"
,
"USER_ID"
],
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
err
);
}
that
.
setState
(
{
IS_LOGIN
:
result
[
0
][
1
],
USER_ID
:
result
[
1
][
1
]
!=
null
?
result
[
1
][
1
]
:
""
},
()
=>
{
this
.
gotoAISolution
();
}
);
});
}
getListData
()
{
let
that
=
this
;
return
fetch
(
`https://devpay.brae.co/test/insurance/topic`
,
{
...
...
@@ -163,10 +209,19 @@ export default class Home extends Component {
<
TouchableOpacity
style
=
{
styles
.
AHContainer
}
onPress
=
{()
=>
{
navigate
(
"AIBegin"
);
if
(
this
.
state
.
tested
)
{
navigate
(
"AISolution"
,
{
result
:
this
.
state
.
result
});
}
else
{
navigate
(
"AIBegin"
);
}
}}
>
<
Image
style
=
{
styles
.
AHIcon
}
source
=
{
require
(
"../../assets/home/ic_intellect.png"
)}
/
>
<
Image
style
=
{
styles
.
AHIcon
}
source
=
{
require
(
"../../assets/home/ic_intellect.png"
)}
/
>
<
Text
style
=
{
styles
.
AHText
}
>
智能方案
<
/Text
>
<
/TouchableOpacity
>
<
TouchableOpacity
...
...
@@ -175,7 +230,10 @@ export default class Home extends Component {
navigate
(
"HealthQuestionnaire"
);
}}
>
<
Image
style
=
{
styles
.
AHIcon
}
source
=
{
require
(
"../../assets/home/ic_questionnaire.png"
)}
/
>
<
Image
style
=
{
styles
.
AHIcon
}
source
=
{
require
(
"../../assets/home/ic_questionnaire.png"
)}
/
>
<
Text
style
=
{
styles
.
AHText
}
>
健康问卷
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
...
...
@@ -263,22 +321,21 @@ const styles = StyleSheet.create({
marginTop
:
10
,
backgroundColor
:
"white"
,
paddingTop
:
10
,
paddingBottom
:
10
,
paddingBottom
:
10
},
AHContainer
:
{
flexDirection
:
"row"
,
justifyContent
:
"center"
,
alignItems
:
"center"
,
alignItems
:
"center"
},
AHIcon
:
{
width
:
40
,
height
:
40
,
height
:
40
},
AHText
:
{
fontSize
:
16
,
color
:
"#242424"
,
marginLeft
:
13
,
marginLeft
:
13
},
textContainer
:
{
backgroundColor
:
"#fff"
,
...
...
Please
register
or
login
to post a comment