Commit 733b0c1b authored by 杜欣's avatar 杜欣

Ui走查

parent 3d2d9451
......@@ -58,6 +58,7 @@ class LevelTwoState extends BaseState<LevelTwoPage>
@override
void initState() {
DioUtil.getInstance().setProxy('172.30.9.253');
super.initState();
_model.plan_id = widget.planId;
_model.init(() {
......@@ -340,8 +341,8 @@ class LevelTwoState extends BaseState<LevelTwoPage>
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
baseText(element.attrName, 14, Color(0xff282828), bold: true),
baseText(element.attrValue, 11, Color(0xff999999)),
baseText(element.attrValue, 14, Color(0xff282828), bold: true),
baseText(element.attrName, 11, Color(0xff999999)),
],
),
),
......@@ -362,7 +363,7 @@ class LevelTwoState extends BaseState<LevelTwoPage>
),
width: double.maxFinite,
height: 62,
margin: EdgeInsets.only(left: 15, right: 15, bottom: 20),
margin: EdgeInsets.only(left: 15, right: 15, bottom: 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: list,
......@@ -373,6 +374,7 @@ class LevelTwoState extends BaseState<LevelTwoPage>
Widget explain() {
List<Widget> list = [];
list.add(Container(
margin: EdgeInsets.only(bottom: 4),
height: 31,
child: Row(
children: <Widget>[
......@@ -399,12 +401,12 @@ class LevelTwoState extends BaseState<LevelTwoPage>
if (_model.planoverItem != null) {
_model.planoverItem.explanationAttrs.forEach((element) {
list.add(Container(
margin: EdgeInsets.only(bottom: 15),
margin: EdgeInsets.only(bottom: 10),
child: Row(
children: <Widget>[
Container(
constraints: BoxConstraints(
maxWidth: 52,
maxWidth: 54,
),
child: Text(
element.attrName,
......@@ -444,7 +446,7 @@ class LevelTwoState extends BaseState<LevelTwoPage>
});
}
return Container(
margin: EdgeInsets.only(left: 15, right: 15, bottom: 20),
margin: EdgeInsets.only(left: 15, right: 15, bottom: 3),
child: Column(
mainAxisSize: MainAxisSize.min,
children: list,
......
......@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/picker/base/BaseBottomPicker.dart';
import 'package:flutter_common/commonModel/toast/NativeToast.dart';
import 'package:gm_flutter/ClueModel/page/levelOne/LevelOneListModel.dart';
import 'package:gm_flutter/ClueModel/server/entity/ConsultHospitalsBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
import 'package:gm_flutter/ClueModel/view/FiveStarView.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
......@@ -16,9 +17,7 @@ class MechanismBox implements IBottomPicker {
VoidCallback dismissCall;
TextEditingController textController = TextEditingController();
MechanismModel _model = new MechanismModel();
List<String> doctor_ids = new List();
LevelOneListModel _levelModel = LevelOneListModel();
RefreshController refreshController = RefreshController();
Function(String str) refresh;
......@@ -35,13 +34,13 @@ class MechanismBox implements IBottomPicker {
@override
initState(dismissCall, BuildContext context) {
this.dismissCall = dismissCall;
_levelModel.plan_id = plan_id;
_levelModel.tab_type = "hospital";
_model.plan_id = plan_id;
_model.tab_type = "hospital";
_model.getQuestions(plan_id);
_levelModel.refreshView(true);
_model.refreshView(true);
refresh = (str) {
_levelModel.stateLive.notifyView(LOADING);
_levelModel.refreshView(true);
_model.stateLive.notifyView(LOADING);
_model.refreshView(true);
};
}
......@@ -93,7 +92,7 @@ class MechanismBox implements IBottomPicker {
RouterCenterImpl().findMainRouter().buriedEvent("page_view", map);
textController.dispose();
refreshController.dispose();
_levelModel.dispose();
_model.dispose();
_model.dispose();
focusNode.dispose();
}
......@@ -104,8 +103,8 @@ class MechanismBox implements IBottomPicker {
children: <Widget>[
title(mq),
StreamBuilder(
stream: _levelModel.stateLive.stream,
initialData: _levelModel.stateLive.data ?? LOADING,
stream: _model.stateLive.stream,
initialData: _model.stateLive.data ?? LOADING,
builder: (c, data) {
if (data.data == LOADING) {
return Container(
......@@ -117,7 +116,7 @@ class MechanismBox implements IBottomPicker {
if (data.data == FAIL) {
return errorItem(MediaQuery.of(context).size.width,
mq.size.height - 140 - 96 - 50 - keyHeight, () {
_levelModel.refreshView(true);
_model.refreshView(true);
});
}
if (data.data == EMPTY) {
......@@ -137,45 +136,41 @@ class MechanismBox implements IBottomPicker {
// 弹窗标题
Widget title(mq) {
return Container(
margin: EdgeInsets.only(left: 15, right: 15),
width: mq.size.width,
decoration: BoxDecoration(
border:
Border(bottom: BorderSide(width: .5, color: Color(0xffE5E5E5)))),
height: 50,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Container(
child: Text(
'请选择要咨询的机构',
style: TextStyle(color: Color(0xff282828), fontSize: 17),
),
),
Positioned(
right: 5,
top: 16.5,
child: GestureDetector(
onTap: () {
dismissCall();
},
child: Container(
width: 13.5,
height: 13.5,
child: Image.asset("assets/close-btn.png"),
return GestureDetector(
onTap: () {
dismissCall();
},
child: Container(
margin: EdgeInsets.only(left: 15, right: 15),
width: mq.size.width,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(width: .5, color: Color(0xffE5E5E5)))),
height: 50,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Container(
child: Text(
'请选择要咨询的机构',
style: TextStyle(color: Color(0xff282828), fontSize: 17),
),
))
],
),
);
),
Positioned(
right: 5,
top: 16.5,
child: Container(
width: 13.5,
height: 13.5,
child: Image.asset("assets/close-btn.png"),
))
],
),
));
}
// 机构列表
Widget mechanismList(mq, keyHeight) {
Hospital firstHospital = _levelModel.cardsLive.data[0].hospital;
firstHospital.isCheck = true;
doctor_ids.add(firstHospital.doctorId);
return Container(
height: mq.size.height - 286 - keyHeight,
width: mq.size.width,
......@@ -184,11 +179,11 @@ class MechanismBox implements IBottomPicker {
customScrollView: CustomScrollView(
physics: ClampingScrollPhysics(),
slivers: <Widget>[
StreamBuilder<List<Cards>>(
stream: _levelModel.cardsLive.stream,
initialData: _levelModel.cardsLive.data ?? [],
StreamBuilder<List<Hospitals>>(
stream: _model.cardsLive.stream,
initialData: _model.cardsLive.data ?? [],
builder: (c, data) {
if (data.data.isEmpty && _levelModel.page > 1) {
if (data.data.isEmpty && _model.page > 1) {
refreshController.loadNoData();
} else {
refreshController.loadComplete();
......@@ -196,44 +191,42 @@ class MechanismBox implements IBottomPicker {
return SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
if (index == _levelModel.data.length) {
if (index == _model.data.length) {
return Container(
height: 0,
color: Color(0xffF7F6FA),
);
}
if (_levelModel.data[index].cardType == 'hospital') {
return HospitalItem(
_levelModel.data[index].hospital, index);
} else {
return Container();
}
return HospitalItem(_model.data[index], index);
},
childCount: _levelModel.data.length + 1,
childCount: _model.data.length + 1,
),
);
},
),
],
), onLoading: () {
_levelModel.loadMore();
_model.loadMore();
}, pullDown: false, pullUp: true));
}
// 机构卡片
Widget HospitalItem(Hospital hospital, index) {
Widget HospitalItem(Hospitals hospital, index) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (doctor_ids.contains(hospital.doctorId)) {
doctor_ids.remove(hospital.doctorId);
if (_model.doctor_ids.contains(hospital.doctorId)) {
_model.doctor_ids.remove(hospital.doctorId);
_model.hospital_ids.remove(hospital.hospitalId);
} else {
doctor_ids.add(hospital.doctorId);
_model.doctor_ids.add(hospital.doctorId);
_model.hospital_ids.add(hospital.hospitalId);
}
hospital.isCheck = !hospital.isCheck;
focusNode.unfocus();
_levelModel.cardsLive.notifyView(_levelModel.cardsLive.data);
if (doctor_ids.length > 3 || doctor_ids.length == 0) {
_model.cardsLive.notifyView(_model.cardsLive.data);
int length = _model.doctor_ids.length;
if (length > 3 || length == 0) {
NativeToast.showNativeToast('请选择1-3个机构咨询');
}
},
......@@ -267,8 +260,11 @@ class MechanismBox implements IBottomPicker {
),
Positioned(
left: 89,
top: 16,
child: baseText(hospital.name, 15, Color(0xff333333)),
top: 13,
child: Container(
width: 230,
child: baseText(hospital.name, 15, Color(0xff282828)),
),
),
Positioned(
top: 38,
......@@ -278,18 +274,22 @@ class MechanismBox implements IBottomPicker {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
baseText("¥", 12, Color(0xffFF5963)),
baseText("${hospital.minPrice}-${hospital.maxPrice}", 15,
baseText(
hospital.minPrice == hospital.maxPrice
? "${hospital.minPrice}-${hospital.maxPrice}"
: "${hospital.minPrice}",
15,
Color(0xffFF5963),
bold: true),
bold: true)
],
),
),
Positioned(
bottom: 16,
bottom: 14,
left: 89,
child: Container(
width: 230,
child: baseText(hospital.address, 12, Color(0xff666666)),
child: baseText(hospital.address, 12, Color(0xff999999)),
),
),
Positioned(
......@@ -386,19 +386,19 @@ class MechanismBox implements IBottomPicker {
focusNode: focusNode,
textInputAction: TextInputAction.send,
onSubmitted: (txt) {
if (doctor_ids.length > 3 || doctor_ids.length < 1) {
NativeToast.showNativeToast('请选择1-3个机构咨询');
} else {
if (txt.isNotEmpty) {
_model.sendMessage(
doctor_ids.join(','), txt, plan_id, (i) {
if (i == 0) {
dismissCall();
textController.text = '';
NativeToast.showNativeToast('消息已发送成功');
}
});
}
print(_model.hospital_ids.toList());
if (txt.isNotEmpty) {
_model.sendMessage(
_model.doctor_ids.join(','),
_model.hospital_ids.join(','),
txt,
plan_id, (i) {
if (i == 0) {
dismissCall();
textController.text = '';
NativeToast.showNativeToast('消息已发送成功');
}
});
}
},
style:
......@@ -411,7 +411,7 @@ class MechanismBox implements IBottomPicker {
hintStyle: TextStyle(
color: Color(0xff999999),
fontSize: 12,
height: 2.2),
height: 2.3),
border: InputBorder.none));
},
))
......
......@@ -2,17 +2,18 @@
* @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/ConsultHospitalsBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.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 'package:gm_flutter/commonModel/bean/Pair.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class MechanismModel extends BaseModel {
LiveData<List<String>> questionsLive = LiveData();
......@@ -21,6 +22,59 @@ class MechanismModel extends BaseModel {
LiveData messageLive = LiveData();
RxDispose rxDispose = RxDispose();
List<String> doctor_ids = new List();
List<String> hospital_ids = new List();
int plan_id;
String tab_type;
int page = 1;
LiveData<int> levelStateLive = LiveData();
LiveData<List<Hospitals>> cardsLive = LiveData();
List<Hospitals> data = [];
void refreshView(bool clear, {RefreshController refreshListener}) {
if (clear) {
data.clear();
page = 1;
}
ClueApiImpl.getInstance()
.getLevelMechanismList(DioUtil.getInstance().getDio(), plan_id, page)
.listen((event) {
if (event.error == 0) {
if ((event.data.hospitals == null ||
event.data.hospitals.isEmpty)) {
if (page == 1) {
levelStateLive.notifyView(EMPTY);
} else {
cardsLive.notifyView([]);
}
} else {
if (page == 1) {
for (var i = 0; i < event.data.hospitals.length; i++) {
if (i < 3) {
event.data.hospitals[i].isCheck = true;
doctor_ids.add(event.data.hospitals[i].doctorId);
hospital_ids.add(event.data.hospitals[i].hospitalId);
}
}
}
data.addAll(event.data.hospitals);
cardsLive.notifyView(data);
levelStateLive.notifyView(ENDLOADING);
}
} else {
NativeToast.showNativeToast(event.message);
levelStateLive.notifyView(FAIL);
}
})
.addToDispose(rxDispose)
.onError((err) {
PrintUtil.printBug(err);
levelStateLive.notifyView(FAIL);
});
}
getQuestions(int plan_id) {
ClueApiImpl.getInstance()
.getConsultQuestions(DioUtil.getInstance().getDio(), plan_id)
......@@ -42,11 +96,11 @@ class MechanismModel extends BaseModel {
});
}
sendMessage(String doctor_ids, String question, int plan_id,
Function(int state) func) {
sendMessage(String doctor_ids, String hospital_ids, String question,
int plan_id, Function(int state) func) {
ClueApiImpl.getInstance()
.sendMessage(
DioUtil.getInstance().getDio(), doctor_ids, question, plan_id)
.sendMessage(DioUtil.getInstance().getDio(), doctor_ids, hospital_ids,
question, plan_id)
.listen((event) {
print(event.toJson());
if (event.error == 0) {
......@@ -67,5 +121,12 @@ class MechanismModel extends BaseModel {
questionsLive.dispost();
stateLive.dispost();
rxDispose.dispose();
levelStateLive.dispost();
cardsLive.dispost();
}
void loadMore() {
page++;
refreshView(false);
}
}
......@@ -6,6 +6,7 @@ import 'package:flutter_common/Annotations/anno/Get.dart';
import 'package:flutter_common/Annotations/anno/Post.dart';
import 'package:flutter_common/Annotations/anno/Query.dart';
import 'package:flutter_common/Annotations/anno/ServiceCenter.dart';
import 'package:gm_flutter/ClueModel/server/entity/ConsultHospitalsBean.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/PlanBarBean.dart';
......@@ -31,6 +32,10 @@ abstract class ClueApi {
LevelOneFeedList getLevelOneList(@Query("plan_id") int plan_id,
@Query("tab_type") String tab_type, @Query("page") int page);
@Get("api/janus/plans/consult_hospitals")
ConsultHospitalsBean getLevelMechanismList(
@Query("plan_id") int plan_id, @Query("page") int page);
@Get("api/janus/plans/plan_compare")
PlanCompareDetail getPlanCompareDetail(@Query("plan_ids") String planIds);
......@@ -52,8 +57,11 @@ abstract class ClueApi {
ConsultQuestionsBean getConsultQuestions(@Query("plan_id") int plan_id);
@Post("api/janus/plans/plan_consult")
PlanConsultBean sendMessage(@Query("doctor_ids") List<int> doctor_ids,
@Query("question") String question, @Query("plan_id") int plan_id);
PlanConsultBean sendMessage(
@Query("doctor_ids") String doctor_ids,
@Query("hospital_ids") String hospital_ids,
@Query("question") String question,
@Query("plan_id") int plan_id);
@Get("api/janus/plans/rank")
PlanBarBean getPlanBar(@Query("rank_type") String rank_type);
......
......@@ -17,6 +17,7 @@ import 'package:flutter/foundation.dart';
import 'package:gm_flutter/ClueModel/server/entity/ProjectDetailsItem.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlansCompareFeed.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
import 'package:gm_flutter/ClueModel/server/entity/ConsultHospitalsBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanCompareDetail.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart';
......@@ -89,6 +90,23 @@ class ClueApiImpl {
});
}
Stream<ConsultHospitalsBean> getLevelMechanismList(
Dio _dio, int plan_id, int page) {
return Stream.fromFuture(
get(_dio, 'api/janus/plans/consult_hospitals', data: {
'plan_id': plan_id,
'page': page,
})).flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Stream.fromFuture(
compute(parseConsultHospitalsBean, value.toString()));
} else {
throw Exception("--未知网络错误--");
}
});
}
Stream<PlanCompareDetail> getPlanCompareDetail(Dio _dio, String planIds) {
return Stream.fromFuture(get(_dio, 'api/janus/plans/plan_compare', data: {
'plan_ids': planIds,
......@@ -159,10 +177,11 @@ class ClueApiImpl {
});
}
Stream<PlanConsultBean> sendMessage(
Dio _dio, String doctor_ids, String question, int plan_id) {
Stream<PlanConsultBean> sendMessage(Dio _dio, String doctor_ids,
String hospital_ids, String question, int plan_id) {
return Stream.fromFuture(post(_dio, 'api/janus/plans/plan_consult', data: {
'doctor_ids': doctor_ids,
'hospital_ids': hospital_ids,
'question': question,
'plan_id': plan_id,
})).flatMap((value) {
......@@ -372,6 +391,10 @@ LevelOneFeedList parseLevelOneFeedList(String value) {
return LevelOneFeedList.fromJson(json.decode(value));
}
ConsultHospitalsBean parseConsultHospitalsBean(String value) {
return ConsultHospitalsBean.fromJson(json.decode(value));
}
PlanCompareDetail parsePlanCompareDetail(String value) {
return PlanCompareDetail.fromJson(json.decode(value));
}
......
class ConsultHospitalsBean {
int error;
String message;
Map extra;
Map errorExtra;
UserType userType;
Data data;
ConsultHospitalsBean(
{this.error,
this.message,
this.extra,
this.errorExtra,
this.userType,
this.data});
ConsultHospitalsBean.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 {
List<Hospitals> hospitals;
Data({this.hospitals});
Data.fromJson(Map<String, dynamic> json) {
if (json['hospitals'] != null) {
hospitals = new List<Hospitals>();
json['hospitals'].forEach((v) {
hospitals.add(new Hospitals.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.hospitals != null) {
data['hospitals'] = this.hospitals.map((v) => v.toJson()).toList();
}
return data;
}
}
class Hospitals {
String hospitalId;
String doctorId;
String portrait;
String name;
String minPrice;
String maxPrice;
String star;
String address;
String consultType;
String messageUrl;
bool isCheck = false;
Hospitals(
{this.hospitalId,
this.doctorId,
this.portrait,
this.name,
this.minPrice,
this.maxPrice,
this.star,
this.address,
this.consultType,
this.messageUrl});
Hospitals.fromJson(Map<String, dynamic> json) {
hospitalId = json['hospital_id'];
doctorId = json['doctor_id'];
portrait = json['portrait'];
name = json['name'];
minPrice = json['min_price'];
maxPrice = json['max_price'];
star = json['star'];
address = json['address'];
consultType = json['consult_type'];
messageUrl = json['message_url'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['hosiptal_id'] = this.hospitalId;
data['doctor_id'] = this.doctorId;
data['portrait'] = this.portrait;
data['name'] = this.name;
data['min_price'] = this.minPrice;
data['max_price'] = this.maxPrice;
data['star'] = this.star;
data['address'] = this.address;
data['consult_type'] = this.consultType;
data['message_url'] = this.messageUrl;
return data;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment