Commit 30c1ef964352bb2f3a84d36cc63297497b770cea

Authored by wdn127929
1 parent 258d67e1

店铺过期弹窗OK

... ... @@ -22,6 +22,7 @@ class User {
String userphone; //角色电话
String token; //token
String nickName; // 昵称
String edate; //店铺过期日期
User(
this.openid,
... ... @@ -41,7 +42,8 @@ class User {
this.night,
this.userphone,
this.token,
this.nickName);
this.nickName,
this.edate);
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
... ... @@ -49,6 +51,6 @@ class User {
@override
String toString() {
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}';
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}';
}
}
... ...
... ... @@ -26,6 +26,7 @@ User _$UserFromJson(Map<String, dynamic> json) {
json['userphone'] as String,
json['token'] as String,
json['nickname'] as String,
json['edate'] as String,
);
}
... ... @@ -47,5 +48,6 @@ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
'night': instance.night,
'userphone': instance.userphone,
'token': instance.token,
'nickname': instance.nickName
'nickname': instance.nickName,
'edate': instance.edate
};
... ...
... ... @@ -37,6 +37,7 @@ import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart';
import 'package:one_key/models/message.dart';
import '../../app.dart';
import '../../provider/feast_model.dart';
import '../feast/feast_page.dart';
... ... @@ -72,6 +73,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
Timer timer;
Timer timerSeller;
Timer timerSellerEdate; //店铺过期时间提醒
int xgCount = 1; //注册信鸽次数,最多5次
... ... @@ -113,6 +115,13 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
WidgetsBinding.instance.addObserver(this);
_currIndex = widget.initialIndex;
if (App.sp.containsKey('sellerEdate')) {
List<String> data = App.sp.getStringList('sellerEdate');
if (data.contains('0')) {
//已经弹过过期弹窗,默认我的
_currIndex = 4;
}
}
_pageController = PageController(initialPage: _currIndex);
pages
// ..add(ChangeNotifierProvider<HomeEnterModel>(
... ... @@ -200,10 +209,104 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
timer = Timer.periodic(Duration(minutes: 3), (_) {
_getAllUnMessages();
});
timerSellerEdate = Timer.periodic(Duration(minutes: 1), (_) {
//店铺过期提醒
// 计算时间差
//店铺过期日期
DateTime edate = DateTime.fromMillisecondsSinceEpoch(int.parse(
Provider.of<UserModel>(context, listen: false).user.edate) *
1000);
//当前日期
final datenow = DateTime.now();
//比较相差的天数
int difference = edate.difference(datenow).inDays;
if (difference == 7) {
_showSellerAlert('7', edate);
} else if (difference == 3) {
//过期差3天,提醒一次
_showSellerAlert('3', edate);
} else if (difference == 2) {
//过期差2天,提醒一次
_showSellerAlert('2', edate);
} else if (difference == 1) {
//过期差1天,提醒一次
_showSellerAlert('1', edate);
} else if (difference == 0) {
//已到期
_showSellerAlert('0', edate);
}
});
_getUnMsgNum();
});
}
_showSellerAlert(String day, DateTime edate) {
if (App.sp.containsKey('sellerEdate')) {
//已经存进去过数据
List<String> data = App.sp.getStringList('sellerEdate');
if (!data.contains(day)) {
data.add(day);
App.sp.setStringList("sellerEdate", data);
//过期差ji天,提醒一次s
if (day == '0') {
DialogUtil.cupertinoAlertSellerHasEdateDialog(
context,
title: '温馨提示',
isBold: true,
lCallback: () {
NavigatorUtil.goHomePage(context, initialIndex: 4);
},
rCallback: () {
//立即续费
},
);
} else {
DialogUtil.cupertinoAlertSellerEdateDialog(
context,
title: '温馨提示',
isBold: true,
content: DateUtil.formatDate(
edate,
format: DateFormats.full,
),
rCallback: () {
//立即续费
},
);
}
}
} else {
App.sp.setStringList("sellerEdate", [day]);
//过期差ji天,提醒一次s
if (day == '0') {
DialogUtil.cupertinoAlertSellerHasEdateDialog(
context,
title: '温馨提示',
isBold: true,
lCallback: () {
NavigatorUtil.goHomePage(context, initialIndex: 4);
},
rCallback: () {
//立即续费
},
);
} else {
DialogUtil.cupertinoAlertSellerEdateDialog(
context,
title: '温馨提示',
isBold: true,
content: DateUtil.formatDate(
edate,
format: DateFormats.full,
),
rCallback: () {
//立即续费
},
);
}
}
}
_initNotification() async {
Map param = await Tools().getIntent();
_getIntent(param);
... ... @@ -745,7 +848,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
};
await messageModel.getNewGetUntreatedMsgNum(context, params,
showLoading: false);
setState(() {});
if (mounted) {
setState(() {});
}
}
// 系统窗口相关改变回调
... ... @@ -925,10 +1030,30 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
currentIndex: _currIndex,
onTap: (int index) {
if (_currIndex != index) {
setState(() {
_currIndex = index;
_pageController.jumpToPage(index);
});
if (App.sp.containsKey('sellerEdate')) {
List<String> data = App.sp.getStringList('sellerEdate');
if (data.contains('0')) {
DialogUtil.cupertinoAlertSellerHasEdateDialog(
context,
title: '温馨提示',
isBold: true,
lCallback: () {
NavigatorUtil.goHomePage(context, initialIndex: 4);
},
rCallback: () {
//立即续费
},
);
return;
}
}
if (mounted) {
setState(() {
_currIndex = index;
_pageController.jumpToPage(index);
});
}
if (_currIndex == 4) {
Utils.changeStatusColor(color: MyColours.color_199095);
} else {
... ... @@ -1015,9 +1140,11 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
controller: _pageController,
children: pages,
onPageChanged: (index) {
setState(() {
_currIndex = index;
});
if (mounted) {
setState(() {
_currIndex = index;
});
}
},
physics: NeverScrollableScrollPhysics(), //禁止底部滑动
)),
... ... @@ -1046,6 +1173,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
if (timerSeller != null) {
timerSeller.cancel();
}
if (timerSellerEdate != null) {
timerSellerEdate.cancel();
}
WidgetsBinding.instance.removeObserver(this);
}
}
... ...
... ... @@ -91,6 +91,7 @@ class UserModel with ChangeNotifier {
'userphone': user['phone'],
'token': baseResp.data[0]["token"]['token'],
'nickname': user['nick_name'],
'edate':seller['edate']
};
await saveUserInfo(User.fromJson(userMap));
return getSellerInfo(
... ...
... ... @@ -5357,6 +5357,254 @@ class DialogUtil {
);
}
///店铺临近过期弹窗
static cupertinoAlertSellerEdateDialog(BuildContext context,
{String title = "",
String content = "内容",
String lTitle = "关闭",
String rTitle = "立即续费",
Color rColor = MyColours.color_438E93,
bool isBold = false,
bool isBoldContent = false,
Color contentColor = MyColours.color_99000000,
VoidCallback lCallback,
VoidCallback rCallback}) async {
// bool isRed = content != '' ? false : true;
final action = await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(50)),
// height: ScreenUtil().setWidth(421 * 2),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(16))),
child: SingleChildScrollView(
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(10)))), //设置圆角
child: Container(
child: Column(
children: [
VEmptyView(64),
Container(
alignment: Alignment.center,
child: Text(title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E5000000)),
),
VEmptyView(16),
Text(
'您的店铺即将在',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
),
VEmptyView(24),
Text(
'$content 过期',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E34D59),
),
VEmptyView(24),
Text(
'请及时续费或联系您的服务商',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
),
VEmptyView(24),
Text(
'以免影响您的正常使用',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
),
VEmptyView(66),
MyDivider(double.infinity, ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: lTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
isBold: false,
fontSize: 32,
onPressed: () {
Navigator.pop(context);
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: rTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
rCallback();
Navigator.pop(
context,
);
}),
],
)
],
),
),
)),
),
));
});
},
);
}
///店铺临近过期弹窗
static cupertinoAlertSellerHasEdateDialog(BuildContext context,
{String title = "",
String content = "内容",
String lTitle = "关闭",
String rTitle = "立即续费",
Color rColor = MyColours.color_438E93,
bool isBold = false,
bool isBoldContent = false,
Color contentColor = MyColours.color_99000000,
VoidCallback lCallback,
VoidCallback rCallback}) async {
// bool isRed = content != '' ? false : true;
final action = await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(50)),
// height: ScreenUtil().setWidth(421 * 2),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(16))),
child: SingleChildScrollView(
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(10)))), //设置圆角
child: Container(
child: Column(
children: [
VEmptyView(64),
Container(
alignment: Alignment.center,
child: Text(title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E5000000)),
),
VEmptyView(16),
Text(
'您的店铺已过期',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_E34D59),
),
VEmptyView(24),
Text(
'请及时续费或联系您的服务商',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
),
VEmptyView(24),
Text(
'以免影响您的正常使用',
style: TextStyle(
fontSize: ScreenUtil().setSp(32),
color: MyColours.color_515151),
),
VEmptyView(66),
MyDivider(double.infinity, ScreenUtil().setWidth(2),
color: MyColours.color_f3f3f3),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RoundButton(
text: lTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_E6000000,
isBold: false,
fontSize: 32,
onPressed: () {
Navigator.pop(context);
lCallback();
}),
MyDivider(ScreenUtil().setWidth(2),
ScreenUtil().setWidth(112),
color: MyColours.color_f3f3f3),
RoundButton(
text: rTitle,
width: (ScreenUtil().screenWidth -
ScreenUtil().setWidth(62) * 2) /
2,
height: ScreenUtil().setWidth(112),
// radius: ScreenUtil().setWidth(10),
gradientStart: Colors.transparent,
gradientEnd: Colors.transparent,
textColor: MyColours.color_438E93,
fontSize: 32,
onPressed: () {
rCallback();
Navigator.pop(
context,
);
}),
],
)
],
),
),
)),
),
));
});
},
);
}
static Future cupertinoAlertDialog(BuildContext context,
{String title = "",
String content = "内容",
... ...