Commit 94216022dbfe6fa576001ef13614c9e0e1d2bc22

Authored by wdn127929
1 parent c03a4e4e

已预订列表issimple

... ... @@ -60,7 +60,7 @@ class Notebook {
String name;
OrderInfo orderInfo;
String nick_name;
bool issimple;
bool issimple = false;
String orderID;
String orderRID;
... ...
... ... @@ -41,7 +41,7 @@ class NoteBookPage extends StatefulWidget {
: super(key: key);
@override
State<StatefulWidget> createState() {
// TODO: implement createState
// TODO: implement createState
return new NoteBookPageState();
}
}
... ... @@ -64,25 +64,25 @@ class NoteBookPageState extends State<NoteBookPage> {
StartingDayOfWeek startingDayOfWeek;
bool clearSel = false;
bool isall = true;
bool isSimple = true;
NoteBookModel noteBookModel;
@override
void initState() {
// TODO: implement initState
// TODO: implement initState
super.initState();
isSimple = App.sp.getBool("isSimple") ?? true;
tabIndex = widget.tabIndex;
LogUtil.v("notebook_page initState");
_controller = EasyRefreshController();
// _initTime();
// _initTime();
bus.on("refresh_book_list", (args) {
_getReserveList();
});
startingDayOfWeek = _initStartingDayOfWeek();
dateTimeNow = DateTime.now();
WidgetsBinding.instance.addPostFrameCallback((_) {
noteBookModel.isSimple = App.sp.getBool("isSimple") ?? true;
_initTime();
setState(() {});
_getReserveList(needLoading: true, showLoading: false);
... ... @@ -90,8 +90,6 @@ class NoteBookPageState extends State<NoteBookPage> {
});
}
/// 第一个显示今天
_initStartingDayOfWeek() {
switch (DateTime.now().weekday.toString()) {
... ... @@ -121,28 +119,28 @@ class NoteBookPageState extends State<NoteBookPage> {
_calendarController.dispose();
}
//初始化时间
//初始化时间
_initTime() {
dateTimeNow = widget.date != null ? widget.date : DateTime.now();
if (widget.date != null) {
_refreshPageCalendar(dateTimeNow);
}
// dateText = "${dateTimeNow.year}年 " +
// Utils.addZeroNumber(dateTimeNow.month) +
// "月" +
// Utils.addZeroNumber(dateTimeNow.day) +
// "日";
// DateTime dateNow = DateTime.now();
// dateText = "${dateTimeNow.year}年 " +
// Utils.addZeroNumber(dateTimeNow.month) +
// "月" +
// Utils.addZeroNumber(dateTimeNow.day) +
// "日";
// DateTime dateNow = DateTime.now();
// if (Utils.isOneDay(dateTimeNow, dateNow)) {
// dateText += " 今天";
// } else if (Utils.isOneDay(dateTimeNow, dateNow.add(Duration(days: 1)))) {
// dateText += " 明天";
// } else if (Utils.isOneDay(dateTimeNow, dateNow.add(Duration(days: 2)))) {
// dateText += " 后天";
// } else {
// dateText += " 周${Utils.formatWeekDayNum(dateTimeNow.weekday)}";
// }
// if (Utils.isOneDay(dateTimeNow, dateNow)) {
// dateText += " 今天";
// } else if (Utils.isOneDay(dateTimeNow, dateNow.add(Duration(days: 1)))) {
// dateText += " 明天";
// } else if (Utils.isOneDay(dateTimeNow, dateNow.add(Duration(days: 2)))) {
// dateText += " 后天";
// } else {
// dateText += " 周${Utils.formatWeekDayNum(dateTimeNow.weekday)}";
// }
morning =
userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
... ... @@ -158,7 +156,7 @@ class NoteBookPageState extends State<NoteBookPage> {
" " +
morning.split("-")[1] +
":00"))) {
//未过早市
//未过早市
currTimeIndex = 1;
} else if (noon != '' &&
dateTimeNow.isAfter(DateTime.parse(dateTimeNow.year.toString() +
... ... @@ -177,7 +175,7 @@ class NoteBookPageState extends State<NoteBookPage> {
" " +
noon.split("-")[1] +
":00"))) {
//过了早市,未过午市
//过了早市,未过午市
currTimeIndex = 2;
} else if (night != '' &&
dateTimeNow.isAfter(DateTime.parse(dateTimeNow.year.toString() +
... ... @@ -196,10 +194,10 @@ class NoteBookPageState extends State<NoteBookPage> {
" " +
night.split("-")[1] +
":00"))) {
//过了午市,未过晚市
//过了午市,未过晚市
currTimeIndex = 3;
} else {
//过了晚市
//过了晚市
currTimeIndex = 3;
}
} else {
... ... @@ -207,10 +205,8 @@ class NoteBookPageState extends State<NoteBookPage> {
}
}
//获取已预订列表
//获取已预订列表
_getReserveList({bool needLoading = false, bool showLoading = true}) async {
Map<String, String> params = {
"sid": userModel.user.sellerid,
"rdate": _getRdate(),
... ... @@ -226,14 +222,10 @@ class NoteBookPageState extends State<NoteBookPage> {
await noteBookModel.getReserveList(context, params,
needLoading: needLoading, showLoading: showLoading);
_simpleState();
// _simpleState();
}
//解析返回显示的日期
//解析返回显示的日期
_parseDateDay(DateTime dateTime) {
DateTime now = DateTime.now();
if (Utils.isOneDay(dateTime, now)) {
... ... @@ -247,9 +239,9 @@ class NoteBookPageState extends State<NoteBookPage> {
}
}
//获取一天开始-结束时间字符串
//获取一天开始-结束时间字符串
String _getRdate() {
//一天开始时间
//一天开始时间
double startDay = (DateTime.parse((dateTimeNow.year.toString() +
"-" +
Utils.addZeroNumber(dateTimeNow.month) +
... ... @@ -258,7 +250,7 @@ class NoteBookPageState extends State<NoteBookPage> {
" 00:00:00"))
.millisecondsSinceEpoch) /
1000;
//一天结束时间
//一天结束时间
double endDay = (DateTime.parse((dateTimeNow.year.toString() +
"-" +
Utils.addZeroNumber(dateTimeNow.month) +
... ... @@ -270,7 +262,7 @@ class NoteBookPageState extends State<NoteBookPage> {
return startDay.floor().toString() + "-" + endDay.floor().toString();
}
//获取订单统计数目
//获取订单统计数目
_reserveCountDay() async {
NoteBookModel model = Provider.of<NoteBookModel>(context, listen: false);
Map<String, String> params = {
... ... @@ -289,7 +281,7 @@ class NoteBookPageState extends State<NoteBookPage> {
await model.getReserveCountDay(context, params);
}
//构建List表头
//构建List表头
Widget _buildListTitle() {
return Container(
width: double.infinity,
... ... @@ -360,21 +352,21 @@ class NoteBookPageState extends State<NoteBookPage> {
//刷新当前页面的日历显示
_refreshPageCalendar(DateTime day) {
setState(() {
// DateTime dateNow = DateTime.now();
// dateText = "${day.year}年 " +
// Utils.addZeroNumber(day.month) +
// "月" +
// Utils.addZeroNumber(day.day) +
// "日";
// if (Utils.isOneDay(day, dateNow)) {
// dateText += " 今天";
// } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 1)))) {
// dateText += " 明天";
// } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 2)))) {
// dateText += " 后天";
// } else {
// dateText += " 周${Utils.formatWeekDayNum(day.weekday)}";
// }
// DateTime dateNow = DateTime.now();
// dateText = "${day.year}年 " +
// Utils.addZeroNumber(day.month) +
// "月" +
// Utils.addZeroNumber(day.day) +
// "日";
// if (Utils.isOneDay(day, dateNow)) {
// dateText += " 今天";
// } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 1)))) {
// dateText += " 明天";
// } else if (Utils.isOneDay(day, dateNow.add(Duration(days: 2)))) {
// dateText += " 后天";
// } else {
// dateText += " 周${Utils.formatWeekDayNum(day.weekday)}";
// }
dateTimeNow = day;
Duration days = day.difference(DateTime.now());
... ... @@ -391,7 +383,7 @@ class NoteBookPageState extends State<NoteBookPage> {
});
}
//生成日期文本
//生成日期文本
_createDateText(DateTime day) {
if (Utils.isOneDay(day, dateTimeNow)) return; //日期没变
_refreshPageCalendar(day);
... ... @@ -400,161 +392,147 @@ class NoteBookPageState extends State<NoteBookPage> {
_reserveCountDay();
}
// Widget _buildTabbar() {
// Container container = Container(
// color: MyColours.color_ffffff,
// width: double.infinity,
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20), top: ScreenUtil().setWidth(20)),
// child: Row(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Container(
// padding:
// EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
// child: GestureDetector(
// onTap: () {
// if (tabIndex == 0) return;
// setState(() {
// tabIndex = 0;
// _getReserveList();
// _reserveCountDay();
// });
// },
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Text(
// "全部预订",
// style: TextStyle(
// color: tabIndex == 0
// ? MyColours.color_353535
// : MyColours.color_999999,
// fontSize: tabIndex == 0
// ? ScreenUtil().setSp(36)
// : ScreenUtil().setSp(28),
// fontWeight: tabIndex == 0
// ? FontWeight.bold
// : FontWeight.normal),
// ),
// Align(
// alignment: Alignment.bottomCenter,
// child: Container(
// height: ScreenUtil().setWidth(6),
// width: ScreenUtil().setWidth(60),
// margin: EdgeInsets.only(top: ScreenUtil().setWidth(8)),
// decoration: tabIndex == 0
// ? BoxDecoration(
// color: MyColours.color_199095,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(6)))
// : BoxDecoration(
// color: MyColours.color_ffffff,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(6))),
// ),
// ),
// ],
// )),
// ),
// Container(
// padding:
// EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
// child: GestureDetector(
// onTap: () {
// if (tabIndex == 1) return;
// setState(() {
// tabIndex = 1;
// _getReserveList();
// _reserveCountDay();
// });
// },
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Text(
// "我录入的",
// style: TextStyle(
// color: tabIndex == 1
// ? MyColours.color_353535
// : MyColours.color_999999,
// fontSize: tabIndex == 1
// ? ScreenUtil().setSp(36)
// : ScreenUtil().setSp(28),
// fontWeight: tabIndex == 1
// ? FontWeight.bold
// : FontWeight.normal),
// ),
// Align(
// alignment: Alignment.bottomCenter,
// child: Container(
// height: ScreenUtil().setWidth(6),
// width: ScreenUtil().setWidth(60),
// margin: EdgeInsets.only(top: ScreenUtil().setWidth(8)),
// decoration: tabIndex == 1
// ? BoxDecoration(
// color: MyColours.color_199095,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(6)))
// : BoxDecoration(
// color: MyColours.color_ffffff,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(6))),
// ),
// ),
// ],
// )),
// ),
// Spacer(),
// GestureDetector(
// onTap: () {
// NavigatorUtil.goStatisticsPage(context);
// },
// child: Container(
// color: Colors.white,
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(40),
// right: ScreenUtil().setWidth(40),
// bottom: ScreenUtil().setWidth(30)),
// child: Text(
// "统计列表",
// style: TextStyle(
// color: MyColours.color_199095,
// fontSize: ScreenUtil().setSp(36),
// fontWeight: FontWeight.bold),
// ))),
// ],
// ),
// );
// return container;
// }
_simpleState() {
if (noteBookModel.notebooks.length > 0) {
if (isSimple) {
for (Notebook item in noteBookModel.notebooks) {
item.issimple = true;
}
} else {
for (Notebook item in noteBookModel.notebooks) {
item.issimple = false;
}
}
}
}
// Widget _buildTabbar() {
// Container container = Container(
// color: MyColours.color_ffffff,
// width: double.infinity,
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20), top: ScreenUtil().setWidth(20)),
// child: Row(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// Container(
// padding:
// EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
// child: GestureDetector(
// onTap: () {
// if (tabIndex == 0) return;
// setState(() {
// tabIndex = 0;
// _getReserveList();
// _reserveCountDay();
// });
// },
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Text(
// "全部预订",
// style: TextStyle(
// color: tabIndex == 0
// ? MyColours.color_353535
// : MyColours.color_999999,
// fontSize: tabIndex == 0
// ? ScreenUtil().setSp(36)
// : ScreenUtil().setSp(28),
// fontWeight: tabIndex == 0
// ? FontWeight.bold
// : FontWeight.normal),
// ),
// Align(
// alignment: Alignment.bottomCenter,
// child: Container(
// height: ScreenUtil().setWidth(6),
// width: ScreenUtil().setWidth(60),
// margin: EdgeInsets.only(top: ScreenUtil().setWidth(8)),
// decoration: tabIndex == 0
// ? BoxDecoration(
// color: MyColours.color_199095,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(6)))
// : BoxDecoration(
// color: MyColours.color_ffffff,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(6))),
// ),
// ),
// ],
// )),
// ),
// Container(
// padding:
// EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
// child: GestureDetector(
// onTap: () {
// if (tabIndex == 1) return;
// setState(() {
// tabIndex = 1;
// _getReserveList();
// _reserveCountDay();
// });
// },
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Text(
// "我录入的",
// style: TextStyle(
// color: tabIndex == 1
// ? MyColours.color_353535
// : MyColours.color_999999,
// fontSize: tabIndex == 1
// ? ScreenUtil().setSp(36)
// : ScreenUtil().setSp(28),
// fontWeight: tabIndex == 1
// ? FontWeight.bold
// : FontWeight.normal),
// ),
// Align(
// alignment: Alignment.bottomCenter,
// child: Container(
// height: ScreenUtil().setWidth(6),
// width: ScreenUtil().setWidth(60),
// margin: EdgeInsets.only(top: ScreenUtil().setWidth(8)),
// decoration: tabIndex == 1
// ? BoxDecoration(
// color: MyColours.color_199095,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(6)))
// : BoxDecoration(
// color: MyColours.color_ffffff,
// borderRadius: BorderRadius.circular(
// ScreenUtil().setWidth(6))),
// ),
// ),
// ],
// )),
// ),
// Spacer(),
// GestureDetector(
// onTap: () {
// NavigatorUtil.goStatisticsPage(context);
// },
// child: Container(
// color: Colors.white,
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(40),
// right: ScreenUtil().setWidth(40),
// bottom: ScreenUtil().setWidth(30)),
// child: Text(
// "统计列表",
// style: TextStyle(
// color: MyColours.color_199095,
// fontSize: ScreenUtil().setSp(36),
// fontWeight: FontWeight.bold),
// ))),
// ],
// ),
// );
// return container;
// }
//获取全选按钮的状态 true or false
//获取全选按钮的状态 true or false
getCheckValue() {
bool temp = noteBookModel.notebooks.any((value) {
return value.issimple == false;
});
if (temp == true) {
isSimple = false;
noteBookModel.isSimple = false;
} else {
isSimple = true;
noteBookModel.isSimple = true;
}
setState(() {});
App.sp.setBool("isSimple", isSimple);
App.sp.setBool("isSimple", noteBookModel.isSimple);
}
///单个item切换模式
... ... @@ -565,7 +543,7 @@ class NoteBookPageState extends State<NoteBookPage> {
@override
Widget build(BuildContext context) {
// TODO: implement build
// TODO: implement build
userModel = Provider.of<UserModel>(context, listen: false);
noteBookModel = Provider.of<NoteBookModel>(context, listen: true);
int sum = 3;
... ... @@ -603,10 +581,10 @@ class NoteBookPageState extends State<NoteBookPage> {
headerVisible: false,
startingDayOfWeek: startingDayOfWeek,
startDay: DateTime.now(),
// endDay: DateTime.now().add(Duration(days: 5)),
// endDay: DateTime.now().add(Duration(days: 5)),
onDaySelected: (day, _, holidays) {
if (!Utils.isOneDay(day, dateTimeNow)) {
//不是一天
//不是一天
dateTimeNow = day;
clearSel = false;
setState(() {
... ... @@ -640,17 +618,17 @@ class NoteBookPageState extends State<NoteBookPage> {
titleTextBuilder: (dateTime, _) {
return '';
},
// titleTextStyle: TextStyle(
// color: MyColours.font_color_333333,
// fontSize: ScreenUtil().setSp(32)),
// leftChevronIcon: Image(
// image: AssetImage(
// Utils.getImgPath('left_arrow')),
// alignment: Alignment.center,
// ),
// rightChevronIcon: const Icon(
// Icons.keyboard_arrow_right,
// color: MyColours.font_color_333333),
// titleTextStyle: TextStyle(
// color: MyColours.font_color_333333,
// fontSize: ScreenUtil().setSp(32)),
// leftChevronIcon: Image(
// image: AssetImage(
// Utils.getImgPath('left_arrow')),
// alignment: Alignment.center,
// ),
// rightChevronIcon: const Icon(
// Icons.keyboard_arrow_right,
// color: MyColours.font_color_333333),
),
builders: CalendarBuilders(
dayBuilder: (context, dateTime, events) {
... ... @@ -822,7 +800,7 @@ class NoteBookPageState extends State<NoteBookPage> {
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
// border: Border.all(color: MyColours.color_FFB116)
// border: Border.all(color: MyColours.color_FFB116)
),
alignment: Alignment.center,
margin: EdgeInsets.all(
... ... @@ -841,25 +819,25 @@ class NoteBookPageState extends State<NoteBookPage> {
)
]);
},
// todayDayBuilder: (context, date, _) {
// return Container(
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// border: Border.all(
// color: MyColours.color_24A4A8, width: 1)),
// alignment: Alignment.center,
// margin: const EdgeInsets.all(6.0),
// padding: const EdgeInsets.only(
// bottom: 4.0, left: 8.0, right: 8.0, top: 4.0),
// child: Text(
// '今',
// style: TextStyle().copyWith(
// fontSize: ScreenUtil().setSp(32),
// color: MyColours.color_438E93,
// fontWeight: FontWeight.bold),
// ),
// );
// },
// todayDayBuilder: (context, date, _) {
// return Container(
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// border: Border.all(
// color: MyColours.color_24A4A8, width: 1)),
// alignment: Alignment.center,
// margin: const EdgeInsets.all(6.0),
// padding: const EdgeInsets.only(
// bottom: 4.0, left: 8.0, right: 8.0, top: 4.0),
// child: Text(
// '今',
// style: TextStyle().copyWith(
// fontSize: ScreenUtil().setSp(32),
// color: MyColours.color_438E93,
// fontWeight: FontWeight.bold),
// ),
// );
// },
singleMarkerBuilder:
(context, dateTime, event) {
return Container(
... ... @@ -929,8 +907,8 @@ class NoteBookPageState extends State<NoteBookPage> {
ScreenUtil().setWidth(20),
)),
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Offstage(
offstage:
... ... @@ -1067,10 +1045,10 @@ class NoteBookPageState extends State<NoteBookPage> {
InkWell(
onTap: () {
setState(() {
isSimple = !isSimple;
noteBookModel.isSimple = !noteBookModel.isSimple;
});
_simpleState();
App.sp.setBool("isSimple", isSimple);
noteBookModel.simpleState();
App.sp.setBool("isSimple", noteBookModel.isSimple);
},
child: Column(
children: [
... ... @@ -1083,8 +1061,9 @@ class NoteBookPageState extends State<NoteBookPage> {
),
VEmptyView(16),
Image.asset(
Utils.getImgPath(
isSimple ? 'f_swich_on' : 'f_swich_off'),
Utils.getImgPath(noteBookModel.isSimple
? 'f_swich_on'
: 'f_swich_off'),
width: ScreenUtil().setWidth(24 * 2))
],
)),
... ... @@ -1131,7 +1110,7 @@ class NoteBookPageState extends State<NoteBookPage> {
}),
);
}, childCount: model.notebooks.length),
// itemExtent: ScreenUtil().setWidth(112),
// itemExtent: ScreenUtil().setWidth(112),
)
],
onRefresh: () async {
... ...
... ... @@ -21,12 +21,14 @@ class NoteBookModel extends ChangeNotifier {
String totalnight = ""; //一天统计
PageState pageState = PageState.Loading;
bool isSimple = true;
//获取已预订订单
Future<List<Notebook>> getReserveList(
BuildContext context, Map<String, String> params,
{bool needLoading = false, bool showLoading = true}) async {
if (needLoading) {
// notebooks = [];
pageState = PageState.Loading;
showLoading = false;
notifyListeners();
... ... @@ -108,7 +110,18 @@ class NoteBookModel extends ChangeNotifier {
// tableManagerModel.tableOuterList //桌子
// tableManagerModel.areaSunModelList //区域
// simpleState();
if (notebooks.length > 0) {
if (isSimple) {
for (Notebook item in notebooks) {
item.issimple = true;
}
} else {
for (Notebook item in notebooks) {
item.issimple = false;
}
}
}
pageState = PageState.Success;
}
} else {
... ... @@ -119,6 +132,20 @@ class NoteBookModel extends ChangeNotifier {
return notebooks;
}
simpleState() {
if (notebooks.length > 0) {
if (isSimple) {
for (Notebook item in notebooks) {
item.issimple = true;
}
} else {
for (Notebook item in notebooks) {
item.issimple = false;
}
}
}
}
//获取订单统计数目
getReserveCountDay(BuildContext context, Map<String, String> params) async {
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
... ...