Commit f491a2deeb1c540f9235a1536d6662ceb82d6683

Authored by wdn127929
1 parent 777f18e2

防抖处理

... ... @@ -27,6 +27,7 @@ import 'package:provider/provider.dart';
import 'package:one_key/utils/event_bus.dart';
import '../../app.dart';
import '../../utils/common_utils.dart';
class HandleOnlinePage extends StatefulWidget {
final String rid;
... ... @@ -127,6 +128,15 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
detailModel.setReserveCusmnan(context, params);
}
_goReserve() async {
Navigator.of(context).pop();
Map temp = await NavigatorUtil.goSelectTableFPage(context, widget.rid,
int.parse(detailEntity.ddate) * 1000, detailEntity.ddate_solt);
if (temp != null && temp['tid'] != null) {
setReserveStatus("5", tid: temp['tid']);
}
}
//拒绝订单弹框
_showRefuseDialog2() {
Widget dialogContent = StatefulBuilder(
... ... @@ -216,15 +226,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
VEmptyView(20),
GestureDetector(
onTap: () async {
Navigator.of(context).pop();
Map temp = await NavigatorUtil.goSelectTableFPage(
context,
widget.rid,
int.parse(detailEntity.ddate) * 1000,
detailEntity.ddate_solt);
if (temp != null && temp['tid'] != null) {
setReserveStatus("5", tid: temp['tid']);
}
JhCommonUtils.debounce(() => _goReserve(), 500);
},
child: Container(
width: ScreenUtil().setWidth(336),
... ...
... ... @@ -60,6 +60,7 @@ import '../../provider/marketing_center_provider.dart';
import '../../provider/remark_manager_model.dart';
import '../../provider/store_base_info_provider.dart';
import '../../utils/call_log_utils.dart';
import '../../utils/common_utils.dart';
import '../../utils/screen_util.dart';
import '../../widgets/loading.dart';
import '../../widgets/special_text/my_extended_text_selection_controls.dart';
... ... @@ -683,15 +684,12 @@ class TableManagerPageState extends State<TableManagerPage> {
// }
_getCallLog() async {
List<Picker.PickerItem<dynamic>> data = [];
List<Picker.PickerItem<dynamic>> data = [];
Iterable<CallLogEntry> result = await CallLogUtils.getCallLog(context);
if (result != null) {
_baseIndoProvider.userHistorys = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
... ... @@ -819,7 +817,6 @@ class TableManagerPageState extends State<TableManagerPage> {
_phoneNode.unfocus();
_baseIndoProvider.userHistorys.clear();
});
}
_getContactData() async {
... ... @@ -2000,6 +1997,111 @@ class TableManagerPageState extends State<TableManagerPage> {
}
*/
_onlyReserve() async {
bool isShow = true; //是否需要弹窗 “预订失败!”
SunReserveInfoModel _model =
await tableManagerModel.setReserveInfo(context, (v) {
if (v) {
isShow = true;
} else {
isShow = false;
}
}, needKeep: true, guest: widget.guest);
if (_model != null &&
ObjectUtil.isNotEmpty(_model.row) &&
ObjectUtil.isNotEmpty(_model.row.id)) {
print('成功');
// tableManagerModel.selectTables = [];
// wechatNotification = true;
_clearData();
// _homeEnterModel.clearData();
bus.emit("refresh_tablemanager"); //刷新当前页面
bus.emit("refresh_book_list"); //刷新已预订列表
//进入订座详情页面
// NavigatorUtil.goNotebookDetailPage(
// context,
// _model.row.id,
// Provider.of<UserModel>(context, listen: false)
// .user
// .openid,
// );
// String ddate_solt = '';
// if (_model.row.isSetDdate == '1') {
// String createtime =
// _model.row.ddate.toString() + '000';
// DateTime createTime =
// DateTime.fromMillisecondsSinceEpoch(
// int.parse(createtime));
// ddate_solt = DateUtil.formatDate(createTime,
// format: DateFormats.h_m);
// } else {
// if (_model.row.ddateSolt == '1') {
// ddate_solt = '早餐';
// } else if (_model.row.ddateSolt == '2') {
// ddate_solt = '午餐';
// } else if (_model.row.ddateSolt == '3') {
// ddate_solt = '晚餐';
// }
// }
// List<dynamic> tableinfo =
// convert.jsonDecode(_model.row.tableinfo);
// print(tableinfo);
// String _nameStr =
// t.TableList.fromJson(tableinfo[0]).name;
// if (tableinfo.length > 1) {
// _nameStr = t.TableList.fromJson(tableinfo[0]).name +
// '等${tableinfo.length}桌';
// }
// LogUtil.v(_nameStr);
// String _tid = '';
// for (int i = 0; i < tableinfo.length; i++) {
// _tid += '${t.TableList.fromJson(tableinfo[i]).id},';
// }
// if (_tid.endsWith(',')) {
// _tid = _tid.substring(0, _tid.length - 1);
// }
// NavigatorUtil.goInvicationPage(
// context,
// _model.row.id,
// _nameStr,
// _model.row.ddate,
// ddate_solt,
// _model.row.phone,
// _model.row.ddateSolt,
// tid: _tid,
// replace: false);
// //今天 明天 其他天
// String tempTime = _homeEnterModel.ddateStr;
// if (_homeEnterModel.ddateStr == '') {
// if (currTimeIndex == 1) {
// tempTime = '08:00';
// } else if (currTimeIndex == 2) {
// tempTime = '12:00';
// } else if (currTimeIndex == 3) {
// tempTime = '18:00';
// }
// }
// print(_model.row.tableinfo);
// _clearData();
// String timeStr = dateText + ' ' + tempTime + ':00';
// LogUtil.v(timeStr);
// int ddate = DateUtil.getDateMsByTimeStr(timeStr);
// _homeEnterModel.getNewTableList(context, '${ddate}',
// currTimeIndex.toString(), pnum);
// EventBus().emit("refresh_tablemanager"); //刷新桌位
} else {
if (isShow) {
Utils.showToast("预订失败!");
}
}
}
///选中的桌子widget
Widget _selectTableWidgetWechat() {
return Container(
... ... @@ -2191,108 +2293,8 @@ class TableManagerPageState extends State<TableManagerPage> {
radius: ScreenUtil().setWidth(8),
isBold: false,
onPressed: () async {
bool isShow = true; //是否需要弹窗 “预订失败!”
SunReserveInfoModel _model = await tableManagerModel
.setReserveInfo(context, (v) {
if (v) {
isShow = true;
} else {
isShow = false;
}
}, needKeep: true, guest: widget.guest);
if (_model != null &&
ObjectUtil.isNotEmpty(_model.row) &&
ObjectUtil.isNotEmpty(_model.row.id)) {
print('成功');
// tableManagerModel.selectTables = [];
// wechatNotification = true;
_clearData();
// _homeEnterModel.clearData();
bus.emit("refresh_tablemanager"); //刷新当前页面
bus.emit("refresh_book_list"); //刷新已预订列表
//进入订座详情页面
// NavigatorUtil.goNotebookDetailPage(
// context,
// _model.row.id,
// Provider.of<UserModel>(context, listen: false)
// .user
// .openid,
// );
// String ddate_solt = '';
// if (_model.row.isSetDdate == '1') {
// String createtime =
// _model.row.ddate.toString() + '000';
// DateTime createTime =
// DateTime.fromMillisecondsSinceEpoch(
// int.parse(createtime));
// ddate_solt = DateUtil.formatDate(createTime,
// format: DateFormats.h_m);
// } else {
// if (_model.row.ddateSolt == '1') {
// ddate_solt = '早餐';
// } else if (_model.row.ddateSolt == '2') {
// ddate_solt = '午餐';
// } else if (_model.row.ddateSolt == '3') {
// ddate_solt = '晚餐';
// }
// }
// List<dynamic> tableinfo =
// convert.jsonDecode(_model.row.tableinfo);
// print(tableinfo);
// String _nameStr =
// t.TableList.fromJson(tableinfo[0]).name;
// if (tableinfo.length > 1) {
// _nameStr = t.TableList.fromJson(tableinfo[0]).name +
// '等${tableinfo.length}桌';
// }
// LogUtil.v(_nameStr);
// String _tid = '';
// for (int i = 0; i < tableinfo.length; i++) {
// _tid += '${t.TableList.fromJson(tableinfo[i]).id},';
// }
// if (_tid.endsWith(',')) {
// _tid = _tid.substring(0, _tid.length - 1);
// }
// NavigatorUtil.goInvicationPage(
// context,
// _model.row.id,
// _nameStr,
// _model.row.ddate,
// ddate_solt,
// _model.row.phone,
// _model.row.ddateSolt,
// tid: _tid,
// replace: false);
// //今天 明天 其他天
// String tempTime = _homeEnterModel.ddateStr;
// if (_homeEnterModel.ddateStr == '') {
// if (currTimeIndex == 1) {
// tempTime = '08:00';
// } else if (currTimeIndex == 2) {
// tempTime = '12:00';
// } else if (currTimeIndex == 3) {
// tempTime = '18:00';
// }
// }
// print(_model.row.tableinfo);
// _clearData();
// String timeStr = dateText + ' ' + tempTime + ':00';
// LogUtil.v(timeStr);
// int ddate = DateUtil.getDateMsByTimeStr(timeStr);
// _homeEnterModel.getNewTableList(context, '${ddate}',
// currTimeIndex.toString(), pnum);
// EventBus().emit("refresh_tablemanager"); //刷新桌位
} else {
if (isShow) {
Utils.showToast("预订失败!");
}
}
// _onlyReserve();
JhCommonUtils.debounce(() => _onlyReserve(), 500);
}),
HEmptyView(22),
RoundButton(
... ... @@ -2322,71 +2324,7 @@ class TableManagerPageState extends State<TableManagerPage> {
radius: ScreenUtil().setWidth(8),
isBold: false,
onPressed: () async {
bool isShow = true; //是否需要弹窗 “预订失败!”
SunReserveInfoModel _model = await tableManagerModel
.setReserveInfo(context, (v) {
if (v) {
isShow = true;
} else {
isShow = false;
}
}, needKeep: true, guest: widget.guest);
if (_model != null &&
ObjectUtil.isNotEmpty(_model.row) &&
ObjectUtil.isNotEmpty(_model.row.id)) {
print('成功');
// tableManagerModel.selectTables = [];
// wechatNotification = true;
_clearData();
// _homeEnterModel.clearData();
bus.emit("refresh_tablemanager"); //刷新当前页面
bus.emit("refresh_book_list"); //刷新已预订列表
// if (youhui != '选择优惠') {
// Map<String, String> params = {
// "rid": _model.row.id,
// "aid":
// '${couponProvider.couponListSelect[couponSelectIndex].id}'
// };
// bool isSuc = await couponProvider
// .setActivityAsReserve(context, params);
// if (isSuc) {
// couponProvider.hasModify = true;
// // bus.emit("refresh_book_list");
// bool isSuccess =
// await Utils.goShareInvicationToWeChat(
// context,
// _model.row.id,
// Provider.of<UserModel>(context,
// listen: false)
// .user
// .openid);
// print(isSuccess);
// if (isSuccess) {
// _addForward(_model.row.id);
// }
// }
// } else {
NavigatorUtil.goInvicationPage(
context, _model.row.id);
// bool isSuccess =
// await Utils.goShareInvicationToWeChat(
// context,
// _model.row.id,
// Provider.of<UserModel>(context,
// listen: false)
// .user
// .openid);
// if (isSuccess) {
// _addForward(_model.row.id);
// }
// }
} else {
//失败
if (isShow) {
Utils.showToast("预订失败!");
}
}
JhCommonUtils.debounce(() => _wechatReserve(), 500);
},
)),
],
... ... @@ -2397,6 +2335,73 @@ class TableManagerPageState extends State<TableManagerPage> {
));
}
_wechatReserve() async {
bool isShow = true; //是否需要弹窗 “预订失败!”
SunReserveInfoModel _model =
await tableManagerModel.setReserveInfo(context, (v) {
if (v) {
isShow = true;
} else {
isShow = false;
}
}, needKeep: true, guest: widget.guest);
if (_model != null &&
ObjectUtil.isNotEmpty(_model.row) &&
ObjectUtil.isNotEmpty(_model.row.id)) {
print('成功');
// tableManagerModel.selectTables = [];
// wechatNotification = true;
_clearData();
// _homeEnterModel.clearData();
bus.emit("refresh_tablemanager"); //刷新当前页面
bus.emit("refresh_book_list"); //刷新已预订列表
// if (youhui != '选择优惠') {
// Map<String, String> params = {
// "rid": _model.row.id,
// "aid":
// '${couponProvider.couponListSelect[couponSelectIndex].id}'
// };
// bool isSuc = await couponProvider
// .setActivityAsReserve(context, params);
// if (isSuc) {
// couponProvider.hasModify = true;
// // bus.emit("refresh_book_list");
// bool isSuccess =
// await Utils.goShareInvicationToWeChat(
// context,
// _model.row.id,
// Provider.of<UserModel>(context,
// listen: false)
// .user
// .openid);
// print(isSuccess);
// if (isSuccess) {
// _addForward(_model.row.id);
// }
// }
// } else {
NavigatorUtil.goInvicationPage(context, _model.row.id);
// bool isSuccess =
// await Utils.goShareInvicationToWeChat(
// context,
// _model.row.id,
// Provider.of<UserModel>(context,
// listen: false)
// .user
// .openid);
// if (isSuccess) {
// _addForward(_model.row.id);
// }
// }
} else {
//失败
if (isShow) {
Utils.showToast("预订失败!");
}
}
}
///清空数据
_clearData() {
nameStr = '';
... ... @@ -2643,298 +2648,7 @@ class TableManagerPageState extends State<TableManagerPage> {
radius: ScreenUtil().setWidth(8),
isBold: false,
onPressed: () async {
if (!noticeSms) {
if (myModel.smsInfo == '0') {
setState(() {
showErro = smsErro;
});
return;
}
}
if ((_baseIndoProvider.phoneController.text
.replaceAll(' ', '')
.isEmpty ||
!Utils.isInteger(_baseIndoProvider
.phoneController.text
.replaceAll(' ', '')))) {
setState(() {
showErro = '请输入正确的11位手机号码';
});
return;
} else {
setState(() {
showErro = '';
});
}
// if (!couponProvider.sendSMS) {
/*
String dateSoltStr = '';
if (widget.dateSolt == '1') {
dateSoltStr = '早餐';
} else if (widget.dateSolt == '2') {
dateSoltStr = '午餐';
} else if (widget.dateSolt == '3') {
dateSoltStr = '晚餐';
}
DateTime dateTimeTemp =
DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.ddate) * 1000);
String dateTimeStrTemp =
"${Utils.addZeroNumber(dateTimeTemp.month)}月${Utils.addZeroNumber(dateTimeTemp.day)}日";
Map<String, String> params = {
"id": widget.rid,
"uid": Provider.of<UserModel>(context,
listen: false)
.user
.openid,
"phone": widget.phone,
// "Strtext": user.sellername +
// dateTimeStrTemp +
// dateSoltStr +
// ',' +
// '餐厅经理' +
// _baseIndoProvider.baseInfoSunModel.name +
// '已为您安排在' +
// widget.tableInfo.replaceAll("\n", "")
};
if (ObjectUtil.isNotEmpty(_baseIndoProvider
.baseInfoSunModel) &&
ObjectUtil.isNotEmpty(_baseIndoProvider
.baseInfoSunModel.name)) {
params['Strtext'] = user.sellername +
_baseIndoProvider
.baseInfoSunModel.name;
} else {
params['Strtext'] = user.sellername;
}
*/
Guest guest = Guest(
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null);
// if (widget.guest == null) {
guest.phone = _baseIndoProvider
.phoneController.text
.replaceAll(' ', ''); //预订人电话
if (nameStr != null &&
nameStr.trim().length > 0) {
String sex = '1';
if (sexStr == '女士') {
sex = '2';
} else if (sexStr == '公司') {
sex = '3';
}
guest.rname = nameStr; //预订人姓名
guest.sex = sex; //预订人性别:1:男 2:女
}
// }
String pnum;
if (pnumController.text != '') {
pnum = pnumController.text;
}
String cusdem;
if (customController.text.trim().length > 0) {
cusdem = customController.text;
}
bool isShow = true; //是否需要弹窗 “预订失败!”
SunReserveInfoModel _model =
await tableManagerModel
.setReserveInfo(context, (v) {
if (v) {
isShow = true;
} else {
isShow = false;
}
},
needKeep: true,
pnum: pnum,
cusdem: cusdem,
tempTime:
ddateHm == '选填' ? null : ddateHm,
guest: guest);
if (_model != null &&
ObjectUtil.isNotEmpty(_model.row) &&
ObjectUtil.isNotEmpty(_model.row.id)) {
print('成功');
// tableManagerModel.selectTables = [];
// wechatNotification = true;
_clearData();
// _homeEnterModel.clearData();
bus.emit("refresh_tablemanager"); //刷新当前页面
bus.emit("refresh_book_list"); //刷新已预订列表
if (youhui != '选择优惠') {
Map<String, String> params = {
"rid": _model.row.id,
"aid":
'${couponProvider.couponListSelect[couponSelectIndex].id}'
};
bool isSuc = await couponProvider
.setActivityAsReserve(context, params);
if (isSuc) {
couponProvider.hasModify = true;
//发短信操作
if (noticeSms) {
//使用手机发短信
_getSmsContent(
_model.row.id, guest.phone);
} else {
UserModel userModel =
Provider.of<UserModel>(context,
listen: false);
Map<String, String> params = {
"rid": _model.row.id,
"sid": userModel.user.sellerid
};
bool success = await couponProvider
.sendSMSWxSendSms(context, params);
print(success);
}
}
} else {
//发短信操作
if (noticeSms) {
//使用手机发短信
_getSmsContent(_model.row.id, guest.phone);
} else {
UserModel userModel =
Provider.of<UserModel>(context,
listen: false);
Map<String, String> params = {
"rid": _model.row.id,
"sid": userModel.user.sellerid
};
bool success = await couponProvider
.sendSMSWxSendSms(context, params);
print(success);
}
}
// if (success) {
// Utils.showToast('短信已经发送成功!');
// } else {
// Utils.showToast('发送次数太频繁!');
// }
// } else {
// Utils.showToast('短信已经发送成功!');
// }
// //进入订座详情页面
// NavigatorUtil.goNotebookDetailPage(
// context,
// _model.row.id,
// Provider.of<UserModel>(context, listen: false)
// .user
// .openid,
// );
// String ddate_solt = '';
// if (_model.row.isSetDdate == '1') {
// String createtime = _model.row.ddate.toString() + '000';
// DateTime createTime =
// DateTime.fromMillisecondsSinceEpoch(
// int.parse(createtime));
// ddate_solt = DateUtil.formatDate(createTime,
// format: DateFormats.h_m);
// } else {
// if (_model.row.ddateSolt == '1') {
// ddate_solt = '早餐';
// } else if (_model.row.ddateSolt == '2') {
// ddate_solt = '午餐';
// } else if (_model.row.ddateSolt == '3') {
// ddate_solt = '晚餐';
// }
// }
// List<dynamic> tableinfo =
// convert.jsonDecode(_model.row.tableinfo);
// print(tableinfo);
// // String _nameStr =
// // table.TableList.fromJson(tableinfo[0]).name;
// // if (tableinfo.length > 1) {
// // _nameStr = table.TableList.fromJson(tableinfo[0]).name +
// // '等${tableinfo.length}桌';
// // }
// // LogUtil.v(_nameStr);
// // String _tid = '';
// // for (int i = 0; i < tableinfo.length; i++) {
// // _tid += '${table.TableList.fromJson(tableinfo[i]).id},';
// // }
// // if (_tid.endsWith(',')) {
// // _tid = _tid.substring(0, _tid.length - 1);
// // }
// String _nameStr = '';
// String _tid = '';
// for (int i = 0; i < tableinfo.length; i++) {
// _nameStr +=
// '${table.TableList.fromJson(tableinfo[i]).name},';
// _tid += '${table.TableList.fromJson(tableinfo[i]).id},';
// }
// if (_tid.endsWith(',')) {
// _tid = _tid.substring(0, _tid.length - 1);
// }
// if (_nameStr.endsWith(',')) {
// _nameStr = _nameStr.substring(0, _nameStr.length - 1);
// }
// NavigatorUtil.goInvicationPage(
// context,
// _model.row.id,
// _nameStr,
// _model.row.ddate,
// ddate_solt,
// _model.row.phone,
// _model.row.ddateSolt,
// _model.row.rname == null ? '' : _model.row.rname,
// _model.row.sex == null ? '' : _model.row.sex,
// tid: _tid,
// replace: false);
// // //今天 明天 其他天
// // String tempTime = _homeEnterModel.ddateStr;
// // if (_homeEnterModel.ddateStr == '') {
// // if (currTimeIndex == 1) {
// // tempTime = '08:00';
// // } else if (currTimeIndex == 2) {
// // tempTime = '12:00';
// // } else if (currTimeIndex == 3) {
// // tempTime = '18:00';
// // }
// // }
// // print(_model.row.tableinfo);
// // _clearData();
// // String timeStr = dateText + ' ' + tempTime + ':00';
// // LogUtil.v(timeStr);
// // int ddate = DateUtil.getDateMsByTimeStr(timeStr);
// // _homeEnterModel.getNewTableList(context, '${ddate}',
// // currTimeIndex.toString(), pnum);
// // EventBus().emit("refresh_tablemanager"); //刷新桌位
} else {
if (isShow) {
Utils.showToast("预订失败!");
}
}
JhCommonUtils.debounce(() => _smsReserve(), 500);
},
)),
HEmptyView(36),
... ... @@ -3304,6 +3018,270 @@ class TableManagerPageState extends State<TableManagerPage> {
)));
}
_smsReserve() async {
if (!noticeSms) {
if (myModel.smsInfo == '0') {
setState(() {
showErro = smsErro;
});
return;
}
}
if ((_baseIndoProvider.phoneController.text.replaceAll(' ', '').isEmpty ||
!Utils.isInteger(
_baseIndoProvider.phoneController.text.replaceAll(' ', '')))) {
setState(() {
showErro = '请输入正确的11位手机号码';
});
return;
} else {
setState(() {
showErro = '';
});
}
// if (!couponProvider.sendSMS) {
/*
String dateSoltStr = '';
if (widget.dateSolt == '1') {
dateSoltStr = '早餐';
} else if (widget.dateSolt == '2') {
dateSoltStr = '午餐';
} else if (widget.dateSolt == '3') {
dateSoltStr = '晚餐';
}
DateTime dateTimeTemp =
DateTime.fromMillisecondsSinceEpoch(
int.parse(widget.ddate) * 1000);
String dateTimeStrTemp =
"${Utils.addZeroNumber(dateTimeTemp.month)}月${Utils.addZeroNumber(dateTimeTemp.day)}日";
Map<String, String> params = {
"id": widget.rid,
"uid": Provider.of<UserModel>(context,
listen: false)
.user
.openid,
"phone": widget.phone,
// "Strtext": user.sellername +
// dateTimeStrTemp +
// dateSoltStr +
// ',' +
// '餐厅经理' +
// _baseIndoProvider.baseInfoSunModel.name +
// '已为您安排在' +
// widget.tableInfo.replaceAll("\n", "")
};
if (ObjectUtil.isNotEmpty(_baseIndoProvider
.baseInfoSunModel) &&
ObjectUtil.isNotEmpty(_baseIndoProvider
.baseInfoSunModel.name)) {
params['Strtext'] = user.sellername +
_baseIndoProvider
.baseInfoSunModel.name;
} else {
params['Strtext'] = user.sellername;
}
*/
Guest guest = Guest(null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null);
// if (widget.guest == null) {
guest.phone =
_baseIndoProvider.phoneController.text.replaceAll(' ', ''); //预订人电话
if (nameStr != null && nameStr.trim().length > 0) {
String sex = '1';
if (sexStr == '女士') {
sex = '2';
} else if (sexStr == '公司') {
sex = '3';
}
guest.rname = nameStr; //预订人姓名
guest.sex = sex; //预订人性别:1:男 2:女
}
// }
String pnum;
if (pnumController.text != '') {
pnum = pnumController.text;
}
String cusdem;
if (customController.text.trim().length > 0) {
cusdem = customController.text;
}
bool isShow = true; //是否需要弹窗 “预订失败!”
SunReserveInfoModel _model = await tableManagerModel.setReserveInfo(context,
(v) {
if (v) {
isShow = true;
} else {
isShow = false;
}
},
needKeep: true,
pnum: pnum,
cusdem: cusdem,
tempTime: ddateHm == '选填' ? null : ddateHm,
guest: guest);
if (_model != null &&
ObjectUtil.isNotEmpty(_model.row) &&
ObjectUtil.isNotEmpty(_model.row.id)) {
print('成功');
// tableManagerModel.selectTables = [];
// wechatNotification = true;
_clearData();
// _homeEnterModel.clearData();
bus.emit("refresh_tablemanager"); //刷新当前页面
bus.emit("refresh_book_list"); //刷新已预订列表
if (youhui != '选择优惠') {
Map<String, String> params = {
"rid": _model.row.id,
"aid": '${couponProvider.couponListSelect[couponSelectIndex].id}'
};
bool isSuc = await couponProvider.setActivityAsReserve(context, params);
if (isSuc) {
couponProvider.hasModify = true;
//发短信操作
if (noticeSms) {
//使用手机发短信
_getSmsContent(_model.row.id, guest.phone);
} else {
UserModel userModel =
Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"rid": _model.row.id,
"sid": userModel.user.sellerid
};
bool success =
await couponProvider.sendSMSWxSendSms(context, params);
print(success);
}
}
} else {
//发短信操作
if (noticeSms) {
//使用手机发短信
_getSmsContent(_model.row.id, guest.phone);
} else {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"rid": _model.row.id,
"sid": userModel.user.sellerid
};
bool success = await couponProvider.sendSMSWxSendSms(context, params);
print(success);
}
}
// if (success) {
// Utils.showToast('短信已经发送成功!');
// } else {
// Utils.showToast('发送次数太频繁!');
// }
// } else {
// Utils.showToast('短信已经发送成功!');
// }
// //进入订座详情页面
// NavigatorUtil.goNotebookDetailPage(
// context,
// _model.row.id,
// Provider.of<UserModel>(context, listen: false)
// .user
// .openid,
// );
// String ddate_solt = '';
// if (_model.row.isSetDdate == '1') {
// String createtime = _model.row.ddate.toString() + '000';
// DateTime createTime =
// DateTime.fromMillisecondsSinceEpoch(
// int.parse(createtime));
// ddate_solt = DateUtil.formatDate(createTime,
// format: DateFormats.h_m);
// } else {
// if (_model.row.ddateSolt == '1') {
// ddate_solt = '早餐';
// } else if (_model.row.ddateSolt == '2') {
// ddate_solt = '午餐';
// } else if (_model.row.ddateSolt == '3') {
// ddate_solt = '晚餐';
// }
// }
// List<dynamic> tableinfo =
// convert.jsonDecode(_model.row.tableinfo);
// print(tableinfo);
// // String _nameStr =
// // table.TableList.fromJson(tableinfo[0]).name;
// // if (tableinfo.length > 1) {
// // _nameStr = table.TableList.fromJson(tableinfo[0]).name +
// // '等${tableinfo.length}桌';
// // }
// // LogUtil.v(_nameStr);
// // String _tid = '';
// // for (int i = 0; i < tableinfo.length; i++) {
// // _tid += '${table.TableList.fromJson(tableinfo[i]).id},';
// // }
// // if (_tid.endsWith(',')) {
// // _tid = _tid.substring(0, _tid.length - 1);
// // }
// String _nameStr = '';
// String _tid = '';
// for (int i = 0; i < tableinfo.length; i++) {
// _nameStr +=
// '${table.TableList.fromJson(tableinfo[i]).name},';
// _tid += '${table.TableList.fromJson(tableinfo[i]).id},';
// }
// if (_tid.endsWith(',')) {
// _tid = _tid.substring(0, _tid.length - 1);
// }
// if (_nameStr.endsWith(',')) {
// _nameStr = _nameStr.substring(0, _nameStr.length - 1);
// }
// NavigatorUtil.goInvicationPage(
// context,
// _model.row.id,
// _nameStr,
// _model.row.ddate,
// ddate_solt,
// _model.row.phone,
// _model.row.ddateSolt,
// _model.row.rname == null ? '' : _model.row.rname,
// _model.row.sex == null ? '' : _model.row.sex,
// tid: _tid,
// replace: false);
// // //今天 明天 其他天
// // String tempTime = _homeEnterModel.ddateStr;
// // if (_homeEnterModel.ddateStr == '') {
// // if (currTimeIndex == 1) {
// // tempTime = '08:00';
// // } else if (currTimeIndex == 2) {
// // tempTime = '12:00';
// // } else if (currTimeIndex == 3) {
// // tempTime = '18:00';
// // }
// // }
// // print(_model.row.tableinfo);
// // _clearData();
// // String timeStr = dateText + ' ' + tempTime + ':00';
// // LogUtil.v(timeStr);
// // int ddate = DateUtil.getDateMsByTimeStr(timeStr);
// // _homeEnterModel.getNewTableList(context, '${ddate}',
// // currTimeIndex.toString(), pnum);
// // EventBus().emit("refresh_tablemanager"); //刷新桌位
} else {
if (isShow) {
Utils.showToast("预订失败!");
}
}
}
//构建常用备注
List<Widget> _buildAlwayItems() {
List<Widget> tables = [];
... ...
import 'dart:async';
class JhCommonUtils {
static Timer _debounceTimer;
/// 防抖 (传入所要防抖的方法/回调与延迟时间)
static void debounce(Function func, [int delay = 500]) {
if (_debounceTimer != null) {
_debounceTimer?.cancel();
}
_debounceTimer = Timer(Duration(milliseconds: delay), () {
func.call();
_debounceTimer = null;
});
}
/// 防抖 (传入所要防抖的方法/回调与延迟时间)
static debounce2(Function func, [int delay = 500]) {
Timer timer;
return () {
if (timer != null) {
timer?.cancel();
}
timer = Timer(Duration(milliseconds: delay), () {
func.call();
timer = null;
});
};
}
/// 录入框防抖 (传入所要防抖的方法/回调与延迟时间)
static debounceInput(Function(dynamic) func, [int delay = 500]) {
Timer timer;
return (dynamic value) {
if (timer != null) {
timer?.cancel();
}
timer = Timer(Duration(milliseconds: delay), () {
func.call(value);
timer = null;
});
};
}
static Timer _throttleTimer;
static bool _throttleFlag = true;
/// 节流 (传入所要节流的方法/回调与延迟时间)
static void throttle(Function func, [int delay = 500]) {
if (_throttleFlag) {
func.call();
_throttleFlag = false;
return;
}
if (_throttleTimer != null) {
return;
}
_throttleTimer = Timer(Duration(milliseconds: delay), () {
func.call();
_throttleTimer = null;
});
}
/// 节流 (传入所要节流的方法/回调与延迟时间)
static throttle2(Function func, [int delay = 500]) {
Timer timer;
bool firstTime = true;
return () {
if (firstTime) {
func.call();
firstTime = false;
return;
}
if (timer != null) {
return;
}
timer = Timer(Duration(milliseconds: delay), () {
func.call();
timer = null;
});
};
}
/// 节流 (传入所要节流的方法/回调与延迟时间)
static throttle3(Function func, [int delay = 500]) {
Timer timer;
bool isExecuting = false;
return () {
if (isExecuting) return;
isExecuting = true;
timer?.cancel();
timer = Timer(Duration(milliseconds: delay), () {
func.call();
isExecuting = false;
});
};
}
}
... ...