Commit f491a2deeb1c540f9235a1536d6662ceb82d6683

Authored by wdn127929
1 parent 777f18e2

防抖处理

@@ -27,6 +27,7 @@ import 'package:provider/provider.dart'; @@ -27,6 +27,7 @@ import 'package:provider/provider.dart';
27 import 'package:one_key/utils/event_bus.dart'; 27 import 'package:one_key/utils/event_bus.dart';
28 28
29 import '../../app.dart'; 29 import '../../app.dart';
  30 +import '../../utils/common_utils.dart';
30 31
31 class HandleOnlinePage extends StatefulWidget { 32 class HandleOnlinePage extends StatefulWidget {
32 final String rid; 33 final String rid;
@@ -127,6 +128,15 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -127,6 +128,15 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
127 detailModel.setReserveCusmnan(context, params); 128 detailModel.setReserveCusmnan(context, params);
128 } 129 }
129 130
  131 + _goReserve() async {
  132 + Navigator.of(context).pop();
  133 + Map temp = await NavigatorUtil.goSelectTableFPage(context, widget.rid,
  134 + int.parse(detailEntity.ddate) * 1000, detailEntity.ddate_solt);
  135 + if (temp != null && temp['tid'] != null) {
  136 + setReserveStatus("5", tid: temp['tid']);
  137 + }
  138 + }
  139 +
130 //拒绝订单弹框 140 //拒绝订单弹框
131 _showRefuseDialog2() { 141 _showRefuseDialog2() {
132 Widget dialogContent = StatefulBuilder( 142 Widget dialogContent = StatefulBuilder(
@@ -216,15 +226,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> { @@ -216,15 +226,7 @@ class HandleOnlinePageState extends State<HandleOnlinePage> {
216 VEmptyView(20), 226 VEmptyView(20),
217 GestureDetector( 227 GestureDetector(
218 onTap: () async { 228 onTap: () async {
219 - Navigator.of(context).pop();  
220 - Map temp = await NavigatorUtil.goSelectTableFPage(  
221 - context,  
222 - widget.rid,  
223 - int.parse(detailEntity.ddate) * 1000,  
224 - detailEntity.ddate_solt);  
225 - if (temp != null && temp['tid'] != null) {  
226 - setReserveStatus("5", tid: temp['tid']);  
227 - } 229 + JhCommonUtils.debounce(() => _goReserve(), 500);
228 }, 230 },
229 child: Container( 231 child: Container(
230 width: ScreenUtil().setWidth(336), 232 width: ScreenUtil().setWidth(336),
@@ -60,6 +60,7 @@ import '../../provider/marketing_center_provider.dart'; @@ -60,6 +60,7 @@ import '../../provider/marketing_center_provider.dart';
60 import '../../provider/remark_manager_model.dart'; 60 import '../../provider/remark_manager_model.dart';
61 import '../../provider/store_base_info_provider.dart'; 61 import '../../provider/store_base_info_provider.dart';
62 import '../../utils/call_log_utils.dart'; 62 import '../../utils/call_log_utils.dart';
  63 +import '../../utils/common_utils.dart';
63 import '../../utils/screen_util.dart'; 64 import '../../utils/screen_util.dart';
64 import '../../widgets/loading.dart'; 65 import '../../widgets/loading.dart';
65 import '../../widgets/special_text/my_extended_text_selection_controls.dart'; 66 import '../../widgets/special_text/my_extended_text_selection_controls.dart';
@@ -683,15 +684,12 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -683,15 +684,12 @@ class TableManagerPageState extends State<TableManagerPage> {
683 // } 684 // }
684 685
685 _getCallLog() async { 686 _getCallLog() async {
686 -  
687 -  
688 - List<Picker.PickerItem<dynamic>> data = []; 687 + List<Picker.PickerItem<dynamic>> data = [];
689 688
690 Iterable<CallLogEntry> result = await CallLogUtils.getCallLog(context); 689 Iterable<CallLogEntry> result = await CallLogUtils.getCallLog(context);
691 if (result != null) { 690 if (result != null) {
692 _baseIndoProvider.userHistorys = []; 691 _baseIndoProvider.userHistorys = [];
693 692
694 -  
695 List<CallLogEntry> object = Utils.removeDuplicates(result.toList()); 693 List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
696 694
697 print(object); 695 print(object);
@@ -819,7 +817,6 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -819,7 +817,6 @@ class TableManagerPageState extends State<TableManagerPage> {
819 _phoneNode.unfocus(); 817 _phoneNode.unfocus();
820 _baseIndoProvider.userHistorys.clear(); 818 _baseIndoProvider.userHistorys.clear();
821 }); 819 });
822 -  
823 } 820 }
824 821
825 _getContactData() async { 822 _getContactData() async {
@@ -2000,6 +1997,111 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -2000,6 +1997,111 @@ class TableManagerPageState extends State<TableManagerPage> {
2000 } 1997 }
2001 */ 1998 */
2002 1999
  2000 + _onlyReserve() async {
  2001 + bool isShow = true; //是否需要弹窗 “预订失败!”
  2002 + SunReserveInfoModel _model =
  2003 + await tableManagerModel.setReserveInfo(context, (v) {
  2004 + if (v) {
  2005 + isShow = true;
  2006 + } else {
  2007 + isShow = false;
  2008 + }
  2009 + }, needKeep: true, guest: widget.guest);
  2010 + if (_model != null &&
  2011 + ObjectUtil.isNotEmpty(_model.row) &&
  2012 + ObjectUtil.isNotEmpty(_model.row.id)) {
  2013 + print('成功');
  2014 + // tableManagerModel.selectTables = [];
  2015 +
  2016 + // wechatNotification = true;
  2017 + _clearData();
  2018 +
  2019 + // _homeEnterModel.clearData();
  2020 + bus.emit("refresh_tablemanager"); //刷新当前页面
  2021 + bus.emit("refresh_book_list"); //刷新已预订列表
  2022 + //进入订座详情页面
  2023 + // NavigatorUtil.goNotebookDetailPage(
  2024 + // context,
  2025 + // _model.row.id,
  2026 + // Provider.of<UserModel>(context, listen: false)
  2027 + // .user
  2028 + // .openid,
  2029 + // );
  2030 + // String ddate_solt = '';
  2031 + // if (_model.row.isSetDdate == '1') {
  2032 + // String createtime =
  2033 + // _model.row.ddate.toString() + '000';
  2034 + // DateTime createTime =
  2035 + // DateTime.fromMillisecondsSinceEpoch(
  2036 + // int.parse(createtime));
  2037 + // ddate_solt = DateUtil.formatDate(createTime,
  2038 + // format: DateFormats.h_m);
  2039 + // } else {
  2040 + // if (_model.row.ddateSolt == '1') {
  2041 + // ddate_solt = '早餐';
  2042 + // } else if (_model.row.ddateSolt == '2') {
  2043 + // ddate_solt = '午餐';
  2044 + // } else if (_model.row.ddateSolt == '3') {
  2045 + // ddate_solt = '晚餐';
  2046 + // }
  2047 + // }
  2048 + // List<dynamic> tableinfo =
  2049 + // convert.jsonDecode(_model.row.tableinfo);
  2050 + // print(tableinfo);
  2051 +
  2052 + // String _nameStr =
  2053 + // t.TableList.fromJson(tableinfo[0]).name;
  2054 + // if (tableinfo.length > 1) {
  2055 + // _nameStr = t.TableList.fromJson(tableinfo[0]).name +
  2056 + // '等${tableinfo.length}桌';
  2057 + // }
  2058 + // LogUtil.v(_nameStr);
  2059 + // String _tid = '';
  2060 + // for (int i = 0; i < tableinfo.length; i++) {
  2061 + // _tid += '${t.TableList.fromJson(tableinfo[i]).id},';
  2062 + // }
  2063 + // if (_tid.endsWith(',')) {
  2064 + // _tid = _tid.substring(0, _tid.length - 1);
  2065 + // }
  2066 + // NavigatorUtil.goInvicationPage(
  2067 + // context,
  2068 + // _model.row.id,
  2069 + // _nameStr,
  2070 + // _model.row.ddate,
  2071 + // ddate_solt,
  2072 + // _model.row.phone,
  2073 + // _model.row.ddateSolt,
  2074 + // tid: _tid,
  2075 + // replace: false);
  2076 + // //今天 明天 其他天
  2077 + // String tempTime = _homeEnterModel.ddateStr;
  2078 + // if (_homeEnterModel.ddateStr == '') {
  2079 + // if (currTimeIndex == 1) {
  2080 + // tempTime = '08:00';
  2081 + // } else if (currTimeIndex == 2) {
  2082 + // tempTime = '12:00';
  2083 + // } else if (currTimeIndex == 3) {
  2084 + // tempTime = '18:00';
  2085 + // }
  2086 + // }
  2087 + // print(_model.row.tableinfo);
  2088 + // _clearData();
  2089 + // String timeStr = dateText + ' ' + tempTime + ':00';
  2090 +
  2091 + // LogUtil.v(timeStr);
  2092 + // int ddate = DateUtil.getDateMsByTimeStr(timeStr);
  2093 +
  2094 + // _homeEnterModel.getNewTableList(context, '${ddate}',
  2095 + // currTimeIndex.toString(), pnum);
  2096 +
  2097 + // EventBus().emit("refresh_tablemanager"); //刷新桌位
  2098 + } else {
  2099 + if (isShow) {
  2100 + Utils.showToast("预订失败!");
  2101 + }
  2102 + }
  2103 + }
  2104 +
2003 ///选中的桌子widget 2105 ///选中的桌子widget
2004 Widget _selectTableWidgetWechat() { 2106 Widget _selectTableWidgetWechat() {
2005 return Container( 2107 return Container(
@@ -2191,108 +2293,8 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -2191,108 +2293,8 @@ class TableManagerPageState extends State<TableManagerPage> {
2191 radius: ScreenUtil().setWidth(8), 2293 radius: ScreenUtil().setWidth(8),
2192 isBold: false, 2294 isBold: false,
2193 onPressed: () async { 2295 onPressed: () async {
2194 - bool isShow = true; //是否需要弹窗 “预订失败!”  
2195 - SunReserveInfoModel _model = await tableManagerModel  
2196 - .setReserveInfo(context, (v) {  
2197 - if (v) {  
2198 - isShow = true;  
2199 - } else {  
2200 - isShow = false;  
2201 - }  
2202 - }, needKeep: true, guest: widget.guest);  
2203 - if (_model != null &&  
2204 - ObjectUtil.isNotEmpty(_model.row) &&  
2205 - ObjectUtil.isNotEmpty(_model.row.id)) {  
2206 - print('成功');  
2207 - // tableManagerModel.selectTables = [];  
2208 -  
2209 - // wechatNotification = true;  
2210 - _clearData();  
2211 -  
2212 - // _homeEnterModel.clearData();  
2213 - bus.emit("refresh_tablemanager"); //刷新当前页面  
2214 - bus.emit("refresh_book_list"); //刷新已预订列表  
2215 - //进入订座详情页面  
2216 - // NavigatorUtil.goNotebookDetailPage(  
2217 - // context,  
2218 - // _model.row.id,  
2219 - // Provider.of<UserModel>(context, listen: false)  
2220 - // .user  
2221 - // .openid,  
2222 - // );  
2223 - // String ddate_solt = '';  
2224 - // if (_model.row.isSetDdate == '1') {  
2225 - // String createtime =  
2226 - // _model.row.ddate.toString() + '000';  
2227 - // DateTime createTime =  
2228 - // DateTime.fromMillisecondsSinceEpoch(  
2229 - // int.parse(createtime));  
2230 - // ddate_solt = DateUtil.formatDate(createTime,  
2231 - // format: DateFormats.h_m);  
2232 - // } else {  
2233 - // if (_model.row.ddateSolt == '1') {  
2234 - // ddate_solt = '早餐';  
2235 - // } else if (_model.row.ddateSolt == '2') {  
2236 - // ddate_solt = '午餐';  
2237 - // } else if (_model.row.ddateSolt == '3') {  
2238 - // ddate_solt = '晚餐';  
2239 - // }  
2240 - // }  
2241 - // List<dynamic> tableinfo =  
2242 - // convert.jsonDecode(_model.row.tableinfo);  
2243 - // print(tableinfo);  
2244 -  
2245 - // String _nameStr =  
2246 - // t.TableList.fromJson(tableinfo[0]).name;  
2247 - // if (tableinfo.length > 1) {  
2248 - // _nameStr = t.TableList.fromJson(tableinfo[0]).name +  
2249 - // '等${tableinfo.length}桌';  
2250 - // }  
2251 - // LogUtil.v(_nameStr);  
2252 - // String _tid = '';  
2253 - // for (int i = 0; i < tableinfo.length; i++) {  
2254 - // _tid += '${t.TableList.fromJson(tableinfo[i]).id},';  
2255 - // }  
2256 - // if (_tid.endsWith(',')) {  
2257 - // _tid = _tid.substring(0, _tid.length - 1);  
2258 - // }  
2259 - // NavigatorUtil.goInvicationPage(  
2260 - // context,  
2261 - // _model.row.id,  
2262 - // _nameStr,  
2263 - // _model.row.ddate,  
2264 - // ddate_solt,  
2265 - // _model.row.phone,  
2266 - // _model.row.ddateSolt,  
2267 - // tid: _tid,  
2268 - // replace: false);  
2269 - // //今天 明天 其他天  
2270 - // String tempTime = _homeEnterModel.ddateStr;  
2271 - // if (_homeEnterModel.ddateStr == '') {  
2272 - // if (currTimeIndex == 1) {  
2273 - // tempTime = '08:00';  
2274 - // } else if (currTimeIndex == 2) {  
2275 - // tempTime = '12:00';  
2276 - // } else if (currTimeIndex == 3) {  
2277 - // tempTime = '18:00';  
2278 - // }  
2279 - // }  
2280 - // print(_model.row.tableinfo);  
2281 - // _clearData();  
2282 - // String timeStr = dateText + ' ' + tempTime + ':00';  
2283 -  
2284 - // LogUtil.v(timeStr);  
2285 - // int ddate = DateUtil.getDateMsByTimeStr(timeStr);  
2286 -  
2287 - // _homeEnterModel.getNewTableList(context, '${ddate}',  
2288 - // currTimeIndex.toString(), pnum);  
2289 -  
2290 - // EventBus().emit("refresh_tablemanager"); //刷新桌位  
2291 - } else {  
2292 - if (isShow) {  
2293 - Utils.showToast("预订失败!");  
2294 - }  
2295 - } 2296 + // _onlyReserve();
  2297 + JhCommonUtils.debounce(() => _onlyReserve(), 500);
2296 }), 2298 }),
2297 HEmptyView(22), 2299 HEmptyView(22),
2298 RoundButton( 2300 RoundButton(
@@ -2322,71 +2324,7 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -2322,71 +2324,7 @@ class TableManagerPageState extends State<TableManagerPage> {
2322 radius: ScreenUtil().setWidth(8), 2324 radius: ScreenUtil().setWidth(8),
2323 isBold: false, 2325 isBold: false,
2324 onPressed: () async { 2326 onPressed: () async {
2325 - bool isShow = true; //是否需要弹窗 “预订失败!”  
2326 - SunReserveInfoModel _model = await tableManagerModel  
2327 - .setReserveInfo(context, (v) {  
2328 - if (v) {  
2329 - isShow = true;  
2330 - } else {  
2331 - isShow = false;  
2332 - }  
2333 - }, needKeep: true, guest: widget.guest);  
2334 - if (_model != null &&  
2335 - ObjectUtil.isNotEmpty(_model.row) &&  
2336 - ObjectUtil.isNotEmpty(_model.row.id)) {  
2337 - print('成功');  
2338 - // tableManagerModel.selectTables = [];  
2339 - // wechatNotification = true;  
2340 - _clearData();  
2341 - // _homeEnterModel.clearData();  
2342 - bus.emit("refresh_tablemanager"); //刷新当前页面  
2343 - bus.emit("refresh_book_list"); //刷新已预订列表  
2344 -  
2345 - // if (youhui != '选择优惠') {  
2346 - // Map<String, String> params = {  
2347 - // "rid": _model.row.id,  
2348 - // "aid":  
2349 - // '${couponProvider.couponListSelect[couponSelectIndex].id}'  
2350 - // };  
2351 - // bool isSuc = await couponProvider  
2352 - // .setActivityAsReserve(context, params);  
2353 - // if (isSuc) {  
2354 - // couponProvider.hasModify = true;  
2355 - // // bus.emit("refresh_book_list");  
2356 - // bool isSuccess =  
2357 - // await Utils.goShareInvicationToWeChat(  
2358 - // context,  
2359 - // _model.row.id,  
2360 - // Provider.of<UserModel>(context,  
2361 - // listen: false)  
2362 - // .user  
2363 - // .openid);  
2364 - // print(isSuccess);  
2365 - // if (isSuccess) {  
2366 - // _addForward(_model.row.id);  
2367 - // }  
2368 - // }  
2369 - // } else {  
2370 - NavigatorUtil.goInvicationPage(  
2371 - context, _model.row.id);  
2372 - // bool isSuccess =  
2373 - // await Utils.goShareInvicationToWeChat(  
2374 - // context,  
2375 - // _model.row.id,  
2376 - // Provider.of<UserModel>(context,  
2377 - // listen: false)  
2378 - // .user  
2379 - // .openid);  
2380 - // if (isSuccess) {  
2381 - // _addForward(_model.row.id);  
2382 - // }  
2383 - // }  
2384 - } else {  
2385 - //失败  
2386 - if (isShow) {  
2387 - Utils.showToast("预订失败!");  
2388 - }  
2389 - } 2327 + JhCommonUtils.debounce(() => _wechatReserve(), 500);
2390 }, 2328 },
2391 )), 2329 )),
2392 ], 2330 ],
@@ -2397,6 +2335,73 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -2397,6 +2335,73 @@ class TableManagerPageState extends State<TableManagerPage> {
2397 )); 2335 ));
2398 } 2336 }
2399 2337
  2338 + _wechatReserve() async {
  2339 + bool isShow = true; //是否需要弹窗 “预订失败!”
  2340 + SunReserveInfoModel _model =
  2341 + await tableManagerModel.setReserveInfo(context, (v) {
  2342 + if (v) {
  2343 + isShow = true;
  2344 + } else {
  2345 + isShow = false;
  2346 + }
  2347 + }, needKeep: true, guest: widget.guest);
  2348 + if (_model != null &&
  2349 + ObjectUtil.isNotEmpty(_model.row) &&
  2350 + ObjectUtil.isNotEmpty(_model.row.id)) {
  2351 + print('成功');
  2352 + // tableManagerModel.selectTables = [];
  2353 + // wechatNotification = true;
  2354 + _clearData();
  2355 + // _homeEnterModel.clearData();
  2356 + bus.emit("refresh_tablemanager"); //刷新当前页面
  2357 + bus.emit("refresh_book_list"); //刷新已预订列表
  2358 +
  2359 + // if (youhui != '选择优惠') {
  2360 + // Map<String, String> params = {
  2361 + // "rid": _model.row.id,
  2362 + // "aid":
  2363 + // '${couponProvider.couponListSelect[couponSelectIndex].id}'
  2364 + // };
  2365 + // bool isSuc = await couponProvider
  2366 + // .setActivityAsReserve(context, params);
  2367 + // if (isSuc) {
  2368 + // couponProvider.hasModify = true;
  2369 + // // bus.emit("refresh_book_list");
  2370 + // bool isSuccess =
  2371 + // await Utils.goShareInvicationToWeChat(
  2372 + // context,
  2373 + // _model.row.id,
  2374 + // Provider.of<UserModel>(context,
  2375 + // listen: false)
  2376 + // .user
  2377 + // .openid);
  2378 + // print(isSuccess);
  2379 + // if (isSuccess) {
  2380 + // _addForward(_model.row.id);
  2381 + // }
  2382 + // }
  2383 + // } else {
  2384 + NavigatorUtil.goInvicationPage(context, _model.row.id);
  2385 + // bool isSuccess =
  2386 + // await Utils.goShareInvicationToWeChat(
  2387 + // context,
  2388 + // _model.row.id,
  2389 + // Provider.of<UserModel>(context,
  2390 + // listen: false)
  2391 + // .user
  2392 + // .openid);
  2393 + // if (isSuccess) {
  2394 + // _addForward(_model.row.id);
  2395 + // }
  2396 + // }
  2397 + } else {
  2398 + //失败
  2399 + if (isShow) {
  2400 + Utils.showToast("预订失败!");
  2401 + }
  2402 + }
  2403 + }
  2404 +
2400 ///清空数据 2405 ///清空数据
2401 _clearData() { 2406 _clearData() {
2402 nameStr = ''; 2407 nameStr = '';
@@ -2643,298 +2648,7 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -2643,298 +2648,7 @@ class TableManagerPageState extends State<TableManagerPage> {
2643 radius: ScreenUtil().setWidth(8), 2648 radius: ScreenUtil().setWidth(8),
2644 isBold: false, 2649 isBold: false,
2645 onPressed: () async { 2650 onPressed: () async {
2646 - if (!noticeSms) {  
2647 - if (myModel.smsInfo == '0') {  
2648 - setState(() {  
2649 - showErro = smsErro;  
2650 - });  
2651 - return;  
2652 - }  
2653 - }  
2654 -  
2655 - if ((_baseIndoProvider.phoneController.text  
2656 - .replaceAll(' ', '')  
2657 - .isEmpty ||  
2658 - !Utils.isInteger(_baseIndoProvider  
2659 - .phoneController.text  
2660 - .replaceAll(' ', '')))) {  
2661 - setState(() {  
2662 - showErro = '请输入正确的11位手机号码';  
2663 - });  
2664 - return;  
2665 - } else {  
2666 - setState(() {  
2667 - showErro = '';  
2668 - });  
2669 - }  
2670 -  
2671 - // if (!couponProvider.sendSMS) {  
2672 - /*  
2673 - String dateSoltStr = '';  
2674 - if (widget.dateSolt == '1') {  
2675 - dateSoltStr = '早餐';  
2676 - } else if (widget.dateSolt == '2') {  
2677 - dateSoltStr = '午餐';  
2678 - } else if (widget.dateSolt == '3') {  
2679 - dateSoltStr = '晚餐';  
2680 - }  
2681 - DateTime dateTimeTemp =  
2682 - DateTime.fromMillisecondsSinceEpoch(  
2683 - int.parse(widget.ddate) * 1000);  
2684 - String dateTimeStrTemp =  
2685 - "${Utils.addZeroNumber(dateTimeTemp.month)}月${Utils.addZeroNumber(dateTimeTemp.day)}日";  
2686 - Map<String, String> params = {  
2687 - "id": widget.rid,  
2688 - "uid": Provider.of<UserModel>(context,  
2689 - listen: false)  
2690 - .user  
2691 - .openid,  
2692 - "phone": widget.phone,  
2693 -  
2694 - // "Strtext": user.sellername +  
2695 - // dateTimeStrTemp +  
2696 - // dateSoltStr +  
2697 - // ',' +  
2698 - // '餐厅经理' +  
2699 - // _baseIndoProvider.baseInfoSunModel.name +  
2700 - // '已为您安排在' +  
2701 - // widget.tableInfo.replaceAll("\n", "")  
2702 - };  
2703 - if (ObjectUtil.isNotEmpty(_baseIndoProvider  
2704 - .baseInfoSunModel) &&  
2705 - ObjectUtil.isNotEmpty(_baseIndoProvider  
2706 - .baseInfoSunModel.name)) {  
2707 - params['Strtext'] = user.sellername +  
2708 - _baseIndoProvider  
2709 - .baseInfoSunModel.name;  
2710 - } else {  
2711 - params['Strtext'] = user.sellername;  
2712 - }  
2713 - */  
2714 - Guest guest = Guest(  
2715 - null,  
2716 - null,  
2717 - null,  
2718 - null,  
2719 - null,  
2720 - null,  
2721 - null,  
2722 - null,  
2723 - null,  
2724 - null,  
2725 - null,  
2726 - null,  
2727 - null,  
2728 - null,  
2729 - null,  
2730 - null,  
2731 - null,  
2732 - null);  
2733 - // if (widget.guest == null) {  
2734 -  
2735 - guest.phone = _baseIndoProvider  
2736 - .phoneController.text  
2737 - .replaceAll(' ', ''); //预订人电话  
2738 -  
2739 - if (nameStr != null &&  
2740 - nameStr.trim().length > 0) {  
2741 - String sex = '1';  
2742 - if (sexStr == '女士') {  
2743 - sex = '2';  
2744 - } else if (sexStr == '公司') {  
2745 - sex = '3';  
2746 - }  
2747 - guest.rname = nameStr; //预订人姓名  
2748 - guest.sex = sex; //预订人性别:1:男 2:女  
2749 -  
2750 - }  
2751 - // }  
2752 - String pnum;  
2753 - if (pnumController.text != '') {  
2754 - pnum = pnumController.text;  
2755 - }  
2756 - String cusdem;  
2757 - if (customController.text.trim().length > 0) {  
2758 - cusdem = customController.text;  
2759 - }  
2760 - bool isShow = true; //是否需要弹窗 “预订失败!”  
2761 - SunReserveInfoModel _model =  
2762 - await tableManagerModel  
2763 - .setReserveInfo(context, (v) {  
2764 - if (v) {  
2765 - isShow = true;  
2766 - } else {  
2767 - isShow = false;  
2768 - }  
2769 - },  
2770 - needKeep: true,  
2771 - pnum: pnum,  
2772 - cusdem: cusdem,  
2773 - tempTime:  
2774 - ddateHm == '选填' ? null : ddateHm,  
2775 - guest: guest);  
2776 - if (_model != null &&  
2777 - ObjectUtil.isNotEmpty(_model.row) &&  
2778 - ObjectUtil.isNotEmpty(_model.row.id)) {  
2779 - print('成功');  
2780 - // tableManagerModel.selectTables = [];  
2781 - // wechatNotification = true;  
2782 - _clearData();  
2783 -  
2784 - // _homeEnterModel.clearData();  
2785 - bus.emit("refresh_tablemanager"); //刷新当前页面  
2786 - bus.emit("refresh_book_list"); //刷新已预订列表  
2787 - if (youhui != '选择优惠') {  
2788 - Map<String, String> params = {  
2789 - "rid": _model.row.id,  
2790 - "aid":  
2791 - '${couponProvider.couponListSelect[couponSelectIndex].id}'  
2792 - };  
2793 - bool isSuc = await couponProvider  
2794 - .setActivityAsReserve(context, params);  
2795 - if (isSuc) {  
2796 - couponProvider.hasModify = true;  
2797 - //发短信操作  
2798 - if (noticeSms) {  
2799 - //使用手机发短信  
2800 - _getSmsContent(  
2801 - _model.row.id, guest.phone);  
2802 - } else {  
2803 - UserModel userModel =  
2804 - Provider.of<UserModel>(context,  
2805 - listen: false);  
2806 - Map<String, String> params = {  
2807 - "rid": _model.row.id,  
2808 - "sid": userModel.user.sellerid  
2809 - };  
2810 - bool success = await couponProvider  
2811 - .sendSMSWxSendSms(context, params);  
2812 - print(success);  
2813 - }  
2814 - }  
2815 - } else {  
2816 - //发短信操作  
2817 - if (noticeSms) {  
2818 - //使用手机发短信  
2819 - _getSmsContent(_model.row.id, guest.phone);  
2820 - } else {  
2821 - UserModel userModel =  
2822 - Provider.of<UserModel>(context,  
2823 - listen: false);  
2824 - Map<String, String> params = {  
2825 - "rid": _model.row.id,  
2826 - "sid": userModel.user.sellerid  
2827 - };  
2828 - bool success = await couponProvider  
2829 - .sendSMSWxSendSms(context, params);  
2830 - print(success);  
2831 - }  
2832 - }  
2833 -  
2834 - // if (success) {  
2835 - // Utils.showToast('短信已经发送成功!');  
2836 - // } else {  
2837 - // Utils.showToast('发送次数太频繁!');  
2838 - // }  
2839 - // } else {  
2840 - // Utils.showToast('短信已经发送成功!');  
2841 - // }  
2842 - // //进入订座详情页面  
2843 - // NavigatorUtil.goNotebookDetailPage(  
2844 - // context,  
2845 - // _model.row.id,  
2846 - // Provider.of<UserModel>(context, listen: false)  
2847 - // .user  
2848 - // .openid,  
2849 - // );  
2850 - // String ddate_solt = '';  
2851 - // if (_model.row.isSetDdate == '1') {  
2852 - // String createtime = _model.row.ddate.toString() + '000';  
2853 - // DateTime createTime =  
2854 - // DateTime.fromMillisecondsSinceEpoch(  
2855 - // int.parse(createtime));  
2856 - // ddate_solt = DateUtil.formatDate(createTime,  
2857 - // format: DateFormats.h_m);  
2858 - // } else {  
2859 - // if (_model.row.ddateSolt == '1') {  
2860 - // ddate_solt = '早餐';  
2861 - // } else if (_model.row.ddateSolt == '2') {  
2862 - // ddate_solt = '午餐';  
2863 - // } else if (_model.row.ddateSolt == '3') {  
2864 - // ddate_solt = '晚餐';  
2865 - // }  
2866 - // }  
2867 - // List<dynamic> tableinfo =  
2868 - // convert.jsonDecode(_model.row.tableinfo);  
2869 - // print(tableinfo);  
2870 -  
2871 - // // String _nameStr =  
2872 - // // table.TableList.fromJson(tableinfo[0]).name;  
2873 - // // if (tableinfo.length > 1) {  
2874 - // // _nameStr = table.TableList.fromJson(tableinfo[0]).name +  
2875 - // // '等${tableinfo.length}桌';  
2876 - // // }  
2877 - // // LogUtil.v(_nameStr);  
2878 - // // String _tid = '';  
2879 - // // for (int i = 0; i < tableinfo.length; i++) {  
2880 - // // _tid += '${table.TableList.fromJson(tableinfo[i]).id},';  
2881 - // // }  
2882 - // // if (_tid.endsWith(',')) {  
2883 - // // _tid = _tid.substring(0, _tid.length - 1);  
2884 - // // }  
2885 - // String _nameStr = '';  
2886 - // String _tid = '';  
2887 - // for (int i = 0; i < tableinfo.length; i++) {  
2888 - // _nameStr +=  
2889 - // '${table.TableList.fromJson(tableinfo[i]).name},';  
2890 -  
2891 - // _tid += '${table.TableList.fromJson(tableinfo[i]).id},';  
2892 - // }  
2893 - // if (_tid.endsWith(',')) {  
2894 - // _tid = _tid.substring(0, _tid.length - 1);  
2895 - // }  
2896 - // if (_nameStr.endsWith(',')) {  
2897 - // _nameStr = _nameStr.substring(0, _nameStr.length - 1);  
2898 - // }  
2899 - // NavigatorUtil.goInvicationPage(  
2900 - // context,  
2901 - // _model.row.id,  
2902 - // _nameStr,  
2903 - // _model.row.ddate,  
2904 - // ddate_solt,  
2905 - // _model.row.phone,  
2906 - // _model.row.ddateSolt,  
2907 - // _model.row.rname == null ? '' : _model.row.rname,  
2908 - // _model.row.sex == null ? '' : _model.row.sex,  
2909 - // tid: _tid,  
2910 - // replace: false);  
2911 - // // //今天 明天 其他天  
2912 - // // String tempTime = _homeEnterModel.ddateStr;  
2913 - // // if (_homeEnterModel.ddateStr == '') {  
2914 - // // if (currTimeIndex == 1) {  
2915 - // // tempTime = '08:00';  
2916 - // // } else if (currTimeIndex == 2) {  
2917 - // // tempTime = '12:00';  
2918 - // // } else if (currTimeIndex == 3) {  
2919 - // // tempTime = '18:00';  
2920 - // // }  
2921 - // // }  
2922 - // // print(_model.row.tableinfo);  
2923 - // // _clearData();  
2924 - // // String timeStr = dateText + ' ' + tempTime + ':00';  
2925 -  
2926 - // // LogUtil.v(timeStr);  
2927 - // // int ddate = DateUtil.getDateMsByTimeStr(timeStr);  
2928 -  
2929 - // // _homeEnterModel.getNewTableList(context, '${ddate}',  
2930 - // // currTimeIndex.toString(), pnum);  
2931 -  
2932 - // // EventBus().emit("refresh_tablemanager"); //刷新桌位  
2933 - } else {  
2934 - if (isShow) {  
2935 - Utils.showToast("预订失败!");  
2936 - }  
2937 - } 2651 + JhCommonUtils.debounce(() => _smsReserve(), 500);
2938 }, 2652 },
2939 )), 2653 )),
2940 HEmptyView(36), 2654 HEmptyView(36),
@@ -3304,6 +3018,270 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -3304,6 +3018,270 @@ class TableManagerPageState extends State<TableManagerPage> {
3304 ))); 3018 )));
3305 } 3019 }
3306 3020
  3021 + _smsReserve() async {
  3022 + if (!noticeSms) {
  3023 + if (myModel.smsInfo == '0') {
  3024 + setState(() {
  3025 + showErro = smsErro;
  3026 + });
  3027 + return;
  3028 + }
  3029 + }
  3030 +
  3031 + if ((_baseIndoProvider.phoneController.text.replaceAll(' ', '').isEmpty ||
  3032 + !Utils.isInteger(
  3033 + _baseIndoProvider.phoneController.text.replaceAll(' ', '')))) {
  3034 + setState(() {
  3035 + showErro = '请输入正确的11位手机号码';
  3036 + });
  3037 + return;
  3038 + } else {
  3039 + setState(() {
  3040 + showErro = '';
  3041 + });
  3042 + }
  3043 +
  3044 + // if (!couponProvider.sendSMS) {
  3045 + /*
  3046 + String dateSoltStr = '';
  3047 + if (widget.dateSolt == '1') {
  3048 + dateSoltStr = '早餐';
  3049 + } else if (widget.dateSolt == '2') {
  3050 + dateSoltStr = '午餐';
  3051 + } else if (widget.dateSolt == '3') {
  3052 + dateSoltStr = '晚餐';
  3053 + }
  3054 + DateTime dateTimeTemp =
  3055 + DateTime.fromMillisecondsSinceEpoch(
  3056 + int.parse(widget.ddate) * 1000);
  3057 + String dateTimeStrTemp =
  3058 + "${Utils.addZeroNumber(dateTimeTemp.month)}月${Utils.addZeroNumber(dateTimeTemp.day)}日";
  3059 + Map<String, String> params = {
  3060 + "id": widget.rid,
  3061 + "uid": Provider.of<UserModel>(context,
  3062 + listen: false)
  3063 + .user
  3064 + .openid,
  3065 + "phone": widget.phone,
  3066 +
  3067 + // "Strtext": user.sellername +
  3068 + // dateTimeStrTemp +
  3069 + // dateSoltStr +
  3070 + // ',' +
  3071 + // '餐厅经理' +
  3072 + // _baseIndoProvider.baseInfoSunModel.name +
  3073 + // '已为您安排在' +
  3074 + // widget.tableInfo.replaceAll("\n", "")
  3075 + };
  3076 + if (ObjectUtil.isNotEmpty(_baseIndoProvider
  3077 + .baseInfoSunModel) &&
  3078 + ObjectUtil.isNotEmpty(_baseIndoProvider
  3079 + .baseInfoSunModel.name)) {
  3080 + params['Strtext'] = user.sellername +
  3081 + _baseIndoProvider
  3082 + .baseInfoSunModel.name;
  3083 + } else {
  3084 + params['Strtext'] = user.sellername;
  3085 + }
  3086 + */
  3087 + Guest guest = Guest(null, null, null, null, null, null, null, null, null,
  3088 + null, null, null, null, null, null, null, null, null);
  3089 + // if (widget.guest == null) {
  3090 +
  3091 + guest.phone =
  3092 + _baseIndoProvider.phoneController.text.replaceAll(' ', ''); //预订人电话
  3093 +
  3094 + if (nameStr != null && nameStr.trim().length > 0) {
  3095 + String sex = '1';
  3096 + if (sexStr == '女士') {
  3097 + sex = '2';
  3098 + } else if (sexStr == '公司') {
  3099 + sex = '3';
  3100 + }
  3101 + guest.rname = nameStr; //预订人姓名
  3102 + guest.sex = sex; //预订人性别:1:男 2:女
  3103 +
  3104 + }
  3105 + // }
  3106 + String pnum;
  3107 + if (pnumController.text != '') {
  3108 + pnum = pnumController.text;
  3109 + }
  3110 + String cusdem;
  3111 + if (customController.text.trim().length > 0) {
  3112 + cusdem = customController.text;
  3113 + }
  3114 + bool isShow = true; //是否需要弹窗 “预订失败!”
  3115 + SunReserveInfoModel _model = await tableManagerModel.setReserveInfo(context,
  3116 + (v) {
  3117 + if (v) {
  3118 + isShow = true;
  3119 + } else {
  3120 + isShow = false;
  3121 + }
  3122 + },
  3123 + needKeep: true,
  3124 + pnum: pnum,
  3125 + cusdem: cusdem,
  3126 + tempTime: ddateHm == '选填' ? null : ddateHm,
  3127 + guest: guest);
  3128 + if (_model != null &&
  3129 + ObjectUtil.isNotEmpty(_model.row) &&
  3130 + ObjectUtil.isNotEmpty(_model.row.id)) {
  3131 + print('成功');
  3132 + // tableManagerModel.selectTables = [];
  3133 + // wechatNotification = true;
  3134 + _clearData();
  3135 +
  3136 + // _homeEnterModel.clearData();
  3137 + bus.emit("refresh_tablemanager"); //刷新当前页面
  3138 + bus.emit("refresh_book_list"); //刷新已预订列表
  3139 + if (youhui != '选择优惠') {
  3140 + Map<String, String> params = {
  3141 + "rid": _model.row.id,
  3142 + "aid": '${couponProvider.couponListSelect[couponSelectIndex].id}'
  3143 + };
  3144 + bool isSuc = await couponProvider.setActivityAsReserve(context, params);
  3145 + if (isSuc) {
  3146 + couponProvider.hasModify = true;
  3147 + //发短信操作
  3148 + if (noticeSms) {
  3149 + //使用手机发短信
  3150 + _getSmsContent(_model.row.id, guest.phone);
  3151 + } else {
  3152 + UserModel userModel =
  3153 + Provider.of<UserModel>(context, listen: false);
  3154 + Map<String, String> params = {
  3155 + "rid": _model.row.id,
  3156 + "sid": userModel.user.sellerid
  3157 + };
  3158 + bool success =
  3159 + await couponProvider.sendSMSWxSendSms(context, params);
  3160 + print(success);
  3161 + }
  3162 + }
  3163 + } else {
  3164 + //发短信操作
  3165 + if (noticeSms) {
  3166 + //使用手机发短信
  3167 + _getSmsContent(_model.row.id, guest.phone);
  3168 + } else {
  3169 + UserModel userModel = Provider.of<UserModel>(context, listen: false);
  3170 + Map<String, String> params = {
  3171 + "rid": _model.row.id,
  3172 + "sid": userModel.user.sellerid
  3173 + };
  3174 + bool success = await couponProvider.sendSMSWxSendSms(context, params);
  3175 + print(success);
  3176 + }
  3177 + }
  3178 +
  3179 + // if (success) {
  3180 + // Utils.showToast('短信已经发送成功!');
  3181 + // } else {
  3182 + // Utils.showToast('发送次数太频繁!');
  3183 + // }
  3184 + // } else {
  3185 + // Utils.showToast('短信已经发送成功!');
  3186 + // }
  3187 + // //进入订座详情页面
  3188 + // NavigatorUtil.goNotebookDetailPage(
  3189 + // context,
  3190 + // _model.row.id,
  3191 + // Provider.of<UserModel>(context, listen: false)
  3192 + // .user
  3193 + // .openid,
  3194 + // );
  3195 + // String ddate_solt = '';
  3196 + // if (_model.row.isSetDdate == '1') {
  3197 + // String createtime = _model.row.ddate.toString() + '000';
  3198 + // DateTime createTime =
  3199 + // DateTime.fromMillisecondsSinceEpoch(
  3200 + // int.parse(createtime));
  3201 + // ddate_solt = DateUtil.formatDate(createTime,
  3202 + // format: DateFormats.h_m);
  3203 + // } else {
  3204 + // if (_model.row.ddateSolt == '1') {
  3205 + // ddate_solt = '早餐';
  3206 + // } else if (_model.row.ddateSolt == '2') {
  3207 + // ddate_solt = '午餐';
  3208 + // } else if (_model.row.ddateSolt == '3') {
  3209 + // ddate_solt = '晚餐';
  3210 + // }
  3211 + // }
  3212 + // List<dynamic> tableinfo =
  3213 + // convert.jsonDecode(_model.row.tableinfo);
  3214 + // print(tableinfo);
  3215 +
  3216 + // // String _nameStr =
  3217 + // // table.TableList.fromJson(tableinfo[0]).name;
  3218 + // // if (tableinfo.length > 1) {
  3219 + // // _nameStr = table.TableList.fromJson(tableinfo[0]).name +
  3220 + // // '等${tableinfo.length}桌';
  3221 + // // }
  3222 + // // LogUtil.v(_nameStr);
  3223 + // // String _tid = '';
  3224 + // // for (int i = 0; i < tableinfo.length; i++) {
  3225 + // // _tid += '${table.TableList.fromJson(tableinfo[i]).id},';
  3226 + // // }
  3227 + // // if (_tid.endsWith(',')) {
  3228 + // // _tid = _tid.substring(0, _tid.length - 1);
  3229 + // // }
  3230 + // String _nameStr = '';
  3231 + // String _tid = '';
  3232 + // for (int i = 0; i < tableinfo.length; i++) {
  3233 + // _nameStr +=
  3234 + // '${table.TableList.fromJson(tableinfo[i]).name},';
  3235 +
  3236 + // _tid += '${table.TableList.fromJson(tableinfo[i]).id},';
  3237 + // }
  3238 + // if (_tid.endsWith(',')) {
  3239 + // _tid = _tid.substring(0, _tid.length - 1);
  3240 + // }
  3241 + // if (_nameStr.endsWith(',')) {
  3242 + // _nameStr = _nameStr.substring(0, _nameStr.length - 1);
  3243 + // }
  3244 + // NavigatorUtil.goInvicationPage(
  3245 + // context,
  3246 + // _model.row.id,
  3247 + // _nameStr,
  3248 + // _model.row.ddate,
  3249 + // ddate_solt,
  3250 + // _model.row.phone,
  3251 + // _model.row.ddateSolt,
  3252 + // _model.row.rname == null ? '' : _model.row.rname,
  3253 + // _model.row.sex == null ? '' : _model.row.sex,
  3254 + // tid: _tid,
  3255 + // replace: false);
  3256 + // // //今天 明天 其他天
  3257 + // // String tempTime = _homeEnterModel.ddateStr;
  3258 + // // if (_homeEnterModel.ddateStr == '') {
  3259 + // // if (currTimeIndex == 1) {
  3260 + // // tempTime = '08:00';
  3261 + // // } else if (currTimeIndex == 2) {
  3262 + // // tempTime = '12:00';
  3263 + // // } else if (currTimeIndex == 3) {
  3264 + // // tempTime = '18:00';
  3265 + // // }
  3266 + // // }
  3267 + // // print(_model.row.tableinfo);
  3268 + // // _clearData();
  3269 + // // String timeStr = dateText + ' ' + tempTime + ':00';
  3270 +
  3271 + // // LogUtil.v(timeStr);
  3272 + // // int ddate = DateUtil.getDateMsByTimeStr(timeStr);
  3273 +
  3274 + // // _homeEnterModel.getNewTableList(context, '${ddate}',
  3275 + // // currTimeIndex.toString(), pnum);
  3276 +
  3277 + // // EventBus().emit("refresh_tablemanager"); //刷新桌位
  3278 + } else {
  3279 + if (isShow) {
  3280 + Utils.showToast("预订失败!");
  3281 + }
  3282 + }
  3283 + }
  3284 +
3307 //构建常用备注 3285 //构建常用备注
3308 List<Widget> _buildAlwayItems() { 3286 List<Widget> _buildAlwayItems() {
3309 List<Widget> tables = []; 3287 List<Widget> tables = [];
  1 +import 'dart:async';
  2 +
  3 +class JhCommonUtils {
  4 + static Timer _debounceTimer;
  5 +
  6 + /// 防抖 (传入所要防抖的方法/回调与延迟时间)
  7 + static void debounce(Function func, [int delay = 500]) {
  8 + if (_debounceTimer != null) {
  9 + _debounceTimer?.cancel();
  10 + }
  11 + _debounceTimer = Timer(Duration(milliseconds: delay), () {
  12 + func.call();
  13 + _debounceTimer = null;
  14 + });
  15 + }
  16 +
  17 + /// 防抖 (传入所要防抖的方法/回调与延迟时间)
  18 + static debounce2(Function func, [int delay = 500]) {
  19 + Timer timer;
  20 + return () {
  21 + if (timer != null) {
  22 + timer?.cancel();
  23 + }
  24 + timer = Timer(Duration(milliseconds: delay), () {
  25 + func.call();
  26 + timer = null;
  27 + });
  28 + };
  29 + }
  30 +
  31 + /// 录入框防抖 (传入所要防抖的方法/回调与延迟时间)
  32 + static debounceInput(Function(dynamic) func, [int delay = 500]) {
  33 + Timer timer;
  34 + return (dynamic value) {
  35 + if (timer != null) {
  36 + timer?.cancel();
  37 + }
  38 + timer = Timer(Duration(milliseconds: delay), () {
  39 + func.call(value);
  40 + timer = null;
  41 + });
  42 + };
  43 + }
  44 +
  45 + static Timer _throttleTimer;
  46 + static bool _throttleFlag = true;
  47 +
  48 + /// 节流 (传入所要节流的方法/回调与延迟时间)
  49 + static void throttle(Function func, [int delay = 500]) {
  50 + if (_throttleFlag) {
  51 + func.call();
  52 + _throttleFlag = false;
  53 + return;
  54 + }
  55 + if (_throttleTimer != null) {
  56 + return;
  57 + }
  58 + _throttleTimer = Timer(Duration(milliseconds: delay), () {
  59 + func.call();
  60 + _throttleTimer = null;
  61 + });
  62 + }
  63 +
  64 + /// 节流 (传入所要节流的方法/回调与延迟时间)
  65 + static throttle2(Function func, [int delay = 500]) {
  66 + Timer timer;
  67 + bool firstTime = true;
  68 + return () {
  69 + if (firstTime) {
  70 + func.call();
  71 + firstTime = false;
  72 + return;
  73 + }
  74 + if (timer != null) {
  75 + return;
  76 + }
  77 + timer = Timer(Duration(milliseconds: delay), () {
  78 + func.call();
  79 + timer = null;
  80 + });
  81 + };
  82 + }
  83 +
  84 + /// 节流 (传入所要节流的方法/回调与延迟时间)
  85 + static throttle3(Function func, [int delay = 500]) {
  86 + Timer timer;
  87 + bool isExecuting = false;
  88 + return () {
  89 + if (isExecuting) return;
  90 + isExecuting = true;
  91 + timer?.cancel();
  92 + timer = Timer(Duration(milliseconds: delay), () {
  93 + func.call();
  94 + isExecuting = false;
  95 + });
  96 + };
  97 + }
  98 +}