|
...
|
...
|
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
import 'package:flutter_screenutil/screenutil.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
|
|
import 'package:one_key/models/cookbook_category_model.dart';
|
|
|
|
import 'package:one_key/models/cookbook_model.dart';
|
|
|
|
import 'package:one_key/provider/menu_provider.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
...
|
...
|
@@ -30,14 +31,17 @@ class MenuManagePage extends StatefulWidget { |
|
|
|
class _MenuManagePageState extends State<MenuManagePage> {
|
|
|
|
ScrollController _controller = ScrollController();
|
|
|
|
MenuManageProvider menuManageProvider;
|
|
|
|
bool isShow = false; //添加菜品按钮
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
|
|
_getCookbookByClass(showLoading: false);
|
|
|
|
_getCookbookBySellerId();
|
|
|
|
});
|
|
|
|
EventBus().on('menu_manage_page', (arg) {
|
|
|
|
_getCookbookByClass(showLoading: false);
|
|
|
|
_getCookbookBySellerId();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -48,6 +52,33 @@ class _MenuManagePageState extends State<MenuManagePage> { |
|
|
|
EventBus().off('menu_manage_page');
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取分类数据
|
|
|
|
_getCookbookBySellerId({bool showLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"SellerId": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
};
|
|
|
|
|
|
|
|
await menuManageProvider.getCookbookClassBySellerId(context, params,
|
|
|
|
showLoading: showLoading);
|
|
|
|
List<CookbookCategorySunModel> temp = [];
|
|
|
|
if (menuManageProvider.categorySunModel.length > 0) {
|
|
|
|
menuManageProvider.categorySunModel.forEach((element) {
|
|
|
|
if (element.className != '10道必点菜') {
|
|
|
|
temp.add(element);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (temp.length == 0) {
|
|
|
|
setState(() {
|
|
|
|
isShow = false;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
setState(() {
|
|
|
|
isShow = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_getCookbookByClass({bool showLoading = true}) async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
...
|
...
|
@@ -77,18 +108,71 @@ class _MenuManagePageState extends State<MenuManagePage> { |
|
|
|
child: Consumer<MenuManageProvider>(
|
|
|
|
builder: (context, model, _) {
|
|
|
|
if (model.pageState != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: model.pageState,
|
|
|
|
callback: () {
|
|
|
|
// offset = 0;
|
|
|
|
// getMessage(showLoading: true);
|
|
|
|
// _couponNetworkData();
|
|
|
|
_getCookbookByClass(showLoading: true);
|
|
|
|
},
|
|
|
|
emptyMsg: "菜品是空哒,快点击分类管理添加分类和菜品吧",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
);
|
|
|
|
return Column(children: [
|
|
|
|
Expanded(
|
|
|
|
child: ExceptionPage(
|
|
|
|
pageState: model.pageState,
|
|
|
|
callback: () {
|
|
|
|
// offset = 0;
|
|
|
|
// getMessage(showLoading: true);
|
|
|
|
// _couponNetworkData();
|
|
|
|
_getCookbookByClass(showLoading: true);
|
|
|
|
},
|
|
|
|
emptyMsg: "菜品是空哒,快点击分类管理添加分类和菜品吧",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
)),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
!isShow
|
|
|
|
? SizedBox()
|
|
|
|
: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
0,
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
ScreenUtil().setWidth(40)),
|
|
|
|
child: RoundButton(
|
|
|
|
onPressed: () async {
|
|
|
|
await NavigatorUtil.goMenuAddDishesPage(
|
|
|
|
context);
|
|
|
|
},
|
|
|
|
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.goMenuCategoryPage(
|
|
|
|
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),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
)
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
// double cellWidth = (MediaQuery.of(context).size.width -
|
|
|
|
// ScreenUtil().setWidth(40 * 2 + 15 * 2) / 2);
|
|
...
|
...
|
@@ -160,95 +244,43 @@ class _MenuManagePageState extends State<MenuManagePage> { |
|
|
|
ScreenUtil()
|
|
|
|
.setWidth(40 * 2 + 15 * 2)) /
|
|
|
|
2);
|
|
|
|
return model.image != null
|
|
|
|
? Stack(children: [
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.circular(
|
|
|
|
ScreenUtil()
|
|
|
|
.setWidth(
|
|
|
|
10))),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius
|
|
|
|
.circular(ScreenUtil()
|
|
|
|
.setWidth(10)),
|
|
|
|
child: CachedNetworkImage(
|
|
|
|
imageUrl: model.image,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: cellWidth,
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(210),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
VEmptyView(15),
|
|
|
|
Text(
|
|
|
|
model.name,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_333333,
|
|
|
|
fontSize: ScreenUtil()
|
|
|
|
.setSp(34),
|
|
|
|
fontWeight:
|
|
|
|
FontWeight.bold),
|
|
|
|
),
|
|
|
|
VEmptyView(20),
|
|
|
|
Text(
|
|
|
|
'${model.price}元/${model.unit}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_333333,
|
|
|
|
fontSize: ScreenUtil()
|
|
|
|
.setSp(28),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom:
|
|
|
|
ScreenUtil().setWidth(14),
|
|
|
|
right:
|
|
|
|
ScreenUtil().setWidth(20),
|
|
|
|
child: model.status == '1'
|
|
|
|
? SizedBox()
|
|
|
|
: Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
'stop-sell'),
|
|
|
|
width: ScreenUtil()
|
|
|
|
.setWidth(82),
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(52),
|
|
|
|
)),
|
|
|
|
])
|
|
|
|
: Stack(children: [
|
|
|
|
Container(
|
|
|
|
width: cellWidth,
|
|
|
|
height:
|
|
|
|
ScreenUtil().setWidth(210),
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: index % 2 == 0
|
|
|
|
? Color.fromRGBO(
|
|
|
|
247, 230, 230, 1)
|
|
|
|
: Color.fromRGBO(
|
|
|
|
234, 236, 252, 1),
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.circular(
|
|
|
|
ScreenUtil()
|
|
|
|
.setWidth(10))),
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil()
|
|
|
|
.setWidth(20)),
|
|
|
|
child: Column(
|
|
|
|
return InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
await NavigatorUtil
|
|
|
|
.goMenuAddDishesPage(context,
|
|
|
|
isNew: false,
|
|
|
|
idstr: model.id);
|
|
|
|
},
|
|
|
|
child: model.image != null
|
|
|
|
? Stack(children: [
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.circular(
|
|
|
|
ScreenUtil()
|
|
|
|
.setWidth(
|
|
|
|
10))),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.circular(
|
|
|
|
ScreenUtil()
|
|
|
|
.setWidth(
|
|
|
|
10)),
|
|
|
|
child:
|
|
|
|
CachedNetworkImage(
|
|
|
|
imageUrl:
|
|
|
|
model.image,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: cellWidth,
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(210),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
VEmptyView(15),
|
|
|
|
Text(
|
|
|
|
model.name,
|
|
|
|
style: TextStyle(
|
|
...
|
...
|
@@ -259,7 +291,7 @@ class _MenuManagePageState extends State<MenuManagePage> { |
|
|
|
fontWeight:
|
|
|
|
FontWeight.bold),
|
|
|
|
),
|
|
|
|
VEmptyView(40),
|
|
|
|
VEmptyView(20),
|
|
|
|
Text(
|
|
|
|
'${model.price}元/${model.unit}',
|
|
|
|
style: TextStyle(
|
|
...
|
...
|
@@ -270,41 +302,113 @@ class _MenuManagePageState extends State<MenuManagePage> { |
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom: ScreenUtil()
|
|
|
|
.setWidth(14),
|
|
|
|
right: ScreenUtil()
|
|
|
|
.setWidth(20),
|
|
|
|
child: model.status == '1'
|
|
|
|
? SizedBox()
|
|
|
|
: Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
'stop-sell'),
|
|
|
|
width: ScreenUtil()
|
|
|
|
.setWidth(82),
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(52),
|
|
|
|
)),
|
|
|
|
])
|
|
|
|
: Stack(children: [
|
|
|
|
Container(
|
|
|
|
width: cellWidth,
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(210),
|
|
|
|
|
|
|
|
// VEmptyView(15),
|
|
|
|
// Text(
|
|
|
|
// ' ',
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_333333,
|
|
|
|
// fontSize:
|
|
|
|
// ScreenUtil().setSp(34),
|
|
|
|
// fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// VEmptyView(20),
|
|
|
|
// Text(' ',
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_333333,
|
|
|
|
// fontSize:
|
|
|
|
// ScreenUtil().setSp(28),
|
|
|
|
// ))
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom:
|
|
|
|
ScreenUtil().setWidth(46),
|
|
|
|
right:
|
|
|
|
ScreenUtil().setWidth(20),
|
|
|
|
child: model.status == '1'
|
|
|
|
? SizedBox()
|
|
|
|
: Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
'stop-sell'),
|
|
|
|
width: ScreenUtil()
|
|
|
|
.setWidth(82),
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(52),
|
|
|
|
)),
|
|
|
|
]);
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: index % 2 == 0
|
|
|
|
? Color.fromRGBO(
|
|
|
|
247, 230, 230, 1)
|
|
|
|
: Color.fromRGBO(
|
|
|
|
234, 236, 252, 1),
|
|
|
|
borderRadius: BorderRadius
|
|
|
|
.circular(ScreenUtil()
|
|
|
|
.setWidth(10))),
|
|
|
|
child: Container(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(
|
|
|
|
horizontal:
|
|
|
|
ScreenUtil()
|
|
|
|
.setWidth(
|
|
|
|
20)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment
|
|
|
|
.start,
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment
|
|
|
|
.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
model.name,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_333333,
|
|
|
|
fontSize:
|
|
|
|
ScreenUtil()
|
|
|
|
.setSp(
|
|
|
|
34),
|
|
|
|
fontWeight:
|
|
|
|
FontWeight
|
|
|
|
.bold),
|
|
|
|
),
|
|
|
|
VEmptyView(40),
|
|
|
|
Text(
|
|
|
|
'${model.price}元/${model.unit}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_333333,
|
|
|
|
fontSize:
|
|
|
|
ScreenUtil()
|
|
|
|
.setSp(
|
|
|
|
28),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
// VEmptyView(15),
|
|
|
|
// Text(
|
|
|
|
// ' ',
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_333333,
|
|
|
|
// fontSize:
|
|
|
|
// ScreenUtil().setSp(34),
|
|
|
|
// fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// VEmptyView(20),
|
|
|
|
// Text(' ',
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_333333,
|
|
|
|
// fontSize:
|
|
|
|
// ScreenUtil().setSp(28),
|
|
|
|
// ))
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom: ScreenUtil()
|
|
|
|
.setWidth(46),
|
|
|
|
right: ScreenUtil()
|
|
|
|
.setWidth(20),
|
|
|
|
child: model.status == '1'
|
|
|
|
? SizedBox()
|
|
|
|
: Image.asset(
|
|
|
|
Utils.getImgPath(
|
|
|
|
'stop-sell'),
|
|
|
|
width: ScreenUtil()
|
|
|
|
.setWidth(82),
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(52),
|
|
|
|
)),
|
|
|
|
]));
|
|
|
|
},
|
|
|
|
staggeredTileBuilder: (int index) =>
|
|
|
|
new StaggeredTile.count(
|
|
...
|
...
|
@@ -327,7 +431,7 @@ class _MenuManagePageState extends State<MenuManagePage> { |
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
model.pageState == PageState.Empty
|
|
|
|
!isShow
|
|
|
|
? SizedBox()
|
|
|
|
: Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(
|
...
|
...
|
|