Commit 54917347 authored by 林生雨's avatar 林生雨

commit

parent 0bf3f8ad
......@@ -4,6 +4,7 @@
* @Last Modified by: zx
* @Last Modified time: 2020-07-04 12:20:45
*/
import 'package:dio/dio.dart';
import 'package:flutter_common/commonModel/live/BaseModel.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
import 'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart';
......@@ -16,8 +17,6 @@ import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceAuthBean.dart'
class DiscussLowPriceModel extends BaseModel {
LiveData<Pair<int, DiscussLowPriceModelBean>> popViewLive = LiveData();
LiveData<bool> phoneAuthLive = LiveData();
RxDispose rxDispose = RxDispose();
fetchPopviewData(String planId, String hospitalId, String doctorId) {
......@@ -43,26 +42,27 @@ class DiscussLowPriceModel extends BaseModel {
});
}
givePhoneAuth(int leadPhoneRequestId) {
givePhoneAuth(int leadPhoneRequestId, VoidCallback callback) {
popViewLive.notifyView(Pair(ENDLOADING, null));
ClueApiImpl.getInstance()
.givePhoneAuth(DioUtil.getInstance().getDio(), leadPhoneRequestId)
.listen((event) {
if (event.error == 0) {
phoneAuthLive.notifyView(event.data.success);
} else {
NativeToast.showNativeToast(event.message);
phoneAuthLive.notifyView(false);
}
callback();
})
.addToDispose(rxDispose)
.onError((err) {
phoneAuthLive.notifyView(false);
NativeToast.showNativeToast(err.message);
callback();
});
}
@override
void dispose() {
popViewLive.dispost();
rxDispose.dispose();
}
}
......@@ -6,9 +6,11 @@
*/
import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/picker/base/BaseCenterPicker.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceModelBean.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/ClueModel/page/DiscussLowPrice/DiscussLowPriceModel.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart';
class DiscussLowPricePopView {
static void showPopView(BuildContext content) {
......@@ -22,101 +24,98 @@ class _PopView implements ICenterPicker {
VoidCallback dismissCallback;
double contentWidth;
DiscussLowPriceModel _model = new DiscussLowPriceModel();
@override
Widget build(BuildContext context, int alp) {
contentWidth = MediaQuery.of(context).size.width - 72;
return StreamBuilder(
return StreamBuilder<Pair<int, DiscussLowPriceModelBean>>(
stream: _model.popViewLive.stream,
initialData: _model.popViewLive ?? Pair(LOADING, null),
initialData: _model.popViewLive.data ?? Pair(LOADING, null),
builder: (c, data) {
if (data.data.first == LOADING) {
return loadingItem();
}
if (data.data.second == null || data.data.first == FAIL) {
return Container(
height: 0,
width: 0,
);
return errorItem(contentWidth, 308.5, () {});
}
return Container(
width: contentWidth,
alignment: AlignmentDirectional.center,
return Opacity(
opacity: alp / 255.0,
child: Container(
child: Container(
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
width: contentWidth,
height: 308.5,
child: Stack(
alignment: AlignmentDirectional.topCenter,
children: <Widget>[
Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: 42.5,
width: contentWidth,
),
Container(
margin: EdgeInsets.only(bottom: 0),
child: Stack(children: <Widget>[
Container(
Positioned(
top: 42.5,
child: setupBodyView(),
),
Positioned(
top: 20,
top: 62.5,
right: 20,
width: 16,
height: 16,
width: 13.5,
height: 13.5,
child: GestureDetector(
onTap: () {
dismissCallback();
},
child: Image.asset(
'assets/discuss_loe_price_cancel.png',
fit: BoxFit.cover),
))
]))
]),
'assets/discuss_loe_price_cancel.png'),
)),
Container(
margin: EdgeInsets.only(top: 0),
width: 85,
height: 85,
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Colors.black12,
offset: Offset(0.0, 15.0),
blurRadius: 15.0,
spreadRadius: 1.0)
], shape: BoxShape.circle),
child: ClipOval(
child: Image.network(
_model.popViewLive.data.second.icon,
fit: BoxFit.cover),
),
)
]),
)));
));
});
}
setupBodyView() {
return Container(
height: 266,
width: contentWidth,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7),
color: Colors.white,
),
child: Container(
alignment: Alignment.center,
margin: EdgeInsets.only(bottom: 0, top: 42.5),
margin: EdgeInsets.only(bottom: 0, top: 44),
child: detailView(),
),
);
}
detailView() {
return Container(
child: Column(
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: 19,
margin: EdgeInsets.only(bottom: 14),
margin: EdgeInsets.only(bottom: 13.5),
alignment: AlignmentDirectional.center,
child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: 16,
height: 16,
child: Image.asset(
'assets/discuss_loe_price_like.png',
fit: BoxFit.cover,
)),
Container(
margin: EdgeInsets.only(left: 4),
......@@ -126,8 +125,6 @@ class _PopView implements ICenterPicker {
]),
),
Container(
alignment: AlignmentDirectional.center,
width: contentWidth - 70,
margin: EdgeInsets.only(bottom: 25),
child: baseText(
_model.popViewLive.data.second.title, 18, Color(0xff464646),
......@@ -141,32 +138,30 @@ class _PopView implements ICenterPicker {
margin: EdgeInsets.only(bottom: 12),
width: contentWidth - 70,
height: 37,
child: baseText(_model.popViewLive.data.second.authorizePhone,
16, Color(0xff484848))),
child: baseText(_model.popViewLive.data.second.authorizePhone, 16,
Color(0xff484848))),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7),
),
child: GestureDetector(
onTap: () {
// 一键授权
_model.givePhoneAuth(111);
dismissCallback();
},
child: Container(
margin: EdgeInsets.only(bottom: 14),
width: contentWidth - 70,
height: 37,
child: Image.asset('assets/discuss_loe_price_auth.png',
fit: BoxFit.cover)))),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(7),
// color: Color.fromARGB(alp, 58, 195, 189)
// ),
child: Image.asset(
"assets/discuss_loe_price_auth.png",
),
).gestureDetector(() {
// 一键授权
_model.givePhoneAuth(111, () {
dismissCallback();
});
}),
Container(
width: contentWidth - 70,
margin: EdgeInsets.only(bottom: 25),
alignment: AlignmentDirectional.center,
child:
baseText('授权后,您的手机将以“虚拟号”方式提供给机构', 11, Color(0xff999999))),
]),
);
margin: EdgeInsets.only(bottom: 23.5),
child: baseText('授权后,您的手机将以“虚拟号”方式提供给机构', 11, Color(0xff999999))),
]);
}
@override
......
......@@ -41,10 +41,10 @@ class LevelOneState extends BaseState<LevelOnePage>
@override
void initState() {
super.initState();
// Future.delayed(Duration(seconds: 3), () {
// _model.loadingLive.notifyView(false);
// _model.refreshView(true);
// });
Future.delayed(Duration(seconds: 3), () {
_model.loadingLive.notifyView(false);
_model.refreshView(true);
});
pageController.addListener(() {
if (screenWidth != null) {
_model.topScrollLive.notifyView(
......@@ -501,8 +501,8 @@ class LevelOneState extends BaseState<LevelOnePage>
controller: pageController,
itemCount: 4,
onPageChanged: (index) {
setState(() {
_refreshController.resetNoData();
setState(() {
});
_model.topIndexLive.notifyView(index);
_model.selectPage(index);
......
......@@ -18,6 +18,7 @@ class TopModel extends BaseModel {
LiveData<String> titleLive = new LiveData();
LiveData<String> imageLive = LiveData();
LiveData<double> textLive = LiveData();
LiveData<int> stateLive = LiveData();
RxDispose rxDispose = RxDispose();
String rank_type;
......@@ -29,6 +30,7 @@ class TopModel extends BaseModel {
titleLive.dispost();
imageLive.dispost();
stateLive.dispost();
textLive.dispost();
}
void selectTab(int index) {
......@@ -44,7 +46,7 @@ class TopModel extends BaseModel {
.listen((event) {
if (event.error == 0) {
stateLive.notifyView(ENDLOADING);
imageUrl=event.data.bannerImage;
imageUrl = event.data.bannerImage;
tabs = event.data.tabs;
back(tabs.length);
} else {
......
......@@ -9,6 +9,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gm_flutter/ClueModel/page/levelTwo/LevelTwoPage.dart';
import 'package:gm_flutter/ClueModel/page/top/TopModel.dart';
import 'package:gm_flutter/ClueModel/util/PosUtil.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/base/BaseState.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart';
......@@ -23,8 +24,8 @@ class TopPage extends StatefulWidget {
class TopPageState extends BaseState<TopPage> with TickerProviderStateMixin {
RefreshController refreshController = RefreshController();
TabController tabController;
TopModel _model = TopModel();
GlobalKey globalKey = GlobalKey();
@override
void initState() {
......@@ -34,7 +35,6 @@ class TopPageState extends BaseState<TopPage> with TickerProviderStateMixin {
void init() {
_model.init((i) {
tabController = TabController(length: i, vsync: this);
setState(() {});
});
}
......@@ -60,9 +60,29 @@ class TopPageState extends BaseState<TopPage> with TickerProviderStateMixin {
height: MediaQuery.of(context).size.height,
child: NotificationListener(
onNotification: (scrollNotification) {
if (scrollNotification is KeepAliveNotification ||
scrollNotification is OverscrollIndicatorNotification) {
return false;
}
if (scrollNotification is ScrollUpdateNotification &&
scrollNotification.metrics.axisDirection.index == 2) {
print("${scrollNotification}");
scrollNotification.metrics.axisDirection.index == 2) {}
print(
"NOT ${scrollNotification} ${scrollNotification is KeepAliveNotification}");
if (scrollNotification.depth == 0) {
if (scrollNotification.metrics.pixels > 80) {
_model.textLive.notifyView(
(scrollNotification.metrics.pixels - 80) / 40 > 1.0
? 1.0
: (scrollNotification.metrics.pixels - 80) /
40);
} else {
_model.textLive.notifyView(0.0);
}
} else if (scrollNotification.depth == 2) {
if (scrollNotification.metrics.pixels < 50 &&
scrollNotification.metrics.pixels > 0) {
_model.textLive.notifyView(1.0);
}
}
return false;
},
......@@ -72,7 +92,8 @@ class TopPageState extends BaseState<TopPage> with TickerProviderStateMixin {
baseSliverBack(() {
Navigator.of(context).pop();
}),
baseSliverTitle("title", MediaQuery.of(context).size.width),
baseSliverTitle(
"title", MediaQuery.of(context).size.width, _model.textLive)
],
), () {
init();
......@@ -84,7 +105,7 @@ class TopPageState extends BaseState<TopPage> with TickerProviderStateMixin {
List<Widget> list = [];
var d = MediaQueryData.fromWindow(window).padding.top;
for (int i = 0; i < _model.tabs.length; i++) {
list.add(TopList(_model.tabs[i].id, 48 +d).toActive());
list.add(TopList(_model.tabs[i].id, 48 + d).toActive());
}
return DefaultTabController(
length: _model.tabs.length,
......
......@@ -8,6 +8,7 @@ import 'package:flutter_common/Annotations/anno/ServiceCenter.dart';
import 'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanBarBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanCompareDetail.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';
......@@ -58,4 +59,7 @@ abstract class ClueApi {
@Get("api/janus/plans/agree_phone_authorize")
DiscussLowPriceAuthBean givePhoneAuth(
@Query("lead_phone_request_id") int leadPhoneRequestId);
@Get("api/janus/plans/plan_overview")
PlanOverViewBean getPlanOverView(@Query("plan_id") int plan_id);
}
......@@ -23,6 +23,7 @@ import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanBarBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceModelBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/DiscussLowPriceAuthBean.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanOverViewBean.dart';
const bool inProduction = const bool.fromEnvironment("dart.vm.product");
......@@ -189,6 +190,20 @@ class ClueApiImpl {
});
}
Stream<PlanOverViewBean> getPlanOverView(Dio _dio, int plan_id) {
return Stream.fromFuture(get(_dio, 'api/janus/plans/plan_overview', data: {
'plan_id': plan_id,
})).flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Stream.fromFuture(
compute(parsePlanOverViewBean, value.toString()));
} else {
throw Exception("--未知网络错误--");
}
});
}
///==================base method==================
Future<Response> get(Dio _dio, url, {data, options, cancelToken}) async {
......@@ -361,3 +376,7 @@ DiscussLowPriceModelBean parseDiscussLowPriceModelBean(String value) {
DiscussLowPriceAuthBean parseDiscussLowPriceAuthBean(String value) {
return DiscussLowPriceAuthBean.fromJson(json.decode(value));
}
PlanOverViewBean parsePlanOverViewBean(String value) {
return PlanOverViewBean.fromJson(json.decode(value));
}
/*
* @author lsy
* @date 2020/7/3
**/
class PlanOverViewBean {
int error;
String message;
Null extra;
Null errorExtra;
UserType userType;
Data data;
PlanOverViewBean(
{this.error,
this.message,
this.extra,
this.errorExtra,
this.userType,
this.data});
PlanOverViewBean.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 {
Banner banner;
String name;
String positiveRate;
String salesCount;
String planDescription;
String guidePrice;
List<OverviewAttrs> overviewAttrs;
List<ExplanationAttrs> explanationAttrs;
List<Tabs> tabs;
Data(
{this.banner,
this.name,
this.positiveRate,
this.salesCount,
this.planDescription,
this.guidePrice,
this.overviewAttrs,
this.explanationAttrs,
this.tabs});
Data.fromJson(Map<String, dynamic> json) {
banner =
json['banner'] != null ? new Banner.fromJson(json['banner']) : null;
name = json['name'];
positiveRate = json['positive_rate'];
salesCount = json['sales_count'];
planDescription = json['plan_description'];
guidePrice = json['guide_price'];
if (json['overview_attrs'] != null) {
overviewAttrs = new List<OverviewAttrs>();
json['overview_attrs'].forEach((v) {
overviewAttrs.add(new OverviewAttrs.fromJson(v));
});
}
if (json['explanation_attrs'] != null) {
explanationAttrs = new List<ExplanationAttrs>();
json['explanation_attrs'].forEach((v) {
explanationAttrs.add(new ExplanationAttrs.fromJson(v));
});
}
if (json['tabs'] != null) {
tabs = new List<Tabs>();
json['tabs'].forEach((v) {
tabs.add(new Tabs.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.banner != null) {
data['banner'] = this.banner.toJson();
}
data['name'] = this.name;
data['positive_rate'] = this.positiveRate;
data['sales_count'] = this.salesCount;
data['plan_description'] = this.planDescription;
data['guide_price'] = this.guidePrice;
if (this.overviewAttrs != null) {
data['overview_attrs'] =
this.overviewAttrs.map((v) => v.toJson()).toList();
}
if (this.explanationAttrs != null) {
data['explanation_attrs'] =
this.explanationAttrs.map((v) => v.toJson()).toList();
}
if (this.tabs != null) {
data['tabs'] = this.tabs.map((v) => v.toJson()).toList();
}
return data;
}
}
class Banner {
String type;
String imageUrl;
String videoUrl;
Banner({this.type, this.imageUrl, this.videoUrl});
Banner.fromJson(Map<String, dynamic> json) {
type = json['type'];
imageUrl = json['image_url'];
videoUrl = json['video_url'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['type'] = this.type;
data['image_url'] = this.imageUrl;
data['video_url'] = this.videoUrl;
return data;
}
}
class OverviewAttrs {
int attrId;
String attrName;
String attrValue;
OverviewAttrs({this.attrId, this.attrName, this.attrValue});
OverviewAttrs.fromJson(Map<String, dynamic> json) {
attrId = json['attr_id'];
attrName = json['attr_name'];
attrValue = json['attr_value'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['attr_id'] = this.attrId;
data['attr_name'] = this.attrName;
data['attr_value'] = this.attrValue;
return data;
}
}
class Tabs {
String tabType;
String name;
Tabs({this.tabType, this.name});
Tabs.fromJson(Map<String, dynamic> json) {
tabType = json['tab_type'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['tab_type'] = this.tabType;
data['name'] = this.name;
return data;
}
}
class ExplanationAttrs {
int attrId;
String attrName;
String attrValue;
ExplanationAttrs({this.attrId, this.attrName, this.attrValue});
ExplanationAttrs.fromJson(Map<String, dynamic> json) {
attrId = json['attr_id'];
attrName = json['attr_name'];
attrValue = json['attr_value'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['attr_id'] = this.attrId;
data['attr_name'] = this.attrName;
data['attr_value'] = this.attrValue;
return data;
}
}
......@@ -470,15 +470,24 @@ Widget baseSliverBack(VoidCallback tap) {
);
}
Widget baseSliverTitle(String text, double width) {
Widget baseSliverTitle(String text, double width, LiveData liveData) {
return Positioned(
top: 57,
child: StreamBuilder(
stream: liveData.stream,
initialData: liveData.data ?? 0.0,
builder: (c, data) {
return Opacity(
opacity: data.data,
child: Container(
alignment: Alignment.center,
width: width,
child: baseText(text, 18, Color(0xff333333)),
),
);
},
),
);
}
Widget baseStateView(double width, double height, LiveData<int> stateLive,
......
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