|
|
|
import 'dart:async';
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
...
|
...
|
@@ -265,10 +266,11 @@ class InvicationPageState extends State<InvicationPage> |
|
|
|
affinity: TextAffinity.downstream,
|
|
|
|
offset: value.toString().length)));
|
|
|
|
});
|
|
|
|
couponProvider.sendSMS = 0;
|
|
|
|
|
|
|
|
// await _couponNetworkData(isShowLoading: false);
|
|
|
|
await _getCustomerActivityBaseinfo();
|
|
|
|
_getSmsInfo(context);
|
|
|
|
_timerShow();
|
|
|
|
await _getReserveDetail(showCicle: false);
|
|
|
|
|
|
|
|
await _getTablesPhoto();
|
|
...
|
...
|
@@ -309,8 +311,61 @@ class InvicationPageState extends State<InvicationPage> |
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_timerShow() {
|
|
|
|
Map<String, dynamic> dataSp = {};
|
|
|
|
if (App.sp.containsKey('notebook_timer')) {
|
|
|
|
dataSp = json.decode(App.sp.getString('notebook_timer'));
|
|
|
|
}
|
|
|
|
if (dataSp.containsKey(widget.rid)) {
|
|
|
|
Map<String, dynamic> mapRid = dataSp[widget.rid];
|
|
|
|
int cacheSeconds = mapRid['cache_seconds']; //剩余时间
|
|
|
|
int nowMilli = mapRid['now_milli']; //缓存当前时间戳
|
|
|
|
DateTime startDate = DateTime.fromMillisecondsSinceEpoch(nowMilli);
|
|
|
|
//获取当前时间戳
|
|
|
|
|
|
|
|
int seconds =
|
|
|
|
DateTime.now().difference(startDate).inSeconds; // 924878906 秒
|
|
|
|
if (seconds < cacheSeconds) {
|
|
|
|
//开始倒计时
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
canSendSms = false;
|
|
|
|
showErroInfo = true;
|
|
|
|
erroInfo = '2分钟内只能发送一条短信';
|
|
|
|
couponProvider.sendSMS = 1;
|
|
|
|
smsTitle = '已发${couponProvider.sendSMS}次';
|
|
|
|
});
|
|
|
|
|
|
|
|
startCountdown(cacheSeconds - seconds);
|
|
|
|
} else {
|
|
|
|
couponProvider.sendSMS = 0;
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
// App.sp.remove('notebook_timer');
|
|
|
|
if (countdownTime >= 1) {
|
|
|
|
//缓存当前订单的剩余倒计时时间
|
|
|
|
// App.sp.remove('notebook_timer');
|
|
|
|
Map<String, dynamic> dataSp = {};
|
|
|
|
if (App.sp.containsKey('notebook_timer')) {
|
|
|
|
dataSp = json.decode(App.sp.getString('notebook_timer'));
|
|
|
|
}
|
|
|
|
// if(dataSp.containsKey(widget.rid)){
|
|
|
|
// //当前rid 有缓存
|
|
|
|
// }
|
|
|
|
|
|
|
|
Map<String, dynamic> mapRid = {
|
|
|
|
'cache_seconds': countdownTime, //剩余时间
|
|
|
|
'now_milli': DateTime.now().millisecondsSinceEpoch //当前时间戳
|
|
|
|
};
|
|
|
|
dataSp[widget.rid] = mapRid;
|
|
|
|
App.sp.setString('notebook_timer', json.encode(dataSp));
|
|
|
|
}
|
|
|
|
|
|
|
|
removeOverlay();
|
|
|
|
Utils.changeStatusColor();
|
|
|
|
couponProvider.clearSelect();
|
|
...
|
...
|
@@ -366,20 +421,37 @@ class InvicationPageState extends State<InvicationPage> |
|
|
|
}
|
|
|
|
|
|
|
|
///倒计时方法
|
|
|
|
startCountdown() {
|
|
|
|
countdownTime = 60;
|
|
|
|
startCountdown(int countdownTimeTemp) {
|
|
|
|
final call = (timer) {
|
|
|
|
// setState(() {
|
|
|
|
if (countdownTime < 1) {
|
|
|
|
if (countdownTimeTemp < 1) {
|
|
|
|
countdownTime = countdownTimeTemp;
|
|
|
|
canSendSms = true;
|
|
|
|
if (erroInfo == '1分钟内只能发送一条短信') {
|
|
|
|
Map<String, dynamic> dataSp = {};
|
|
|
|
if (App.sp.containsKey('notebook_timer')) {
|
|
|
|
dataSp = json.decode(App.sp.getString('notebook_timer'));
|
|
|
|
}
|
|
|
|
if (dataSp.containsKey(widget.rid)) {
|
|
|
|
//当前rid 有缓存
|
|
|
|
dataSp.remove(widget.rid);
|
|
|
|
if (dataSp.length == 0) {
|
|
|
|
App.sp.remove('notebook_timer');
|
|
|
|
} else {
|
|
|
|
App.sp.setString('notebook_timer', json.encode(dataSp));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (erroInfo == '2分钟内只能发送一条短信') {
|
|
|
|
setState(() {
|
|
|
|
showErroInfo = false;
|
|
|
|
couponProvider.sendSMS = 0;
|
|
|
|
smsTitle = '发短信';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_timer.cancel();
|
|
|
|
} else {
|
|
|
|
countdownTime -= 1;
|
|
|
|
countdownTimeTemp -= 1;
|
|
|
|
countdownTime = countdownTimeTemp;
|
|
|
|
}
|
|
|
|
// });
|
|
|
|
};
|
|
...
|
...
|
@@ -2333,14 +2405,14 @@ class InvicationPageState extends State<InvicationPage> |
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(erroInfo == '1分钟内只能发送一条短信'
|
|
|
|
Utils.getImgPath(erroInfo == '2分钟内只能发送一条短信'
|
|
|
|
? 'error_circle_yellow'
|
|
|
|
: 'error_circle_red'),
|
|
|
|
width: ScreenUtil().setWidth(40)),
|
|
|
|
HEmptyView(10),
|
|
|
|
Text(erroInfo,
|
|
|
|
style: TextStyle(
|
|
|
|
color: erroInfo == '1分钟内只能发送一条短信'
|
|
|
|
color: erroInfo == '2分钟内只能发送一条短信'
|
|
|
|
? MyColours.color_ED7B2F
|
|
|
|
: MyColours.color_E34D59,
|
|
|
|
fontSize: ScreenUtil().setSp(28))),
|
|
...
|
...
|
@@ -4056,7 +4128,7 @@ class InvicationPageState extends State<InvicationPage> |
|
|
|
smsTitle = '已发${couponProvider.sendSMS}次';
|
|
|
|
});
|
|
|
|
canSendSms = false;
|
|
|
|
startCountdown();
|
|
|
|
startCountdown(120);
|
|
|
|
} else {
|
|
|
|
if (couponProvider.errorSMS != '') {
|
|
|
|
setState(() {
|
|
...
|
...
|
@@ -4073,10 +4145,10 @@ class InvicationPageState extends State<InvicationPage> |
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//显示1分钟只能发1次短信
|
|
|
|
//显示2分钟只能发1次短信
|
|
|
|
setState(() {
|
|
|
|
showErroInfo = true;
|
|
|
|
erroInfo = '1分钟内只能发送一条短信';
|
|
|
|
erroInfo = '2分钟内只能发送一条短信';
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
...
|
...
|
@@ -4133,7 +4205,7 @@ class InvicationPageState extends State<InvicationPage> |
|
|
|
smsTitle = '已发${couponProvider.sendSMS}次';
|
|
|
|
});
|
|
|
|
canSendSms = false;
|
|
|
|
startCountdown();
|
|
|
|
startCountdown(120);
|
|
|
|
} else {
|
|
|
|
if (couponProvider.errorSMS != '') {
|
|
|
|
setState(() {
|
|
...
|
...
|
@@ -4144,10 +4216,10 @@ class InvicationPageState extends State<InvicationPage> |
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//显示1分钟只能发1次短信
|
|
|
|
//显示2分钟只能发1次短信
|
|
|
|
setState(() {
|
|
|
|
showErroInfo = true;
|
|
|
|
erroInfo = '1分钟内只能发送一条短信';
|
|
|
|
erroInfo = '2分钟内只能发送一条短信';
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
...
|
...
|
|