Commit 6d1074920f7dd935ded74038cc6b2443b5d74932

Authored by wdn127929
1 parent 221ea277

菜单数据

import 'package:flutter/material.dart';
///菜单
class MenuModel {
... ... @@ -82,6 +84,8 @@ class MenuSunModel {
int isSpec;
List practice;
int amount = 0; //菜品数量
MenuSunModel({
this.id,
this.sellerid,
... ...
... ... @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/provider/plan_dish_provider.dart';
import '../../../models/cookbook_model.dart';
import '../../../res/colors.dart';
import '../../../utils/screen_util.dart';
import '../../../widgets/round_button.dart';
... ... @@ -423,8 +424,7 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
if (value != null) {
setState(() {
labelSelIndex = value.first;
labelShow =
labelList[labelSelIndex];
labelShow = labelList[labelSelIndex];
});
}
},
... ... @@ -661,13 +661,28 @@ class _PlanDishEidtPageState extends State<PlanDishEidtPage> {
color: MyColours.color_DBDBDB),
VEmptyView(24),
_select('菜品', '编辑', () async {
// Map temp =
// await NavigatorUtil.godishToPersonnalPage(
// context, uids);
// if (temp != null && temp['object'] != null) {
// uids = temp['object'];
// }
NavigatorUtil.goPlanNewDishPage(context);
Map temp =
await NavigatorUtil.goPlanNewDishPage(
context);
if (temp != null) {
int priceSum = temp['priceSum'];
int memberPriceSum = temp['memberPriceSum'];
String planDishSum = temp['planDishSum'];
List<MenuModel> menuModel =
temp['menu']; //菜品数据
print(priceSum);
print(memberPriceSum);
print(planDishSum);
print(menuModel);
// 刷新页面***************
}
}),
_explain('券说明', '点击上面右侧的“编辑”,开始选菜吧!'),
VEmptyView(20),
... ...
import 'package:flutter/material.dart';
import 'package:one_key/models/cookbook_model.dart';
import 'package:one_key/provider/plan_dish_provider.dart';
import 'package:one_key/utils/screen_util.dart';
import 'package:one_key/widgets/h_empty_view.dart';
... ... @@ -9,6 +10,7 @@ import 'package:provider/provider.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../../../constant/state.dart';
import '../../../provider/user_model.dart';
import '../../../res/colors.dart';
import '../../../route/navigator_util.dart';
import '../../../utils/utils.dart';
... ... @@ -39,19 +41,27 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
ItemPositionsListener.create();
PlanDishProvider _planDishProvider;
int carSum = 0; //购物车显示菜品总个数
double priceSum = 0; //总计
double memberPriceSum = 0; //会员价
TextEditingController planDishC = TextEditingController(); //排菜价
List<MenuSunModel> selectMenu = [];
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
_getMenuData();
_getCookbookByClass(showLoading: false);
});
}
///接口
_getMenuData() {
// Map<String, dynamic> params = {"sellerid": int.parse(widget.sellerID)};
// _storeMenuProvider.getStoreMenu(context, params);
_getCookbookByClass({bool showLoading = true}) async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await _planDishProvider.getCookbookByClass(context, params,
showLoading: showLoading);
}
Widget list(List data) => ScrollablePositionedList.builder(
... ... @@ -140,11 +150,16 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
@override
Widget build(BuildContext context) {
_planDishProvider = Provider.of<PlanDishProvider>(context, listen: true);
// _planDishProvider.menuModel.forEach((element) {
// element.cookbooklist.forEach((value) {
// carSum += value.amount;
// });
// });
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar('经理排菜'),
body: Consumer<PlanDishProvider>(builder: (context, model, child) {
if (model.pageStateMy == PageState.Success) {
if (model.pageState == PageState.Success) {
return Column(
children: [
MyDivider(
... ... @@ -154,6 +169,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
),
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ValueListenableBuilder<Iterable<ItemPosition>>(
valueListenable: itemPositionsListener.itemPositions,
... ... @@ -198,9 +214,16 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
child: ListView.builder(
// itemCount:
// _storeMenuProvider.menulist.length,
itemCount: 100,
itemCount:
_planDishProvider.menuModel.length,
itemBuilder:
(BuildContext context, int index) {
MenuModel menuModel =
_planDishProvider.menuModel[index];
int sum = 0;
menuModel.cookbooklist.forEach((element) {
sum += element.amount;
});
return InkWell(
onTap: () {
isTap = true;
... ... @@ -236,7 +259,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
child: Text(
// _storeMenuProvider
// .menulist[index].className,
'热菜',
menuModel.className,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
... ... @@ -248,29 +271,34 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
.color_999999),
),
),
Positioned(
top: w(2),
right: w(2),
child: Container(
// width: w(16),
constraints: BoxConstraints(
minWidth: w(16)),
height: w(16),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(
r(8)),
color: MyColours
.color_E34D59),
child: Text(
'23',
style: TextStyle(
fontSize: font(10),
color: MyColours
.color_F6F6F6),
),
))
sum > 0
? Positioned(
top: w(2),
right: w(2),
child: Container(
// width: w(16),
constraints:
BoxConstraints(
minWidth: w(16)),
height: w(16),
alignment:
Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius
.circular(
r(8)),
color: MyColours
.color_E34D59),
child: Text(
'${sum}',
style: TextStyle(
fontSize: font(10),
color: MyColours
.color_F6F6F6),
),
))
: SizedBox()
],
),
);
... ... @@ -284,9 +312,16 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
child: ListView.builder(
shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
itemCount: 10,
itemCount: _planDishProvider
.menuModel[_selectIndex]
.cookbooklist
.length,
itemBuilder:
(BuildContext context, int index) {
MenuSunModel menuSunModel =
_planDishProvider
.menuModel[_selectIndex]
.cookbooklist[index];
return Container(
padding:
EdgeInsets.symmetric(vertical: w(16)),
... ... @@ -309,7 +344,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
BoxConstraints(
maxWidth: w(100)),
child: Text(
'菜菜菜',
menuSunModel.name,
maxLines: 10,
overflow: TextOverflow
.ellipsis,
... ... @@ -320,22 +355,23 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
color: MyColours
.color_515151),
)),
HEmptyView(8),
_laduWidget()
// HEmptyView(8),
// _laduWidget()
],
),
VEmptyView(24),
Row(
children: [
Text(
'858.0元/份',
'${menuSunModel.price}元/${menuSunModel.unit}',
style: TextStyle(
fontSize: font(12),
color: MyColours
.color_999999),
),
HEmptyView(48),
Text(
'824.0元/份',
'${menuSunModel.member_price}元/${menuSunModel.unit}',
style: TextStyle(
fontSize: font(10),
color: MyColours
... ... @@ -346,75 +382,130 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
],
)),
// Spacer(),
Image.asset(
Utils.getImgPath('plan_dish_minus'),
width: w(16),
),
menuSunModel.amount != null &&
menuSunModel.amount > 0
? InkWell(
onTap: () {
if (menuSunModel.amount >
0) {
setState(() {
menuSunModel.amount--;
carSum--;
priceSum -=
double.parse(
menuSunModel
.price);
memberPriceSum -= double
.parse(menuSunModel
.member_price);
planDishC.text =
'${priceSum}';
});
}
},
child: Image.asset(
Utils.getImgPath(
'plan_dish_minus'),
width: w(16),
))
: SizedBox(),
HEmptyView(8),
Container(
width: w(32),
height: w(16),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(
r(5)),
border: Border.all(
width: w(1),
color: MyColours
.color_999999)),
// constraints: BoxConstraints(minWidth: w(20)),
child: TextField(
maxLines: 1,
// controller:
// focusNode: _focusNode,
// autofocus: true,
style: TextStyle(
color:
MyColours.color_438E93,
fontSize: font(12)),
textAlign: TextAlign.center,
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: "人数",
hintStyle: TextStyle(
color:
MyColours.color_999999,
fontSize: font(12),
menuSunModel.amount != null &&
menuSunModel.amount > 0
? Container(
constraints: BoxConstraints(
minWidth: w(32),
),
// width: w(32),
height: w(16),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(
r(5)),
border: Border.all(
width: w(1),
color: MyColours
.color_999999)),
alignment: Alignment.center,
// constraints: BoxConstraints(minWidth: w(20)),
child: Text(
'${menuSunModel.amount}',
style: TextStyle(
color: MyColours
.color_438E93,
fontSize: font(12)),
),
// isCollapsed:
// true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
border: OutlineInputBorder(
borderSide:
BorderSide.none),
contentPadding:
EdgeInsets.zero,
),
keyboardType:
TextInputType.number,
textInputAction:
TextInputAction.done,
// child: TextField(
// maxLines: 1,
// // controller:
// // focusNode: _focusNode,
// // autofocus: true,
onChanged: (value) {
// setState(() {});
// _searchSellerLocation();
// customerProvider.searchData(value);
},
onEditingComplete: () {
FocusScope.of(context)
.requestFocus(
FocusNode()); //点击空白处隐藏键盘
// contantShowModel.searchData(
// contantShowModel.controller.text);
// _searchSellerLocation();
// _focusNode.unfocus();
},
)),
// style: TextStyle(
// color: MyColours
// .color_438E93,
// fontSize: font(12)),
// textAlign: TextAlign.center,
// // textAlignVertical: TextAlignVertical.center,
// decoration: InputDecoration(
// hintText: "人数",
// hintStyle: TextStyle(
// color: MyColours
// .color_999999,
// fontSize: font(12),
// ),
// // isCollapsed:
// // true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
// border:
// OutlineInputBorder(
// borderSide:
// BorderSide
// .none),
// contentPadding:
// EdgeInsets.zero,
// ),
// keyboardType:
// TextInputType.number,
// textInputAction:
// TextInputAction.done,
// onChanged: (value) {
// // setState(() {});
// // _searchSellerLocation();
// // customerProvider.searchData(value);
// },
// onEditingComplete: () {
// FocusScope.of(context)
// .requestFocus(
// FocusNode()); //点击空白处隐藏键盘
// // contantShowModel.searchData(
// // contantShowModel.controller.text);
// // _searchSellerLocation();
// // _focusNode.unfocus();
// },
// )
)
: SizedBox(),
HEmptyView(8),
Image.asset(
Utils.getImgPath('plan_dish_add'),
width: w(16),
),
InkWell(
onTap: () {
setState(() {
menuSunModel.amount++;
carSum++;
priceSum += double.parse(
menuSunModel.price);
memberPriceSum +=
double.parse(menuSunModel
.member_price);
planDishC.text =
'${priceSum}';
});
},
child: Image.asset(
Utils.getImgPath(
'plan_dish_add'),
width: w(16),
)),
],
),
);
... ... @@ -438,24 +529,28 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
Utils.getImgPath('plan_dish_car'),
width: w(35),
),
Positioned(
top: w(-3),
right: w(-4),
child: Container(
// width: w(16),
constraints: BoxConstraints(minWidth: w(16)),
height: w(16),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(r(8)),
color: MyColours.color_E34D59),
child: Text(
'23',
style: TextStyle(
fontSize: font(10),
color: MyColours.color_F6F6F6),
),
))
carSum > 0
? Positioned(
top: w(-3),
right: w(-4),
child: Container(
// width: w(16),
constraints:
BoxConstraints(minWidth: w(16)),
height: w(16),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(r(8)),
color: MyColours.color_E34D59),
child: Text(
'${carSum}',
style: TextStyle(
fontSize: font(10),
color: MyColours.color_F6F6F6),
),
))
: SizedBox()
],
),
HEmptyView(66),
... ... @@ -471,7 +566,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
color: MyColours.color_515151),
),
Text(
'0.00',
'${priceSum}',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_000000),
... ... @@ -494,7 +589,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
color: MyColours.color_515151),
),
Text(
'0.00',
'${memberPriceSum}',
style: TextStyle(
fontSize: font(12),
color: MyColours.color_000000),
... ... @@ -525,7 +620,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
// constraints: BoxConstraints(minWidth: w(20)),
child: TextField(
maxLines: 1,
// controller:
controller: planDishC,
// focusNode: _focusNode,
// autofocus: true,
... ... @@ -585,7 +680,19 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
fontSize: 36,
isBold: false,
onPressed: () {
Navigator.pop(context);
// _planDishProvider.menuModel.forEach((element) {
// element.cookbooklist.forEach((value) {
// selectMenu.add(value);
// });
// });
Map data = {
'priceSum': priceSum,
'memberPriceSum': memberPriceSum,
'planDishSum': planDishC.text,
'menu': _planDishProvider.menuModel
};
Navigator.of(context).pop(data);
},
),
)
... ... @@ -597,6 +704,7 @@ class _PlanNewDishPageState extends State<PlanNewDishPage> {
emptyMsg: '暂时没有菜单哦',
callback: () {
// _getMenuData();
_getCookbookByClass(showLoading: true);
},
);
}
... ...
... ... @@ -13,10 +13,10 @@ import '../net/http_url.dart';
* 预排菜
*/
class PlanDishProvider extends ChangeNotifier {
PageState pageState = PageState.Success;
PageState pageState = PageState.Loading;
PageState pageStateStore = PageState.Success;
PageState pageStateMine = PageState.Success;
PageState pageStateMy = PageState.Success;
PageState pageStateMy = PageState.Loading;
List<MenuModel> menuModel; //菜品数据
// List<CookbookCategorySunModel> categorySunModel; //菜品分类数据
... ...