Commit 30c1ef964352bb2f3a84d36cc63297497b770cea

Authored by wdn127929
1 parent 258d67e1

店铺过期弹窗OK

@@ -22,6 +22,7 @@ class User { @@ -22,6 +22,7 @@ class User {
22 String userphone; //角色电话 22 String userphone; //角色电话
23 String token; //token 23 String token; //token
24 String nickName; // 昵称 24 String nickName; // 昵称
  25 + String edate; //店铺过期日期
25 26
26 User( 27 User(
27 this.openid, 28 this.openid,
@@ -41,7 +42,8 @@ class User { @@ -41,7 +42,8 @@ class User {
41 this.night, 42 this.night,
42 this.userphone, 43 this.userphone,
43 this.token, 44 this.token,
44 - this.nickName); 45 + this.nickName,
  46 + this.edate);
45 47
46 factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json); 48 factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
47 49
@@ -49,6 +51,6 @@ class User { @@ -49,6 +51,6 @@ class User {
49 51
50 @override 52 @override
51 String toString() { 53 String toString() {
52 - return 'User{openid: $openid, account: $account, role_name: $role_name, sellerid: $sellerid, sellercode: $sellercode, sellername: $sellername,sellerimage:$sellerimage, sellerphone: $sellerphone, sellerAddr: $sellerAddr, scatter: $scatter, room: $room, cassette: $cassette, morning: $morning, noon: $noon, night: $night ,userphone:$userphone},token:$token},nickName:$nickName}'; 54 + return 'User{openid: $openid, account: $account, role_name: $role_name, sellerid: $sellerid, sellercode: $sellercode, sellername: $sellername,sellerimage:$sellerimage, sellerphone: $sellerphone, sellerAddr: $sellerAddr, scatter: $scatter, room: $room, cassette: $cassette, morning: $morning, noon: $noon, night: $night ,userphone:$userphone,token:$token,nickName:$nickName,edate:$edate}';
53 } 55 }
54 } 56 }
@@ -26,6 +26,7 @@ User _$UserFromJson(Map<String, dynamic> json) { @@ -26,6 +26,7 @@ User _$UserFromJson(Map<String, dynamic> json) {
26 json['userphone'] as String, 26 json['userphone'] as String,
27 json['token'] as String, 27 json['token'] as String,
28 json['nickname'] as String, 28 json['nickname'] as String,
  29 + json['edate'] as String,
29 ); 30 );
30 } 31 }
31 32
@@ -47,5 +48,6 @@ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{ @@ -47,5 +48,6 @@ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
47 'night': instance.night, 48 'night': instance.night,
48 'userphone': instance.userphone, 49 'userphone': instance.userphone,
49 'token': instance.token, 50 'token': instance.token,
50 - 'nickname': instance.nickName 51 + 'nickname': instance.nickName,
  52 + 'edate': instance.edate
51 }; 53 };
@@ -37,6 +37,7 @@ import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; @@ -37,6 +37,7 @@ import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
37 import 'package:flutter_app_badger/flutter_app_badger.dart'; 37 import 'package:flutter_app_badger/flutter_app_badger.dart';
38 import 'package:one_key/models/message.dart'; 38 import 'package:one_key/models/message.dart';
39 39
  40 +import '../../app.dart';
40 import '../../provider/feast_model.dart'; 41 import '../../provider/feast_model.dart';
41 import '../feast/feast_page.dart'; 42 import '../feast/feast_page.dart';
42 43
@@ -72,6 +73,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -72,6 +73,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
72 73
73 Timer timer; 74 Timer timer;
74 Timer timerSeller; 75 Timer timerSeller;
  76 + Timer timerSellerEdate; //店铺过期时间提醒
75 77
76 int xgCount = 1; //注册信鸽次数,最多5次 78 int xgCount = 1; //注册信鸽次数,最多5次
77 79
@@ -113,6 +115,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -113,6 +115,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
113 WidgetsBinding.instance.addObserver(this); 115 WidgetsBinding.instance.addObserver(this);
114 116
115 _currIndex = widget.initialIndex; 117 _currIndex = widget.initialIndex;
  118 + if (App.sp.containsKey('sellerEdate')) {
  119 + List<String> data = App.sp.getStringList('sellerEdate');
  120 + if (data.contains('0')) {
  121 + //已经弹过过期弹窗,默认我的
  122 + _currIndex = 4;
  123 + }
  124 + }
116 _pageController = PageController(initialPage: _currIndex); 125 _pageController = PageController(initialPage: _currIndex);
117 pages 126 pages
118 // ..add(ChangeNotifierProvider<HomeEnterModel>( 127 // ..add(ChangeNotifierProvider<HomeEnterModel>(
@@ -200,10 +209,104 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -200,10 +209,104 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
200 timer = Timer.periodic(Duration(minutes: 3), (_) { 209 timer = Timer.periodic(Duration(minutes: 3), (_) {
201 _getAllUnMessages(); 210 _getAllUnMessages();
202 }); 211 });
  212 + timerSellerEdate = Timer.periodic(Duration(minutes: 1), (_) {
  213 + //店铺过期提醒
  214 + // 计算时间差
  215 + //店铺过期日期
  216 + DateTime edate = DateTime.fromMillisecondsSinceEpoch(int.parse(
  217 + Provider.of<UserModel>(context, listen: false).user.edate) *
  218 + 1000);
  219 + //当前日期
  220 + final datenow = DateTime.now();
  221 + //比较相差的天数
  222 + int difference = edate.difference(datenow).inDays;
  223 + if (difference == 7) {
  224 + _showSellerAlert('7', edate);
  225 + } else if (difference == 3) {
  226 + //过期差3天,提醒一次
  227 + _showSellerAlert('3', edate);
  228 + } else if (difference == 2) {
  229 + //过期差2天,提醒一次
  230 + _showSellerAlert('2', edate);
  231 + } else if (difference == 1) {
  232 + //过期差1天,提醒一次
  233 + _showSellerAlert('1', edate);
  234 + } else if (difference == 0) {
  235 + //已到期
  236 + _showSellerAlert('0', edate);
  237 + }
  238 + });
203 _getUnMsgNum(); 239 _getUnMsgNum();
204 }); 240 });
205 } 241 }
206 242
  243 + _showSellerAlert(String day, DateTime edate) {
  244 + if (App.sp.containsKey('sellerEdate')) {
  245 + //已经存进去过数据
  246 + List<String> data = App.sp.getStringList('sellerEdate');
  247 + if (!data.contains(day)) {
  248 + data.add(day);
  249 + App.sp.setStringList("sellerEdate", data);
  250 + //过期差ji天,提醒一次s
  251 + if (day == '0') {
  252 + DialogUtil.cupertinoAlertSellerHasEdateDialog(
  253 + context,
  254 + title: '温馨提示',
  255 + isBold: true,
  256 + lCallback: () {
  257 + NavigatorUtil.goHomePage(context, initialIndex: 4);
  258 + },
  259 + rCallback: () {
  260 + //立即续费
  261 + },
  262 + );
  263 + } else {
  264 + DialogUtil.cupertinoAlertSellerEdateDialog(
  265 + context,
  266 + title: '温馨提示',
  267 + isBold: true,
  268 + content: DateUtil.formatDate(
  269 + edate,
  270 + format: DateFormats.full,
  271 + ),
  272 + rCallback: () {
  273 + //立即续费
  274 + },
  275 + );
  276 + }
  277 + }
  278 + } else {
  279 + App.sp.setStringList("sellerEdate", [day]);
  280 + //过期差ji天,提醒一次s
  281 + if (day == '0') {
  282 + DialogUtil.cupertinoAlertSellerHasEdateDialog(
  283 + context,
  284 + title: '温馨提示',
  285 + isBold: true,
  286 + lCallback: () {
  287 + NavigatorUtil.goHomePage(context, initialIndex: 4);
  288 + },
  289 + rCallback: () {
  290 + //立即续费
  291 + },
  292 + );
  293 + } else {
  294 + DialogUtil.cupertinoAlertSellerEdateDialog(
  295 + context,
  296 + title: '温馨提示',
  297 + isBold: true,
  298 + content: DateUtil.formatDate(
  299 + edate,
  300 + format: DateFormats.full,
  301 + ),
  302 + rCallback: () {
  303 + //立即续费
  304 + },
  305 + );
  306 + }
  307 + }
  308 + }
  309 +
207 _initNotification() async { 310 _initNotification() async {
208 Map param = await Tools().getIntent(); 311 Map param = await Tools().getIntent();
209 _getIntent(param); 312 _getIntent(param);
@@ -745,7 +848,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -745,7 +848,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
745 }; 848 };
746 await messageModel.getNewGetUntreatedMsgNum(context, params, 849 await messageModel.getNewGetUntreatedMsgNum(context, params,
747 showLoading: false); 850 showLoading: false);
748 - setState(() {}); 851 + if (mounted) {
  852 + setState(() {});
  853 + }
749 } 854 }
750 855
751 // 系统窗口相关改变回调 856 // 系统窗口相关改变回调
@@ -925,10 +1030,30 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -925,10 +1030,30 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
925 currentIndex: _currIndex, 1030 currentIndex: _currIndex,
926 onTap: (int index) { 1031 onTap: (int index) {
927 if (_currIndex != index) { 1032 if (_currIndex != index) {
928 - setState(() {  
929 - _currIndex = index;  
930 - _pageController.jumpToPage(index);  
931 - }); 1033 + if (App.sp.containsKey('sellerEdate')) {
  1034 + List<String> data = App.sp.getStringList('sellerEdate');
  1035 + if (data.contains('0')) {
  1036 + DialogUtil.cupertinoAlertSellerHasEdateDialog(
  1037 + context,
  1038 + title: '温馨提示',
  1039 + isBold: true,
  1040 + lCallback: () {
  1041 + NavigatorUtil.goHomePage(context, initialIndex: 4);
  1042 + },
  1043 + rCallback: () {
  1044 + //立即续费
  1045 + },
  1046 + );
  1047 + return;
  1048 + }
  1049 + }
  1050 +
  1051 + if (mounted) {
  1052 + setState(() {
  1053 + _currIndex = index;
  1054 + _pageController.jumpToPage(index);
  1055 + });
  1056 + }
932 if (_currIndex == 4) { 1057 if (_currIndex == 4) {
933 Utils.changeStatusColor(color: MyColours.color_199095); 1058 Utils.changeStatusColor(color: MyColours.color_199095);
934 } else { 1059 } else {
@@ -1015,9 +1140,11 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -1015,9 +1140,11 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
1015 controller: _pageController, 1140 controller: _pageController,
1016 children: pages, 1141 children: pages,
1017 onPageChanged: (index) { 1142 onPageChanged: (index) {
1018 - setState(() {  
1019 - _currIndex = index;  
1020 - }); 1143 + if (mounted) {
  1144 + setState(() {
  1145 + _currIndex = index;
  1146 + });
  1147 + }
1021 }, 1148 },
1022 physics: NeverScrollableScrollPhysics(), //禁止底部滑动 1149 physics: NeverScrollableScrollPhysics(), //禁止底部滑动
1023 )), 1150 )),
@@ -1046,6 +1173,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -1046,6 +1173,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
1046 if (timerSeller != null) { 1173 if (timerSeller != null) {
1047 timerSeller.cancel(); 1174 timerSeller.cancel();
1048 } 1175 }
  1176 + if (timerSellerEdate != null) {
  1177 + timerSellerEdate.cancel();
  1178 + }
1049 WidgetsBinding.instance.removeObserver(this); 1179 WidgetsBinding.instance.removeObserver(this);
1050 } 1180 }
1051 } 1181 }
@@ -91,6 +91,7 @@ class UserModel with ChangeNotifier { @@ -91,6 +91,7 @@ class UserModel with ChangeNotifier {
91 'userphone': user['phone'], 91 'userphone': user['phone'],
92 'token': baseResp.data[0]["token"]['token'], 92 'token': baseResp.data[0]["token"]['token'],
93 'nickname': user['nick_name'], 93 'nickname': user['nick_name'],
  94 + 'edate':seller['edate']
94 }; 95 };
95 await saveUserInfo(User.fromJson(userMap)); 96 await saveUserInfo(User.fromJson(userMap));
96 return getSellerInfo( 97 return getSellerInfo(
@@ -5357,6 +5357,254 @@ class DialogUtil { @@ -5357,6 +5357,254 @@ class DialogUtil {
5357 ); 5357 );
5358 } 5358 }
5359 5359
  5360 + ///店铺临近过期弹窗
  5361 + static cupertinoAlertSellerEdateDialog(BuildContext context,
  5362 + {String title = "",
  5363 + String content = "内容",
  5364 + String lTitle = "关闭",
  5365 + String rTitle = "立即续费",
  5366 + Color rColor = MyColours.color_438E93,
  5367 + bool isBold = false,
  5368 + bool isBoldContent = false,
  5369 + Color contentColor = MyColours.color_99000000,
  5370 + VoidCallback lCallback,
  5371 + VoidCallback rCallback}) async {
  5372 + // bool isRed = content != '' ? false : true;
  5373 + final action = await showDialog(
  5374 + context: context,
  5375 + barrierDismissible: false,
  5376 + builder: (BuildContext context) {
  5377 + return StatefulBuilder(builder: (context, state) {
  5378 + return Scaffold(
  5379 + backgroundColor: Colors.transparent,
  5380 + body: Center(
  5381 + child: Container(
  5382 + padding: EdgeInsets.symmetric(
  5383 + horizontal: ScreenUtil().setWidth(50)),
  5384 + // height: ScreenUtil().setWidth(421 * 2),
  5385 + decoration: BoxDecoration(
  5386 + borderRadius:
  5387 + BorderRadius.circular(ScreenUtil().setWidth(16))),
  5388 + child: SingleChildScrollView(
  5389 + child: Card(
  5390 + shape: RoundedRectangleBorder(
  5391 + borderRadius: BorderRadius.all(
  5392 + Radius.circular(ScreenUtil().setWidth(10)))), //设置圆角
  5393 + child: Container(
  5394 + child: Column(
  5395 + children: [
  5396 + VEmptyView(64),
  5397 + Container(
  5398 + alignment: Alignment.center,
  5399 + child: Text(title,
  5400 + style: TextStyle(
  5401 + fontWeight: FontWeight.bold,
  5402 + fontSize: ScreenUtil().setSp(32),
  5403 + color: MyColours.color_E5000000)),
  5404 + ),
  5405 + VEmptyView(16),
  5406 + Text(
  5407 + '您的店铺即将在',
  5408 + style: TextStyle(
  5409 + fontSize: ScreenUtil().setSp(32),
  5410 + color: MyColours.color_515151),
  5411 + ),
  5412 + VEmptyView(24),
  5413 + Text(
  5414 + '$content 过期',
  5415 + style: TextStyle(
  5416 + fontSize: ScreenUtil().setSp(32),
  5417 + color: MyColours.color_E34D59),
  5418 + ),
  5419 + VEmptyView(24),
  5420 + Text(
  5421 + '请及时续费或联系您的服务商',
  5422 + style: TextStyle(
  5423 + fontSize: ScreenUtil().setSp(32),
  5424 + color: MyColours.color_515151),
  5425 + ),
  5426 + VEmptyView(24),
  5427 + Text(
  5428 + '以免影响您的正常使用',
  5429 + style: TextStyle(
  5430 + fontSize: ScreenUtil().setSp(32),
  5431 + color: MyColours.color_515151),
  5432 + ),
  5433 + VEmptyView(66),
  5434 + MyDivider(double.infinity, ScreenUtil().setWidth(2),
  5435 + color: MyColours.color_f3f3f3),
  5436 + Row(
  5437 + // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  5438 + children: [
  5439 + RoundButton(
  5440 + text: lTitle,
  5441 + width: (ScreenUtil().screenWidth -
  5442 + ScreenUtil().setWidth(62) * 2) /
  5443 + 2,
  5444 + height: ScreenUtil().setWidth(112),
  5445 + // radius: ScreenUtil().setWidth(10),
  5446 + gradientStart: Colors.transparent,
  5447 + gradientEnd: Colors.transparent,
  5448 + textColor: MyColours.color_E6000000,
  5449 + isBold: false,
  5450 + fontSize: 32,
  5451 + onPressed: () {
  5452 + Navigator.pop(context);
  5453 + }),
  5454 + MyDivider(ScreenUtil().setWidth(2),
  5455 + ScreenUtil().setWidth(112),
  5456 + color: MyColours.color_f3f3f3),
  5457 + RoundButton(
  5458 + text: rTitle,
  5459 + width: (ScreenUtil().screenWidth -
  5460 + ScreenUtil().setWidth(62) * 2) /
  5461 + 2,
  5462 + height: ScreenUtil().setWidth(112),
  5463 + // radius: ScreenUtil().setWidth(10),
  5464 + gradientStart: Colors.transparent,
  5465 + gradientEnd: Colors.transparent,
  5466 + textColor: MyColours.color_438E93,
  5467 + fontSize: 32,
  5468 + onPressed: () {
  5469 + rCallback();
  5470 + Navigator.pop(
  5471 + context,
  5472 + );
  5473 + }),
  5474 + ],
  5475 + )
  5476 + ],
  5477 + ),
  5478 + ),
  5479 + )),
  5480 + ),
  5481 + ));
  5482 + });
  5483 + },
  5484 + );
  5485 + }
  5486 +
  5487 + ///店铺临近过期弹窗
  5488 + static cupertinoAlertSellerHasEdateDialog(BuildContext context,
  5489 + {String title = "",
  5490 + String content = "内容",
  5491 + String lTitle = "关闭",
  5492 + String rTitle = "立即续费",
  5493 + Color rColor = MyColours.color_438E93,
  5494 + bool isBold = false,
  5495 + bool isBoldContent = false,
  5496 + Color contentColor = MyColours.color_99000000,
  5497 + VoidCallback lCallback,
  5498 + VoidCallback rCallback}) async {
  5499 + // bool isRed = content != '' ? false : true;
  5500 + final action = await showDialog(
  5501 + context: context,
  5502 + barrierDismissible: false,
  5503 + builder: (BuildContext context) {
  5504 + return StatefulBuilder(builder: (context, state) {
  5505 + return Scaffold(
  5506 + backgroundColor: Colors.transparent,
  5507 + body: Center(
  5508 + child: Container(
  5509 + padding: EdgeInsets.symmetric(
  5510 + horizontal: ScreenUtil().setWidth(50)),
  5511 + // height: ScreenUtil().setWidth(421 * 2),
  5512 + decoration: BoxDecoration(
  5513 + borderRadius:
  5514 + BorderRadius.circular(ScreenUtil().setWidth(16))),
  5515 + child: SingleChildScrollView(
  5516 + child: Card(
  5517 + shape: RoundedRectangleBorder(
  5518 + borderRadius: BorderRadius.all(
  5519 + Radius.circular(ScreenUtil().setWidth(10)))), //设置圆角
  5520 + child: Container(
  5521 + child: Column(
  5522 + children: [
  5523 + VEmptyView(64),
  5524 + Container(
  5525 + alignment: Alignment.center,
  5526 + child: Text(title,
  5527 + style: TextStyle(
  5528 + fontWeight: FontWeight.bold,
  5529 + fontSize: ScreenUtil().setSp(32),
  5530 + color: MyColours.color_E5000000)),
  5531 + ),
  5532 + VEmptyView(16),
  5533 + Text(
  5534 + '您的店铺已过期',
  5535 + style: TextStyle(
  5536 + fontSize: ScreenUtil().setSp(32),
  5537 + color: MyColours.color_E34D59),
  5538 + ),
  5539 + VEmptyView(24),
  5540 + Text(
  5541 + '请及时续费或联系您的服务商',
  5542 + style: TextStyle(
  5543 + fontSize: ScreenUtil().setSp(32),
  5544 + color: MyColours.color_515151),
  5545 + ),
  5546 + VEmptyView(24),
  5547 + Text(
  5548 + '以免影响您的正常使用',
  5549 + style: TextStyle(
  5550 + fontSize: ScreenUtil().setSp(32),
  5551 + color: MyColours.color_515151),
  5552 + ),
  5553 + VEmptyView(66),
  5554 + MyDivider(double.infinity, ScreenUtil().setWidth(2),
  5555 + color: MyColours.color_f3f3f3),
  5556 + Row(
  5557 + // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  5558 + children: [
  5559 + RoundButton(
  5560 + text: lTitle,
  5561 + width: (ScreenUtil().screenWidth -
  5562 + ScreenUtil().setWidth(62) * 2) /
  5563 + 2,
  5564 + height: ScreenUtil().setWidth(112),
  5565 + // radius: ScreenUtil().setWidth(10),
  5566 + gradientStart: Colors.transparent,
  5567 + gradientEnd: Colors.transparent,
  5568 + textColor: MyColours.color_E6000000,
  5569 + isBold: false,
  5570 + fontSize: 32,
  5571 + onPressed: () {
  5572 + Navigator.pop(context);
  5573 + lCallback();
  5574 + }),
  5575 + MyDivider(ScreenUtil().setWidth(2),
  5576 + ScreenUtil().setWidth(112),
  5577 + color: MyColours.color_f3f3f3),
  5578 + RoundButton(
  5579 + text: rTitle,
  5580 + width: (ScreenUtil().screenWidth -
  5581 + ScreenUtil().setWidth(62) * 2) /
  5582 + 2,
  5583 + height: ScreenUtil().setWidth(112),
  5584 + // radius: ScreenUtil().setWidth(10),
  5585 + gradientStart: Colors.transparent,
  5586 + gradientEnd: Colors.transparent,
  5587 + textColor: MyColours.color_438E93,
  5588 + fontSize: 32,
  5589 + onPressed: () {
  5590 + rCallback();
  5591 + Navigator.pop(
  5592 + context,
  5593 + );
  5594 + }),
  5595 + ],
  5596 + )
  5597 + ],
  5598 + ),
  5599 + ),
  5600 + )),
  5601 + ),
  5602 + ));
  5603 + });
  5604 + },
  5605 + );
  5606 + }
  5607 +
5360 static Future cupertinoAlertDialog(BuildContext context, 5608 static Future cupertinoAlertDialog(BuildContext context,
5361 {String title = "", 5609 {String title = "",
5362 String content = "内容", 5610 String content = "内容",