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-09-27 22:19:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5f5b02b0c59e2f3ddd4b5546b0f0cdedeae40583
5f5b02b0
1 parent
94201f10
返回可刷新保圈
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
31 deletions
src/pages/InsuranceCircle/index.js
src/pages/InsuranceCircle/release.js
src/pages/InsuranceCircle/index.js
View file @
5f5b02b
...
...
@@ -8,7 +8,7 @@ import {
TouchableOpacity
,
Image
,
AsyncStorage
,
Alert
,
Alert
}
from
"react-native"
;
import
{
StackNavigator
,
TabNavigator
}
from
"react-navigation"
;
import
Details
from
"./details"
;
...
...
@@ -37,7 +37,8 @@ export default class InsuranceCircle extends Component {
IS_LOGIN
:
""
,
USER_ID
:
""
,
NICKNAME
:
""
,
PROFESSION
:
""
PROFESSION
:
""
,
forGoBack
:
""
,
};
}
componentWillMount
()
{
...
...
@@ -52,7 +53,7 @@ export default class InsuranceCircle extends Component {
testLoginAndGo
()
{
const
that
=
this
;
const
{
navigate
}
=
this
.
props
.
navigation
;
console
.
log
(
"为何是underfined?"
,
this
);
//
console.log("为何是underfined?",this);
// this.getAsyncStorage();
AsyncStorage
.
multiGet
(
[
"IS_LOGIN"
,
"USER_ID"
,
"NICKNAME"
,
"PROFESSION"
],
...
...
@@ -60,26 +61,28 @@ export default class InsuranceCircle extends Component {
if
(
err
)
{
console
.
error
(
err
);
}
console
.
log
(
"点击登录后的值"
,
result
);
that
.
setState
({
IS_LOGIN
:
result
[
0
][
1
],
USER_ID
:
result
[
1
][
1
]
!=
null
?
result
[
1
][
1
]
:
""
,
NICKNAME
:
result
[
2
][
1
]
!=
null
?
result
[
2
][
1
]
:
""
,
PROFESSION
:
result
[
3
][
1
]
!=
null
?
result
[
3
][
1
]
:
""
},()
=>
{
if
(
this
.
state
.
IS_LOGIN
==
'yes'
)
{
navigate
(
"Release"
);
}
else
{
Alert
.
alert
(
"请先登录账号"
);
// console.log("点击登录后的值", result);
that
.
setState
(
{
IS_LOGIN
:
result
[
0
][
1
],
USER_ID
:
result
[
1
][
1
]
!=
null
?
result
[
1
][
1
]
:
""
,
NICKNAME
:
result
[
2
][
1
]
!=
null
?
result
[
2
][
1
]
:
""
,
PROFESSION
:
result
[
3
][
1
]
!=
null
?
result
[
3
][
1
]
:
""
},
()
=>
{
if
(
this
.
state
.
IS_LOGIN
==
"yes"
)
{
navigate
(
"Release"
,
{
refreshCallback
:
data
=>
{
that
.
setState
({
ListData
:
data
})
}
});
}
else
{
Alert
.
alert
(
"请先登录账号"
);
}
}
}
);
);
}
);
// if (this.state.IS_LOGIN == 'yes') {
// navigate("Release");
// } else {
// Alert.alert("请先登录账号");
// }
}
getAsyncStorage
()
{
...
...
@@ -125,7 +128,7 @@ export default class InsuranceCircle extends Component {
that
.
setState
({
ListData
:
respJson
.
data
.
data
});
console
.
log
(
"state.ListData"
,
this
.
state
.
ListData
);
//
console.log("state.ListData", this.state.ListData);
}
})
.
catch
(
err
=>
console
.
error
(
err
));
...
...
src/pages/InsuranceCircle/release.js
View file @
5f5b02b
...
...
@@ -24,7 +24,8 @@ export default class Home extends Component {
IS_LOGIN
:
""
,
USER_ID
:
""
,
NICKNAME
:
""
,
PROFESSION
:
""
PROFESSION
:
""
,
listData
:
[]
};
}
componentWillMount
()
{
...
...
@@ -51,9 +52,45 @@ export default class Home extends Component {
}
);
}
getListData
()
{
let
that
=
this
;
return
fetch
(
`https://devpay.brae.co/test/insurance/topic`
,
{
addArticle
()
{
let
that
=
this
,
id
=
this
.
state
.
USER_ID
,
content
=
this
.
state
.
content
,
title
=
this
.
state
.
title
,
formData
=
new
FormData
();
formData
.
append
(
"userid"
,
id
);
formData
.
append
(
"title"
,
title
);
formData
.
append
(
"content"
,
content
);
return
fetch
(
`https://devpay.brae.co/test/insurance/article/add`
,
{
method
:
"POST"
,
headers
:
{
Accept
:
"application/json"
,
"Content-Type"
:
"application/json"
},
body
:
formData
})
.
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
.
getArticles
();
setTimeout
(
function
()
{
that
.
props
.
navigation
.
goBack
();
},
1000
);
}
});
}
getArticles
()
{
var
that
=
this
;
// 请求文章数据
return
fetch
(
`https://devpay.brae.co/test/insurance/article`
,
{
method
:
"POST"
,
headers
:
{
Accept
:
"application/json"
,
...
...
@@ -72,23 +109,27 @@ export default class Home extends Component {
alert
(
respJson
.
cnmsg
);
}
else
{
that
.
setState
({
ListData
:
respJson
.
data
.
topic
});
console
.
log
(
"首页列表"
,
this
.
state
.
ListData
);
listData
:
respJson
.
data
.
data
},()
=>
{
that
.
props
.
navigation
.
state
.
params
.
refreshCallback
(
that
.
state
.
listData
)
console
.
log
(
"fanhuide"
,
that
.
state
.
listData
)
})
}
});
})
.
catch
(
err
=>
console
.
error
(
err
));
}
submit
()
{
if
(
!
this
.
state
.
title
)
{
Alert
.
alert
(
"请填写标题"
);
return
false
;
}
}
if
(
!
this
.
state
.
content
)
{
Alert
.
alert
(
"请填写内容"
);
return
false
;
}
console
.
log
(
"title和content"
,
this
.
state
.
title
,
this
.
state
.
content
);
this
.
addArticle
(
);
}
render
()
{
const
{
navigate
}
=
this
.
props
.
navigation
;
return
(
...
...
Please
register
or
login
to post a comment