Commit 8d689f9d86c2d1e6479a30b8a58a25e092954a26

Authored by wdn127929
1 parent 00c1d080

菜品管理数据+UI

... ... @@ -57,28 +57,28 @@ class _MenuManagePageState extends State<MenuManagePage> {
},
),
body: WillPopScope(
onWillPop: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
child: Column(
children: [
Expanded(child: Consumer<MenuManageProvider>(
builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
// _couponNetworkData();
},
emptyMsg: "菜品是空哒,快点击分类管理添加分类和菜品吧",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return ListView.builder(
onWillPop: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
child: Consumer<MenuManageProvider>(
builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
// offset = 0;
// getMessage(showLoading: true);
// _couponNetworkData();
},
emptyMsg: "菜品是空哒,快点击分类管理添加分类和菜品吧",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(children: [
Expanded(
child: ListView.builder(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(40)),
... ... @@ -215,65 +215,68 @@ class _MenuManagePageState extends State<MenuManagePage> {
// // getMessage(showLoading: false);
// },
);
});
}
},
)),
// VEmptyView(20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(40),
0,
ScreenUtil().setWidth(40),
ScreenUtil().setWidth(40)),
child: RoundButton(
onPressed: () async {
bool needRefresh =
await NavigatorUtil.goCouponEditPage(context);
print(needRefresh);
if (needRefresh != null && needRefresh) {
//刷新页面数据
// _controller.callRefresh();
// _couponNetworkData();
}
},
text: '添加\n菜品',
fontSize: 26,
isBold: false,
height: ScreenUtil().setWidth(120),
width: ScreenUtil().setWidth(120),
radius: ScreenUtil().setWidth(60),
)),
Padding(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(40),
0,
ScreenUtil().setWidth(40),
ScreenUtil().setWidth(40)),
child: RoundButton(
onPressed: () async {
bool needRefresh =
await NavigatorUtil.goCouponEditPage(context);
print(needRefresh);
if (needRefresh != null && needRefresh) {
//刷新页面数据
// _controller.callRefresh();
// _couponNetworkData();
}
},
text: '分类\n管理',
fontSize: 26,
isBold: false,
height: ScreenUtil().setWidth(120),
width: ScreenUtil().setWidth(120),
radius: ScreenUtil().setWidth(60),
))
],
)
],
)));
})),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
model.pageState == PageState.Empty
? SizedBox()
: Padding(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(40),
0,
ScreenUtil().setWidth(40),
ScreenUtil().setWidth(40)),
child: RoundButton(
onPressed: () async {
bool needRefresh =
await NavigatorUtil.goCouponEditPage(
context);
print(needRefresh);
if (needRefresh != null && needRefresh) {
//刷新页面数据
// _controller.callRefresh();
// _couponNetworkData();
}
},
text: '添加\n菜品',
fontSize: 26,
isBold: false,
height: ScreenUtil().setWidth(120),
width: ScreenUtil().setWidth(120),
radius: ScreenUtil().setWidth(60),
)),
Padding(
padding: EdgeInsets.fromLTRB(
ScreenUtil().setWidth(40),
0,
ScreenUtil().setWidth(40),
ScreenUtil().setWidth(40)),
child: RoundButton(
onPressed: () async {
bool needRefresh =
await NavigatorUtil.goCouponEditPage(context);
print(needRefresh);
if (needRefresh != null && needRefresh) {
//刷新页面数据
// _controller.callRefresh();
// _couponNetworkData();
}
},
text: '分类\n管理',
fontSize: 26,
isBold: false,
height: ScreenUtil().setWidth(120),
width: ScreenUtil().setWidth(120),
radius: ScreenUtil().setWidth(60),
))
],
)
]);
}
},
),
// VEmptyView(20),
));
}
}
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/cookbook_model.dart';
import 'package:one_key/net/base_resp.dart';
... ... @@ -8,7 +9,7 @@ import 'package:one_key/net/http_url.dart';
import 'package:one_key/utils/utils.dart';
class MenuManageProvider extends ChangeNotifier {
PageState pageState = PageState.Success;
PageState pageState = PageState.Loading;
List<MenuModel> menuModel; //菜品数据
///分类下所有菜品列表(1.传orderid顾客端获取带订单信息的 否则不传
... ... @@ -19,18 +20,38 @@ class MenuManageProvider extends ChangeNotifier {
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
menuModel = [];
if (baseResp != null && baseResp.code == Constant.status_success) {
List menu = baseResp.data[0]['list'];
for (int i = 0; i < menu.length; i++) {
menuModel.add(MenuModel.fromJson(menu[i]));
if (baseResp.data[0]['list'] == '') {
pageState = PageState.Empty;
} else {
List menu = baseResp.data[0]['list'];
for (int i = 0; i < menu.length; i++) {
menuModel.add(MenuModel.fromJson(menu[i]));
}
print(menuModel);
pageState = PageState.Success;
}
print(menuModel);
notifyListeners();
} else {
Utils.showToast(baseResp.msg ?? "");
pageState = PageState.ConnectivityError;
}
notifyListeners();
}
}
... ...