Commit 45a5876d00bed34e4f298727eb87716bbfbe8d00

Authored by wdn127929
2 parents 110264ba e724a624

软件过期提醒

... ... @@ -15,17 +15,19 @@ if (flutterRoot == null) {
def flutterVersionCode = "489"
def flutterVersionCode = "490"
if (flutterVersionCode == null) {
flutterVersionCode = '489'
flutterVersionCode = '490'
}
def flutterVersionName = "4.8.9"
def flutterVersionName = "4.9.0"
if (flutterVersionName == null) {
flutterVersionName = '4.8.9'
flutterVersionName = '4.9.0'
}
... ...
... ... @@ -162,47 +162,52 @@ class Data extends Object {
@JsonKey(name: 'real_address')
String realAddress;
@JsonKey(name: 'edate')
String edate;
Data(
this.id,
this.pid,
this.openid,
this.sellername,
this.selleralias,
this.slogan,
this.sellerdesc,
this.sellerLogo,
this.sellerImage,
this.sellerTel,
this.phone,
this.mapAddress,
this.long,
this.lat,
this.discountType,
this.lastNum,
this.ispass,
this.disIspass,
this.accountMoney,
this.isopenDc,
this.isopenMd,
this.dcAdduserCode,
this.average,
this.isOnlineReserve,
this.isTele,
this.daily,
this.dailyTime,
this.scale,
this.score,
this.isAuth,
this.isCallTel,
this.recStime,
this.recEtime,
this.status,
this.cdate,
this.proCode,
this.cityCode,
this.disCode,
this.sellerCode,
this.realAddress);
this.id,
this.pid,
this.openid,
this.sellername,
this.selleralias,
this.slogan,
this.sellerdesc,
this.sellerLogo,
this.sellerImage,
this.sellerTel,
this.phone,
this.mapAddress,
this.long,
this.lat,
this.discountType,
this.lastNum,
this.ispass,
this.disIspass,
this.accountMoney,
this.isopenDc,
this.isopenMd,
this.dcAdduserCode,
this.average,
this.isOnlineReserve,
this.isTele,
this.daily,
this.dailyTime,
this.scale,
this.score,
this.isAuth,
this.isCallTel,
this.recStime,
this.recEtime,
this.status,
this.cdate,
this.proCode,
this.cityCode,
this.disCode,
this.sellerCode,
this.realAddress,
this.edate
);
factory Data.fromJson(Map<String, dynamic> srcJson) =>
_$DataFromJson(srcJson);
... ...
... ... @@ -76,6 +76,7 @@ Data _$DataFromJson(Map<String, dynamic> json) {
json['dis_code'] as String,
json['seller_code'] as String,
json['real_address'] as String,
json['edate'] as String,
);
}
... ... @@ -119,5 +120,6 @@ Map<String, dynamic> _$DataToJson(Data instance) => <String, dynamic>{
'city_code': instance.cityCode,
'dis_code': instance.disCode,
'seller_code': instance.sellerCode,
'real_address': instance.realAddress
'real_address': instance.realAddress,
'edate': instance.edate
};
... ...
... ... @@ -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
};
... ...
... ... @@ -40,7 +40,12 @@ import 'package:one_key/models/message.dart';
import '../../constant/state.dart';
import '../../models/customer_by_seller_model.dart';
import '../../app.dart';
import '../../models/get_seller_info_model.dart';
import '../../provider/feast_model.dart';
import '../../provider/store_base_info_provider.dart';
import '../feast/feast_page.dart';
class HomePage extends StatefulWidget {
... ... @@ -75,6 +80,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
Timer timer;
Timer timerSeller;
Timer timerSellerEdate; //店铺过期时间提醒
int xgCount = 1; //注册信鸽次数,最多5次
... ... @@ -84,6 +90,8 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
bool needRefreshTemp = true;
static const MethodChannel _channel = MethodChannel("com.naji/book");
GetSellerInfoSunModel sellerInfoSunModel;
//实现监听
Future<dynamic> platformCallHandler(MethodCall call) async {
switch (call.method) {
... ... @@ -116,6 +124,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>(
... ... @@ -158,6 +173,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
WidgetsBinding.instance.addPostFrameCallback((_) {
initPlatformState();
_getTableList();
_getSellerById();
List<PullMarketingByUidSunModel> data =
Provider.of<UserModel>(context, listen: false)
... ... @@ -204,6 +220,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
timer = Timer.periodic(Duration(minutes: 3), (_) {
_getAllUnMessages();
});
_getUnMsgNum();
});
}
... ... @@ -217,6 +234,120 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
);
}
_edateShow() {
//店铺过期提醒
// 计算时间差
//店铺过期日期
DateTime edate = DateTime.fromMillisecondsSinceEpoch(
int.parse(sellerInfoSunModel.data.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);
}
}
///获取店铺过期时间
_getSellerById() async {
StoreBaseIndoProvider storeBaseIndoProvider =
Provider.of<StoreBaseIndoProvider>(context, listen: false);
sellerInfoSunModel = await storeBaseIndoProvider.getSellerById(context);
if (sellerInfoSunModel != null) {
//获取到店铺过期时间
//店铺过期提醒
// 计算时间差
//店铺过期日期
_edateShow();
timerSellerEdate = Timer.periodic(Duration(days: 1), (_) {
//店铺过期提醒
// 计算时间差
//店铺过期日期
_edateShow();
});
}
}
_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);
... ... @@ -777,9 +908,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
case AppLifecycleState.resumed: //应用前台可见
// if (widget.initialIndex == 1 && needRefreshTemp == false) {
// } else {
_clearBadge(() {
// _getAllUnMessages();
});
_clearBadge(() {
// _getAllUnMessages();
});
// }
break;
... ... @@ -863,7 +994,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
};
await messageModel.getNewGetUntreatedMsgNum(context, params,
showLoading: false);
setState(() {});
if (mounted) {
setState(() {});
}
}
// 系统窗口相关改变回调
... ... @@ -1083,10 +1216,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 {
... ... @@ -1173,9 +1326,11 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
controller: _pageController,
children: pages,
onPageChanged: (index) {
setState(() {
_currIndex = index;
});
if (mounted) {
setState(() {
_currIndex = index;
});
}
},
physics: NeverScrollableScrollPhysics(), //禁止底部滑动
)),
... ... @@ -1204,6 +1359,9 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
if (timerSeller != null) {
timerSeller.cancel();
}
if (timerSellerEdate != null) {
timerSellerEdate.cancel();
}
WidgetsBinding.instance.removeObserver(this);
}
}
... ...
... ... @@ -92,6 +92,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));
... ...
... ... @@ -258,12 +258,14 @@ var homeHandler = new Handler(
int.parse(params["dateTime"].first));
return ChangeNotifierProvider<TableManagerModel>(
create: (_) => TableManagerModel(),
child: HomePage(
initialIndex: int.parse(initialIndex),
needReresh: needRefresh,
mine: mine,
date: dateTime,
solt: solt));
child: ChangeNotifierProvider<StoreBaseIndoProvider>(
create: (_) => StoreBaseIndoProvider(),
child: HomePage(
initialIndex: int.parse(initialIndex),
needReresh: needRefresh,
mine: mine,
date: dateTime,
solt: solt)));
});
// 跳转预订详情页
... ...
... ... @@ -6337,6 +6337,300 @@ 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(
'400-000-9690 及时续费',
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),
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);
}),
// 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(
// padding: EdgeInsets.symmetric(horizontal: w(20)),
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(
'400-000-9690 及时续费',
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),
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();
}),
// 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 confirmTimeAlertDialog(BuildContext context, String morning,
String noon, String night, VoidCallback callback) async {
... ... @@ -6560,6 +6854,8 @@ class DialogUtil {
);
}
// static Future cupertinoAlertDialogOnly(BuildContext context,
static Future cupertinoAlertDialogOnly(BuildContext context,
{String title = "",
String content = "内容",
... ...
... ... @@ -1506,5 +1506,7 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.18.0 <3.0.0"
flutter: ">=3.3.0"
... ...