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

w

parent b3998064
...@@ -15,7 +15,7 @@ import 'package:gm_flutter/commonModel/bean/Pair.dart'; ...@@ -15,7 +15,7 @@ import 'package:gm_flutter/commonModel/bean/Pair.dart';
class PlanCompareDetailModel extends BaseModel { class PlanCompareDetailModel extends BaseModel {
LiveData<Pair<int, List<Groups>>> detailLive = LiveData(); LiveData<Pair<int, List<Groups>>> detailLive = LiveData();
LiveData<Pair<int, List<PlansInfo>>> headerLive = LiveData(); LiveData<List<PlansInfoDetail>> headerLive = LiveData();
LiveData<int> stateLive = LiveData(); LiveData<int> stateLive = LiveData();
RxDispose rxDispose = RxDispose(); RxDispose rxDispose = RxDispose();
...@@ -26,24 +26,24 @@ class PlanCompareDetailModel extends BaseModel { ...@@ -26,24 +26,24 @@ class PlanCompareDetailModel extends BaseModel {
.listen((event) { .listen((event) {
if (event.error == 0) { if (event.error == 0) {
stateLive.notifyView(ENDLOADING); stateLive.notifyView(ENDLOADING);
if (event.data.plansInfo == null || event.data.groups.isEmpty) { if (event.data.groups == null || event.data.groups.isEmpty) {
headerLive.notifyView(Pair(ENDLOADING, [])); detailLive.notifyView(Pair(EMPTY, null));
detailLive.notifyView(Pair(ENDLOADING, []));
} else { } else {
detailLive.notifyView(Pair(ENDLOADING, event.data.groups)); detailLive.notifyView(Pair(ENDLOADING, event.data.groups));
headerLive.notifyView(Pair(ENDLOADING, event.data.plansInfo)); }
if (event.data.plansInfo != null &&
event.data.plansInfo.length > 1) {
headerLive.notifyView(event.data.plansInfo);
} }
} else { } else {
stateLive.notifyView(FAIL); stateLive.notifyView(FAIL);
NativeToast.showNativeToast(event.message); NativeToast.showNativeToast(event.message);
headerLive.notifyView(Pair(FAIL, null));
detailLive.notifyView(Pair(FAIL, null)); detailLive.notifyView(Pair(FAIL, null));
} }
}) })
.addToDispose(rxDispose) .addToDispose(rxDispose)
.onError((err) { .onError((err) {
stateLive.notifyView(FAIL); stateLive.notifyView(FAIL);
headerLive.notifyView(Pair(FAIL, null));
detailLive.notifyView(Pair(FAIL, null)); detailLive.notifyView(Pair(FAIL, null));
NativeToast.showNativeToast(err.message); NativeToast.showNativeToast(err.message);
}); });
......
...@@ -16,6 +16,7 @@ import 'package:gm_flutter/ClueModel/view/FiveStarView.dart'; ...@@ -16,6 +16,7 @@ import 'package:gm_flutter/ClueModel/view/FiveStarView.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart'; import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/base/BaseState.dart'; import 'package:gm_flutter/commonModel/base/BaseState.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart'; import 'package:gm_flutter/commonModel/bean/Pair.dart';
import 'package:gm_flutter/commonModel/net/DioUtil.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:gm_flutter/main.mark.dart'; import 'package:gm_flutter/main.mark.dart';
...@@ -35,8 +36,10 @@ class PlanCompareDetailPage extends StatefulWidget { ...@@ -35,8 +36,10 @@ class PlanCompareDetailPage extends StatefulWidget {
class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> { class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
PlanCompareDetailModel _model = new PlanCompareDetailModel(); PlanCompareDetailModel _model = new PlanCompareDetailModel();
double screenWidth; double screenWidth;
@override @override
void initState() { void initState() {
// DioUtil.getInstance().setProxy("172.30.9.128");
super.initState(); super.initState();
_model.init(widget._planIds); _model.init(widget._planIds);
} }
...@@ -55,9 +58,9 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> { ...@@ -55,9 +58,9 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
title: "对比详情", title: "对比详情",
centerTitle: true, centerTitle: true,
backClick: () { backClick: () {
if(RouterCenterImpl().findMainRouter().isWithNative()){ if (RouterCenterImpl().findMainRouter().isWithNative()) {
FlutterBoost.singleton.closeCurrent(); FlutterBoost.singleton.closeCurrent();
}else{ } else {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
}), }),
...@@ -74,6 +77,7 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> { ...@@ -74,6 +77,7 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
if (data.data == FAIL) { if (data.data == FAIL) {
return errorItem(MediaQuery.of(context).size.width, return errorItem(MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height, () { MediaQuery.of(context).size.height, () {
_model.stateLive.notifyView(LOADING);
_model.init(widget._planIds); _model.init(widget._planIds);
}); });
} }
...@@ -98,9 +102,14 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> { ...@@ -98,9 +102,14 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
if (data.data.first == FAIL) { if (data.data.first == FAIL) {
return errorItem(MediaQuery.of(context).size.width, return errorItem(MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height, () { MediaQuery.of(context).size.height, () {
_model.stateLive.notifyView(LOADING);
_model.init(widget._planIds); _model.init(widget._planIds);
}); });
} }
if (data.data.first == EMPTY) {
return emptyItem(MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height);
}
return ListView.builder( return ListView.builder(
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
if (index == data.data.second.length * 2 - 1) { if (index == data.data.second.length * 2 - 1) {
...@@ -119,10 +128,10 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> { ...@@ -119,10 +128,10 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
Groups group = data.data.second[newIndex]; Groups group = data.data.second[newIndex];
Widget widget; Widget widget;
if (group.groupType == 'hot') { if (group.groupType == 'hot') {
widget = planPopularityView(group); widget = planPopularityView(group);
// height: 100, // height: 100,
// alignment: Alignment.center, // alignment: Alignment.center,
// child: baseText("第一个", 15, Colors.black), // child: baseText("第一个", 15, Colors.black),
} else if (group.groupType == 'normal_attrs') { } else if (group.groupType == 'normal_attrs') {
widget = Container( widget = Container(
child: planNormalEffectiveAttrsView(group), child: planNormalEffectiveAttrsView(group),
...@@ -163,14 +172,13 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> { ...@@ -163,14 +172,13 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
} }
Widget headItem(int index) { Widget headItem(int index) {
return StreamBuilder( return StreamBuilder<List<PlansInfoDetail>>(
stream: _model.headerLive.stream, stream: _model.headerLive.stream,
initialData: _model.headerLive.data ?? null, initialData: _model.headerLive.data ?? null,
builder: (c, data) { builder: (c, data) {
if (data.data == null) { if (data.data == null || data.data.length != 2) {
return Container(); return Container();
} }
PlansInfo planinfo = data.data.second[index];
return Container( return Container(
child: Stack(children: <Widget>[ child: Stack(children: <Widget>[
Positioned( Positioned(
...@@ -188,14 +196,19 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> { ...@@ -188,14 +196,19 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
Positioned( Positioned(
left: 12, left: 12,
top: 24, top: 24,
child: child: baseText(data.data[index].planName, 15, Color(0xff333333),
baseText(planinfo.planName, 15, Color(0xff333333), bold: true), bold: true),
), ),
Positioned( Positioned(
left: 12, left: 12,
top: 48, top: 48,
child: baseText('¥' + planinfo.minPrice + '-' + planinfo.maxPrice, child: baseText(
14, Colors.red, '¥' +
data.data[index].minPrice +
'-' +
data.data[index].maxPrice,
14,
Colors.red,
bold: true), bold: true),
), ),
])); ]));
...@@ -234,22 +247,21 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> { ...@@ -234,22 +247,21 @@ class PlanCompareDetailPageState extends BaseState<PlanCompareDetailPage> {
} }
Widget planPopularityView(Groups groups) { Widget planPopularityView(Groups groups) {
return Container( return Column(
child: Column( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
children: <Widget>[ titleView(groups.groupName),
titleView(groups.groupName), planPopularityBodyView(groups),
Container(child: planPopularityBodyView(groups)), Container()
Container() ]);
]),
);
} }
Widget planPopularityBodyView(Groups groups) { Widget planPopularityBodyView(Groups groups) {
return Container( return Container(
height: 170, height: 170,
child: Row(children: <Widget>[ child: Row(
children: <Widget>[
Expanded( Expanded(
flex: 1, child: planPopularityLeftItem(groups.plans[0], groups)), flex: 1, child: planPopularityLeftItem(groups.plans[0], groups)),
Expanded( Expanded(
......
...@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart'; ...@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/toast/NativeToast.dart'; import 'package:flutter_common/commonModel/toast/NativeToast.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlansCompareFeed.dart'; import 'package:gm_flutter/ClueModel/server/entity/PlansCompareFeed.dart';
import 'package:gm_flutter/ClueModel/util/NumPlanUtil.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart'; import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/base/BaseState.dart'; import 'package:gm_flutter/commonModel/base/BaseState.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart'; import 'package:gm_flutter/commonModel/util/DartUtil.dart';
...@@ -113,7 +114,7 @@ class _PlansCompareFeedItemViewState ...@@ -113,7 +114,7 @@ class _PlansCompareFeedItemViewState
baseText('¥${widget.plan.minPrice}-${widget.plan.maxPrice}', baseText('¥${widget.plan.minPrice}-${widget.plan.maxPrice}',
13, Color(0xFFFF5963)), 13, Color(0xFFFF5963)),
baseText( baseText(
"销量${widget.plan.salesCount}", 11, Color(0xFF282828)) "销量${NumPlanUtil.getSale(widget.plan.salesCount)}", 11, Color(0xFF282828))
], ],
) )
], ],
......
...@@ -66,6 +66,7 @@ class LevelOneListState extends State<LevelOneList> ...@@ -66,6 +66,7 @@ class LevelOneListState extends State<LevelOneList>
super.build(context); super.build(context);
return baseStateView(MediaQuery.of(context).size.width, return baseStateView(MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height, _model.stateLive, pages(), () { MediaQuery.of(context).size.height, _model.stateLive, pages(), () {
_model.stateLive.notifyView(LOADING);
_model.refreshView(true); _model.refreshView(true);
}, paddingTop: widget.topHeight); }, paddingTop: widget.topHeight);
} }
...@@ -166,12 +167,12 @@ class LevelOneListState extends State<LevelOneList> ...@@ -166,12 +167,12 @@ class LevelOneListState extends State<LevelOneList>
totalHeight += LevelOneItem.getCardTypeHeight(element); totalHeight += LevelOneItem.getCardTypeHeight(element);
}); });
double height = MediaQuery.of(context).size.height - double height = MediaQuery.of(context).size.height -
40 - 40 -
widget.topHeight - widget.topHeight -
totalHeight totalHeight
// - 55 // - 55
// - 40 // - 40
; ;
return SliverToBoxAdapter( return SliverToBoxAdapter(
child: Container( child: Container(
color: Color(0xffF7F6FA), color: Color(0xffF7F6FA),
...@@ -183,7 +184,7 @@ class LevelOneListState extends State<LevelOneList> ...@@ -183,7 +184,7 @@ class LevelOneListState extends State<LevelOneList>
], ],
), onLoading: () { ), onLoading: () {
_model.loadMore(); _model.loadMore();
}, pullDown: false, pullUp: true,loadMoreColor: Color(0xffF7F6FA)); }, pullDown: false, pullUp: true, loadMoreColor: Color(0xffF7F6FA));
} }
@override @override
......
...@@ -110,31 +110,30 @@ class LevelTwoState extends BaseState<LevelTwoPage> ...@@ -110,31 +110,30 @@ class LevelTwoState extends BaseState<LevelTwoPage>
MediaQuery.of(context).size.height, MediaQuery.of(context).size.height,
_model.stateLive, _model.stateLive,
Container( Container(
child: BaseNestedScrollViewRefreshIndicator( child: Column(
onRefresh: () async { children: <Widget>[
Completer completer = new Completer(); Expanded(
_model.init(() { child: BaseNestedScrollViewRefreshIndicator(
_initTabBar(); onRefresh: () async {
SimpleEventBus.instance() Completer completer = new Completer();
.notifyListener("LevelOneList", ""); _model.init(() {
completer.complete(); _initTabBar();
}); SimpleEventBus.instance()
return completer.future; .notifyListener("LevelOneList", "");
}, completer.complete();
child: Column( });
children: <Widget>[ return completer.future;
Expanded( },
child: newHomeWarp(), child: newHomeWarp()),
), ),
Container( Container(
height: 0.5, height: 0.5,
width: double.maxFinite, width: double.maxFinite,
color: Color(0xffE5E5E5), color: Color(0xffE5E5E5),
), ),
bottomWidget(), bottomWidget(),
], ],
)), )), () {
), () {
_model.stateLive.notifyView(LOADING); _model.stateLive.notifyView(LOADING);
_model.init(() { _model.init(() {
_initTabBar(); _initTabBar();
......
...@@ -4,16 +4,50 @@ ...@@ -4,16 +4,50 @@
**/ **/
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
import 'package:gm_flutter/ClueModel/page/plan/PlanProgressBar.dart'; import 'package:gm_flutter/ClueModel/page/plan/PlanProgressBar.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart'; import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/eventbus/SimpleEventBus.dart'; import 'package:gm_flutter/commonModel/eventbus/SimpleEventBus.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart'; import 'package:gm_flutter/commonModel/util/DartUtil.dart';
class FilterView extends StatelessWidget { class FilterView extends StatefulWidget {
final Function(int high, int low) call; final Function(int high, int low) call;
FilterView(this.call); int high;
int low;
FilterView(this.call, {this.high, this.low});
@override
State<StatefulWidget> createState() => FilterViewState();
}
class FilterViewState extends State<FilterView> {
LiveData<String> lowLive = new LiveData();
LiveData<String> highLive = new LiveData();
Function(String str) func;
@override
void initState() {
func = (str) {
if (str == "reset") {
highLive.notifyView("无限");
lowLive.notifyView("¥0");
SimpleEventBus.instance().notifyListener("PlanProgressBarState", "");
}
};
SimpleEventBus.instance().resignEvent("FilterViewState", func);
super.initState();
}
@override
void dispose() {
SimpleEventBus.instance().unResignEvent("FilterViewState", func);
lowLive.dispost();
highLive.dispost();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -28,11 +62,13 @@ class FilterView extends StatelessWidget { ...@@ -28,11 +62,13 @@ class FilterView extends StatelessWidget {
child: Container( child: Container(
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
child: PlanProgressBar( child: PlanProgressBar(
0, widget.low,
19600, widget.high,
0, 0,
20010, 20010,
call, widget.call,
lowLive,
highLive,
padding: 15, padding: 15,
), ),
), ),
...@@ -40,12 +76,25 @@ class FilterView extends StatelessWidget { ...@@ -40,12 +76,25 @@ class FilterView extends StatelessWidget {
Positioned( Positioned(
top: 54.5, top: 54.5,
right: 15, right: 15,
child: baseText("无限", 12, Color(0xff3FB5AF)), child: StreamBuilder(
stream: highLive.stream,
initialData: highLive.data ??
(widget.high >= 19600 ? "无限" : "${widget.high}"),
builder: (c, data) {
return baseText("${data.data}", 12, Color(0xff3FB5AF));
},
),
), ),
Positioned( Positioned(
top: 54.5, top: 54.5,
left: 15, left: 15,
child: baseText("¥0", 12, Color(0xff3FB5AF)), child: StreamBuilder(
stream: lowLive.stream,
initialData: lowLive.data ?? "¥${widget.low}",
builder: (c, data) {
return baseText("${data.data}", 12, Color(0xff3FB5AF));
},
),
), ),
Positioned( Positioned(
top: 25, top: 25,
...@@ -64,8 +113,7 @@ class FilterView extends StatelessWidget { ...@@ -64,8 +113,7 @@ class FilterView extends StatelessWidget {
child: baseText("重置", 16, Color(0xff3FB5AF)), child: baseText("重置", 16, Color(0xff3FB5AF)),
alignment: Alignment.center, alignment: Alignment.center,
).gestureDetector(() { ).gestureDetector(() {
SimpleEventBus.instance() SimpleEventBus.instance().notifyListener("FilterViewState", "reset");
.notifyListener("PlanProgressBarState", "");
}), }),
), ),
Expanded( Expanded(
...@@ -74,7 +122,8 @@ class FilterView extends StatelessWidget { ...@@ -74,7 +122,8 @@ class FilterView extends StatelessWidget {
alignment: Alignment.center, alignment: Alignment.center,
child: baseText("确定", 16, Colors.white), child: baseText("确定", 16, Colors.white),
).gestureDetector(() { ).gestureDetector(() {
SimpleEventBus.instance().notifyListener("PlanProgressBarState", "sure"); SimpleEventBus.instance()
.notifyListener("PlanProgressBarState", "sure");
}), }),
) )
], ],
......
...@@ -6,6 +6,7 @@ import 'package:cached_network_image/cached_network_image.dart'; ...@@ -6,6 +6,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/PlanFeedBean.dart';
import 'package:gm_flutter/ClueModel/util/NumPlanUtil.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart'; import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart'; import 'package:gm_flutter/commonModel/util/DartUtil.dart';
import 'package:gm_flutter/main.mark.dart'; import 'package:gm_flutter/main.mark.dart';
...@@ -97,7 +98,7 @@ class PlanItem extends StatelessWidget { ...@@ -97,7 +98,7 @@ class PlanItem extends StatelessWidget {
Positioned( Positioned(
bottom: 14, bottom: 14,
right: 10, right: 10,
child: baseText("销量${plans.salesCount}", 11, Color(0xff282828)), child: baseText("销量${NumPlanUtil.getSale(plans.salesCount)}", 11, Color(0xff282828)),
), ),
Positioned( Positioned(
left: 91, left: 91,
......
...@@ -22,46 +22,58 @@ import 'package:gm_flutter/commonModel/util/PrintUtil.dart'; ...@@ -22,46 +22,58 @@ import 'package:gm_flutter/commonModel/util/PrintUtil.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
class PlanModel extends BaseModel { class PlanModel extends BaseModel {
final String PLAN_MODEL_BUFFER = "PLAN_MODEL_BUFFER";
final String PLAN_MODEL_LIST_BUFFER = "PLAN_MODEL_LIST_BUFFER";
LiveData<List> managerLive = new LiveData(); LiveData<List> managerLive = new LiveData();
LiveData<List<double>> posLive = new LiveData(); LiveData<List<double>> posLive = new LiveData();
LiveData<List<double>> backLive = new LiveData(); LiveData<List<double>> backLive = new LiveData();
LiveData<List<Ranks>> picLive = LiveData(); LiveData<List<Ranks>> picLive = LiveData();
LiveData<bool> showTab = LiveData(); LiveData<bool> showTab = LiveData();
LiveData<int> stateLive = LiveData(); LiveData<int> stateLive = LiveData();
LiveData<Pair<int, List<Plans>>> feedsLive = LiveData();
RxDispose rxDispose = RxDispose();
double menuBottom; double menuBottom;
int menuIndex = -1; int menuIndex = -1;
bool needChangBack = true; bool needChangBack = true;
LiveData<Pair<int, List<Plans>>> feedsLive = LiveData(); String current_city_id = "";
List<Plans> feedDatas = []; String rank_type = "";
List<Plans> feedDatas = [];
List<Tags> projectData = []; List<Tags> projectData = [];
List<Orders> sortList = []; List<Orders> sortList = [];
RxDispose rxDispose = RxDispose(); List<String> normalData = ["全部项目", "智能筛选", "筛选"];
String tag_id = "0"; String tag_id = "0";
String order_by = ""; String order_by = "";
String current_city_id = "";
String min_price = "0"; String min_price = "0";
String max_price = "100000000"; String max_price = "100000000";
String rank_type = ""; int low = 0;
int high = 20100;
List<String> normalData = ["全部项目", "智能筛选", "筛选"]; int projectSelectIndex = 0;
PlanBean planBean;
int page = 1; int page = 1;
int sortPos = 0; int sortPos = 0;
void init({VoidCallback call, bool needCache = false}) { void init({VoidCallback call, bool needCache = false}) {
if (PlanModelInstance.getInstance().planBean != null && needCache) { if (PlanModelInstance.getInstance().planBean != null && needCache) {
var event = PlanModelInstance.getInstance().planBean; planBean = PlanModelInstance.getInstance().planBean;
projectData = event.data.tags; projectData = planBean.data.tags;
sortList = event.data.orders; sortList = planBean.data.orders;
picLive.notifyView(event.data.ranks); picLive.notifyView(planBean.data.ranks);
low = PlanModelInstance.getInstance().low;
high = PlanModelInstance.getInstance().high;
print("QWEEW${low} ${high}");
projectSelectIndex = PlanModelInstance.getInstance().projectSelectIndex;
stateLive.notifyView(ENDLOADING); stateLive.notifyView(ENDLOADING);
normalData[1] = event.data.orders[0].name; normalData.clear();
normalData.addAll(PlanModelInstance.getInstance().normalData);
managerLive.notifyView(normalData); managerLive.notifyView(normalData);
tag_id = PlanModelInstance.getInstance().tag_id;
order_by = PlanModelInstance.getInstance().order_by;
min_price = PlanModelInstance.getInstance().min_price;
max_price = PlanModelInstance.getInstance().max_price;
sortPos = PlanModelInstance.getInstance().sortPos;
if (call != null) { if (call != null) {
call(); call();
} }
...@@ -73,12 +85,28 @@ class PlanModel extends BaseModel { ...@@ -73,12 +85,28 @@ class PlanModel extends BaseModel {
.listen((event) { .listen((event) {
if (event.error == 0) { if (event.error == 0) {
projectData = event.data.tags; projectData = event.data.tags;
if (event.data.tags != null &&
event.data.tags.length > 0 &&
event.data.tags[0].subtags != null &&
event.data.tags[0].subtags.length > 0) {
tag_id = "${event.data.tags[0].subtags[0].tagId}";
normalData[0] = "${event.data.tags[0].subtags[0].name}";
}
sortList = event.data.orders; sortList = event.data.orders;
order_by = "${sortList[0].id}";
min_price = "0";
max_price = "100000000";
low = 0;
projectSelectIndex = 0;
high = 20100;
sortPos = 0;
picLive.notifyView(event.data.ranks); picLive.notifyView(event.data.ranks);
stateLive.notifyView(ENDLOADING); stateLive.notifyView(ENDLOADING);
normalData[1] = event.data.orders[0].name; normalData[1] = event.data.orders[0].name;
managerLive.notifyView(normalData); managerLive.notifyView(normalData);
if (call != null) { if (call != null) {
SimpleEventBus.instance().notifyListener("FilterViewState", "reset");
SimpleEventBus.instance().notifyListener("ProjectViewState", "reset");
call(); call();
} }
refreshFeed(true, needCache: needCache); refreshFeed(true, needCache: needCache);
...@@ -96,10 +124,11 @@ class PlanModel extends BaseModel { ...@@ -96,10 +124,11 @@ class PlanModel extends BaseModel {
}); });
} }
void projectClick(String id, String name) { void projectClick(String id, String name, int index) {
if (tag_id == id) { if (tag_id == id) {
return; return;
} }
projectSelectIndex = index;
normalData[0] = name; normalData[0] = name;
managerLive.notifyView(normalData); managerLive.notifyView(normalData);
tag_id = id; tag_id = id;
...@@ -109,22 +138,25 @@ class PlanModel extends BaseModel { ...@@ -109,22 +138,25 @@ class PlanModel extends BaseModel {
void refreshFeed(bool clear, void refreshFeed(bool clear,
{RefreshController controller, bool needCache = false}) { {RefreshController controller, bool needCache = false}) {
if (clear) { if (needCache && PlanModelInstance.getInstance().feedDatas != null) {
page = 1; page = PlanModelInstance.getInstance().page;
feedDatas.clear();
}
if (needCache &&
PlanModelInstance.getInstance().feedDatas != null &&
PlanModelInstance.getInstance().feedDatas.isNotEmpty) {
feedDatas.clear(); feedDatas.clear();
feedDatas.addAll(PlanModelInstance.getInstance().feedDatas); feedDatas.addAll(PlanModelInstance.getInstance().feedDatas);
feedsLive.notifyView(Pair(ENDLOADING, feedDatas)); if (feedDatas.isEmpty) {
WidgetsBinding.instance.addPostFrameCallback((_) { feedsLive.notifyView(Pair(EMPTY, null));
SimpleEventBus.instance() } else {
.notifyListener("BaseNestedScrollViewRefreshIndicator", "refresh"); feedsLive.notifyView(Pair(ENDLOADING, feedDatas));
}); }
// WidgetsBinding.instance.addPostFrameCallback((_) {
// SimpleEventBus.instance()
// .notifyListener("BaseNestedScrollViewRefreshIndicator", "refresh");
// });
return; return;
} }
if (clear) {
page = 1;
feedDatas.clear();
}
ClueApiImpl.getInstance() ClueApiImpl.getInstance()
.getPlanFeed(DioUtil.getInstance().getDio(), tag_id, order_by, .getPlanFeed(DioUtil.getInstance().getDio(), tag_id, order_by,
current_city_id, min_price, max_price, rank_type, page) current_city_id, min_price, max_price, rank_type, page)
...@@ -138,11 +170,14 @@ class PlanModel extends BaseModel { ...@@ -138,11 +170,14 @@ class PlanModel extends BaseModel {
} }
} else { } else {
feedDatas.addAll(event.data.plans); feedDatas.addAll(event.data.plans);
PlanModelInstance.getInstance().feedDatas.clear();
PlanModelInstance.getInstance().feedDatas.addAll(feedDatas);
feedsLive.notifyView(Pair(ENDLOADING, feedDatas)); feedsLive.notifyView(Pair(ENDLOADING, feedDatas));
} }
controller?.refreshCompleted(); controller?.refreshCompleted();
if (PlanModelInstance.getInstance().feedDatas == null) {
PlanModelInstance.getInstance().feedDatas = [];
}
PlanModelInstance.getInstance().feedDatas.clear();
PlanModelInstance.getInstance().feedDatas.addAll(feedDatas);
} else { } else {
NativeToast.showNativeToast(event.message); NativeToast.showNativeToast(event.message);
feedsLive.notifyView(Pair(FAIL, null)); feedsLive.notifyView(Pair(FAIL, null));
...@@ -160,6 +195,16 @@ class PlanModel extends BaseModel { ...@@ -160,6 +195,16 @@ class PlanModel extends BaseModel {
@override @override
void dispose() { void dispose() {
PlanModelInstance.getInstance().normalData.clear();
PlanModelInstance.getInstance().normalData.addAll(normalData);
PlanModelInstance.getInstance().tag_id = tag_id;
PlanModelInstance.getInstance().projectSelectIndex = projectSelectIndex;
PlanModelInstance.getInstance().order_by = order_by;
PlanModelInstance.getInstance().min_price = min_price;
PlanModelInstance.getInstance().max_price = max_price;
PlanModelInstance.getInstance().sortPos = sortPos;
PlanModelInstance.getInstance().low = low;
PlanModelInstance.getInstance().high = high;
stateLive.dispost(); stateLive.dispost();
picLive.dispost(); picLive.dispost();
rxDispose.dispose(); rxDispose.dispose();
...@@ -197,6 +242,8 @@ class PlanModel extends BaseModel { ...@@ -197,6 +242,8 @@ class PlanModel extends BaseModel {
if (max_price == "${max}" && min_price == "${min}") { if (max_price == "${max}" && min_price == "${min}") {
return; return;
} }
low = min;
high = max > 20000 ? 20000 : max;
if (max > 20000) { if (max > 20000) {
max = 20000000; max = 20000000;
} }
......
...@@ -17,9 +17,24 @@ class PlanModelInstance { ...@@ -17,9 +17,24 @@ class PlanModelInstance {
return _instance; return _instance;
} }
List<Plans> feedDatas;
List<Tags> projectData = [];
List<Orders> sortList = [];
List<String> normalData = ["全部项目", "智能筛选", "筛选"]; List<String> normalData = ["全部项目", "智能筛选", "筛选"];
PlanBean planBean; List<Ranks> ranks = [];
List<Plans> feedDatas = [];
String tag_id = "0";
String order_by = "";
String current_city_id = "";
String min_price = "0";
String max_price = "100000000";
String rank_type = "";
int low = 0;
int high = 19600;
int projectSelectIndex = 0;
int page = 1;
int sortPos = 0;
PlanBean planBean;
} }
...@@ -19,6 +19,7 @@ import 'package:gm_flutter/ClueModel/page/plan/PlanItem.dart'; ...@@ -19,6 +19,7 @@ import 'package:gm_flutter/ClueModel/page/plan/PlanItem.dart';
import 'package:gm_flutter/ClueModel/page/plan/SortView.dart'; import 'package:gm_flutter/ClueModel/page/plan/SortView.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart'; 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/PlanFeedBean.dart';
import 'package:gm_flutter/ClueModel/util/NumPlanUtil.dart';
import 'package:gm_flutter/ClueModel/util/PosUtil.dart'; import 'package:gm_flutter/ClueModel/util/PosUtil.dart';
import 'package:gm_flutter/commonModel/App.dart'; import 'package:gm_flutter/commonModel/App.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart'; import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
...@@ -62,7 +63,7 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin { ...@@ -62,7 +63,7 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
@override @override
void initState() { void initState() {
print("LSY PLAN INIT"); print("LSY PLAN INIT ");
// DioUtil.getInstance().setProxy("172.30.9.128"); // DioUtil.getInstance().setProxy("172.30.9.128");
_model.init(needCache: true); _model.init(needCache: true);
super.initState(); super.initState();
...@@ -182,9 +183,9 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin { ...@@ -182,9 +183,9 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
maxHeight: 450, maxHeight: 450,
listener: projectMenuListener, listener: projectMenuListener,
child: ProjectView(_model.projectData, (id, name) { child: ProjectView(_model.projectSelectIndex,_model.projectData, (id, name,index) {
clickIndexOther(0); clickIndexOther(0);
_model.projectClick(id, name); _model.projectClick(id, name,index);
}), }),
proListener: (pro) { proListener: (pro) {
_model.backProgress(pro, 0); _model.backProgress(pro, 0);
...@@ -221,10 +222,14 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin { ...@@ -221,10 +222,14 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
width: MediaQuery.of(context).size.width, width: MediaQuery.of(context).size.width,
maxHeight: 186, maxHeight: 186,
listener: filterMenuListener, listener: filterMenuListener,
child: FilterView((max, min) { child: FilterView(
clickIndexOther(2); (max, min) {
_model.filterClick(max, min); clickIndexOther(2);
}), _model.filterClick(max, min);
},
low: _model.low,
high: _model.high,
),
proListener: (pro) { proListener: (pro) {
_model.backProgress(pro, 2); _model.backProgress(pro, 2);
}, },
...@@ -243,7 +248,7 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin { ...@@ -243,7 +248,7 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
); );
}, },
), ),
// baseSliverBack((){ // baseSliverBack(() {
// Navigator.pop(context); // Navigator.pop(context);
// }) // })
], ],
...@@ -409,7 +414,7 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin { ...@@ -409,7 +414,7 @@ class PlanState extends BaseState<PlanPage> with TickerProviderStateMixin {
}, },
pullDown: false, pullDown: false,
pullUp: true, pullUp: true,
loadMoreColor: Color(0xffF7F6FA))); loadMoreColor: Color(0xffF7F6FA)));
}, },
); );
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
**/ **/
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_common/commonModel/live/LiveData.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart'; import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/eventbus/SimpleEventBus.dart'; import 'package:gm_flutter/commonModel/eventbus/SimpleEventBus.dart';
...@@ -13,9 +14,14 @@ class PlanProgressBar extends StatefulWidget { ...@@ -13,9 +14,14 @@ class PlanProgressBar extends StatefulWidget {
int maxlow; int maxlow;
int maxHigh; int maxHigh;
int padding; int padding;
LiveData<String> lowLive;
LiveData<String> highLive;
final Function(int high, int low) call; final Function(int high, int low) call;
PlanProgressBar(this.low, this.high, this.maxlow, this.maxHigh, this.call, PlanProgressBar(this.low, this.high, this.maxlow, this.maxHigh, this.call,
this.lowLive, this.highLive,
{this.padding}); {this.padding});
@override @override
...@@ -52,6 +58,8 @@ class PlanProgressBarState extends State<PlanProgressBar> { ...@@ -52,6 +58,8 @@ class PlanProgressBarState extends State<PlanProgressBar> {
if (str == "sure") { if (str == "sure") {
widget.call(high, low); widget.call(high, low);
} else { } else {
widget.low = 0;
widget.high = 20100;
init(); init();
setState(() {}); setState(() {});
} }
...@@ -63,7 +71,8 @@ class PlanProgressBarState extends State<PlanProgressBar> { ...@@ -63,7 +71,8 @@ class PlanProgressBarState extends State<PlanProgressBar> {
leftStarPosPercent = (widget.low / distance); leftStarPosPercent = (widget.low / distance);
leftPosTempPercent = leftStarPosPercent; leftPosTempPercent = leftStarPosPercent;
rightStarPosPercent = (widget.high / distance); rightStarPosPercent =
(widget.high / distance) > 0.03 ? (widget.high / distance) - 0.03 : 0.0;
rightPosTempPercent = rightStarPosPercent; rightPosTempPercent = rightStarPosPercent;
} }
...@@ -76,7 +85,7 @@ class PlanProgressBarState extends State<PlanProgressBar> { ...@@ -76,7 +85,7 @@ class PlanProgressBarState extends State<PlanProgressBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double totle = MediaQuery.of(context).size.width - widget.padding * 2; double totle = MediaQuery.of(context).size.width - widget.padding * 2;
scrollDistance = 0.05; scrollDistance = 0.03;
int textInt = (widget.maxlow + int textInt = (widget.maxlow +
(isLeftMove ? leftPosTempPercent : rightPosTempPercent + 0.03) * (isLeftMove ? leftPosTempPercent : rightPosTempPercent + 0.03) *
distance) distance)
...@@ -91,6 +100,11 @@ class PlanProgressBarState extends State<PlanProgressBar> { ...@@ -91,6 +100,11 @@ class PlanProgressBarState extends State<PlanProgressBar> {
if (textInt > 20000) { if (textInt > 20000) {
textStr = "无限"; textStr = "无限";
} }
if (isLeftMove) {
widget.lowLive.notifyView(textStr);
} else {
widget.highLive.notifyView(textStr);
}
double textWidth = textStr.length * 12.0; double textWidth = textStr.length * 12.0;
if (textStr == "无限") { if (textStr == "无限") {
......
...@@ -7,21 +7,45 @@ import 'package:flutter/material.dart'; ...@@ -7,21 +7,45 @@ import 'package:flutter/material.dart';
import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart'; import 'package:gm_flutter/ClueModel/server/entity/PlanBean.dart';
import 'package:gm_flutter/commonModel/base/BaseComponent.dart'; import 'package:gm_flutter/commonModel/base/BaseComponent.dart';
import 'package:gm_flutter/commonModel/bean/Pair.dart'; import 'package:gm_flutter/commonModel/bean/Pair.dart';
import 'package:gm_flutter/commonModel/eventbus/SimpleEventBus.dart';
import 'package:gm_flutter/commonModel/util/DartUtil.dart'; import 'package:gm_flutter/commonModel/util/DartUtil.dart';
class ProjectView extends StatefulWidget { class ProjectView extends StatefulWidget {
final List<Tags> datas; final List<Tags> datas;
final Function(String id,String name) clickCall; final Function(String id, String name, int first) clickCall;
int selectIndex = 0;
ProjectView(this.datas, this.clickCall); ProjectView(this.selectIndex, this.datas, this.clickCall);
@override @override
State<StatefulWidget> createState() => ProjectViewState(); State<StatefulWidget> createState() => ProjectViewState(selectIndex);
} }
class ProjectViewState extends State<ProjectView> { class ProjectViewState extends State<ProjectView> {
int selectIndex = 0; int selectIndex = 0;
ProjectViewState(this.selectIndex);
Function(String str) func;
@override
void initState() {
func = (str) {
if (str == "reset") {
selectIndex = 0;
setState(() {});
}
};
SimpleEventBus.instance().resignEvent("ProjectViewState", func);
super.initState();
}
@override
void dispose() {
SimpleEventBus.instance().unResignEvent("ProjectViewState", func);
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (widget.datas == null || widget.datas.isEmpty) { if (widget.datas == null || widget.datas.isEmpty) {
...@@ -82,8 +106,10 @@ class ProjectViewState extends State<ProjectView> { ...@@ -82,8 +106,10 @@ class ProjectViewState extends State<ProjectView> {
child: baseText(widget.datas[selectIndex].subtags[index].name, child: baseText(widget.datas[selectIndex].subtags[index].name,
14, Color(0xff464646)), 14, Color(0xff464646)),
).gestureDetector(() { ).gestureDetector(() {
widget.clickCall("${widget.datas[selectIndex].subtags[index].tagId}" widget.clickCall(
,"${widget.datas[selectIndex].subtags[index].name}"); "${widget.datas[selectIndex].subtags[index].tagId}",
"${widget.datas[selectIndex].subtags[index].name}",
selectIndex);
}); });
}, },
itemCount: widget.datas[selectIndex].subtags.length, itemCount: widget.datas[selectIndex].subtags.length,
......
...@@ -54,15 +54,15 @@ class UserType { ...@@ -54,15 +54,15 @@ class UserType {
} }
class Data { class Data {
List<PlansInfo> plansInfo; List<PlansInfoDetail> plansInfo;
List<Groups> groups; List<Groups> groups;
Data({this.plansInfo, this.groups}); Data({this.plansInfo, this.groups});
Data.fromJson(Map<String, dynamic> json) { Data.fromJson(Map<String, dynamic> json) {
if (json['plans_info'] != null) { if (json['plans_info'] != null) {
plansInfo = new List<PlansInfo>(); plansInfo = new List<PlansInfoDetail>();
json['plans_info'].forEach((v) { plansInfo.add(new PlansInfo.fromJson(v)); }); json['plans_info'].forEach((v) { plansInfo.add(new PlansInfoDetail.fromJson(v)); });
} }
if (json['groups'] != null) { if (json['groups'] != null) {
groups = new List<Groups>(); groups = new List<Groups>();
...@@ -82,15 +82,15 @@ class Data { ...@@ -82,15 +82,15 @@ class Data {
} }
} }
class PlansInfo { class PlansInfoDetail {
int planId; int planId;
String planName; String planName;
String minPrice; String minPrice;
String maxPrice; String maxPrice;
PlansInfo({this.planId, this.planName, this.minPrice, this.maxPrice}); PlansInfoDetail({this.planId, this.planName, this.minPrice, this.maxPrice});
PlansInfo.fromJson(Map<String, dynamic> json) { PlansInfoDetail.fromJson(Map<String, dynamic> json) {
planId = json['plan_id']; planId = json['plan_id'];
planName = json['plan_name']; planName = json['plan_name'];
minPrice = json['min_price']; minPrice = json['min_price'];
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
class PlanOverViewBean { class PlanOverViewBean {
int error; int error;
String message; String message;
Null extra; Map extra;
Null errorExtra; Map errorExtra;
UserType userType; UserType userType;
PlanOverData data; PlanOverData data;
......
/*
* @author lsy
* @date 2020/7/10
**/
import 'package:common_utils/common_utils.dart';
class NumPlanUtil {
static String getSale(String sale) {
int count = 0;
try {
count = int.parse(sale);
} catch (e) {
print(e.toString());
}
if (count < 1000) {
return "${count}";
} else if (count < 10000) {
return "${formatNum(count / 1000.0, 1)}k";
} else {
return "${formatNum(count / 10000.0, 1)}w";
}
}
static formatNum(double num, int postion) {
return (NumUtil.getNumByValueDouble(num, postion)).toStringAsFixed(postion);
}
}
...@@ -155,6 +155,13 @@ packages: ...@@ -155,6 +155,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.14.12" version: "1.14.12"
common_utils:
dependency: "direct main"
description:
name: common_utils
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.1"
convert: convert:
dependency: transitive dependency: transitive
description: description:
...@@ -190,6 +197,13 @@ packages: ...@@ -190,6 +197,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.6" version: "1.3.6"
decimal:
dependency: transitive
description:
name: decimal
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.5"
dio: dio:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -573,6 +587,13 @@ packages: ...@@ -573,6 +587,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.3" version: "2.1.3"
rational:
dependency: transitive
description:
name: rational
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.8"
rxdart: rxdart:
dependency: "direct main" dependency: "direct main"
description: description:
......
...@@ -36,6 +36,7 @@ dependencies: ...@@ -36,6 +36,7 @@ dependencies:
extended_nested_scroll_view: ^1.0.0 extended_nested_scroll_view: ^1.0.0
#适配库 #适配库
flutter_screenutil: ^1.1.0 flutter_screenutil: ^1.1.0
common_utils: ^1.2.1
dev_dependencies: dev_dependencies:
......
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