Commit 98013eea0427d3b096e6f6d24e60d08ab0c41c95

Authored by wdn127929
1 parent f985f1ac

预订安排和桌位弹窗

  1 +import 'dart:async';
1 import 'dart:typed_data'; 2 import 'dart:typed_data';
2 import 'dart:ui'; 3 import 'dart:ui';
3 4
@@ -127,6 +128,14 @@ class InvicationPageState extends State<InvicationPage> @@ -127,6 +128,14 @@ class InvicationPageState extends State<InvicationPage>
127 TextEditingController customController = TextEditingController(); 128 TextEditingController customController = TextEditingController();
128 FocusNode _cusdemNode = FocusNode(); 129 FocusNode _cusdemNode = FocusNode();
129 String oldRemarkBtn = ''; 130 String oldRemarkBtn = '';
  131 + //定义变量
  132 + Timer _timer;
  133 + //倒计时数值
  134 + var countdownTime = 0;
  135 + String smsTitle = '发短信';
  136 + bool canSendSms = true;
  137 + bool showErroInfo = false;
  138 + String erroInfo = '';
130 139
131 @override 140 @override
132 void initState() { 141 void initState() {
@@ -186,7 +195,7 @@ class InvicationPageState extends State<InvicationPage> @@ -186,7 +195,7 @@ class InvicationPageState extends State<InvicationPage>
186 }); 195 });
187 196
188 WidgetsBinding.instance.addPostFrameCallback((_) async { 197 WidgetsBinding.instance.addPostFrameCallback((_) async {
189 - couponProvider.sendSMS = false; 198 + couponProvider.sendSMS = 0;
190 await _couponNetworkData(isShowLoading: false); 199 await _couponNetworkData(isShowLoading: false);
191 await _getCustomerActivityBaseinfo(); 200 await _getCustomerActivityBaseinfo();
192 201
@@ -220,6 +229,7 @@ class InvicationPageState extends State<InvicationPage> @@ -220,6 +229,7 @@ class InvicationPageState extends State<InvicationPage>
220 bus.off("refresh_invitaion_info"); 229 bus.off("refresh_invitaion_info");
221 bus.off("refresh_photo_invication"); 230 bus.off("refresh_photo_invication");
222 WidgetsBinding.instance.removeObserver(this); //销毁观察者 231 WidgetsBinding.instance.removeObserver(this); //销毁观察者
  232 + _timer.cancel();
223 233
224 super.dispose(); 234 super.dispose();
225 } 235 }
@@ -234,6 +244,27 @@ class InvicationPageState extends State<InvicationPage> @@ -234,6 +244,27 @@ class InvicationPageState extends State<InvicationPage>
234 } 244 }
235 } 245 }
236 246
  247 + ///倒计时方法
  248 + startCountdown() {
  249 + countdownTime = 60;
  250 + final call = (timer) {
  251 + // setState(() {
  252 + if (countdownTime < 1) {
  253 + canSendSms = true;
  254 + if (erroInfo == '1分钟内只能发送一条短信') {
  255 + setState(() {
  256 + showErroInfo = false;
  257 + });
  258 + }
  259 + _timer.cancel();
  260 + } else {
  261 + countdownTime -= 1;
  262 + }
  263 + // });
  264 + };
  265 + _timer = Timer.periodic(Duration(seconds: 1), call);
  266 + }
  267 +
237 _showConfirmWidget( 268 _showConfirmWidget(
238 {needBack = false, 269 {needBack = false,
239 needSex = false, 270 needSex = false,
@@ -1311,6 +1342,7 @@ class InvicationPageState extends State<InvicationPage> @@ -1311,6 +1342,7 @@ class InvicationPageState extends State<InvicationPage>
1311 _customerInfoWidget() { 1342 _customerInfoWidget() {
1312 return Container( 1343 return Container(
1313 child: Column( 1344 child: Column(
  1345 + crossAxisAlignment: CrossAxisAlignment.start,
1314 children: [ 1346 children: [
1315 // VEmptyView(30), 1347 // VEmptyView(30),
1316 // MyDivider(double.infinity, 1348 // MyDivider(double.infinity,
@@ -1592,6 +1624,7 @@ class InvicationPageState extends State<InvicationPage> @@ -1592,6 +1624,7 @@ class InvicationPageState extends State<InvicationPage>
1592 clipBehavior: Clip.none, 1624 clipBehavior: Clip.none,
1593 children: [ 1625 children: [
1594 Column( 1626 Column(
  1627 + crossAxisAlignment: CrossAxisAlignment.start,
1595 children: [ 1628 children: [
1596 //姓名 1629 //姓名
1597 enterMore 1630 enterMore
@@ -1811,7 +1844,45 @@ class InvicationPageState extends State<InvicationPage> @@ -1811,7 +1844,45 @@ class InvicationPageState extends State<InvicationPage>
1811 ], 1844 ],
1812 ), 1845 ),
1813 // 选择优惠 1846 // 选择优惠
1814 - _couponWidget() 1847 + _couponWidget(),
  1848 + showErroInfo
  1849 + ? Container(
  1850 + margin: EdgeInsets.only(
  1851 + top: ScreenUtil().setWidth(40),
  1852 + bottom: ScreenUtil().setWidth(24)),
  1853 + height: ScreenUtil().setWidth(46 * 2),
  1854 + padding: EdgeInsets.symmetric(
  1855 + horizontal: ScreenUtil().setWidth(34)),
  1856 + decoration: BoxDecoration(
  1857 + color: MyColours.color_ffffff,
  1858 + borderRadius:
  1859 + BorderRadius.circular(ScreenUtil().setWidth(8)),
  1860 + boxShadow: [
  1861 + BoxShadow(
  1862 + color: Color.fromRGBO(0, 0, 0, 0.2),
  1863 + blurRadius: ScreenUtil().setWidth(8),
  1864 + spreadRadius: ScreenUtil().setWidth(2),
  1865 + offset: Offset(0, ScreenUtil().setWidth(2)))
  1866 + ]),
  1867 + child: Row(
  1868 + mainAxisSize: MainAxisSize.min,
  1869 + children: [
  1870 + Image.asset(
  1871 + Utils.getImgPath(erroInfo == '1分钟内只能发送一条短信'
  1872 + ? 'error_circle_yellow'
  1873 + : 'error_circle_red'),
  1874 + width: ScreenUtil().setWidth(40)),
  1875 + HEmptyView(10),
  1876 + Text(erroInfo,
  1877 + style: TextStyle(
  1878 + color: erroInfo == '1分钟内只能发送一条短信'
  1879 + ? MyColours.color_ED7B2F
  1880 + : MyColours.color_E34D59,
  1881 + fontSize: ScreenUtil().setSp(28))),
  1882 + ],
  1883 + ),
  1884 + )
  1885 + : SizedBox()
1815 ], 1886 ],
1816 ), 1887 ),
1817 enterMore 1888 enterMore
@@ -3370,44 +3441,44 @@ class InvicationPageState extends State<InvicationPage> @@ -3370,44 +3441,44 @@ class InvicationPageState extends State<InvicationPage>
3370 child: Row( 3441 child: Row(
3371 children: [ 3442 children: [
3372 RoundButton( 3443 RoundButton(
3373 - text: '发短信',  
3374 - width: ScreenUtil().setWidth(65 * 2),  
3375 - height: ScreenUtil().setWidth(48 * 2),  
3376 - fontSize: 30,  
3377 - textColor: MyColours.color_999999,  
3378 - gradientStart: MyColours.color_f3f3f3,  
3379 - gradientEnd: MyColours.color_f3f3f3,  
3380 - radius: ScreenUtil().setWidth(16),  
3381 - isBold: false,  
3382 - onPressed: () async {  
3383 - if (_nameNode.hasFocus ||  
3384 - _phoneNode.hasFocus ||  
3385 - _cusdemNode.hasFocus) {  
3386 - needWechat = true;  
3387 - _showConfirmWidget(  
3388 - needWechat: true,  
3389 - callback: () async {  
3390 - if (reserverPhone == null || reserverPhone.isEmpty) {  
3391 - //跳转到录入联系人页面  
3392 - // String temp = await NavigatorUtil.goEditReserverPage(  
3393 - // context, widget.rid, name, sex,  
3394 - // needBtn: true);  
3395 - // if (temp != null) {  
3396 - // reserverPhone = temp;  
3397 - // }  
3398 - Utils.showToast('请输入客户手机号');  
3399 - } else if (!Utils.phoneRegExp(reserverPhone)) {  
3400 - Utils.showToast('手机号格式错误,请修改正确');  
3401 - //跳转到录入联系人页面  
3402 - // String temp = await NavigatorUtil.goEditReserverPage(  
3403 - // context, widget.rid, name, sex,  
3404 - // needBtn: true);  
3405 - // if (temp != null) {  
3406 - // reserverPhone = temp;  
3407 - // }  
3408 - } else {  
3409 - if (!couponProvider.sendSMS) {  
3410 - /* 3444 + text: smsTitle,
  3445 + width: ScreenUtil().setWidth(65 * 2),
  3446 + height: ScreenUtil().setWidth(48 * 2),
  3447 + fontSize: 30,
  3448 + textColor: MyColours.color_999999,
  3449 + gradientStart: MyColours.color_f3f3f3,
  3450 + gradientEnd: MyColours.color_f3f3f3,
  3451 + radius: ScreenUtil().setWidth(16),
  3452 + isBold: false,
  3453 + onPressed: () async {
  3454 + if (_nameNode.hasFocus ||
  3455 + _phoneNode.hasFocus ||
  3456 + _cusdemNode.hasFocus) {
  3457 + needWechat = true;
  3458 + _showConfirmWidget(
  3459 + needWechat: true,
  3460 + callback: () async {
  3461 + if (canSendSms) {
  3462 + if (reserverPhone == null ||
  3463 + reserverPhone.isEmpty ||
  3464 + !Utils.phoneRegExp(reserverPhone)) {
  3465 + //跳转到录入联系人页面
  3466 + // String temp = await NavigatorUtil.goEditReserverPage(
  3467 + // context, widget.rid, name, sex,
  3468 + // needBtn: true);
  3469 + // if (temp != null) {
  3470 + // reserverPhone = temp;
  3471 + // }
  3472 + // Utils.showToast('请输入客户手机号');
  3473 + //显示请输入11位手机号码
  3474 + setState(() {
  3475 + showErroInfo = true;
  3476 + erroInfo = '请正确输入11位手机号码';
  3477 + });
  3478 +
  3479 + return;
  3480 + } else {
  3481 + /*
3411 String dateSoltStr = ''; 3482 String dateSoltStr = '';
3412 if (widget.dateSolt == '1') { 3483 if (widget.dateSolt == '1') {
3413 dateSoltStr = '早餐'; 3484 dateSoltStr = '早餐';
@@ -3449,110 +3520,87 @@ class InvicationPageState extends State<InvicationPage> @@ -3449,110 +3520,87 @@ class InvicationPageState extends State<InvicationPage>
3449 params['Strtext'] = user.sellername; 3520 params['Strtext'] = user.sellername;
3450 } 3521 }
3451 */ 3522 */
3452 - UserModel userModel =  
3453 - Provider.of<UserModel>(context, listen: false);  
3454 - Map<String, String> params = {  
3455 - "rid": widget.rid,  
3456 - "sid": userModel.user.sellerid  
3457 - };  
3458 - bool success = await couponProvider  
3459 - .sendSMSWxSendSms(context, params);  
3460 - print(success);  
3461 - // if (success) {  
3462 - // Utils.showToast('短信已经发送成功!');  
3463 - // } else {  
3464 - // Utils.showToast('发送次数太频繁!');  
3465 - // }  
3466 - } else {  
3467 - Utils.showToast('短信已经发送成功!');  
3468 - }  
3469 - }  
3470 - });  
3471 - removeOverlay();  
3472 - } else {  
3473 - if (reserverPhone == null || reserverPhone.isEmpty) {  
3474 - //跳转到录入联系人页面  
3475 - // String temp = await NavigatorUtil.goEditReserverPage(  
3476 - // context, widget.rid, name, sex,  
3477 - // needBtn: true);  
3478 - // if (temp != null) {  
3479 - // reserverPhone = temp;  
3480 - // }  
3481 - Utils.showToast('请输入客户手机号');  
3482 - } else if (!Utils.phoneRegExp(reserverPhone)) {  
3483 - Utils.showToast('手机号格式错误,请修改正确');  
3484 - //跳转到录入联系人页面  
3485 - // String temp = await NavigatorUtil.goEditReserverPage(  
3486 - // context, widget.rid, name, sex,  
3487 - // needBtn: true);  
3488 - // if (temp != null) {  
3489 - // reserverPhone = temp;  
3490 - // }  
3491 - } else {  
3492 - if (!couponProvider.sendSMS) {  
3493 - /*  
3494 - String dateSoltStr = '';  
3495 - if (widget.dateSolt == '1') {  
3496 - dateSoltStr = '早餐';  
3497 - } else if (widget.dateSolt == '2') {  
3498 - dateSoltStr = '午餐';  
3499 - } else if (widget.dateSolt == '3') {  
3500 - dateSoltStr = '晚餐';  
3501 - }  
3502 - DateTime dateTimeTemp =  
3503 - DateTime.fromMillisecondsSinceEpoch(  
3504 - int.parse(widget.ddate) * 1000);  
3505 - String dateTimeStrTemp =  
3506 - "${Utils.addZeroNumber(dateTimeTemp.month)}月${Utils.addZeroNumber(dateTimeTemp.day)}日"; 3523 + setState(() {
  3524 + showErroInfo = false;
  3525 + erroInfo = '';
  3526 + });
  3527 + UserModel userModel = Provider.of<UserModel>(
  3528 + context,
  3529 + listen: false);
3507 Map<String, String> params = { 3530 Map<String, String> params = {
3508 - "id": widget.rid,  
3509 - "uid": Provider.of<UserModel>(context,  
3510 - listen: false)  
3511 - .user  
3512 - .openid,  
3513 - "phone": widget.phone,  
3514 -  
3515 - // "Strtext": user.sellername +  
3516 - // dateTimeStrTemp +  
3517 - // dateSoltStr +  
3518 - // ',' +  
3519 - // '餐厅经理' +  
3520 - // _baseIndoProvider.baseInfoSunModel.name +  
3521 - // '已为您安排在' +  
3522 - // widget.tableInfo.replaceAll("\n", "") 3531 + "rid": widget.rid,
  3532 + "sid": userModel.user.sellerid
3523 }; 3533 };
3524 - if (ObjectUtil.isNotEmpty(_baseIndoProvider  
3525 - .baseInfoSunModel) &&  
3526 - ObjectUtil.isNotEmpty(_baseIndoProvider  
3527 - .baseInfoSunModel.name)) {  
3528 - params['Strtext'] = user.sellername +  
3529 - _baseIndoProvider  
3530 - .baseInfoSunModel.name;  
3531 - } else {  
3532 - params['Strtext'] = user.sellername; 3534 + bool success = await couponProvider
  3535 + .sendSMSWxSendSms(context, params);
  3536 + print(success);
  3537 + if (success) {
  3538 + setState(() {
  3539 + smsTitle = '已发${couponProvider.sendSMS}次';
  3540 + });
  3541 + canSendSms = false;
  3542 + startCountdown();
3533 } 3543 }
3534 - */  
3535 - UserModel userModel =  
3536 - Provider.of<UserModel>(context, listen: false);  
3537 - Map<String, String> params = {  
3538 - "rid": widget.rid,  
3539 - "sid": userModel.user.sellerid  
3540 - };  
3541 - bool success = await couponProvider.sendSMSWxSendSms(  
3542 - context, params);  
3543 - print(success);  
3544 - // if (success) {  
3545 - // Utils.showToast('短信已经发送成功!');  
3546 - // } else {  
3547 - // Utils.showToast('发送次数太频繁!');  
3548 - // } 3544 + // if (success) {
  3545 + // Utils.showToast('短信已经发送成功!');
  3546 + // } else {
  3547 + // Utils.showToast('发送次数太频繁!');
  3548 + // }
  3549 +
  3550 + }
  3551 + } else {
  3552 + //显示1分钟只能发1次短信
  3553 + setState(() {
  3554 + showErroInfo = true;
  3555 + erroInfo = '1分钟内只能发送一条短信';
  3556 + });
  3557 + return;
  3558 + }
  3559 + });
  3560 + removeOverlay();
  3561 + } else {
  3562 + if (canSendSms) {
  3563 + if (reserverPhone == null ||
  3564 + reserverPhone.isEmpty ||
  3565 + !Utils.phoneRegExp(reserverPhone)) {
  3566 + //显示请输入11位手机号码
  3567 + setState(() {
  3568 + showErroInfo = true;
  3569 + erroInfo = '请正确输入11位手机号码';
  3570 + });
  3571 + return;
  3572 + } else {
  3573 + setState(() {
  3574 + showErroInfo = false;
  3575 + erroInfo = '';
  3576 + });
  3577 + UserModel userModel =
  3578 + Provider.of<UserModel>(context, listen: false);
  3579 + Map<String, String> params = {
  3580 + "rid": widget.rid,
  3581 + "sid": userModel.user.sellerid
  3582 + };
  3583 + bool success = await couponProvider.sendSMSWxSendSms(
  3584 + context, params);
  3585 + print(success);
  3586 + if (success) {
  3587 + setState(() {
  3588 + smsTitle = '已发${couponProvider.sendSMS}次';
  3589 + });
  3590 + canSendSms = false;
  3591 + startCountdown();
  3592 + }
  3593 + }
3549 } else { 3594 } else {
3550 - Utils.showToast('短信已经发送成功!'); 3595 + //显示1分钟只能发1次短信
  3596 + setState(() {
  3597 + showErroInfo = true;
  3598 + erroInfo = '1分钟内只能发送一条短信';
  3599 + });
  3600 + return;
3551 } 3601 }
3552 } 3602 }
3553 - }  
3554 - },  
3555 - ), 3603 + }),
3556 HEmptyView(40), 3604 HEmptyView(40),
3557 Expanded( 3605 Expanded(
3558 child: Stack(children: [ 3606 child: Stack(children: [
@@ -108,7 +108,7 @@ class TableManagerPageState extends State<TableManagerPage> { @@ -108,7 +108,7 @@ class TableManagerPageState extends State<TableManagerPage> {
108 // personNumList.add('30以上'); 108 // personNumList.add('30以上');
109 109
110 WidgetsBinding.instance.addPostFrameCallback((_) { 110 WidgetsBinding.instance.addPostFrameCallback((_) {
111 - couponProvider.sendSMS = false; 111 + // couponProvider.sendSMS = false;
112 tableManagerModel.initTime(context); 112 tableManagerModel.initTime(context);
113 _couponNetworkData(); 113 _couponNetworkData();
114 _getSmsInfo(context); 114 _getSmsInfo(context);
@@ -20,7 +20,7 @@ class CouponProvider with ChangeNotifier { @@ -20,7 +20,7 @@ class CouponProvider with ChangeNotifier {
20 PageState pageStateHistory = PageState.Loading; 20 PageState pageStateHistory = PageState.Loading;
21 PageState pageStateSelect = PageState.Loading; 21 PageState pageStateSelect = PageState.Loading;
22 bool hasModify = false; 22 bool hasModify = false;
23 - bool sendSMS = false; 23 + int sendSMS = 0;
24 24
25 bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true 25 bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true
26 // List<Map<String, dynamic>> listData = []; //优惠券页面数据 26 // List<Map<String, dynamic>> listData = []; //优惠券页面数据
@@ -197,7 +197,7 @@ class CouponProvider with ChangeNotifier { @@ -197,7 +197,7 @@ class CouponProvider with ChangeNotifier {
197 if (baseResp.code == Constant.status_success) { 197 if (baseResp.code == Constant.status_success) {
198 if (baseResp.data.isEmpty) { 198 if (baseResp.data.isEmpty) {
199 // if (isShowLoading) { 199 // if (isShowLoading) {
200 - state = PageState.Empty; 200 + state = PageState.Empty;
201 // } 201 // }
202 } else { 202 } else {
203 // if (isShowLoading) { 203 // if (isShowLoading) {
@@ -510,7 +510,7 @@ class CouponProvider with ChangeNotifier { @@ -510,7 +510,7 @@ class CouponProvider with ChangeNotifier {
510 }); 510 });
511 if (baseResp.code == Constant.status_success) { 511 if (baseResp.code == Constant.status_success) {
512 Utils.showToast("短信发送成功"); 512 Utils.showToast("短信发送成功");
513 - sendSMS = true; 513 + sendSMS++;
514 return true; 514 return true;
515 } else { 515 } else {
516 Utils.showToast(baseResp.msg ?? ""); 516 Utils.showToast(baseResp.msg ?? "");