Commit 00c1d0809ef089d9da128d985a59f344244bd147

Authored by wdn127929
1 parent 497bdbda

菜品管理数据

... ... @@ -11,14 +11,14 @@ if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = "300"
def flutterVersionCode = "301"
if (flutterVersionCode == null) {
flutterVersionCode = '300'
flutterVersionCode = '301'
}
def flutterVersionName = "3.0.0"
def flutterVersionName = "3.0.1"
if (flutterVersionName == null) {
flutterVersionName = '3.0.0'
flutterVersionName = '3.0.1'
}
apply plugin: 'com.android.application'
... ...
///菜单
class MenuModel {
String id;
String sellerid;
String className;
Null classLabel;
String order;
String status;
String classType;
List<MenuSunModel> cookbooklist;
MenuModel(
{this.id,
this.sellerid,
this.className,
this.classLabel,
this.order,
this.status,
this.classType,
this.cookbooklist});
MenuModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sellerid = json['sellerid'];
className = json['class_name'];
classLabel = json['class_label'];
order = json['order'];
status = json['status'];
classType = json['class_type'];
if (json['cookbooklist'] != null) {
cookbooklist = [];
json['cookbooklist'][0].forEach((v) {
cookbooklist.add(new MenuSunModel.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sellerid'] = this.sellerid;
data['class_name'] = this.className;
data['class_label'] = this.classLabel;
data['order'] = this.order;
data['status'] = this.status;
data['class_type'] = this.classType;
if (this.cookbooklist != null) {
data['cookbooklist'] = this.cookbooklist.map((v) => v.toJson()).toList();
}
return data;
}
}
class MenuSunModel {
String id;
String sellerid;
String mid;
String cid;
String lid;
String unit;
String name;
String price;
String member_price;
String first_name;
String search_code;
String channel;
String dishesvideo;
String dishesgif;
String status;
String setup;
String give;
String clear_num;
String record_num;
String image;
String is_weigh;
String desc;
String order_o;
String cdate;
List spec;
int isSpec;
List practice;
MenuSunModel({
this.id,
this.sellerid,
this.mid,
this.cid,
this.lid,
this.unit,
this.name,
this.price,
this.member_price,
this.first_name,
this.search_code,
this.channel,
this.dishesvideo,
this.dishesgif,
this.status,
this.setup,
this.give,
this.clear_num,
this.record_num,
this.image,
this.is_weigh,
this.desc,
this.order_o,
this.cdate,
this.spec,
this.isSpec,
this.practice,
});
MenuSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sellerid = json['sellerid'];
mid = json['mid'];
lid = json['lid'];
unit = json['unit'];
name = json['name'];
price = json['price'];
member_price = json['member_price'];
first_name = json['first_name'];
search_code = json['search_code'];
channel = json['channel'];
dishesvideo = json['dishesvideo'];
dishesgif = json['dishesgif'];
status = json['status'];
setup = json['setup'];
give = json['give'];
clear_num = json['clear_num'];
record_num = json['record_num'];
image = json['image'];
is_weigh = json['is_weigh'];
desc = json['desc'];
order_o = json['order_o'];
cdate = json['cdate'];
spec = json['spec'];
isSpec = json['isSpec'];
practice = json['practice'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sellerid'] = this.sellerid;
data['mid'] = this.mid;
data['lid'] = this.lid;
data['unit'] = this.unit;
data['name'] = this.name;
data['price'] = this.price;
data['member_price'] = this.member_price;
data['first_name'] = this.first_name;
data['search_code'] = this.search_code;
data['channel'] = this.channel;
data['dishesvideo'] = this.dishesvideo;
data['dishesgif'] = this.dishesgif;
data['status'] = this.status;
data['setup'] = this.setup;
data['give'] = this.give;
data['clear_num'] = this.clear_num;
data['record_num'] = this.record_num;
data['image'] = this.image;
data['is_weigh'] = this.is_weigh;
data['desc'] = this.desc;
data['order_o'] = this.order_o;
data['cdate'] = this.cdate;
data['spec'] = this.spec;
data['isSpec'] = this.isSpec;
data['practice'] = this.practice;
return data;
}
}
... ...
... ... @@ -139,5 +139,7 @@ class HttpUrl {
"?service=App.Seller.GetTableClassById"; // 获取包间分类
static const String set_table_class =
"?service=App.Seller.SetTableClass"; // 添加/修改包间分类
static const String get_cookbook_by_class =
"?service=App.Cookbook.GetCookbookByClass"; //分类下所有菜品列表(1.传orderid顾客端获取带订单信息的 否则不传
}
... ...
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
import 'package:cached_network_image/cached_network_image.dart';
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_model.dart';
import 'package:one_key/provider/menu_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
class MenuManagePage extends StatefulWidget {
MenuManagePage({Key key}) : super(key: key);
@override
_MenuManagePageState createState() => _MenuManagePageState();
}
class _MenuManagePageState extends State<MenuManagePage> {
ScrollController _controller = ScrollController();
MenuManageProvider menuManageProvider;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
_getCookbookByClass();
});
}
_getCookbookByClass() async {
Map<String, String> params = {
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
};
await menuManageProvider.getCookbookByClass(context, params);
}
@override
Widget build(BuildContext context) {
menuManageProvider = Provider.of<MenuManageProvider>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'菜单管理',
onTap: () {
EventBus().emit('changeStatusColor');
Navigator.of(context).pop();
},
),
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(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40),
vertical: ScreenUtil().setWidth(40)),
itemCount: menuManageProvider.menuModel.length,
shrinkWrap: true,
controller: _controller,
itemBuilder: (BuildContext context, int indexOut) {
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: ScreenUtil().setWidth(10),
height: ScreenUtil().setWidth(10),
decoration: BoxDecoration(
color: MyColours.color_0D0D0D,
shape: BoxShape.circle),
),
MyDivider(ScreenUtil().setWidth(80),
ScreenUtil().setWidth(2),
color: MyColours.color_0D0D0D),
HEmptyView(20),
Text(
menuManageProvider
.menuModel[indexOut].className,
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(28),
),
),
HEmptyView(20),
MyDivider(ScreenUtil().setWidth(80),
ScreenUtil().setWidth(2),
color: MyColours.color_0D0D0D),
Container(
width: ScreenUtil().setWidth(10),
height: ScreenUtil().setWidth(10),
decoration: BoxDecoration(
color: MyColours.color_0D0D0D,
shape: BoxShape.circle),
),
],
),
GridView.builder(
controller: _controller,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(40)),
shrinkWrap: true,
cacheExtent: ScreenUtil().setWidth(0),
itemCount: menuManageProvider
.menuModel[indexOut]
.cookbooklist
.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 80 / 56,
mainAxisSpacing:
ScreenUtil().setWidth(15 * 2),
crossAxisSpacing:
ScreenUtil().setWidth(15 * 2)),
itemBuilder:
(BuildContext context, int index) {
MenuSunModel model = menuManageProvider
.menuModel[indexOut]
.cookbooklist[index];
return Container(
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: model.image != null
? ClipRRect(
borderRadius:
BorderRadius.circular(
ScreenUtil()
.setWidth(10)),
child: CachedNetworkImage(
imageUrl: model.image,
fit: BoxFit.cover,
width: ScreenUtil()
.setWidth(30 * 2),
height: ScreenUtil()
.setWidth(30 * 2),
),
)
: 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),
))
],
),
),
);
})
],
// onRefresh: () async {
// // offset = 0;
// // getMessage(showLoading: false);
// },
// onLoad: () async {
// // offset++;
// // 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),
))
],
)
],
)));
}
}
... ...
... ... @@ -338,6 +338,23 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
smsInfoData: smsInfoData);
},
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyItem(
title: "菜单管理",
content: "",
callback: () {
NavigatorUtil.goMenuManagePage(context);
},
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
color: MyColours.color_f3f3f3,
),
MyDivider(
double.infinity,
ScreenUtil().setHeight(1),
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/cookbook_model.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/utils/utils.dart';
class MenuManageProvider extends ChangeNotifier {
PageState pageState = PageState.Success;
List<MenuModel> menuModel; //菜品数据
///分类下所有菜品列表(1.传orderid顾客端获取带订单信息的 否则不传
getCookbookByClass(BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_cookbook_by_class,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
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]));
}
print(menuModel);
notifyListeners();
} else {
Utils.showToast(baseResp.msg ?? "");
}
}
}
... ...
... ... @@ -379,8 +379,8 @@ class NavigatorUtil {
SmsInfoData smsInfoData,
bool isNew = true,
String tableClassId}) {
return _navigateTo(
context, "${Routes.room_type_create_page}?isnew=${isNew}&tableClassId=${tableClassId}",
return _navigateTo(context,
"${Routes.room_type_create_page}?isnew=${isNew}&tableClassId=${tableClassId}",
replace: replace);
}
... ... @@ -399,4 +399,10 @@ class NavigatorUtil {
return _navigateTo(context,
"${Routes.room_type_select_table_page}?rid=$rid&tid=$tid&dateTime=$dateTime&fromPage=$fromPage&ddate_slot=$ddate_slot&canChoose=$canChoose");
}
/// 菜单管理
static Future<dynamic> goMenuManagePage(BuildContext context,
{replace = false}) {
return _navigateTo(context, "${Routes.menu_manage_page}", replace: replace);
}
}
... ...
... ... @@ -37,6 +37,7 @@ import 'package:one_key/pages/message/message_order_menu.dart';
import 'package:one_key/pages/my/base_info.dart';
import 'package:one_key/pages/my/book_time_set.dart';
import 'package:one_key/pages/my/contant_page.dart';
import 'package:one_key/pages/my/menu_type/menu_manage_page.dart';
import 'package:one_key/pages/my/my_integral_page.dart';
import 'package:one_key/pages/my/receive_orders_time_set.dart';
import 'package:one_key/pages/my/remark_manager_page.dart';
... ... @@ -61,6 +62,7 @@ import 'package:one_key/provider/book_set_time_model.dart';
import 'package:one_key/provider/choose_table_model.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/provider/create_store_model.dart';
import 'package:one_key/provider/menu_provider.dart';
import 'package:one_key/provider/my_model.dart';
import 'package:one_key/provider/notebook_detail_change_model.dart';
import 'package:one_key/provider/notebook_detail_model.dart';
... ... @@ -615,3 +617,14 @@ var roomTypeSelectTablePageHandler = new Handler(
fromPage: fromPage,
tid: tid));
});
///菜单管理页面
var menuManagePageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
// SmsInfoData data = SmsInfoData.fromJson(json.decode(
// FluroConvertUtils.fluroCnParamsDecode(params["smsInfoData"].first)));
return ChangeNotifierProvider<MenuManageProvider>(
create: (_) => MenuManageProvider(), child: MenuManagePage());
// return ChangeNotifierProvider<UploadImageProvider>(
// create: (_) => UploadImageProvider(), child: EnterStoreFrontPhotoPage());
});
... ...
... ... @@ -55,6 +55,7 @@ class Routes {
static String room_type_create_page = "/room_type_create_page"; //包间类型创建
static String room_type_select_table_page =
"/room_type_select_table_page"; //包间管理中桌位选择页面
static String menu_manage_page = "/menu_manage_page"; //菜单管理页面
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -117,5 +118,6 @@ class Routes {
router.define(room_type_create_page, handler: roomTypeCreatePageHandler);
router.define(room_type_select_table_page,
handler: roomTypeSelectTablePageHandler);
router.define(menu_manage_page, handler: menuManagePageHandle);
}
}
... ...