Commit ebd42b62c48bf91df0757abe7190f848c97e32c8

Authored by “gaiyaguang”
1 parent 718ad81f

可订时段管理

import 'package:json_annotation/json_annotation.dart';
part 'set_seller_info_model.g.dart';
@JsonSerializable()
class SetSellerInfoModel extends Object {
@JsonKey(name: 'ret')
int ret;
@JsonKey(name: 'data')
SetSellerInfoSunModel data;
@JsonKey(name: 'msg')
String msg;
SetSellerInfoModel(this.ret,this.data,this.msg,);
factory SetSellerInfoModel.fromJson(Map<String, dynamic> srcJson) => _$SetSellerInfoModelFromJson(srcJson);
Map<String, dynamic> toJson() => _$SetSellerInfoModelToJson(this);
}
@JsonSerializable()
class SetSellerInfoSunModel extends Object {
@JsonKey(name: 'sellerid')
int sellerid;
SetSellerInfoSunModel(this.sellerid,);
factory SetSellerInfoSunModel.fromJson(Map<String, dynamic> srcJson) => _$DataFromJson(srcJson);
Map<String, dynamic> toJson() => _$DataToJson(this);
}
... ...
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'set_seller_info_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
SetSellerInfoModel _$SetSellerInfoModelFromJson(Map<String, dynamic> json) {
return SetSellerInfoModel(
json['ret'] as int,
json['data'] == null
? null
: SetSellerInfoSunModel.fromJson(
json['data'] as Map<String, dynamic>),
json['msg'] as String);
}
Map<String, dynamic> _$SetSellerInfoModelToJson(SetSellerInfoModel instance) =>
<String, dynamic>{
'ret': instance.ret,
'data': instance.data,
'msg': instance.msg
};
SetSellerInfoSunModel _$DataFromJson(Map<String, dynamic> json) {
return SetSellerInfoSunModel(json['sellerid'] as int);
}
Map<String, dynamic> _$DataToJson(SetSellerInfoSunModel instance) =>
<String, dynamic>{'sellerid': instance.sellerid};
... ...
... ... @@ -38,4 +38,5 @@ class HttpUrl {
static const String set_switch_status =
"?service=App.Reserve.SetSwitchStatus"; //启用/停用桌位
static const String sms_info = "?service=App.SendSMS.SmsInfo"; //短信余量查询及套餐查询接口
static const String set_seller_info = "?service=App.Seller.SetSellerById"; // 根据商家ID获取商家信息
}
... ...
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/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/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
typedef BookTimeSetCallback = void Function(bool needChange);
... ... @@ -26,6 +32,7 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
SetTime morning = SetTime();
SetTime noon = SetTime();
SetTime night = SetTime();
BookSetTimeModel bookSetTimeModel;
@override
void initState() {
... ... @@ -36,18 +43,7 @@ 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]
... ... @@ -122,6 +118,139 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
'晚上23时': [00, 30]
}
];
WidgetsBinding.instance.addPostFrameCallback((_) {
_getDailyTime();
});
}
_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) {
_compareDateTime(noon.start, morning.end, (needChange) {
if (needChange) {
morning.end = noon.start;
} else {
morning.end = '10:00';
}
});
_compareDateTime(noon.start, morning.start, (needChange) {
if (needChange) {
morning.start = noon.start;
} else {
morning.start = '07:00';
}
});
} else if (model.daily.night.isNotEmpty) {
_compareDateTime(night.start, morning.end, (needChange) {
if (needChange) {
morning.end = night.start;
} else {
morning.end = '10:00';
}
});
_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) {
_compareDateTime(noon.start, morning.end, (needChange) {
if (needChange) {
noon.start = morning.end;
} else {
noon.start = '11:00';
}
});
_compareDateTime(noon.end, morning.end, (needChange) {
if (needChange) {
noon.end = morning.end;
} else {
_compareDateTime(noon.end, night.start, (needChange) {
if (needChange) {
noon.end = '14:30';
} else {
noon.end = night.start;
}
});
}
});
}
if (model.daily.night.isNotEmpty) {
_compareDateTime(noon.start, night.start, (needChange) {
if (!needChange) {
noon.start = night.start;
}
});
_compareDateTime(noon.end, morning.start, (needChange) {
if (!needChange) {
noon.end = night.start;
}
});
}
}
if (swichState[2] == false) {
if (model.daily.noon.isNotEmpty) {
_compareDateTime(night.start, noon.end, (needChange) {
if (needChange) {
night.start = noon.end;
night.end = noon.end;
}
});
_compareDateTime(night.end, noon.start, (needChange) {
if (needChange) {
night.end = noon.start;
}
});
} else if (model.daily.morning.isNotEmpty) {
_compareDateTime(night.start, morning.end, (needChange) {
if (needChange) {
night.start = morning.end;
night.end = morning.end;
}
});
_compareDateTime(night.start, morning.start, (needChange) {
if (needChange) {
night.start = morning.start;
}
});
}
}
});
}
///item
... ... @@ -147,11 +276,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,9 +295,8 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3,
),
_timeWidget('开始时间', startTime, highted: swichState[tag]["on"],
onTap: () {
if (swichState[tag]["on"]) {
timeWidget('开始时间', startTime, highted: swichState[tag], onTap: () {
if (swichState[tag]) {
List data = dateData;
if (tag == 0) {
//早市
... ... @@ -184,11 +312,16 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
DialogUtil.showSelectCusmanDialog(context, data, (value) {
if (value != null) {
String temp;
if (value[1] == 0) {
temp = '00';
} else {
if (data.length == 1) {
temp = '30';
} else {
if (value[1] == 0) {
temp = '00';
} else {
temp = '30';
}
}
print(data[value[0]].keys.first);
String time = _getTimeString(
_getHourFromTitle(data[value[0]].keys.first), temp);
... ... @@ -196,16 +329,66 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
if (tag == 0) {
//早市
morning.start = time;
setState(() {
_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;
}
});
});
} else if (tag == 1) {
//午市
noon.start = time;
setState(() {
_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;
}
});
});
} else if (tag == 2) {
//晚市
night.start = time;
setState(() {
_compareDateTime(night.end, time, (needChange) {
if (needChange) {
night.end = time;
}
});
});
}
});
print(value);
_compare(time);
}
}, selecteds: [
_getFirSelected(startTime, data),
... ... @@ -223,9 +406,8 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3,
)),
_timeWidget('结束时间', endTime, highted: swichState[tag]["on"],
onTap: () {
if (swichState[tag]["on"]) {
timeWidget('结束时间', endTime, highted: swichState[tag], onTap: () {
if (swichState[tag]) {
List data = dateData;
if (tag == 0) {
//早市
... ... @@ -240,10 +422,14 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
DialogUtil.showSelectCusmanDialog(context, data, (value) {
if (value != null) {
String temp;
if (value[1] == 0) {
temp = '00';
} else {
if (data.length == 1) {
temp = '30';
} else {
if (value[1] == 0) {
temp = '00';
} else {
temp = '30';
}
}
String time = _getTimeString(
_getHourFromTitle(data[value[0]].keys.first), temp);
... ... @@ -251,16 +437,49 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
if (tag == 0) {
//早市
morning.end = time;
setState(() {
_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;
}
});
});
} else if (tag == 1) {
//午市
noon.end = time;
setState(() {
_compareDateTime(night.start, time, (needChange) {
if (needChange) {
night.start = time;
}
});
_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),
... ... @@ -274,52 +493,17 @@ 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-10:00
_getTimelLongString(String start, String end) {
return '${start}-${end}';
}
/// 从07:00中获取07
_getHourFromhourAndMinute(String hourAndMinute) {
return hourAndMinute.substring(0, 2);
... ... @@ -368,79 +552,177 @@ class _BookTimeSetPageState extends State<BookTimeSetPage> {
List tempList = List();
tempList.addAll(dateData);
tempList.removeRange(0, int.parse(hour));
if (tempList.length == 0) {
tempList = [
{
'晚上23时': [30]
}
];
}
return tempList;
}
///判断时间大小
/// a > b
/// a < b 则 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);
} else {
callback(false);
}
}
_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) {
bookSetTimeModel = Provider.of<BookSetTimeModel>(context, listen: true);
return Scaffold(
key: _scaffoldKey,
backgroundColor: MyColours.color_f5f5f5,
appBar: SystemAppBar('可订时段'),
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
MyAppBar(
"可订时段",
showBack: true,
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()
],
),
_itemWidget('早市', morning.start, morning.end, 0),
VEmptyView(20),
_itemWidget('午市', noon.start, noon.end, 1),
VEmptyView(20),
_itemWidget('晚市', night.start, night.end, 2),
],
),
)),
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 =
_getTimelLongString(morning.start, morning.end);
}
if (swichState[1]) {
noonStr = _getTimelLongString(noon.start, noon.end);
}
if (swichState[2]) {
nightStr = _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('保存成功');
Navigator.pop(context);
} else {
// Utils.showToast('保存失败');
}
});
},
))
],
)),
);
}
}
/// 开始时间和结束时间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)),
),
);
}
... ...
... ... @@ -206,7 +206,9 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
MyItem(
title: "接单时间管理",
content: "",
callback: () {},
callback: () {
NavigatorUtil.goReceiveOrdersTimeSetPage(context);
},
),
VEmptyView(40),
MyItem(
... ...
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:one_key/models/settime.dart';
import 'package:one_key/pages/my/book_time_set.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/common_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
class ReceiveOrdersTimeSetPage extends StatefulWidget {
ReceiveOrdersTimeSetPage({Key key}) : super(key: key);
@override
_ReceiveOrdersTimeSetPageState createState() =>
_ReceiveOrdersTimeSetPageState();
}
class _ReceiveOrdersTimeSetPageState extends State<ReceiveOrdersTimeSetPage> {
SetTime receiveOrdersTime = SetTime();
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// _getDailyTime();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: MyColours.color_f5f5f5,
appBar: SystemAppBar('接单时间'),
body: SafeArea(
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: ScreenUtil().setWidth(126 * 2),
color: MyColours.color_ffffff,
child: Column(
children: [
timeWidget('开始时间', '07:00', highted: true, onTap: () {}),
Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: MyDivider(
double.infinity,
ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3,
)),
timeWidget('结束时间', '07:00', highted: true, onTap: () {}),
],
),
),
VEmptyView(60),
Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: textWidget('温馨提示:'),
),
VEmptyView(10),
Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: textWidget('修改接单时间后,必须重启话机才能正常生效。'))
],
),
)),
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 {},
))
],
)),
);
}
}
... ...
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.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/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
class BookSetTimeModel with ChangeNotifier {
//构造函数,初始化
BookSetTimeModel() {}
///获取某个商家下所有服务员信息 **** 取得某个商家的早市、午市、晚市营业时间
Future<SunSellerInfoModel> getManagersInfo(BuildContext context) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"seller_id": userModel.user.sellerid,
"seller_openid": userModel.user.openid
};
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(context, Method.get, HttpUrl.sellerinfo,
data: params)
.catchError((error) {
print(error.toString());
});
SunSellerInfoModel itemModel;
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData['data'] != null) {
itemModel = SellerInfoModel.fromJson(baseResp.responseData).data;
} else {
Utils.showToast(baseResp.msg ?? "");
}
return itemModel;
}
}
///根据商家ID修改商家信息
Future<SetSellerInfoSunModel> setSellerInfoById(
BuildContext context, Map daily) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"id": userModel.user.sellerid,
"daily": jsonEncode(daily)
};
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.get, HttpUrl.set_seller_info,
data: params)
.catchError((error) {
print(error.toString());
});
SetSellerInfoSunModel itemModel;
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData['data'] != null) {
itemModel = SetSellerInfoModel.fromJson(baseResp.responseData).data;
} else {
Utils.showToast(baseResp.msg ?? "");
}
return itemModel;
}
}
}
... ...
... ... @@ -48,4 +48,5 @@ class MyColours {
static const Color color_A9E3E6 = Color(0xffA9E3E6);
static const Color color_e5e5e5 = Color(0xffe5e5e5);
static const Color color_efefef = Color(0xffefefef);
static const Color color_0A0A0A = Color(0xff0A0A0A);
}
... ...
... ... @@ -13,9 +13,11 @@ import 'package:one_key/pages/detail/handle_online_page.dart';
import 'package:one_key/pages/detail/notebook_detail_page.dart';
import 'package:one_key/pages/login/web_page.dart';
import 'package:one_key/pages/my/book_time_set.dart';
import 'package:one_key/pages/my/receive_orders_time_set.dart';
import 'package:one_key/pages/sms/sms_page.dart';
import 'package:one_key/pages/table/select_table_page.dart';
import 'package:one_key/pages/webview/webview_page.dart';
import 'package:one_key/provider/book_set_time_model.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';
... ... @@ -139,5 +141,13 @@ var handleChangeDetailHandler = new Handler(
// 跳转可订时段管理页面
var handleBookTimeSetHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
return BookTimeSetPage();
return ChangeNotifierProvider<BookSetTimeModel>(
create: (_) => BookSetTimeModel(), child: BookTimeSetPage());
});
// 跳转可订时段管理页面
var handleReceiveOrdersTimeSetHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
return ChangeNotifierProvider<BookSetTimeModel>(
create: (_) => BookSetTimeModel(), child: ReceiveOrdersTimeSetPage());
});
... ...
... ... @@ -15,7 +15,8 @@ class Routes {
static String webview = "/webview"; //网页
static String web_page = '/web_page'; //隐私协议
static String change_detail = "/change_detail"; //变更预订
static String book_time_set = "/book_time_set"; //可订时段管理
static String book_time_set = "/book_time_set"; //可订时段管理
static String receive_orders_time_set = "/receive_orders_time_set"; //接单时间管理
static void configureRoutes(Router router) {
router.notFoundHandler = new Handler(
... ... @@ -34,5 +35,7 @@ class Routes {
router.define(web_page, handler: webPageHandler);
router.define(change_detail, handler: handleChangeDetailHandler);
router.define(book_time_set, handler: handleBookTimeSetHandler);
router.define(receive_orders_time_set,
handler: handleReceiveOrdersTimeSetHandler);
}
}
... ...
... ... @@ -759,18 +759,155 @@ class DialogUtil {
),
),
);
// return AlertDialog(
// title: Text('未获得通讯录权限'),
// content: Text('请在手机的权限管理里,将联系人权限开启'),
// actions: <Widget>[
// FlatButton(
// child: Text('去设置'),
// onPressed: () {
// Navigator.pop(context, '确认');
// },
// ),
// ],
// );
},
);
switch (action) {
// case Action.Ok:
// setState(() {
// _choice = 'Ok';
// });
// break;
// case Action.Cancel:
// setState(() {
// _choice = 'Cancel';
// });
// break;
// default:
}
}
///时段设置提示弹框
static Future confirmTimeAlertDialog(BuildContext context, String morning,
String noon, String night, VoidCallback callback) async {
int space = 52;
List temp = [morning, noon, night];
int tempHeight = 0;
for (int i = 0; i < temp.length; i++) {
if (temp[i] == '') {
if (i == 2) {
space = 42;
}
tempHeight += space;
}
}
int height = 166 * 2 + 20 + 15 * 2 + 20 - tempHeight;
final action = await showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return Center(
child: Container(
height: ScreenUtil().setWidth(height),
width: ScreenUtil().setWidth(280 * 2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20))),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(20)))), //设置圆角
child: Column(
children: [
VEmptyView(40),
Container(
height: ScreenUtil().setWidth(42),
alignment: Alignment.center,
child: Text(
"请确认时段信息",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(30),
fontWeight: FontWeight.bold),
),
),
VEmptyView(20),
Column(
children: [
morning.isNotEmpty
? Container(
height: ScreenUtil().setWidth(42),
child: Text("早市:${morning}",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(30),
)))
: Container(),
morning.isNotEmpty ? VEmptyView(10) : VEmptyView(0),
noon.isNotEmpty
? Container(
height: ScreenUtil().setWidth(42),
child: Text(
"午市:${noon}",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(30),
),
))
: Container(),
noon.isNotEmpty ? VEmptyView(10) : VEmptyView(0),
night.isNotEmpty
? Container(
height: ScreenUtil().setWidth(42),
child: Text(
"晚市:${night}",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(30),
),
))
: Container(),
],
),
VEmptyView(40),
MyDivider(
ScreenUtil().setWidth(280 * 2), ScreenUtil().setWidth(2),
color: MyColours.color_efefef),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
InkWell(
child: Container(
height: ScreenUtil().setWidth(47 * 2),
alignment: Alignment.center,
child: Text(
"信息有误",
style: TextStyle(
color: MyColours.color_666666,
fontSize: ScreenUtil().setSp(34)),
),
),
onTap: () {
Navigator.pop(context, '');
},
),
Container(
color: MyColours.color_efefef,
width: ScreenUtil().setWidth(2),
height: ScreenUtil().setWidth(47 * 2),
),
InkWell(
child: Container(
height: ScreenUtil().setWidth(47 * 2),
alignment: Alignment.center,
child: Text(
"确认无误",
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(34)),
),
),
onTap: () {
Navigator.pop(context, '');
callback();
},
)
],
)
],
),
),
),
);
},
);
... ...
... ... @@ -110,4 +110,9 @@ class NavigatorUtil {
static void goBookTimeSetPage(BuildContext context) {
_navigateTo(context, "${Routes.book_time_set}");
}
/// 可订时段管理
static void goReceiveOrdersTimeSetPage(BuildContext context) {
_navigateTo(context, "${Routes.receive_orders_time_set}");
}
}
... ...