|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/screenutil.dart';
|
|
|
|
import 'package:one_key/models/seller_info.dart';
|
|
|
|
import 'package:one_key/models/set_seller_info_model.dart';
|
|
|
|
import 'package:one_key/models/settime.dart';
|
|
|
|
import 'package:one_key/provider/book_set_time_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/event_bus.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
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/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/set_time_widget.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
typedef BookTimeSetCallback = void Function(bool needChange);
|
|
|
|
|
|
...
|
...
|
@@ -22,10 +30,10 @@ class BookTimeSetPage extends StatefulWidget { |
|
|
|
class _BookTimeSetPageState extends State<BookTimeSetPage> {
|
|
|
|
List swichState;
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
List dateData;
|
|
|
|
SetTime morning = SetTime();
|
|
|
|
SetTime noon = SetTime();
|
|
|
|
SetTime night = SetTime();
|
|
|
|
BookSetTimeModel bookSetTimeModel;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
...
|
...
|
@@ -36,95 +44,153 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> { |
|
|
|
noon.end = '14:30';
|
|
|
|
night.start = '16:00';
|
|
|
|
night.end = '21:00';
|
|
|
|
swichState = [
|
|
|
|
{
|
|
|
|
'on': false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'on': true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'on': true,
|
|
|
|
}
|
|
|
|
];
|
|
|
|
swichState = [false, true, true];
|
|
|
|
|
|
|
|
dateData = [
|
|
|
|
{
|
|
|
|
'深夜00时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'深夜01时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'深夜02时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'深夜03时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'深夜04时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'深夜05时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'早上06时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'早上07时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'早上08时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'早上09时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'中午10时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'中午11时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'中午12时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'中午13时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'中午14时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'下午15时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'下午16时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'下午17时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'下午18时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'晚上19时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'晚上20时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'晚上21时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'晚上22时': [00, 30]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'晚上23时': [00, 30]
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_getDailyTime();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 从接口获取可订时段信息 daily
|
|
|
|
_getDailyTime() async {
|
|
|
|
SunSellerInfoModel model = await bookSetTimeModel.getManagersInfo(context);
|
|
|
|
setState(() {
|
|
|
|
if (model.daily.morning.isNotEmpty) {
|
|
|
|
List temp = model.daily.morning.split('-');
|
|
|
|
morning.start = temp.length > 0 ? temp[0] : '07:00';
|
|
|
|
morning.end = temp.length > 1 ? temp[1] : '10:00';
|
|
|
|
swichState[0] = true;
|
|
|
|
} else {
|
|
|
|
swichState[0] = false;
|
|
|
|
}
|
|
|
|
if (model.daily.noon.isNotEmpty) {
|
|
|
|
List temp = model.daily.noon.split('-');
|
|
|
|
noon.start = temp.length > 0 ? temp[0] : '11:00';
|
|
|
|
noon.end = temp.length > 1 ? temp[1] : '14:30';
|
|
|
|
swichState[1] = true;
|
|
|
|
} else {
|
|
|
|
swichState[1] = false;
|
|
|
|
noon.start = '11:00';
|
|
|
|
noon.end = '14:30';
|
|
|
|
}
|
|
|
|
if (model.daily.night.isNotEmpty) {
|
|
|
|
List temp = model.daily.night.split('-');
|
|
|
|
night.start = temp.length > 0 ? temp[0] : '16:00';
|
|
|
|
night.end = temp.length > 1 ? temp[1] : '21:00';
|
|
|
|
swichState[2] = true;
|
|
|
|
} else {
|
|
|
|
swichState[2] = false;
|
|
|
|
night.start = '16:00';
|
|
|
|
night.end = '21:00';
|
|
|
|
}
|
|
|
|
if (swichState[0] == false) {
|
|
|
|
if (model.daily.noon.isNotEmpty) {
|
|
|
|
Utils.compareDateTime(noon.start, morning.end, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.end = noon.start;
|
|
|
|
} else {
|
|
|
|
morning.end = '10:00';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.start, morning.start, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.start = noon.start;
|
|
|
|
} else {
|
|
|
|
morning.start = '07:00';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (model.daily.night.isNotEmpty) {
|
|
|
|
Utils.compareDateTime(night.start, morning.end, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.end = night.start;
|
|
|
|
} else {
|
|
|
|
morning.end = '10:00';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, morning.start, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.start = night.start;
|
|
|
|
} else {
|
|
|
|
morning.start = '07:00';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (swichState[1] == false) {
|
|
|
|
if (model.daily.morning.isNotEmpty) {
|
|
|
|
Utils.compareDateTime(noon.start, morning.end, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.start = morning.end;
|
|
|
|
} else {
|
|
|
|
noon.start = '11:00';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.end, morning.end, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = morning.end;
|
|
|
|
} else {
|
|
|
|
Utils.compareDateTime(noon.end, night.start, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = '14:30';
|
|
|
|
} else {
|
|
|
|
noon.end = night.start;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (model.daily.night.isNotEmpty) {
|
|
|
|
Utils.compareDateTime(noon.start, night.start, (needChange) {
|
|
|
|
if (!needChange) {
|
|
|
|
noon.start = night.start;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.end, night.start, (needChange) {
|
|
|
|
if (!needChange) {
|
|
|
|
noon.end = night.start;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (swichState[2] == false) {
|
|
|
|
if (model.daily.noon.isNotEmpty) {
|
|
|
|
Utils.compareDateTime(night.start, noon.end, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = noon.end;
|
|
|
|
Utils.compareDateTime(night.end, noon.end, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = noon.end;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.end, noon.start, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = noon.start;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (model.daily.morning.isNotEmpty) {
|
|
|
|
Utils.compareDateTime(night.start, morning.end, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = morning.end;
|
|
|
|
Utils.compareDateTime(night.end, noon.end, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = morning.end;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, morning.start, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = morning.start;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///item
|
|
|
|
///item 早市,晚市,午时widhet
|
|
|
|
Widget _itemWidget(String title, String startTime, String endTime, int tag) {
|
|
|
|
return Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
...
|
...
|
@@ -147,11 +213,11 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> { |
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
swichState[tag]["on"] = !swichState[tag]["on"];
|
|
|
|
swichState[tag] = !swichState[tag];
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Image.asset(
|
|
|
|
swichState[tag]["on"]
|
|
|
|
swichState[tag]
|
|
|
|
? Utils.getImgPath('swich_on')
|
|
|
|
: Utils.getImgPath('swich_off'),
|
|
|
|
width: ScreenUtil().setWidth(122),
|
|
...
|
...
|
@@ -166,52 +232,97 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> { |
|
|
|
ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_f3f3f3,
|
|
|
|
),
|
|
|
|
_timeWidget('开始时间', startTime, highted: swichState[tag]["on"],
|
|
|
|
onTap: () {
|
|
|
|
if (swichState[tag]["on"]) {
|
|
|
|
List data = dateData;
|
|
|
|
timeWidget('开始时间', startTime, highted: swichState[tag], onTap: () {
|
|
|
|
if (swichState[tag]) {
|
|
|
|
List data = SetTimeWidget.dateData;
|
|
|
|
if (tag == 0) {
|
|
|
|
//早市
|
|
|
|
data = dateData;
|
|
|
|
data = SetTimeWidget.dateData;
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
data = _getPickerData(morning.end);
|
|
|
|
data =
|
|
|
|
Utils.getPickerData(morning.end, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
data = _getPickerData(noon.end);
|
|
|
|
data = Utils.getPickerData(noon.end, SetTimeWidget.dateData);
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogUtil.showSelectCusmanDialog(context, data, (value) {
|
|
|
|
SetTimeWidget().showTimeSelector(context, data, startTime,
|
|
|
|
(value) {
|
|
|
|
if (value != null) {
|
|
|
|
String temp;
|
|
|
|
if (value[1] == 0) {
|
|
|
|
temp = '00';
|
|
|
|
} else {
|
|
|
|
temp = '30';
|
|
|
|
}
|
|
|
|
String tempMinute = _getMinuteStrFromPicker(data, value);
|
|
|
|
print(data[value[0]].keys.first);
|
|
|
|
String time = _getTimeString(
|
|
|
|
_getHourFromTitle(data[value[0]].keys.first), temp);
|
|
|
|
String time = Utils.getTimeString(
|
|
|
|
Utils.getHourFromTitle(data[value[0]].keys.first),
|
|
|
|
tempMinute);
|
|
|
|
setState(() {
|
|
|
|
if (tag == 0) {
|
|
|
|
//早市
|
|
|
|
morning.start = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(morning.end, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.start, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
noon.start = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(noon.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
night.start = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(night.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
print(value);
|
|
|
|
_compare(time);
|
|
|
|
}
|
|
|
|
}, selecteds: [
|
|
|
|
_getFirSelected(startTime, data),
|
|
|
|
_getSecSelected(startTime)
|
|
|
|
]).then((value) {
|
|
|
|
print(value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
...
|
...
|
@@ -223,50 +334,79 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> { |
|
|
|
ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_f3f3f3,
|
|
|
|
)),
|
|
|
|
_timeWidget('结束时间', endTime, highted: swichState[tag]["on"],
|
|
|
|
onTap: () {
|
|
|
|
if (swichState[tag]["on"]) {
|
|
|
|
List data = dateData;
|
|
|
|
timeWidget('结束时间', endTime, highted: swichState[tag], onTap: () {
|
|
|
|
if (swichState[tag]) {
|
|
|
|
List data = SetTimeWidget.dateData;
|
|
|
|
if (tag == 0) {
|
|
|
|
//早市
|
|
|
|
data = _getPickerData(morning.start);
|
|
|
|
data = Utils.getPickerData(
|
|
|
|
morning.start, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
data = _getPickerData(noon.start);
|
|
|
|
data =
|
|
|
|
Utils.getPickerData(noon.start, SetTimeWidget.dateData);
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
data = _getPickerData(night.start);
|
|
|
|
data =
|
|
|
|
Utils.getPickerData(night.start, SetTimeWidget.dateData);
|
|
|
|
}
|
|
|
|
DialogUtil.showSelectCusmanDialog(context, data, (value) {
|
|
|
|
SetTimeWidget().showTimeSelector(context, data, startTime,
|
|
|
|
(value) {
|
|
|
|
if (value != null) {
|
|
|
|
String temp;
|
|
|
|
if (value[1] == 0) {
|
|
|
|
temp = '00';
|
|
|
|
} else {
|
|
|
|
temp = '30';
|
|
|
|
}
|
|
|
|
String time = _getTimeString(
|
|
|
|
_getHourFromTitle(data[value[0]].keys.first), temp);
|
|
|
|
String tempMinute = _getMinuteStrFromPicker(data, value);
|
|
|
|
String time = Utils.getTimeString(
|
|
|
|
Utils.getHourFromTitle(data[value[0]].keys.first),
|
|
|
|
tempMinute);
|
|
|
|
setState(() {
|
|
|
|
if (tag == 0) {
|
|
|
|
//早市
|
|
|
|
morning.end = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(noon.start, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(noon.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (tag == 1) {
|
|
|
|
//午市
|
|
|
|
noon.end = time;
|
|
|
|
setState(() {
|
|
|
|
Utils.compareDateTime(night.start, time,
|
|
|
|
(needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Utils.compareDateTime(night.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (tag == 2) {
|
|
|
|
//晚市
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
print(value);
|
|
|
|
_compare(time);
|
|
|
|
}
|
|
|
|
}, selecteds: [
|
|
|
|
_getFirSelected(endTime, data),
|
|
|
|
_getSecSelected(endTime)
|
|
|
|
]).then((value) {
|
|
|
|
print(value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
...
|
...
|
@@ -274,173 +414,180 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> { |
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 开始时间和结束时间widget
|
|
|
|
_timeWidget(String title, String time,
|
|
|
|
{bool highted = true, GestureTapCallback onTap}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil().setWidth(124),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: highted
|
|
|
|
? MyColours.color_353535
|
|
|
|
: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(30),
|
|
|
|
)),
|
|
|
|
Spacer(),
|
|
|
|
Text(time,
|
|
|
|
style: TextStyle(
|
|
|
|
color: highted
|
|
|
|
? MyColours.color_353535
|
|
|
|
: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(30),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('arrow_right_new'),
|
|
|
|
width: ScreenUtil().setWidth(16),
|
|
|
|
height: ScreenUtil().setWidth(28),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
///工具
|
|
|
|
/// 组装成07:00
|
|
|
|
_getTimeString(dynamic hour, String minute) {
|
|
|
|
return '${hour}:${minute}';
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 从07:00中获取07
|
|
|
|
_getHourFromhourAndMinute(String hourAndMinute) {
|
|
|
|
return hourAndMinute.substring(0, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
///从深夜00时中获取00
|
|
|
|
_getHourFromTitle(String title) {
|
|
|
|
return title.substring(2, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 第一列当前选中第几个
|
|
|
|
_getFirSelected(String hourAndMinute, List data) {
|
|
|
|
String hour = _getHourFromhourAndMinute(hourAndMinute);
|
|
|
|
for (int i = 0; i < data.length; i++) {
|
|
|
|
Map map = data[i];
|
|
|
|
String key = map.keys.first;
|
|
|
|
if (key.contains(hour)) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 第二列当前选中第几个
|
|
|
|
_getSecSelected(String hourAndMinute) {
|
|
|
|
String minute = _getMinuteFromhourAndMinute(hourAndMinute);
|
|
|
|
if (minute == '00') {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 0 还是 30
|
|
|
|
/// 从07:00中获取0 或者 30
|
|
|
|
_getMinuteFromhourAndMinute(String hourAndMinute) {
|
|
|
|
return hourAndMinute.substring(3, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
///获取选择器数据
|
|
|
|
_getPickerData(String lastTime) {
|
|
|
|
String hour = _getHourFromhourAndMinute(lastTime);
|
|
|
|
String minute = _getMinuteFromhourAndMinute(lastTime);
|
|
|
|
if (minute == '30') {
|
|
|
|
hour = '${int.parse(hour) + 1}';
|
|
|
|
}
|
|
|
|
List tempList = List();
|
|
|
|
tempList.addAll(dateData);
|
|
|
|
tempList.removeRange(0, int.parse(hour));
|
|
|
|
return tempList;
|
|
|
|
}
|
|
|
|
|
|
|
|
///判断时间大小
|
|
|
|
/// a > b
|
|
|
|
_compareDateTime(String a, String b, BookTimeSetCallback callback) {
|
|
|
|
String tempa = '${DateUtil.getNowDateStr().substring(0, 10)} ${a}:00';
|
|
|
|
String tempb = '${DateUtil.getNowDateStr().substring(0, 10)} ${b}:00';
|
|
|
|
int aMs = DateUtil.getDateMsByTimeStr(tempa);
|
|
|
|
int bMs = DateUtil.getDateMsByTimeStr(tempb);
|
|
|
|
if (aMs < bMs) {
|
|
|
|
a = b;
|
|
|
|
callback(true);
|
|
|
|
///从时间选择器中获取分钟数字符串 00 or 30
|
|
|
|
String _getMinuteStrFromPicker(List data, List value) {
|
|
|
|
if (data.length == 1) {
|
|
|
|
return '30';
|
|
|
|
} else {
|
|
|
|
callback(false);
|
|
|
|
if (value[1] == 0) {
|
|
|
|
return '00';
|
|
|
|
} else {
|
|
|
|
return '30';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_compare(String time) {
|
|
|
|
setState(() {
|
|
|
|
_compareDateTime(morning.start, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_compareDateTime(morning.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
morning.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_compareDateTime(noon.start, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_compareDateTime(noon.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
noon.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_compareDateTime(night.start, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.start = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_compareDateTime(night.end, time, (needChange) {
|
|
|
|
if (needChange) {
|
|
|
|
night.end = time;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
///底部widget
|
|
|
|
///
|
|
|
|
_bottomWidget() {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
ScreenUtil().setWidth(60),
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
ScreenUtil().setWidth(60),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
textWidget('温馨提示:'),
|
|
|
|
VEmptyView(10),
|
|
|
|
textWidget('1.时段停用,表示餐厅将不支持该时段的预订;'),
|
|
|
|
VEmptyView(10),
|
|
|
|
textWidget('2.修改起始时间后,为确保正常生效,建议重启话机。'),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
key: _scaffoldKey,
|
|
|
|
body: SafeArea(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
MyAppBar(
|
|
|
|
"可订时段",
|
|
|
|
showBack: true,
|
|
|
|
),
|
|
|
|
_itemWidget('早市', morning.start, morning.end, 0),
|
|
|
|
VEmptyView(20),
|
|
|
|
_itemWidget('午市', noon.start, noon.end, 1),
|
|
|
|
VEmptyView(20),
|
|
|
|
_itemWidget('晚市', night.start, night.end, 2),
|
|
|
|
],
|
|
|
|
bookSetTimeModel = Provider.of<BookSetTimeModel>(context, listen: true);
|
|
|
|
return WillPopScope(
|
|
|
|
child: Scaffold(
|
|
|
|
key: _scaffoldKey,
|
|
|
|
backgroundColor: MyColours.color_f5f5f5,
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'可订时段',
|
|
|
|
onTap: () {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: SafeArea(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
_itemWidget('早市', morning.start, morning.end, 0),
|
|
|
|
VEmptyView(20),
|
|
|
|
_itemWidget('午市', noon.start, noon.end, 1),
|
|
|
|
VEmptyView(20),
|
|
|
|
_itemWidget('晚市', night.start, night.end, 2),
|
|
|
|
_bottomWidget()
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
ScreenUtil().setWidth(0),
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
ScreenUtil().setWidth(60)),
|
|
|
|
child: CommonButton(
|
|
|
|
width: double.infinity,
|
|
|
|
height: 84,
|
|
|
|
fontSize: 34,
|
|
|
|
content: '保存',
|
|
|
|
state: 2,
|
|
|
|
onPress: () async {
|
|
|
|
String morningStr = '';
|
|
|
|
String noonStr = '';
|
|
|
|
String nightStr = '';
|
|
|
|
if (swichState[0]) {
|
|
|
|
morningStr = Utils.getTimelLongString(
|
|
|
|
morning.start, morning.end);
|
|
|
|
}
|
|
|
|
if (swichState[1]) {
|
|
|
|
noonStr =
|
|
|
|
Utils.getTimelLongString(noon.start, noon.end);
|
|
|
|
}
|
|
|
|
if (swichState[2]) {
|
|
|
|
nightStr =
|
|
|
|
Utils.getTimelLongString(night.start, night.end);
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogUtil.confirmTimeAlertDialog(
|
|
|
|
context, morningStr, noonStr, nightStr, () async {
|
|
|
|
///接口
|
|
|
|
///
|
|
|
|
SetSellerInfoSunModel sunModel = await bookSetTimeModel
|
|
|
|
.setSellerInfoById(context, {
|
|
|
|
'morning': morningStr,
|
|
|
|
'noon': noonStr,
|
|
|
|
'night': nightStr
|
|
|
|
});
|
|
|
|
if (sunModel != null) {
|
|
|
|
//修改成功
|
|
|
|
Utils.showToast('保存成功');
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
Navigator.pop(context);
|
|
|
|
} else {
|
|
|
|
// Utils.showToast('保存失败');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
))
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
onWillPop: () async {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 开始时间和结束时间widget
|
|
|
|
timeWidget(String title, String time,
|
|
|
|
{bool highted = true, GestureTapCallback onTap}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
child: Container(
|
|
|
|
height: ScreenUtil().setWidth(124),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: highted
|
|
|
|
? MyColours.color_353535
|
|
|
|
: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(30),
|
|
|
|
)),
|
|
|
|
Spacer(),
|
|
|
|
Text(time,
|
|
|
|
style: TextStyle(
|
|
|
|
color: highted
|
|
|
|
? MyColours.color_353535
|
|
|
|
: MyColours.color_999999,
|
|
|
|
fontSize: ScreenUtil().setSp(30),
|
|
|
|
)),
|
|
|
|
HEmptyView(20),
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath('arrow_right_new'),
|
|
|
|
width: ScreenUtil().setWidth(16),
|
|
|
|
height: ScreenUtil().setWidth(28),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
///文本widget
|
|
|
|
///
|
|
|
|
textWidget(String title) {
|
|
|
|
return Container(
|
|
|
|
height: ScreenUtil().setWidth(40),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_353535, fontSize: ScreenUtil().setSp(28)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} |
...
|
...
|
|