Commit 4b3857d53b0007e42a931b74c996f318d917fb02

Authored by wdn127929
2 parents 490142ac 8fa26689

Merge branch 'v5.1.0+' into v5.1.1+

@@ -211,73 +211,76 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -211,73 +211,76 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
211 child: ChangeNotifierProvider<CollectStoreProvider>( 211 child: ChangeNotifierProvider<CollectStoreProvider>(
212 create: (_) => CollectStoreProvider(), child: MyPage()), 212 create: (_) => CollectStoreProvider(), child: MyPage()),
213 ))); 213 )));
214 - WidgetsBinding.instance.addPostFrameCallback((_) { 214 + WidgetsBinding.instance.addPostFrameCallback((_) async {
215 bus.on('refresh_token', (arg) { 215 bus.on('refresh_token', (arg) {
216 initPlatformState(); 216 initPlatformState();
217 }); 217 });
218 - getSellerVersion();  
219 - initPlatformState();  
220 - _getTableList();  
221 - _getSellerById();  
222 -  
223 - List<PullMarketingByUidSunModel> data =  
224 - Provider.of<UserModel>(context, listen: false)  
225 - .pullMarketingByUidSunModel;  
226 - if (data != null && Utils.getAuthority(context, '全店任务')) {  
227 - if (data.length > 0) {  
228 - Future.delayed(Duration(milliseconds: 300), () {  
229 - DialogUtil.cupertinoAlertDialog(context,  
230 - title: "全店任务",  
231 - content: "管理员发布了新的任务,请立即查看并完成任务",  
232 - lTitle: "稍后提醒",  
233 - rTitle: "立即查看", lCallback: () {  
234 - print("稍后提醒");  
235 - // 30分钟后重新弹窗  
236 - _startTimerSeller();  
237 - }, rCallback: () {  
238 - _endTimerSeller();  
239 - if (data.length == 1) {  
240 - //进入营销详情  
241 - NavigatorUtil.goSellerMyMarketingRecordsDetailPage(  
242 - context, data[0].mid,  
243 - fromNotify: true);  
244 - } else {  
245 - //进入我的客情首页  
246 - NavigatorUtil.goMyCustomerPage(context);  
247 - } 218 + bool success = await getSellerVersion();
  219 + if (success) {
  220 + initPlatformState();
  221 + _getTableList();
  222 + _getSellerById();
  223 +
  224 + List<PullMarketingByUidSunModel> data =
  225 + Provider.of<UserModel>(context, listen: false)
  226 + .pullMarketingByUidSunModel;
  227 + if (data != null && Utils.getAuthority(context, '全店任务')) {
  228 + if (data.length > 0) {
  229 + Future.delayed(Duration(milliseconds: 300), () {
  230 + DialogUtil.cupertinoAlertDialog(context,
  231 + title: "全店任务",
  232 + content: "管理员发布了新的任务,请立即查看并完成任务",
  233 + lTitle: "稍后提醒",
  234 + rTitle: "立即查看", lCallback: () {
  235 + print("稍后提醒");
  236 + // 30分钟后重新弹窗
  237 + _startTimerSeller();
  238 + }, rCallback: () {
  239 + _endTimerSeller();
  240 + if (data.length == 1) {
  241 + //进入营销详情
  242 + NavigatorUtil.goSellerMyMarketingRecordsDetailPage(
  243 + context, data[0].mid,
  244 + fromNotify: true);
  245 + } else {
  246 + //进入我的客情首页
  247 + NavigatorUtil.goMyCustomerPage(context);
  248 + }
  249 + });
248 }); 250 });
249 - }); 251 + }
250 } 252 }
251 - }  
252 - if (widget.initialIndex == 0 ||  
253 - widget.initialIndex == 1 && needRefreshTemp == false) return;  
254 - _initNotification();  
255 - Future.delayed(Duration(milliseconds: 30000), () {  
256 - //30000  
257 - ContactModel.getInstance().uploadLocalContact(context);  
258 - UserModel usermodel = Provider.of<UserModel>(context, listen: false);  
259 -  
260 - if (needUpdate && !usermodel.downLoading) {  
261 - UpdateModelMy updateModel = new UpdateModelMy();  
262 - updateModel.checkUpdate(context, (version) {  
263 - updateModel.showUpdateDialog(context, version);  
264 - }, showToast: false); 253 + if (widget.initialIndex == 0 ||
  254 + widget.initialIndex == 1 && needRefreshTemp == false) return;
  255 + _initNotification();
  256 + Future.delayed(Duration(milliseconds: 30000), () {
  257 + //30000
  258 + ContactModel.getInstance().uploadLocalContact(context);
  259 + UserModel usermodel = Provider.of<UserModel>(context, listen: false);
  260 +
  261 + if (needUpdate && !usermodel.downLoading) {
  262 + UpdateModelMy updateModel = new UpdateModelMy();
  263 + updateModel.checkUpdate(context, (version) {
  264 + updateModel.showUpdateDialog(context, version);
  265 + }, showToast: false);
  266 + }
  267 + });
  268 +
  269 + if (Utils.getAuthority(context, '消息中心')) {
  270 + timer = Timer.periodic(Duration(minutes: 3), (_) {
  271 + _getAllUnMessages();
  272 + });
265 } 273 }
266 - });  
267 274
268 - if (Utils.getAuthority(context, '消息中心')) {  
269 - timer = Timer.periodic(Duration(minutes: 3), (_) {  
270 - _getAllUnMessages();  
271 - }); 275 + _getUnMsgNum();
272 } 276 }
273 -  
274 - _getUnMsgNum();  
275 }); 277 });
276 } 278 }
277 279
278 getSellerVersion() async { 280 getSellerVersion() async {
279 await collectStoreProvider.getSellerVersion(context); 281 await collectStoreProvider.getSellerVersion(context);
280 - if (collectStoreProvider.sellerVersionList != null) { 282 + if (collectStoreProvider.sellerVersionList != null &&
  283 + collectStoreProvider.sellerVersionList.length > 0) {
281 //获取到店铺过期时间 284 //获取到店铺过期时间
282 //店铺过期提醒 285 //店铺过期提醒
283 // 计算时间差 286 // 计算时间差
@@ -312,8 +315,21 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -312,8 +315,21 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
312 // //店铺过期日期 315 // //店铺过期日期
313 // _edateShow(); 316 // _edateShow();
314 // }); 317 // });
  318 + return true;
  319 + } else {
  320 + if (_currIndex != 4) {
  321 + if (App.sp.containsKey('sellerEdate')) {
  322 + List<String> data = App.sp.getStringList('sellerEdate');
  323 + if (data.contains('-1')) {
  324 + //已经弹过过期弹窗,默认我的
  325 + _currIndex = 4;
  326 + }
  327 + }
  328 + NavigatorUtil.goHomePage(context, initialIndex: _currIndex);
  329 + }
  330 +
  331 + return false;
315 } 332 }
316 - setState(() {});  
317 } 333 }
318 334
319 _getTableList() async { 335 _getTableList() async {
@@ -551,19 +567,19 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver { @@ -551,19 +567,19 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
551 Provider.of<StoreBaseIndoProvider>(context, listen: false); 567 Provider.of<StoreBaseIndoProvider>(context, listen: false);
552 sellerInfoSunModel = await storeBaseIndoProvider.getSellerById(context); 568 sellerInfoSunModel = await storeBaseIndoProvider.getSellerById(context);
553 if (sellerInfoSunModel != null) { 569 if (sellerInfoSunModel != null) {
554 - if (sellerInfoSunModel.data.edate != null) {  
555 -//获取到店铺过期时间  
556 - //店铺过期提醒  
557 - // 计算时间差  
558 - //店铺过期日期  
559 - _edateShow();  
560 - timerSellerEdate = Timer.periodic(Duration(days: 1), (_) {  
561 - //店铺过期提醒  
562 - // 计算时间差  
563 - //店铺过期日期  
564 - _edateShow();  
565 - });  
566 - } 570 +// if (sellerInfoSunModel.data.edate != null) {
  571 +// //获取到店铺过期时间
  572 +// //店铺过期提醒
  573 +// // 计算时间差
  574 +// //店铺过期日期
  575 +// _edateShow();
  576 +// timerSellerEdate = Timer.periodic(Duration(days: 1), (_) {
  577 +// //店铺过期提醒
  578 +// // 计算时间差
  579 +// //店铺过期日期
  580 +// _edateShow();
  581 +// });
  582 +// }
567 583
568 if (App.sp.containsKey('user')) { 584 if (App.sp.containsKey('user')) {
569 String s = App.sp.getString('user'); 585 String s = App.sp.getString('user');
@@ -93,7 +93,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -93,7 +93,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
93 ///获取积分 93 ///获取积分
94 _getMyIntegral(context); 94 _getMyIntegral(context);
95 95
96 - _getSellerById(); 96 + // _getSellerById();
97 97
98 ///apk版本检测 98 ///apk版本检测
99 checkUpdate(); 99 checkUpdate();
@@ -139,34 +139,34 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -139,34 +139,34 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
139 } 139 }
140 140
141 ///获取店铺过期时间 141 ///获取店铺过期时间
142 - _getSellerById() async {  
143 - StoreBaseIndoProvider storeBaseIndoProvider =  
144 - Provider.of<StoreBaseIndoProvider>(context, listen: false);  
145 - GetSellerInfoSunModel sellerInfoSunModel =  
146 - await storeBaseIndoProvider.getSellerById(context);  
147 - if (sellerInfoSunModel != null) {  
148 - if (sellerInfoSunModel.data.edate != null) {  
149 - //店铺过期提醒  
150 - // 计算时间差  
151 - //店铺过期日期  
152 - edate = DateTime.fromMillisecondsSinceEpoch(  
153 - int.parse(sellerInfoSunModel.data.edate) * 1000); 142 +// _getSellerById() async {
  143 +// StoreBaseIndoProvider storeBaseIndoProvider =
  144 +// Provider.of<StoreBaseIndoProvider>(context, listen: false);
  145 +// GetSellerInfoSunModel sellerInfoSunModel =
  146 +// await storeBaseIndoProvider.getSellerById(context);
  147 +// if (sellerInfoSunModel != null) {
  148 +// if (sellerInfoSunModel.data.edate != null) {
  149 +// //店铺过期提醒
  150 +// // 计算时间差
  151 +// //店铺过期日期
  152 +// edate = DateTime.fromMillisecondsSinceEpoch(
  153 +// int.parse(sellerInfoSunModel.data.edate) * 1000);
154 154
155 - String from =  
156 - DateUtil.formatDate(DateTime.now(), format: DateFormats.y_mo_d) +  
157 - ' 00:00:00';  
158 - DateTime datenow = DateUtil.getDateTime(from);  
159 - //比较相差的天数  
160 - int day = edate.difference(datenow).inDays;  
161 - outDay = day < 0 ? '0' : day.toString();  
162 - // print(outDay);  
163 - } else {  
164 - outDay = '';  
165 - }  
166 - setState(() {});  
167 -//  
168 - }  
169 - } 155 +// String from =
  156 +// DateUtil.formatDate(DateTime.now(), format: DateFormats.y_mo_d) +
  157 +// ' 00:00:00';
  158 +// DateTime datenow = DateUtil.getDateTime(from);
  159 +// //比较相差的天数
  160 +// int day = edate.difference(datenow).inDays;
  161 +// outDay = day < 0 ? '0' : day.toString();
  162 +// // print(outDay);
  163 +// } else {
  164 +// outDay = '';
  165 +// }
  166 +// setState(() {});
  167 +// //
  168 +// }
  169 +// }
170 170
171 ///获取短信余量 171 ///获取短信余量
172 _getSmsInfo(context) async { 172 _getSmsInfo(context) async {
@@ -204,7 +204,29 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -204,7 +204,29 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
204 204
205 getSellerVersion() async { 205 getSellerVersion() async {
206 await collectStoreProvider.getSellerVersion(context); 206 await collectStoreProvider.getSellerVersion(context);
  207 + if (collectStoreProvider.sellerNormal) {
  208 + if (collectStoreProvider.sellerNormalEdate != null) {
  209 + //店铺过期提醒
  210 + // 计算时间差
  211 + //店铺过期日期
  212 + edate = DateTime.fromMillisecondsSinceEpoch(
  213 + int.parse(collectStoreProvider.sellerNormalEdate) * 1000);
207 214
  215 + String from =
  216 + DateUtil.formatDate(DateTime.now(), format: DateFormats.y_mo_d) +
  217 + ' 00:00:00';
  218 + DateTime datenow = DateUtil.getDateTime(from);
  219 + //比较相差的天数
  220 + int day = edate.difference(datenow).inDays;
  221 + outDay = day < 0 ? '0' : day.toString();
  222 + // print(outDay);
  223 + } else {
  224 + outDay = '0';
  225 + }
  226 + setState(() {});
  227 + } else {
  228 + outDay = '0';
  229 + }
208 setState(() {}); 230 setState(() {});
209 } 231 }
210 232
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
2 import 'package:one_key/provider/user_model.dart'; 2 import 'package:one_key/provider/user_model.dart';
3 import 'package:provider/provider.dart'; 3 import 'package:provider/provider.dart';
4 4
  5 +import '../app.dart';
5 import '../constant/constant.dart'; 6 import '../constant/constant.dart';
6 import '../constant/error.dart'; 7 import '../constant/error.dart';
7 import '../models/seller_version_model.dart'; 8 import '../models/seller_version_model.dart';
@@ -21,6 +22,9 @@ class CollectStoreProvider with ChangeNotifier { @@ -21,6 +22,9 @@ class CollectStoreProvider with ChangeNotifier {
21 bool sellerFeast = false; //宴会 22 bool sellerFeast = false; //宴会
22 bool sellerPreserve = false; //客情维护 23 bool sellerPreserve = false; //客情维护
23 bool sellerMarketing = false; //客情营销 24 bool sellerMarketing = false; //客情营销
  25 + bool sellerNormal = false; //超能或者标准
  26 +
  27 + String sellerNormalEdate = '';
24 28
25 /// 收集店铺信息 29 /// 收集店铺信息
26 Future<dynamic> setSellerCollect( 30 Future<dynamic> setSellerCollect(
@@ -114,6 +118,31 @@ class CollectStoreProvider with ChangeNotifier { @@ -114,6 +118,31 @@ class CollectStoreProvider with ChangeNotifier {
114 element == '2' || 118 element == '2' ||
115 element == '3' || 119 element == '3' ||
116 element == '11'); 120 element == '11');
  121 +
  122 + sellerNormal = versionCodeList.any((element) =>
  123 + element == '1' ||
  124 + element == '2' ||
  125 + element == '3' ||
  126 + element == '4');
  127 + sellerVersionList.forEach((element) {
  128 + if (element.vid == '1' ||
  129 + element.vid == '2' ||
  130 + element.vid == '3' ||
  131 + element.vid == '4') {
  132 + sellerNormalEdate = element.edate;
  133 + }
  134 + });
  135 + if (!sellerNormal) {
  136 + //超能版或者标准版过期
  137 + App.sp.setStringList("sellerEdate", ['-1']);
  138 + } else {
  139 + if (App.sp.containsKey("sellerEdate")) {
  140 + App.sp.remove("sellerEdate");
  141 + }
  142 + }
  143 + }else{
  144 + //超能版或者标准版过期
  145 + App.sp.setStringList("sellerEdate", ['-1']);
117 } 146 }
118 147
119 return true; 148 return true;