Commit 98013eea0427d3b096e6f6d24e60d08ab0c41c95

Authored by wdn127929
1 parent f985f1ac

预订安排和桌位弹窗

import 'dart:async';
import 'dart:typed_data';
import 'dart:ui';
... ... @@ -127,6 +128,14 @@ class InvicationPageState extends State<InvicationPage>
TextEditingController customController = TextEditingController();
FocusNode _cusdemNode = FocusNode();
String oldRemarkBtn = '';
//定义变量
Timer _timer;
//倒计时数值
var countdownTime = 0;
String smsTitle = '发短信';
bool canSendSms = true;
bool showErroInfo = false;
String erroInfo = '';
@override
void initState() {
... ... @@ -186,7 +195,7 @@ class InvicationPageState extends State<InvicationPage>
});
WidgetsBinding.instance.addPostFrameCallback((_) async {
couponProvider.sendSMS = false;
couponProvider.sendSMS = 0;
await _couponNetworkData(isShowLoading: false);
await _getCustomerActivityBaseinfo();
... ... @@ -220,6 +229,7 @@ class InvicationPageState extends State<InvicationPage>
bus.off("refresh_invitaion_info");
bus.off("refresh_photo_invication");
WidgetsBinding.instance.removeObserver(this); //销毁观察者
_timer.cancel();
super.dispose();
}
... ... @@ -234,6 +244,27 @@ class InvicationPageState extends State<InvicationPage>
}
}
///倒计时方法
startCountdown() {
countdownTime = 60;
final call = (timer) {
// setState(() {
if (countdownTime < 1) {
canSendSms = true;
if (erroInfo == '1分钟内只能发送一条短信') {
setState(() {
showErroInfo = false;
});
}
_timer.cancel();
} else {
countdownTime -= 1;
}
// });
};
_timer = Timer.periodic(Duration(seconds: 1), call);
}
_showConfirmWidget(
{needBack = false,
needSex = false,
... ... @@ -1311,6 +1342,7 @@ class InvicationPageState extends State<InvicationPage>
_customerInfoWidget() {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// VEmptyView(30),
// MyDivider(double.infinity,
... ... @@ -1592,6 +1624,7 @@ class InvicationPageState extends State<InvicationPage>
clipBehavior: Clip.none,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
//姓名
enterMore
... ... @@ -1811,7 +1844,45 @@ class InvicationPageState extends State<InvicationPage>
],
),
// 选择优惠
_couponWidget()
_couponWidget(),
showErroInfo
? Container(
margin: EdgeInsets.only(
top: ScreenUtil().setWidth(40),
bottom: ScreenUtil().setWidth(24)),
height: ScreenUtil().setWidth(46 * 2),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(34)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(8)),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.2),
blurRadius: ScreenUtil().setWidth(8),
spreadRadius: ScreenUtil().setWidth(2),
offset: Offset(0, ScreenUtil().setWidth(2)))
]),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
Utils.getImgPath(erroInfo == '1分钟内只能发送一条短信'
? 'error_circle_yellow'
: 'error_circle_red'),
width: ScreenUtil().setWidth(40)),
HEmptyView(10),
Text(erroInfo,
style: TextStyle(
color: erroInfo == '1分钟内只能发送一条短信'
? MyColours.color_ED7B2F
: MyColours.color_E34D59,
fontSize: ScreenUtil().setSp(28))),
],
),
)
: SizedBox()
],
),
enterMore
... ... @@ -3370,44 +3441,44 @@ class InvicationPageState extends State<InvicationPage>
child: Row(
children: [
RoundButton(
text: '发短信',
width: ScreenUtil().setWidth(65 * 2),
height: ScreenUtil().setWidth(48 * 2),
fontSize: 30,
textColor: MyColours.color_999999,
gradientStart: MyColours.color_f3f3f3,
gradientEnd: MyColours.color_f3f3f3,
radius: ScreenUtil().setWidth(16),
isBold: false,
onPressed: () async {
if (_nameNode.hasFocus ||
_phoneNode.hasFocus ||
_cusdemNode.hasFocus) {
needWechat = true;
_showConfirmWidget(
needWechat: true,
callback: () async {
if (reserverPhone == null || reserverPhone.isEmpty) {
//跳转到录入联系人页面
// String temp = await NavigatorUtil.goEditReserverPage(
// context, widget.rid, name, sex,
// needBtn: true);
// if (temp != null) {
// reserverPhone = temp;
// }
Utils.showToast('请输入客户手机号');
} else if (!Utils.phoneRegExp(reserverPhone)) {
Utils.showToast('手机号格式错误,请修改正确');
//跳转到录入联系人页面
// String temp = await NavigatorUtil.goEditReserverPage(
// context, widget.rid, name, sex,
// needBtn: true);
// if (temp != null) {
// reserverPhone = temp;
// }
} else {
if (!couponProvider.sendSMS) {
/*
text: smsTitle,
width: ScreenUtil().setWidth(65 * 2),
height: ScreenUtil().setWidth(48 * 2),
fontSize: 30,
textColor: MyColours.color_999999,
gradientStart: MyColours.color_f3f3f3,
gradientEnd: MyColours.color_f3f3f3,
radius: ScreenUtil().setWidth(16),
isBold: false,
onPressed: () async {
if (_nameNode.hasFocus ||
_phoneNode.hasFocus ||
_cusdemNode.hasFocus) {
needWechat = true;
_showConfirmWidget(
needWechat: true,
callback: () async {
if (canSendSms) {
if (reserverPhone == null ||
reserverPhone.isEmpty ||
!Utils.phoneRegExp(reserverPhone)) {
//跳转到录入联系人页面
// String temp = await NavigatorUtil.goEditReserverPage(
// context, widget.rid, name, sex,
// needBtn: true);
// if (temp != null) {
// reserverPhone = temp;
// }
// Utils.showToast('请输入客户手机号');
//显示请输入11位手机号码
setState(() {
showErroInfo = true;
erroInfo = '请正确输入11位手机号码';
});
return;
} else {
/*
String dateSoltStr = '';
if (widget.dateSolt == '1') {
dateSoltStr = '早餐';
... ... @@ -3449,110 +3520,87 @@ class InvicationPageState extends State<InvicationPage>
params['Strtext'] = user.sellername;
}
*/
UserModel userModel =
Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"rid": widget.rid,
"sid": userModel.user.sellerid
};
bool success = await couponProvider
.sendSMSWxSendSms(context, params);
print(success);
// if (success) {
// Utils.showToast('短信已经发送成功!');
// } else {
// Utils.showToast('发送次数太频繁!');
// }
} else {
Utils.showToast('短信已经发送成功!');
}
}
});
removeOverlay();
} else {
if (reserverPhone == null || reserverPhone.isEmpty) {
//跳转到录入联系人页面
// String temp = await NavigatorUtil.goEditReserverPage(
// context, widget.rid, name, sex,
// needBtn: true);
// if (temp != null) {
// reserverPhone = temp;
// }
Utils.showToast('请输入客户手机号');
} else if (!Utils.phoneRegExp(reserverPhone)) {
Utils.showToast('手机号格式错误,请修改正确');
//跳转到录入联系人页面
// String temp = await NavigatorUtil.goEditReserverPage(
// context, widget.rid, name, sex,
// needBtn: true);
// if (temp != null) {
// reserverPhone = temp;
// }
} else {
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)}日";
setState(() {
showErroInfo = false;
erroInfo = '';
});
UserModel userModel = Provider.of<UserModel>(
context,
listen: false);
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", "")
"rid": widget.rid,
"sid": userModel.user.sellerid
};
if (ObjectUtil.isNotEmpty(_baseIndoProvider
.baseInfoSunModel) &&
ObjectUtil.isNotEmpty(_baseIndoProvider
.baseInfoSunModel.name)) {
params['Strtext'] = user.sellername +
_baseIndoProvider
.baseInfoSunModel.name;
} else {
params['Strtext'] = user.sellername;
bool success = await couponProvider
.sendSMSWxSendSms(context, params);
print(success);
if (success) {
setState(() {
smsTitle = '已发${couponProvider.sendSMS}次';
});
canSendSms = false;
startCountdown();
}
*/
UserModel userModel =
Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"rid": widget.rid,
"sid": userModel.user.sellerid
};
bool success = await couponProvider.sendSMSWxSendSms(
context, params);
print(success);
// if (success) {
// Utils.showToast('短信已经发送成功!');
// } else {
// Utils.showToast('发送次数太频繁!');
// }
// if (success) {
// Utils.showToast('短信已经发送成功!');
// } else {
// Utils.showToast('发送次数太频繁!');
// }
}
} else {
//显示1分钟只能发1次短信
setState(() {
showErroInfo = true;
erroInfo = '1分钟内只能发送一条短信';
});
return;
}
});
removeOverlay();
} else {
if (canSendSms) {
if (reserverPhone == null ||
reserverPhone.isEmpty ||
!Utils.phoneRegExp(reserverPhone)) {
//显示请输入11位手机号码
setState(() {
showErroInfo = true;
erroInfo = '请正确输入11位手机号码';
});
return;
} else {
setState(() {
showErroInfo = false;
erroInfo = '';
});
UserModel userModel =
Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"rid": widget.rid,
"sid": userModel.user.sellerid
};
bool success = await couponProvider.sendSMSWxSendSms(
context, params);
print(success);
if (success) {
setState(() {
smsTitle = '已发${couponProvider.sendSMS}次';
});
canSendSms = false;
startCountdown();
}
}
} else {
Utils.showToast('短信已经发送成功!');
//显示1分钟只能发1次短信
setState(() {
showErroInfo = true;
erroInfo = '1分钟内只能发送一条短信';
});
return;
}
}
}
},
),
}),
HEmptyView(40),
Expanded(
child: Stack(children: [
... ...
... ... @@ -108,7 +108,7 @@ class TableManagerPageState extends State<TableManagerPage> {
// personNumList.add('30以上');
WidgetsBinding.instance.addPostFrameCallback((_) {
couponProvider.sendSMS = false;
// couponProvider.sendSMS = false;
tableManagerModel.initTime(context);
_couponNetworkData();
_getSmsInfo(context);
... ...
... ... @@ -20,7 +20,7 @@ class CouponProvider with ChangeNotifier {
PageState pageStateHistory = PageState.Loading;
PageState pageStateSelect = PageState.Loading;
bool hasModify = false;
bool sendSMS = false;
int sendSMS = 0;
bool checkValue = true; //优惠券页面“全选”按钮状态 ----- 数据状态全部选中为true
// List<Map<String, dynamic>> listData = []; //优惠券页面数据
... ... @@ -197,7 +197,7 @@ class CouponProvider with ChangeNotifier {
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
// if (isShowLoading) {
state = PageState.Empty;
state = PageState.Empty;
// }
} else {
// if (isShowLoading) {
... ... @@ -510,7 +510,7 @@ class CouponProvider with ChangeNotifier {
});
if (baseResp.code == Constant.status_success) {
Utils.showToast("短信发送成功");
sendSMS = true;
sendSMS++;
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
... ...