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();
}
}
......@@ -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) {
_refreshController.resetNoData();
setState(() {
_refreshController.resetNoData();
});
_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,13 +470,22 @@ Widget baseSliverBack(VoidCallback tap) {
);
}
Widget baseSliverTitle(String text, double width) {
Widget baseSliverTitle(String text, double width, LiveData liveData) {
return Positioned(
top: 57,
child: Container(
alignment: Alignment.center,
width: width,
child: baseText(text, 18, Color(0xff333333)),
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)),
),
);
},
),
);
}
......
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