Commit 40e8d2d59dc0bbca207e30eaa919fcd755454959

Authored by “gaiyaguang”
1 parent e08b7dcf

合并

... ... @@ -178,7 +178,7 @@ class DioUtil {
// Utils.showToast("网络错误,请稍后重试");
throw MyError(type: 1);
}
if (showLoading) Loading.showLoading(context);
// if (showLoading) Loading.showLoading(context);
try {
print('--------' + path + '---------');
Response response = await _dio.request(path,
... ...
... ... @@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/manager.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/provider/notebook_detail_model.dart';
... ... @@ -14,6 +15,7 @@ import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/app_bar.dart';
import 'package:one_key/widgets/common_button.dart';
import 'package:one_key/widgets/need_item.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/row_multi_text.dart';
import 'package:one_key/widgets/table_item.dart';
import 'package:one_key/models/table.dart' as t;
... ... @@ -37,7 +39,7 @@ class HandleOnlinePage extends StatefulWidget {
}
class HandleOnlinePageState extends State<HandleOnlinePage> {
NotebookDetailModel detailModel = NotebookDetailModel();
NotebookDetailModel detailModel;
NotebookDetail detailEntity;
... ... @@ -55,39 +57,44 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
detailEntity = await detailModel.getReserveDetail(context, {
"rid": widget.rid,
});
setState(() {
//未处理
cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman;
formatPhone = detailEntity.phone;
if (App.sp.getString("is_call_tel") != null &&
App.sp.getString("is_call_tel") == "1") {
isCallTel = true;
} else {
isCallTel = false;
if (detailEntity.phone.isNotEmpty &&
detailEntity.phone.length == 11 &&
(detailEntity.status == "0" || detailEntity.status == "6")) {
formatPhone = detailEntity.phone.substring(0, 3) +
"****" +
detailEntity.phone.substring(7);
}
}
});
if (detailEntity.status != "0") {
//已处理
Future.delayed(Duration(milliseconds: 200), () {
NavigatorUtil.goNotebookDetailPage(context, detailEntity.id,
fromNotify: widget.fromNotify, replace: true);
});
setMessageStatus();
WidgetsBinding.instance.addPostFrameCallback((_) {
_getOrderListData();
});
}
/// 获取当前预订订单详情
_getOrderListData() async {
detailEntity = await detailModel.getReserveDetail(context, {
"rid": widget.rid,
});
setState(() {
//未处理
cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman;
formatPhone = detailEntity.phone;
if (App.sp.getString("is_call_tel") != null &&
App.sp.getString("is_call_tel") == "1") {
isCallTel = true;
} else {
managers = await detailModel.getManagers(context);
isCallTel = false;
if (detailEntity.phone.isNotEmpty &&
detailEntity.phone.length == 11 &&
(detailEntity.status == "0" || detailEntity.status == "6")) {
formatPhone = detailEntity.phone.substring(0, 3) +
"****" +
detailEntity.phone.substring(7);
}
}
});
if (detailEntity.status != "0") {
//已处理
Future.delayed(Duration(milliseconds: 200), () {
NavigatorUtil.goNotebookDetailPage(context, detailEntity.id,
fromNotify: widget.fromNotify, replace: true);
});
setMessageStatus();
} else {
managers = await detailModel.getManagers(context);
}
}
//设置当前客户经理
... ... @@ -140,7 +147,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
widget.rid,
int.parse(detailEntity.ddate) * 1000,
detailEntity.ddate_solt);
if (temp['tid'] != null) {
if (temp != null && temp['tid'] != null) {
setReserveStatus("5", tid: temp['tid']);
}
},
... ... @@ -186,30 +193,37 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
@override
Widget build(BuildContext context) {
// TODO: implement build
return SafeArea(
child: WillPopScope(
child: detailEntity == null
? Container(
width: double.infinity,
height: double.infinity,
color: MyColours.color_ffffff,
)
: Column(
children: <Widget>[
MyAppBar(
"在线预订详情",
showBack: true,
detailModel = Provider.of<NotebookDetailModel>(context, listen: true);
return Scaffold(
body: SafeArea(
child: WillPopScope(
child: Column(
children: <Widget>[
MyAppBar(
"在线预订详情",
showBack: true,
callback: () {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
} else {
Navigator.of(context).pop();
}
},
),
Expanded(child: Consumer<NotebookDetailModel>(
builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
} else {
Navigator.of(context).pop();
}
_getOrderListData();
},
),
Expanded(
emptyMsg: "暂时没有预订列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Expanded(
child: DefaultTextStyle(
style: TextStyle(decoration: TextDecoration.none),
child: Container(
... ... @@ -464,9 +478,12 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
)
],
))),
)
],
),
);
}
},
))
],
),
onWillPop: () async {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
... ... @@ -475,6 +492,6 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
Navigator.of(context).pop();
return true;
},
));
)));
}
}
... ...
... ... @@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/manager.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/provider/message_dialog_model.dart';
... ... @@ -21,6 +22,7 @@ import 'package:one_key/widgets/dialog.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/loading.dart';
import 'package:one_key/widgets/need_item.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/row_multi_text.dart';
import 'package:one_key/widgets/table_item.dart';
... ... @@ -45,7 +47,7 @@ class NotebookDetailPage extends StatefulWidget {
}
class NotebookDetailPageState extends State<NotebookDetailPage> {
NotebookDetailModel detailModel = NotebookDetailModel();
NotebookDetailModel detailModel;
NotebookDetail detailEntity;
... ... @@ -64,7 +66,7 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
ScrollController _scrollController;
String formatPhone="";
String formatPhone = "";
@override
void initState() {
... ... @@ -119,11 +121,16 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
});
setState(() {
cusmanText = detailEntity.cusman.isEmpty ? "请选择" : detailEntity.cusman;
formatPhone=detailEntity.phone;
if(App.sp.getString("is_call_tel")!=null&&App.sp.getString("is_call_tel")=="1"){
}else{
if(detailEntity.phone.isNotEmpty&&detailEntity.phone.length==11&&(detailEntity.status=="0"||detailEntity.status=="6")){
formatPhone=detailEntity.phone.substring(0,3)+"****"+detailEntity.phone.substring(7);
formatPhone = detailEntity.phone;
if (App.sp.getString("is_call_tel") != null &&
App.sp.getString("is_call_tel") == "1") {
} else {
if (detailEntity.phone.isNotEmpty &&
detailEntity.phone.length == 11 &&
(detailEntity.status == "0" || detailEntity.status == "6")) {
formatPhone = detailEntity.phone.substring(0, 3) +
"****" +
detailEntity.phone.substring(7);
}
}
});
... ... @@ -409,346 +416,384 @@ class NotebookDetailPageState extends State<NotebookDetailPage> {
if (MediaQuery.of(context).viewInsets.bottom == 0) {
_cancelNode.unfocus();
}
return WillPopScope(
child: detailEntity == null
? Container(
width: double.infinity,
height: double.infinity,
color: MyColours.color_ffffff,
)
: Container(
color: MyColours.color_ffffff,
child: Column(
children: <Widget>[
SizedBox(height: ScreenUtil.statusBarHeight),
MyAppBar(
"订座详情",
showBack: true,
detailModel = Provider.of<NotebookDetailModel>(context, listen: true);
return Scaffold(
body: SafeArea(
child: WillPopScope(
child: Container(
color: MyColours.color_ffffff,
child: Column(
children: <Widget>[
SizedBox(height: ScreenUtil.statusBarHeight),
MyAppBar(
"订座详情",
showBack: true,
callback: () {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
} else {
Navigator.of(context).pop();
}
},
),
Expanded(child:
Consumer<NotebookDetailModel>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
} else {
Navigator.of(context).pop();
}
// _getOrderListData();
},
),
Expanded(
child: DefaultTextStyle(
style: TextStyle(decoration: TextDecoration.none),
child: Container(
color: MyColours.color_ffffff,
child: SingleChildScrollView(
emptyMsg: "暂时没有预订列表信息哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(
children: [
Expanded(
child: DefaultTextStyle(
style: TextStyle(decoration: TextDecoration.none),
child: Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(43)),
child: Column(
children: <Widget>[
RowMultiText("用餐时段", detailEntity.ddateMd),
Stack(
alignment: Alignment.center,
color: MyColours.color_ffffff,
child: SingleChildScrollView(
child: Container(
color: MyColours.color_ffffff,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(43)),
child: Column(
children: <Widget>[
Column(
RowMultiText(
"用餐时段", detailEntity.ddateMd),
Stack(
alignment: Alignment.center,
children: <Widget>[
RowMultiText(
"用餐时间", detailEntity.ddateHm),
Offstage(
offstage: detailEntity.type == "0"
? false
: true,
child: RowMultiText(
"用餐人数", detailEntity.pnum),
Column(
children: <Widget>[
RowMultiText("用餐时间",
detailEntity.ddateHm),
Offstage(
offstage:
detailEntity.type == "0"
? false
: true,
child: RowMultiText("用餐人数",
detailEntity.pnum),
)
],
),
Image.asset(
detailEntity.statuImgAssets,
width: ScreenUtil().setWidth(100),
height: ScreenUtil().setWidth(30),
)
],
),
Image.asset(
detailEntity.statuImgAssets,
width: ScreenUtil().setWidth(100),
height: ScreenUtil().setWidth(30),
)
],
),
Offstage(
offstage: detailEntity.demands.length <= 0
? true
: false,
child: Column(
children: <Widget>[
RowMultiText(
"包间需求",
(detailEntity.demands.length
.toString() +
"个") ??
""),
Align(
alignment: Alignment.centerRight,
child: Offstage(
offstage: detailEntity
.demands.length >
0
? false
: true,
child: Container(
height: ScreenUtil()
.setHeight(210),
child: ListView.builder(
itemBuilder:
(BuildContext contxt,
int index) {
return NeedItem(
detailEntity
.demands[index]);
},
itemCount: detailEntity
.demands.length,
shrinkWrap: true,
scrollDirection:
Axis.horizontal,
),
),
))
],
),
),
RowMultiText(
"预订桌位",
(detailEntity.tables.length.toString() +
"个")),
Align(
alignment: Alignment.centerRight,
child: Offstage(
Offstage(
offstage:
detailEntity.tables.length > 0
? false
: true,
child: Container(
height: ScreenUtil().setHeight(210),
child: ListView.builder(
itemBuilder: (BuildContext contxt,
int index) {
return TableItem(
detailEntity.tables[index]);
},
itemCount:
detailEntity.tables.length,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
),
),
)),
RowMultiText("客户姓名", detailEntity.rnameStr),
RowMultiText(
"客户电话", formatPhone),
Offstage(
offstage: detailEntity.cusdem == '' ||
detailEntity.cusdem == null,
child: RowMultiText(
"备注信息", detailEntity.cusdem ?? ""),
),
MyDivider(double.infinity,
ScreenUtil().setHeight(1)),
Container(
color: MyColours.color_ffffff,
width: double.infinity,
height: ScreenUtil().setHeight(80),
alignment: Alignment.center,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
left: 0,
child: Text(
"客户经理",
style: TextStyle(
color: MyColours.color_828282,
fontSize:
ScreenUtil().setSp(30)),
),
detailEntity.demands.length <= 0
? true
: false,
child: Column(
children: <Widget>[
RowMultiText(
"包间需求",
(detailEntity.demands.length
.toString() +
"个") ??
""),
Align(
alignment:
Alignment.centerRight,
child: Offstage(
offstage: detailEntity
.demands
.length >
0
? false
: true,
child: Container(
height: ScreenUtil()
.setHeight(210),
child: ListView.builder(
itemBuilder:
(BuildContext
contxt,
int index) {
return NeedItem(
detailEntity
.demands[
index]);
},
itemCount: detailEntity
.demands.length,
shrinkWrap: true,
scrollDirection:
Axis.horizontal,
),
),
))
],
),
Positioned(
right: 0,
child: GestureDetector(
onTap: () async {
List<String> list = [];
for (Manager manager
in managers) {
list.add(
manager.roleUserName);
}
DialogUtil
.showSelectCusmanDialog(
context, list, (value) {
if (value != null) {
setState(() {
cusmanText =
managers[value.first]
.userName;
});
_setCurrManager();
}
}).then((value) {});
},
child: Text(
cusmanText,
style: TextStyle(
color: MyColours.color_353535,
fontSize:
ScreenUtil().setSp(30),
decoration:
TextDecoration.underline,
),
RowMultiText(
"预订桌位",
(detailEntity.tables.length
.toString() +
"个")),
Align(
alignment: Alignment.centerRight,
child: Offstage(
offstage:
detailEntity.tables.length > 0
? false
: true,
child: Container(
height:
ScreenUtil().setHeight(210),
child: ListView.builder(
itemBuilder:
(BuildContext contxt,
int index) {
return TableItem(
detailEntity
.tables[index]);
},
itemCount: detailEntity
.tables.length,
shrinkWrap: true,
scrollDirection:
Axis.horizontal,
),
),
),
)
],
),
),
Offstage(
offstage: detailEntity.note_name == '' ||
detailEntity.note_name == null,
child: RowMultiText(
"记录人", detailEntity.note_name ?? ""),
),
Offstage(
offstage: (detailEntity.status == "4" &&
detailEntity.cancel != null)
? false
: true,
child: Column(
children: <Widget>[
MyDivider(double.infinity,
ScreenUtil().setHeight(2)),
RowMultiText("取消原因",
detailEntity.cancel?.desc ?? "",
textAlign: TextAlign.left),
RowMultiText(
"取消时间",
detailEntity.cancel?.cdateStr ??
""),
RowMultiText(
"操作人",
detailEntity.abolition == '2'
? '顾客在线取消'
: detailEntity
.cancel?.uname ??
)),
RowMultiText(
"客户姓名", detailEntity.rnameStr),
RowMultiText("客户电话", formatPhone),
Offstage(
offstage: detailEntity.cusdem == '' ||
detailEntity.cusdem == null,
child: RowMultiText("备注信息",
detailEntity.cusdem ?? ""),
),
MyDivider(double.infinity,
ScreenUtil().setHeight(1)),
Container(
color: MyColours.color_ffffff,
width: double.infinity,
height: ScreenUtil().setHeight(80),
alignment: Alignment.center,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
left: 0,
child: Text(
"客户经理",
style: TextStyle(
color: MyColours
.color_828282,
fontSize: ScreenUtil()
.setSp(30)),
),
),
Positioned(
right: 0,
child: GestureDetector(
onTap: () async {
List<String> list = [];
for (Manager manager
in managers) {
list.add(
manager.roleUserName);
}
DialogUtil
.showSelectCusmanDialog(
context, list,
(value) {
if (value != null) {
setState(() {
cusmanText = managers[
value.first]
.userName;
});
_setCurrManager();
}
}).then((value) {});
},
child: Text(
cusmanText,
style: TextStyle(
color: MyColours
.color_353535,
fontSize: ScreenUtil()
.setSp(30),
decoration: TextDecoration
.underline,
),
),
),
)
],
),
),
Offstage(
offstage: detailEntity.note_name ==
'' ||
detailEntity.note_name == null,
child: RowMultiText("记录人",
detailEntity.note_name ?? ""),
),
Offstage(
offstage: (detailEntity.status ==
"4" &&
detailEntity.cancel != null)
? false
: true,
child: Column(
children: <Widget>[
MyDivider(double.infinity,
ScreenUtil().setHeight(2)),
RowMultiText(
"取消原因",
detailEntity.cancel?.desc ??
"",
textAlign: TextAlign.left),
RowMultiText(
"取消时间",
detailEntity
.cancel?.cdateStr ??
""),
],
),
),
],
)),
),
)),
),
Offstage(
offstage: (detailEntity.status == "3" ||
detailEntity.status == "4" ||
detailEntity.status == "6")
? true
: false,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border(
top: BorderSide(
color: MyColours.color_dbe3e3,
width: ScreenUtil().setWidth(1)))),
padding: EdgeInsets.fromLTRB(
ScreenUtil().setHeight(40),
ScreenUtil().setHeight(40),
ScreenUtil().setHeight(40),
ScreenUtil().setHeight(0)),
margin: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(20)),
child: CommonButton(
content: "通知客户",
width: 669,
height: 84,
fontSize: 34,
onPress: () {
DialogUtil.showShareDialog(context)?.then((value) {
switch (value) {
case 1: //微信
NavigatorUtil.goInvicationPage(
context,
detailEntity.id,
detailEntity.tableinfoStr,
detailEntity.ddate,
detailEntity.ddateStr);
break;
case 2: //短信
NavigatorUtil.goSmsPage(
context, detailEntity.id);
break;
case 3: //电话
if (detailEntity.phone != null &&
detailEntity.phone.isNotEmpty) {
Utils.goPhone(detailEntity.phone);
} else {
Utils.showToast("没有客户电话!");
}
break;
}
});
},
RowMultiText(
"操作人",
detailEntity.abolition == '2'
? '顾客在线取消'
: detailEntity
.cancel?.uname ??
""),
],
),
),
],
)),
),
)),
),
),
),
Offstage(
offstage: (detailEntity.status == "3" ||
detailEntity.status == "4" ||
detailEntity.status == "6")
? true
: false,
child: Container(
width: double.infinity,
height: ScreenUtil().setWidth(84),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setHeight(40)),
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_199095,
width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(10)),
Offstage(
offstage: (detailEntity.status == "3" ||
detailEntity.status == "4" ||
detailEntity.status == "6")
? true
: false,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border(
top: BorderSide(
color: MyColours.color_dbe3e3,
width: ScreenUtil().setWidth(1)))),
padding: EdgeInsets.fromLTRB(
ScreenUtil().setHeight(40),
ScreenUtil().setHeight(40),
ScreenUtil().setHeight(40),
ScreenUtil().setHeight(0)),
margin: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(20)),
child: CommonButton(
content: "通知客户",
width: 669,
height: 84,
fontSize: 34,
onPress: () {
DialogUtil.showShareDialog(context)
?.then((value) {
switch (value) {
case 1: //微信
NavigatorUtil.goInvicationPage(
context,
detailEntity.id,
detailEntity.tableinfoStr,
detailEntity.ddate,
detailEntity.ddateStr);
break;
case 2: //短信
NavigatorUtil.goSmsPage(
context, detailEntity.id);
break;
case 3: //电话
if (detailEntity.phone != null &&
detailEntity.phone.isNotEmpty) {
Utils.goPhone(detailEntity.phone);
} else {
Utils.showToast("没有客户电话!");
}
break;
}
});
},
),
),
),
// child: Text('fff'),
child: Material(
color: Colors.transparent,
child: Row(
children: [
Expanded(
child: _cancelAndChangeBtn(() {
print('点击变更预订');
NavigatorUtil.goNoteBookChangePage(
context, detailEntity, widget.rid);
}, '变更预订')),
MyDivider(
ScreenUtil().setWidth(2),
ScreenUtil().setWidth(50),
Offstage(
offstage: (detailEntity.status == "3" ||
detailEntity.status == "4" ||
detailEntity.status == "6")
? true
: false,
child: Container(
width: double.infinity,
height: ScreenUtil().setWidth(84),
margin: EdgeInsets.symmetric(
horizontal: ScreenUtil().setHeight(40)),
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_199095,
),
Expanded(
child: _cancelAndChangeBtn(() {
_showCancelWidget(context);
}, '取消预订')),
],
)),
),
),
VEmptyView(ScreenUtil().setWidth(60))
],
),
),
onWillPop: () async {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(10)),
),
// child: Text('fff'),
child: Material(
color: Colors.transparent,
child: Row(
children: [
Expanded(
child: _cancelAndChangeBtn(() {
print('点击变更预订');
NavigatorUtil.goNoteBookChangePage(
context, detailEntity, widget.rid);
}, '变更预订')),
MyDivider(
ScreenUtil().setWidth(2),
ScreenUtil().setWidth(50),
color: MyColours.color_199095,
),
Expanded(
child: _cancelAndChangeBtn(() {
_showCancelWidget(context);
}, '取消预订')),
],
)),
),
),
VEmptyView(ScreenUtil().setWidth(60))
],
);
}
})),
],
),
),
onWillPop: () async {
if (widget.fromNotify) {
NavigatorUtil.goHomePage(context, initialIndex: 0);
return true;
}
Navigator.of(context).pop();
return true;
}
Navigator.of(context).pop();
return true;
},
},
)),
);
}
}
... ...
... ... @@ -2,6 +2,7 @@ import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/area.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/models/tableOuter.dart';
... ... @@ -16,6 +17,7 @@ import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/app_bar.dart';
import 'package:one_key/widgets/area_item.dart';
import 'package:one_key/widgets/common_button.dart';
import 'package:one_key/widgets/page_exception.dart';
import 'package:one_key/widgets/table_item.dart';
import 'package:one_key/models/table.dart' as t;
import 'package:provider/provider.dart';
... ... @@ -46,8 +48,6 @@ class SelectTablePageState extends State<SelectTablePage> {
Map<String, List<t.Table>> areaTableMap = {}; //区域-桌位Map
SelectTableModel selectTableModel = new SelectTableModel();
ChooseTableModel _chooseTableModel;
Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单
... ... @@ -67,7 +67,10 @@ class SelectTablePageState extends State<SelectTablePage> {
getTableList() async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {"sellerid": userModel.user.sellerid};
tableOuterList = await selectTableModel.getTableList(context, params);
tableOuterList = await _chooseTableModel.getTableList(
context,
params,
);
for (TableOuter item in tableOuterList) {
// if (item.name == "推荐") {
// itemModelList.remove(item);
... ... @@ -83,7 +86,9 @@ class SelectTablePageState extends State<SelectTablePage> {
}
}
}
_getReserveList(userModel.user.sellerid);
if (_chooseTableModel.pageState == PageState.Success) {
_getReserveList(userModel.user.sellerid);
}
}
//获取已预订列表
... ... @@ -175,101 +180,124 @@ class SelectTablePageState extends State<SelectTablePage> {
@override
Widget build(BuildContext context) {
_chooseTableModel = Provider.of<ChooseTableModel>(context);
return SafeArea(
child: areaTableMap.isEmpty
? Container(
width: double.infinity,
height: double.infinity,
color: MyColours.color_ffffff,
)
: Column(
children: <Widget>[
MyAppBar(
"选择桌位",
showBack: true,
),
Expanded(
child: Container(
color: MyColours.color_ffffff,
child: Row(
children: <Widget>[
Container(
width: ScreenUtil().setWidth(170),
height: double.infinity,
color: MyColours.color_f1f1f1,
child: ListView.builder(
itemBuilder: (context, index) {
return AreaItem(areas[index], currentArea,
(area) {
setState(() {
currentArea = (area as Area).name;
});
return Scaffold(
body: SafeArea(
child: Column(
children: <Widget>[
MyAppBar(
"选择桌位",
showBack: true,
),
Expanded(
child: Consumer<ChooseTableModel>(builder: (context, model, _) {
if (model.pageState != PageState.Success) {
return ExceptionPage(
pageState: model.pageState,
callback: () {
getTableList();
},
emptyMsg: "暂时没有预订哦",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Container(
color: MyColours.color_ffffff,
child: Row(
children: <Widget>[
Container(
width: ScreenUtil().setWidth(170),
height: double.infinity,
color: MyColours.color_f1f1f1,
child: ListView.builder(
itemBuilder: (context, index) {
return AreaItem(areas[index], currentArea, (area) {
setState(() {
currentArea = (area as Area).name;
});
},
itemExtent: ScreenUtil().setHeight(207),
itemCount: areas.length,
),
});
},
itemExtent: ScreenUtil().setHeight(207),
itemCount: areas.length,
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(10),
horizontal: ScreenUtil().setWidth(9)),
child: Column(
children: [
Expanded(
child: GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 8 / 9),
itemBuilder: (context, index) {
return TableItem(
areaTableMap[currentArea][index],
onSelected: (table) {
if ((table as t.Table).selected) {
selectTables.add(table);
widget.tableList
.add(tableToTableList(table));
} else {
widget.tableList.removeWhere(
(t) => t.id == table.id);
selectTables.removeWhere(
(t) => t.id == table.id);
}
},
canSelected: true,
canChoose: widget.canChoose,
tableMap: tableMap,
rid: widget.rid);
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(10),
horizontal: ScreenUtil().setWidth(9)),
child: Column(
children: [
Expanded(
child: GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: 8 / 9),
itemBuilder: (context, index) {
return TableItem(
areaTableMap[currentArea][index],
onSelected: (table) {
if ((table as t.Table).selected) {
selectTables.add(table);
widget.tableList
.add(tableToTableList(table));
} else {
widget.tableList.removeWhere(
(t) => t.id == table.id);
selectTables.removeWhere(
(t) => t.id == table.id);
}
},
itemCount: areaTableMap[currentArea].length,
)),
Container(
width: double.infinity,
height: ScreenUtil().setHeight(84),
margin: EdgeInsets.only(
bottom: ScreenUtil().setWidth(50)),
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(31)),
alignment: Alignment.center,
color: MyColours.color_ffffff,
child: CommonButton(
content: "确定",
width: 500,
height: 84,
fontSize: 34,
state: 1,
onPress: () {
if (widget.canChoose) {
// if (widget.tableList.length > 0) {
canSelected: true,
canChoose: widget.canChoose,
tableMap: tableMap,
rid: widget.rid);
},
itemCount: areaTableMap[currentArea].length,
)),
Container(
width: double.infinity,
height: ScreenUtil().setHeight(84),
margin: EdgeInsets.only(
bottom: ScreenUtil().setWidth(50)),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(31)),
alignment: Alignment.center,
color: MyColours.color_ffffff,
child: CommonButton(
content: "确定",
width: 500,
height: 84,
fontSize: 34,
state: 1,
onPress: () {
if (widget.canChoose) {
// if (widget.tableList.length > 0) {
String tid = "";
for (TableList table
in widget.tableList) {
tid += table.id + ",";
}
if (widget.tableList.length > 0) {
tid = tid.substring(
0, tid.length - 1);
}
Map temp = {
'object': widget.tableList,
'tid': tid
};
Navigator.of(context).pop(temp);
// }
} else {
if (selectTables.length > 0) {
String tid = "";
for (TableList table
in widget.tableList) {
for (t.Table table
in selectTables) {
tid += table.id + ",";
}
if (widget.tableList.length > 0) {
if (selectTables.length > 0) {
tid = tid.substring(
0, tid.length - 1);
}
... ... @@ -279,38 +307,22 @@ class SelectTablePageState extends State<SelectTablePage> {
'tid': tid
};
Navigator.of(context).pop(temp);
// }
} else {
if (selectTables.length > 0) {
String tid = "";
for (t.Table table
in selectTables) {
tid += table.id + ",";
}
if (selectTables.length > 0) {
tid = tid.substring(
0, tid.length - 1);
}
Map temp = {
'object': widget.tableList,
'tid': tid
};
Navigator.of(context).pop(temp);
}
}
},
)),
],
)),
)
],
),
}
},
)),
],
)),
)
],
),
),
],
),
);
);
}
}),
),
],
),
));
}
tableToTableList(t.Table table) {
... ...
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/tableOuter.dart';
import 'package:one_key/models/table_list.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/models/table.dart' as t;
class ChooseTableModel with ChangeNotifier {
List<TableList> tableList = [];
PageState pageState = PageState.Loading;
//获取桌位数据
Future<List<TableOuter>> getTableList(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
if (isShowLoading) {
pageState = PageState.Loading;
notifyListeners();
}
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.table_list,
data: params, showLoading: true)
.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();
});
if (baseResp.code == Constant.status_success) {
if ((baseResp.data[0] as List).isEmpty) {
pageState = PageState.Empty;
notifyListeners();
} else {
pageState = PageState.Success;
}
return (baseResp.data[0] as List).map((value) {
TableOuter tableOuter = TableOuter();
tableOuter.name = value["name"];
tableOuter.list = (value["list"] as List).map((table) {
return t.Table.fromJson(table as Map<String, dynamic>);
}).toList();
return tableOuter;
}).toList();
} else {
pageState = PageState.ConnectivityError;
notifyListeners();
}
return [];
}
}
... ...
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/manager.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/net/base_resp.dart';
... ... @@ -11,18 +13,50 @@ import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
class NotebookDetailModel extends ChangeNotifier {
PageState pageState = PageState.Loading;
///获取已预订订单
Future<NotebookDetail> getReserveDetail(
BuildContext context, Map<String, String> params) async {
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
if (isShowLoading) {
pageState = PageState.Loading;
notifyListeners();
}
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.get, HttpUrl.reserve_detail,
data: params)
.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();
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageState = PageState.ConnectivityError;
} else {
pageState = PageState.Success;
}
notifyListeners();
return NotebookDetail.fromJson(baseResp.data);
} else {
pageState = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
}
... ... @@ -61,7 +95,8 @@ class NotebookDetailModel extends ChangeNotifier {
}
//安排在线预订
Future<bool> setReserveStatus(BuildContext context, Map<String, String> params,
Future<bool> setReserveStatus(
BuildContext context, Map<String, String> params,
{ifPush = true, showLoading = false}) async {
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
... ... @@ -70,7 +105,7 @@ class NotebookDetailModel extends ChangeNotifier {
.catchError((error) {
print(error.toString());
});
if(baseResp==null) return false;
if (baseResp == null) return false;
if (baseResp.code == Constant.status_success) {
if (ifPush) {
NavigatorUtil.goNotebookDetailPage(context, params["rid"],
... ...
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/models/tableOuter.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/models/table.dart' as t;
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
// import 'package:flutter/material.dart';
// import 'package:one_key/constant/constant.dart';
// import 'package:one_key/constant/state.dart';
// import 'package:one_key/models/tableOuter.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/models/table.dart' as t;
// import 'package:one_key/utils/navigator_util.dart';
// import 'package:one_key/utils/utils.dart';
class SelectTableModel{
// class SelectTableModel {
// PageState pageState = PageState.Loading;
//获取桌位数据
Future<List<TableOuter>> getTableList(BuildContext context,Map<String,String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.table_list,
data: params,showLoading: true)
.catchError((error) {
print(error.toString());
});
if(baseResp.code==Constant.status_success){
return (baseResp.data[0] as List).map((value){
TableOuter tableOuter=TableOuter();
tableOuter.name=value["name"];
tableOuter.list=(value["list"] as List).map((table){
return t.Table.fromJson(table as Map<String,dynamic>);
}).toList();
return tableOuter;
}).toList();
}
return [];
}
}
\ No newline at end of file
// //获取桌位数据
// Future<List<TableOuter>> getTableList(
// BuildContext context, Map<String, String> params,
// {isShowLoading = true}) async {
// if (isShowLoading) {
// pageState = PageState.Loading;
// notifyListeners();
// }
// BaseResp<List> baseResp = await DioUtil()
// .request<List>(context, Method.get, HttpUrl.table_list,
// data: params, showLoading: true)
// .catchError((error) {
// print(error.toString());
// });
// if (baseResp.code == Constant.status_success) {
// return (baseResp.data[0] as List).map((value) {
// TableOuter tableOuter = TableOuter();
// tableOuter.name = value["name"];
// tableOuter.list = (value["list"] as List).map((table) {
// return t.Table.fromJson(table as Map<String, dynamic>);
// }).toList();
// return tableOuter;
// }).toList();
// }
// return [];
// }
// }
... ...
... ... @@ -17,6 +17,7 @@ import 'package:one_key/pages/table/select_table_page.dart';
import 'package:one_key/pages/webview/webview_page.dart';
import 'package:one_key/provider/choose_table_model.dart';
import 'package:one_key/provider/notebook_detail_change_model.dart';
import 'package:one_key/provider/notebook_detail_model.dart';
import 'package:one_key/utils/fluro_convert_utils.dart';
import 'package:one_key/utils/log_util.dart';
import 'package:provider/provider.dart';
... ... @@ -40,9 +41,15 @@ var homeHandler = new Handler(
var reserveDetailHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
String rid = params['rid'].first;
String mid=params['mid'].first;
bool fromNotify=FluroConvertUtils.string2bool(params["fromNotify"].first);
return NotebookDetailPage(rid,mid:mid,fromNotify: fromNotify,);
String mid = params['mid'].first;
bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);
return ChangeNotifierProvider<NotebookDetailModel>(
create: (_) => NotebookDetailModel(),
child: NotebookDetailPage(
rid,
mid: mid,
fromNotify: fromNotify,
));
});
// 跳转到处理在线预订
... ... @@ -50,8 +57,11 @@ var handleOnlineHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
String rid = params['rid'].first;
String mid = params["mid"].first;
bool fromNotify=FluroConvertUtils.string2bool(params["fromNotify"].first);
return HandleOnlinePage(rid, mid,fromNotify: fromNotify,);
bool fromNotify = FluroConvertUtils.string2bool(params["fromNotify"].first);
return ChangeNotifierProvider<NotebookDetailModel>(
create: (_) => NotebookDetailModel(),
child: HandleOnlinePage(rid, mid, fromNotify: fromNotify));
// return HandleOnlinePage(rid, mid,fromNotify: fromNotify);
});
// 跳转到选择桌位
... ...
... ... @@ -66,7 +66,7 @@ class ExceptionPageState extends State<ExceptionPage> {
page = Container(
width: 0,
height: 10,
color: Colors.blue,
color: Colors.white,
);
break;
default:
... ...