Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gmalpha_flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile
gmalpha_flutter
Commits
f5f15dff
Commit
f5f15dff
authored
May 20, 2019
by
jinzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update comment_suggest
parent
26a89835
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
42 deletions
+77
-42
comment_suggest.dart
lib/comment_suggest.dart
+7
-8
main.dart
lib/main.dart
+27
-19
DioUtil.dart
lib/netWork/DioUtil.dart
+43
-11
applicationTest.dart
lib/testPage/applicationTest.dart
+0
-4
No files found.
lib/comment_suggest.dart
View file @
f5f15dff
...
@@ -145,7 +145,8 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
...
@@ -145,7 +145,8 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
void
confimSuggestInfo
()
{
void
confimSuggestInfo
()
{
print
(
'11111111----come----confimSuggestInfo'
);
print
(
'11111111----come----confimSuggestInfo'
);
BaseOptions
options
=
DioUtil
.
getDefOptions
();
BaseOptions
options
=
DioUtil
.
getDefOptions
();
HttpConfig
config
=
new
HttpConfig
(
options:
options
,
nativeCookie:
widget
.
nativeCookie
);
final
cookie
=
new
Map
<
String
,
dynamic
>.
from
(
widget
.
nativeCookie
);
HttpConfig
config
=
new
HttpConfig
(
options:
options
,
nativeCookie:
cookie
);
DioUtil
().
setConfig
(
config
);
DioUtil
().
setConfig
(
config
);
print
(
'aaaaaaaa----come----config'
);
print
(
'aaaaaaaa----come----config'
);
print
(
config
.
nativeCookie
);
print
(
config
.
nativeCookie
);
...
@@ -153,20 +154,20 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
...
@@ -153,20 +154,20 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
print
(
widget
.
nativeCookie
);
print
(
widget
.
nativeCookie
);
DioUtil
().
requestR
(
Method
.
post
,
"api/v1/suggestion"
,
data:
{
"content"
:
"add"
,
"phone"
:
"aaa"
}).
then
((
res
){
DioUtil
().
requestR
(
Method
.
post
,
"api/v1/suggestion"
,
data:
{
"content"
:
"add"
,
"phone"
:
"aaa"
}).
then
((
res
){
showAlertDialog
(
context
,
res
.
data
);
print
(
'请求成功'
);
print
(
res
);
// showAlertDialog(context, '请求成功');
}
}
).
then
((
error
){
).
then
((
error
){
print
(
error
);
print
(
error
);
});
});
}
}
void
showAlertDialog
(
BuildContext
context
,
Text
tes
tStr
)
{
void
showAlertDialog
(
BuildContext
context
,
String
tex
tStr
)
{
showDialog
(
showDialog
(
context:
context
,
context:
context
,
builder:
(
_
)
=>
new
AlertDialog
(
builder:
(
_
)
=>
new
AlertDialog
(
title:
testStr
,
title:
new
Text
(
textStr
)
,
content:
new
Text
(
"This is my content"
),
content:
new
Text
(
"This is my content"
),
actions:
<
Widget
>[
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
"CANCEL"
),
onPressed:
(){
new
FlatButton
(
child:
new
Text
(
"CANCEL"
),
onPressed:
(){
...
@@ -174,8 +175,6 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
...
@@ -174,8 +175,6 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
},),
},),
new
FlatButton
(
child:
new
Text
(
"OK"
),
onPressed:
(){
new
FlatButton
(
child:
new
Text
(
"OK"
),
onPressed:
(){
// Navigator.of(context).pop();
},)
},)
]
]
...
...
lib/main.dart
View file @
f5f15dff
...
@@ -35,28 +35,36 @@ class _MyAppState extends State<MyApp> {
...
@@ -35,28 +35,36 @@ class _MyAppState extends State<MyApp> {
FlutterBoost
.
handleOnStartPage
();
FlutterBoost
.
handleOnStartPage
();
}
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
return
MaterialApp
(
locale:
Locale
(
'en'
,
'US'
),
title:
'Flutter Boost example'
,
supportedLocales:
[
builder:
FlutterBoost
.
init
(
postPush:
_onRoutePushed
),
Locale
(
'en'
,
'US'
),
home:
Container
());
Locale
(
'zh'
,
'CN'
),
],
debugShowCheckedModeBanner:
false
,
// home: NavigatorDemo(),
initialRoute:
'/test'
,
routes:
{
'/'
:
(
context
)
=>
CommentSuggest
({
'cookie'
:
'124'
}),
},
theme:
ThemeData
(
primarySwatch:
Colors
.
yellow
,
highlightColor:
Color
.
fromRGBO
(
255
,
255
,
255
,
0.5
),
splashColor:
Colors
.
white70
,
accentColor:
Color
.
fromRGBO
(
3
,
54
,
255
,
1.0
),
)
);
}
}
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// locale: Locale('en', 'US'),
// supportedLocales: [
// Locale('en', 'US'),
// Locale('zh', 'CN'),
// ],
// debugShowCheckedModeBanner: false,
// // home: NavigatorDemo(),
// initialRoute: '/test',
// routes: {
// '/': (context) => CommentSuggest({'cookie': '124'}),
// },
// builder: FlutterBoost.init(postPush: _onRoutePushed),
// theme: ThemeData(
// primarySwatch: Colors.yellow,
// highlightColor: Color.fromRGBO(255, 255, 255, 0.5),
// splashColor: Colors.white70,
// accentColor: Color.fromRGBO(3, 54, 255, 1.0),
// )
// );
// }
void
_onRoutePushed
(
void
_onRoutePushed
(
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
_
)
{
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
_
)
{
...
...
lib/netWork/DioUtil.dart
View file @
f5f15dff
...
@@ -8,8 +8,10 @@ class BaseResp<T> {
...
@@ -8,8 +8,10 @@ class BaseResp<T> {
int
code
;
int
code
;
String
msg
;
String
msg
;
T
data
;
T
data
;
T
extra
;
T
userType
;
BaseResp
(
this
.
status
,
this
.
code
,
this
.
msg
,
this
.
data
);
BaseResp
(
this
.
status
,
this
.
code
,
this
.
msg
,
this
.
data
,
this
.
extra
,
this
.
userType
);
@override
@override
String
toString
()
{
String
toString
()
{
...
@@ -18,6 +20,8 @@ class BaseResp<T> {
...
@@ -18,6 +20,8 @@ class BaseResp<T> {
sb
.
write
(
",
\"
code
\"
:
$code
"
);
sb
.
write
(
",
\"
code
\"
:
$code
"
);
sb
.
write
(
",
\"
msg
\"
:
\"
$msg
\"
"
);
sb
.
write
(
",
\"
msg
\"
:
\"
$msg
\"
"
);
sb
.
write
(
",
\"
data
\"
:
\"
$data
\"
"
);
sb
.
write
(
",
\"
data
\"
:
\"
$data
\"
"
);
sb
.
write
(
",
\"
extra
\"
:
\"
$extra
\"
"
);
sb
.
write
(
",
\"
userType
\"
:
\"
$userType
\"
"
);
sb
.
write
(
'}'
);
sb
.
write
(
'}'
);
return
sb
.
toString
();
return
sb
.
toString
();
}
}
...
@@ -29,9 +33,11 @@ class BaseRespR<T> {
...
@@ -29,9 +33,11 @@ class BaseRespR<T> {
int
code
;
int
code
;
String
msg
;
String
msg
;
T
data
;
T
data
;
T
extra
;
T
userType
;
Response
response
;
Response
response
;
BaseRespR
(
this
.
status
,
this
.
code
,
this
.
msg
,
this
.
data
,
this
.
response
);
BaseRespR
(
this
.
status
,
this
.
code
,
this
.
msg
,
this
.
data
,
this
.
extra
,
this
.
userType
,
this
.
response
);
@override
@override
String
toString
()
{
String
toString
()
{
...
@@ -40,8 +46,10 @@ class BaseRespR<T> {
...
@@ -40,8 +46,10 @@ class BaseRespR<T> {
sb
.
write
(
",
\"
code
\"
:
$code
"
);
sb
.
write
(
",
\"
code
\"
:
$code
"
);
sb
.
write
(
",
\"
msg
\"
:
\"
$msg
\"
"
);
sb
.
write
(
",
\"
msg
\"
:
\"
$msg
\"
"
);
sb
.
write
(
",
\"
data
\"
:
\"
$data
\"
"
);
sb
.
write
(
",
\"
data
\"
:
\"
$data
\"
"
);
sb
.
write
(
",
\"
extra
\"
:
\"
$extra
\"
"
);
sb
.
write
(
",
\"
userType
\"
:
\"
$userType
\"
"
);
sb
.
write
(
'}'
);
sb
.
write
(
'}'
);
return
sb
.
toString
();
return
sb
.
toString
();
;
}
}
}
}
...
@@ -110,15 +118,21 @@ class DioUtil {
...
@@ -110,15 +118,21 @@ class DioUtil {
/// BaseResp [String status]字段 key, 默认:status.
/// BaseResp [String status]字段 key, 默认:status.
String
_statusKey
=
"status"
;
String
_statusKey
=
"status"
;
/// BaseResp [int code]字段 key, 默认:error
Code
.
/// BaseResp [int code]字段 key, 默认:error
= 0 代表成功
.
String
_codeKey
=
"error
Code
"
;
String
_codeKey
=
"error"
;
/// BaseResp [String msg]字段 key, 默认:errorMsg.
/// BaseResp [String msg]字段 key, 默认:errorMsg.
String
_msgKey
=
"
errorMsg
"
;
String
_msgKey
=
"
message
"
;
/// BaseResp [T data]字段 key, 默认:data.
/// BaseResp [T data]字段 key, 默认:data.
String
_dataKey
=
"data"
;
String
_dataKey
=
"data"
;
/// BaseResp [T data]字段 key, 默认:extra.
String
_extraKey
=
'extra'
;
// BaseResp [T data]字段 key, 默认:user_type.
String
_userType
=
'user_type'
;
/// Options.
/// Options.
static
BaseOptions
_options
=
getDefOptions
();
static
BaseOptions
_options
=
getDefOptions
();
...
@@ -132,7 +146,7 @@ class DioUtil {
...
@@ -132,7 +146,7 @@ class DioUtil {
String
_pKCSPwd
;
String
_pKCSPwd
;
/// 是否是debug模式.
/// 是否是debug模式.
static
bool
_isDebug
=
fals
e
;
static
bool
_isDebug
=
tru
e
;
static
DioUtil
getInstance
()
{
static
DioUtil
getInstance
()
{
return
_instance
;
return
_instance
;
...
@@ -158,6 +172,7 @@ class DioUtil {
...
@@ -158,6 +172,7 @@ class DioUtil {
_msgKey
=
config
.
msg
??
_msgKey
;
_msgKey
=
config
.
msg
??
_msgKey
;
_dataKey
=
config
.
data
??
_dataKey
;
_dataKey
=
config
.
data
??
_dataKey
;
_mergeOption
(
config
.
options
);
_mergeOption
(
config
.
options
);
_mergeNativeCookie
(
config
);
_pem
=
config
.
pem
??
_pem
;
_pem
=
config
.
pem
??
_pem
;
if
(
_dio
!=
null
)
{
if
(
_dio
!=
null
)
{
_dio
.
options
=
_options
;
_dio
.
options
=
_options
;
...
@@ -204,6 +219,8 @@ class DioUtil {
...
@@ -204,6 +219,8 @@ class DioUtil {
int
_code
;
int
_code
;
String
_msg
;
String
_msg
;
T
_data
;
T
_data
;
T
_extra
;
T
_userType
;
if
(
response
.
statusCode
==
HttpStatus
.
ok
||
if
(
response
.
statusCode
==
HttpStatus
.
ok
||
response
.
statusCode
==
HttpStatus
.
created
)
{
response
.
statusCode
==
HttpStatus
.
created
)
{
try
{
try
{
...
@@ -216,6 +233,7 @@ class DioUtil {
...
@@ -216,6 +233,7 @@ class DioUtil {
:
response
.
data
[
_codeKey
];
:
response
.
data
[
_codeKey
];
_msg
=
response
.
data
[
_msgKey
];
_msg
=
response
.
data
[
_msgKey
];
_data
=
response
.
data
[
_dataKey
];
_data
=
response
.
data
[
_dataKey
];
_extra
=
response
.
data
[
_extraKey
];
}
else
{
}
else
{
Map
<
String
,
dynamic
>
_dataMap
=
_decodeData
(
response
);
Map
<
String
,
dynamic
>
_dataMap
=
_decodeData
(
response
);
_status
=
(
_dataMap
[
_statusKey
]
is
int
)
_status
=
(
_dataMap
[
_statusKey
]
is
int
)
...
@@ -226,8 +244,10 @@ class DioUtil {
...
@@ -226,8 +244,10 @@ class DioUtil {
:
_dataMap
[
_codeKey
];
:
_dataMap
[
_codeKey
];
_msg
=
_dataMap
[
_msgKey
];
_msg
=
_dataMap
[
_msgKey
];
_data
=
_dataMap
[
_dataKey
];
_data
=
_dataMap
[
_dataKey
];
_extra
=
response
.
data
[
_extraKey
];
_userType
=
response
.
data
[
_userType
];
}
}
return
new
BaseResp
(
_status
,
_code
,
_msg
,
_data
);
return
new
BaseResp
(
_status
,
_code
,
_msg
,
_data
,
_extra
,
_userType
);
}
catch
(
e
)
{
}
catch
(
e
)
{
return
new
Future
.
error
(
new
DioError
(
return
new
Future
.
error
(
new
DioError
(
response:
response
,
response:
response
,
...
@@ -260,6 +280,10 @@ class DioUtil {
...
@@ -260,6 +280,10 @@ class DioUtil {
int
_code
;
int
_code
;
String
_msg
;
String
_msg
;
T
_data
;
T
_data
;
T
_extra
;
T
_userType
;
print
(
'打印http response'
);
print
(
response
);
if
(
response
.
statusCode
==
HttpStatus
.
ok
||
if
(
response
.
statusCode
==
HttpStatus
.
ok
||
response
.
statusCode
==
HttpStatus
.
created
)
{
response
.
statusCode
==
HttpStatus
.
created
)
{
try
{
try
{
...
@@ -282,8 +306,10 @@ class DioUtil {
...
@@ -282,8 +306,10 @@ class DioUtil {
:
_dataMap
[
_codeKey
];
:
_dataMap
[
_codeKey
];
_msg
=
_dataMap
[
_msgKey
];
_msg
=
_dataMap
[
_msgKey
];
_data
=
_dataMap
[
_dataKey
];
_data
=
_dataMap
[
_dataKey
];
_extra
=
response
.
data
[
_extraKey
];
_userType
=
response
.
data
[
_userType
];
}
}
return
new
BaseRespR
(
_status
,
_code
,
_msg
,
_data
,
response
);
return
new
BaseRespR
(
_status
,
_code
,
_msg
,
_data
,
_extra
,
_userType
,
response
);
}
catch
(
e
)
{
}
catch
(
e
)
{
return
new
Future
.
error
(
new
DioError
(
return
new
Future
.
error
(
new
DioError
(
response:
response
,
response:
response
,
...
@@ -328,8 +354,6 @@ class DioUtil {
...
@@ -328,8 +354,6 @@ class DioUtil {
/// check Options.
/// check Options.
Options
_checkOptions
(
method
,
options
)
{
Options
_checkOptions
(
method
,
options
)
{
print
(
'_checkOptionsAAAA'
);
print
(
options
);
if
(
options
==
null
)
{
if
(
options
==
null
)
{
options
=
new
Options
();
options
=
new
Options
();
}
}
...
@@ -351,6 +375,14 @@ class DioUtil {
...
@@ -351,6 +375,14 @@ class DioUtil {
_options
.
followRedirects
=
opt
.
followRedirects
??
_options
.
followRedirects
;
_options
.
followRedirects
=
opt
.
followRedirects
??
_options
.
followRedirects
;
}
}
void
_mergeNativeCookie
(
HttpConfig
config
)
{
//合并native cookie
_options
.
headers
=
(
new
Map
.
from
(
_options
.
headers
))..
addAll
(
config
.
nativeCookie
);
print
(
'cookie---------'
);
print
(
_options
.
headers
);
}
/// print Http Log.
/// print Http Log.
void
_printHttpLog
(
Response
response
)
{
void
_printHttpLog
(
Response
response
)
{
if
(!
_isDebug
)
{
if
(!
_isDebug
)
{
...
...
lib/testPage/applicationTest.dart
View file @
f5f15dff
...
@@ -47,10 +47,6 @@ class _WidgetAState extends State<WidgetA> {
...
@@ -47,10 +47,6 @@ class _WidgetAState extends State<WidgetA> {
child:
Column
(
child:
Column
(
children:
<
Widget
>[
children:
<
Widget
>[
Center
(
Center
(
<<<<<<<
HEAD
// child1: Text('data'),
=======
>>>>>>>
dev
child:
FlatButton
(
child:
FlatButton
(
child:
Text
(
'hit me'
),
child:
Text
(
'hit me'
),
onPressed:
(){
onPressed:
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment