Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm_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
林生雨
gm_flutter
Commits
f2ed5c15
Commit
f2ed5c15
authored
Jul 03, 2020
by
杜欣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二级方案
parent
1cb532f5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
186 additions
and
61 deletions
+186
-61
MechanismBoxPage.dart
lib/ClueModel/page/mechanismBox/MechanismBoxPage.dart
+75
-49
MechanismModel.dart
lib/ClueModel/page/mechanismBox/MechanismModel.dart
+35
-5
ClueApi.dart
lib/ClueModel/server/api/ClueApi.dart
+2
-2
ClueApi.serv.dart
lib/ClueModel/server/api/ClueApi.serv.dart
+5
-5
PlanConsultBean.dart
lib/ClueModel/server/entity/PlanConsultBean.dart
+69
-0
No files found.
lib/ClueModel/page/mechanismBox/MechanismBoxPage.dart
View file @
f2ed5c15
import
'package:cached_network_image/cached_network_image.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_common/commonModel/picker/base/BaseBottomPicker.dart'
;
import
'package:
gm_flutter/ClueModel/server/entity/ConsultQuestionsBean
.dart'
;
import
'package:
flutter_common/commonModel/toast/NativeToast
.dart'
;
import
'package:gm_flutter/ClueModel/view/FiveStarView.dart'
;
import
'package:gm_flutter/commonModel/base/BaseComponent.dart'
;
import
'package:gm_flutter/commonModel/base/BaseUtil.dart'
;
import
'package:gm_flutter/ClueModel/page/mechanismBox/MechanismModel.dart'
;
class
MechanismBox
implements
IBottomPicker
{
VoidCallback
dismissCall
;
TextEditingController
textController
=
TextEditingController
();
MechanismModel
_model
=
new
MechanismModel
();
List
<
int
>
doctor_ids
=
new
List
();
@required
final
int
plan_id
;
...
...
@@ -186,7 +185,6 @@ class MechanismBox implements IBottomPicker {
width:
double
.
maxFinite
,
margin:
EdgeInsets
.
only
(
top:
12
),
child:
Row
(
mainAxisSize:
MainAxisSize
.
max
,
children:
<
Widget
>[
Container
(
margin:
EdgeInsets
.
only
(
left:
15
,
right:
8
),
...
...
@@ -198,40 +196,47 @@ class MechanismBox implements IBottomPicker {
color:
Color
(
0xff666666
),
fontSize:
12
),
)),
StreamBuilder
<
ConsultQuestionsBean
>(
stream:
_model
.
questionsLive
.
stream
,
initialData:
_model
.
questionsLive
.
data
,
builder:
(
c
,
data
)
{
List
<
String
>
questions
=
data
.
data
.
data
.
questions
;
return
ListView
.
builder
(
scrollDirection:
Axis
.
horizontal
,
//横向滚动
itemBuilder:
(
c
,
index
)
{
return
GestureDetector
(
onTap:
()
{
textController
.
text
+=
questions
[
index
];
},
child:
Container
(
height:
25
,
margin:
EdgeInsets
.
only
(
right:
12
),
padding:
EdgeInsets
.
only
(
left:
8
,
right:
8
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
Color
(
0xffE5E5E5
),
width:
0.5
),
color:
Color
(
0xffffffff
),
borderRadius:
BorderRadius
.
circular
(
20
)),
child:
Text
(
questions
[
index
],
style:
TextStyle
(
fontSize:
12
,
color:
Color
(
0xff666666
),
height:
1.8
),
Expanded
(
child:
StreamBuilder
<
List
<
String
>>(
stream:
_model
.
questionsLive
.
stream
,
initialData:
_model
.
questionsLive
.
data
??
null
,
builder:
(
c
,
e
)
{
if
(
e
.
data
==
null
)
{
return
Container
();
}
List
<
String
>
questions
=
e
.
data
;
return
ListView
.
builder
(
scrollDirection:
Axis
.
horizontal
,
//横向滚动
itemBuilder:
(
c
,
index
)
{
return
GestureDetector
(
onTap:
()
{
textController
.
text
+=
questions
[
index
];
},
child:
Container
(
height:
25
,
margin:
EdgeInsets
.
only
(
right:
12
),
padding:
EdgeInsets
.
only
(
left:
8
,
right:
8
),
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
Color
(
0xffE5E5E5
),
width:
0.5
),
color:
Color
(
0xffffffff
),
borderRadius:
BorderRadius
.
circular
(
20
)),
child:
Text
(
questions
[
index
],
style:
TextStyle
(
fontSize:
12
,
color:
Color
(
0xff666666
),
height:
1.8
),
),
),
)
,
);
}
,
itemCount:
questions
.
length
,
);
}),
)
;
},
itemCount:
questions
.
length
,
);
}),
)
],
)),
Container
(
...
...
@@ -242,18 +247,39 @@ class MechanismBox implements IBottomPicker {
border:
Border
.
all
(
color:
Color
(
0xffE5E5E5
),
width:
0.5
),
color:
Color
(
0xffffffff
),
borderRadius:
BorderRadius
.
circular
(
35
)),
child:
TextField
(
controller:
textController
,
keyboardType:
TextInputType
.
text
,
textInputAction:
TextInputAction
.
send
,
onSubmitted:
(
txt
)
{},
style:
TextStyle
(
fontSize:
12
),
maxLines:
1
,
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
only
(
left:
16
,
top:
0
,
bottom:
12
,
right:
16
),
hintText:
'请输入您想了解的问题'
,
border:
InputBorder
.
none
)))
child:
StreamBuilder
(
stream:
_model
.
messageLive
.
stream
,
initialData:
_model
.
messageLive
.
data
??
null
,
builder:
(
context
,
snapshot
)
{
return
TextField
(
controller:
textController
,
keyboardType:
TextInputType
.
text
,
textInputAction:
TextInputAction
.
send
,
onSubmitted:
(
txt
)
{
if
(!(
doctor_ids
.
length
>
3
||
doctor_ids
.
length
<
1
))
{
NativeToast
.
showNativeToast
(
'请选择1-3个机构咨询'
);
}
else
{
if
(
txt
==
''
)
{
NativeToast
.
showNativeToast
(
'text'
);
}
else
{
_model
.
sendMessage
(
doctor_ids
,
txt
,
plan_id
);
}
// dismissCall();
// textController.text = '';
// NativeToast.showNativeToast('消息已发送成功');
}
},
style:
TextStyle
(
fontSize:
12
),
maxLines:
1
,
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
only
(
left:
16
,
top:
0
,
bottom:
12
,
right:
16
),
hintText:
'请输入您想了解的问题'
,
border:
InputBorder
.
none
));
},
))
],
));
}
...
...
lib/ClueModel/page/mechanismBox/MechanismModel.dart
View file @
f2ed5c15
...
...
@@ -2,27 +2,56 @@
* @author lsy
* @date 2020/6/29
**/
import
'dart:math'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_common/commonModel/live/BaseModel.dart'
;
import
'package:flutter_common/commonModel/live/LiveData.dart'
;
import
'package:flutter_common/commonModel/toast/NativeToast.dart'
;
import
'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/ConsultQuestionsBean.dart'
;
import
'package:gm_flutter/commonModel/net/DioUtil.dart'
;
import
'package:gm_flutter/commonModel/rx/RxDispose.dart'
;
import
'package:gm_flutter/commonModel/util/PrintUtil.dart'
;
import
'../../../commonModel/net/DioUtil.dart'
;
import
'../../../commonModel/util/PrintUtil.dart'
;
import
'../../server/api/ClueApi.serv.dart'
;
class
MechanismModel
extends
BaseModel
{
LiveData
<
ConsultQuestionsBean
>
questionsLive
=
LiveData
();
LiveData
<
List
<
String
>>
questionsLive
=
LiveData
();
LiveData
messageLive
=
LiveData
();
RxDispose
rxDispose
=
RxDispose
();
getQuestions
(
int
plan_id
)
{
ClueApiImpl
.
getInstance
()
.
getConsultQuestions
(
DioUtil
.
getInstance
().
getDio
(),
plan_id
)
.
listen
((
event
)
{
print
(
'dadsadsa'
);
print
(
event
.
data
.
questions
.
toList
());
print
(
'dadsadsa'
);
questionsLive
.
data
=
event
;
if
(
event
.
error
==
0
)
{
questionsLive
.
notifyView
(
event
.
data
.
questions
);
}
else
{
NativeToast
.
showNativeToast
(
event
.
message
);
//TODO
}
})
.
addToDispose
(
rxDispose
)
.
onError
((
err
)
{
PrintUtil
.
printBug
(
err
);
});
}
sendMessage
(
List
<
int
>
doctor_ids
,
String
question
,
int
plan_id
)
{
ClueApiImpl
.
getInstance
()
.
sendMessage
(
DioUtil
.
getInstance
().
getDio
(),
doctor_ids
,
question
,
plan_id
)
.
listen
((
event
)
{
print
(
'11111'
);
if
(
event
.
error
==
0
)
{
print
(
'kljfjkfdhkhkdfsklkds'
);
messageLive
.
notifyView
(
event
.
data
.
success
);
}
else
{
NativeToast
.
showNativeToast
(
event
.
message
);
}
})
.
addToDispose
(
rxDispose
)
.
onError
((
err
)
{
...
...
@@ -33,5 +62,6 @@ class MechanismModel extends BaseModel {
@override
void
dispose
()
{
questionsLive
.
dispost
();
rxDispose
.
dispose
();
}
}
lib/ClueModel/server/api/ClueApi.dart
View file @
f2ed5c15
...
...
@@ -9,12 +9,12 @@ import 'package:flutter_common/Annotations/anno/ServiceCenter.dart';
import
'package:gm_flutter/ClueModel/server/entity/ConsultQuestionsBean.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/PlanCompareDetail.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/PlanConsultBean.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/PlanOverviewBean.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/PlansCompareFeed.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/ProjectDetailsItem.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/PlanBean.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart'
;
import
'package:gm_flutter/commonModel/net/Responce/SimpleResponce.dart'
;
@ServiceCenter
()
abstract
class
ClueApi
{
...
...
@@ -53,6 +53,6 @@ abstract class ClueApi {
ConsultQuestionsBean
getConsultQuestions
(
@Query
(
"plan_id"
)
int
plan_id
);
@Post
(
"/api/janus/plans/plan_consult"
)
SimpleResponce
sendMessage
(
@Query
(
"doctor_ids"
)
List
<
int
>
doctor_ids
,
PlanConsultBean
sendMessage
(
@Query
(
"doctor_ids"
)
List
<
int
>
doctor_ids
,
@Query
(
"question"
)
String
question
,
@Query
(
"plan_id"
)
int
plan_id
);
}
lib/ClueModel/server/api/ClueApi.serv.dart
View file @
f2ed5c15
...
...
@@ -22,7 +22,7 @@ import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart';
import
'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/PlanOverviewBean.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/ConsultQuestionsBean.dart'
;
import
'package:gm_flutter/
commonModel/net/Responce/SimpleResponce
.dart'
;
import
'package:gm_flutter/
ClueModel/server/entity/PlanConsultBean
.dart'
;
const
bool
inProduction
=
const
bool
.
fromEnvironment
(
"dart.vm.product"
);
...
...
@@ -171,7 +171,7 @@ class ClueApiImpl {
});
}
Stream
<
SimpleResponce
>
sendMessage
(
Stream
<
PlanConsultBean
>
sendMessage
(
Dio
_dio
,
List
<
int
>
doctor_ids
,
String
question
,
int
plan_id
)
{
return
Stream
.
fromFuture
(
post
(
_dio
,
'/api/janus/plans/plan_consult'
,
data:
{
'doctor_ids'
:
doctor_ids
,
...
...
@@ -181,7 +181,7 @@ class ClueApiImpl {
if
(
value
!=
null
&&
(
value
.
statusCode
>=
200
&&
value
.
statusCode
<
300
))
{
return
Stream
.
fromFuture
(
compute
(
parse
SimpleResponce
,
value
.
toString
()));
compute
(
parse
PlanConsultBean
,
value
.
toString
()));
}
else
{
throw
Exception
(
"--未知网络错误--"
);
}
...
...
@@ -357,6 +357,6 @@ ConsultQuestionsBean parseConsultQuestionsBean(String value) {
return
ConsultQuestionsBean
.
fromJson
(
json
.
decode
(
value
));
}
SimpleResponce
parseSimpleResponce
(
String
value
)
{
return
SimpleResponce
.
fromJson
(
json
.
decode
(
value
));
PlanConsultBean
parsePlanConsultBean
(
String
value
)
{
return
PlanConsultBean
.
fromJson
(
json
.
decode
(
value
));
}
lib/ClueModel/server/entity/PlanConsultBean.dart
0 → 100644
View file @
f2ed5c15
class
PlanConsultBean
{
int
error
;
String
message
;
Null
extra
;
Null
errorExtra
;
UserType
userType
;
Data
data
;
PlanConsultBean
(
{
this
.
error
,
this
.
message
,
this
.
extra
,
this
.
errorExtra
,
this
.
userType
,
this
.
data
});
PlanConsultBean
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
error
=
json
[
'error'
];
message
=
json
[
'message'
];
extra
=
json
[
'extra'
];
errorExtra
=
json
[
'error_extra'
];
userType
=
json
[
'user_type'
]
!=
null
?
new
UserType
.
fromJson
(
json
[
'user_type'
])
:
null
;
data
=
json
[
'data'
]
!=
null
?
new
Data
.
fromJson
(
json
[
'data'
])
:
null
;
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'error'
]
=
this
.
error
;
data
[
'message'
]
=
this
.
message
;
data
[
'extra'
]
=
this
.
extra
;
data
[
'error_extra'
]
=
this
.
errorExtra
;
if
(
this
.
userType
!=
null
)
{
data
[
'user_type'
]
=
this
.
userType
.
toJson
();
}
if
(
this
.
data
!=
null
)
{
data
[
'data'
]
=
this
.
data
.
toJson
();
}
return
data
;
}
}
class
UserType
{
UserType
();
UserType
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
return
data
;
}
}
class
Data
{
bool
success
;
Data
({
this
.
success
});
Data
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
success
=
json
[
'success'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'success'
]
=
this
.
success
;
return
data
;
}
}
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