|
@@ -1,4 +1,4 @@
|
|
|
-import 'dart:async';
|
|
|
+
|
|
|
|
|
|
// import 'package:amap_all_fluttify/amap_all_fluttify.dart';
|
|
|
import 'package:amap_location_flutter_plugin/amap_location_flutter_plugin.dart';
|
|
@@ -37,6 +37,7 @@ import 'package:liftmanager/internal/news/news_router.dart';
|
|
|
import 'package:uni_links/uni_links.dart';
|
|
|
import 'package:liftmanager/utils/theme_utils.dart';
|
|
|
import 'package:fluwx/fluwx.dart' as fluwx;
|
|
|
+import 'dart:async';
|
|
|
|
|
|
class BbsPage extends StatefulWidget {
|
|
|
@override
|
|
@@ -54,7 +55,6 @@ class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
|
|
|
StreamSubscription<Map<String, Object>> _locationListener;
|
|
|
Map<String, Object> _locationResult;
|
|
|
int _index = 0;
|
|
|
- Timer _timer;
|
|
|
String _keyword;
|
|
|
int _page = 1;
|
|
|
List<String> menuTitle = ["案例中心", "视频学堂", "在线商城", "招聘专区", "资料库"];
|
|
@@ -124,17 +124,12 @@ class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
|
|
|
_locationPlugin.stopLocation();
|
|
|
_locationResult = result;
|
|
|
// address latitude longitude
|
|
|
- _locationResult.forEach((key, value) {
|
|
|
- if(key == 'city'){
|
|
|
- cityName = '$value';
|
|
|
- setState(() {
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
- print(111);
|
|
|
- print('key:$key :');
|
|
|
- print('value:$value :');
|
|
|
- });
|
|
|
+ lat = _locationResult["latitude"];
|
|
|
+ lng = _locationResult["longitude"];
|
|
|
+ cityName = _locationResult["city"];
|
|
|
+ if(FlutterStars.SpUtil.getString(Constant.userId) != "-1") {
|
|
|
+ isDelayAddress();
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -173,8 +168,25 @@ class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
|
|
|
setState(() {});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ Timer _timer;
|
|
|
+ void startTimer(int intervalTime) {
|
|
|
+ //设置 intervalTime 秒回调一次
|
|
|
+ print(1234);
|
|
|
+ Duration period = Duration(minutes: intervalTime);
|
|
|
+ _timer = Timer.periodic(period, (timer) {
|
|
|
+ print(1236);
|
|
|
+ getStartDelayAddress();
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ void cancelTimer() {
|
|
|
+ if (_timer != null) {
|
|
|
+ _timer.cancel();
|
|
|
+ _timer = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ double lat;
|
|
|
+ double lng;
|
|
|
Widget bannerLastWidget;
|
|
|
List<dynamic> bannerList;
|
|
|
List<dynamic> questionsList;
|
|
@@ -183,9 +195,43 @@ class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
|
|
|
List<dynamic> shopList;
|
|
|
List<dynamic> positionList;
|
|
|
bool isCustom = false;
|
|
|
+ Future isDelayAddress() async {
|
|
|
+ await NewApiService().isDelayAddress(onSuccess: (res) {
|
|
|
+ print("665-------------------////");
|
|
|
+ print(res["id"]);
|
|
|
+ print(jsonEncode(res));
|
|
|
+ print("666-------------------////");
|
|
|
+ if(res["isPush"]!=null && res["isPush"] == 1){
|
|
|
+ getStartDelayAddress();
|
|
|
+ startTimer(res["intervalTime"]);
|
|
|
+ }
|
|
|
+ //intervalTime:时间间隔分钟 ; isPush:1推送 2不推送
|
|
|
+ }, onError: (code, msg) {
|
|
|
+ toasts(msg);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ Future getStartDelayAddress() async {
|
|
|
+ String position = lat.toString() +","+ lng.toString();
|
|
|
+ await NewApiService().startDelayAddress(
|
|
|
+ {
|
|
|
+ "mobile":FlutterStars.SpUtil.getString(Constant.phone),
|
|
|
+ "mtCompanyId":FlutterStars.SpUtil.getString(Constant.companyId)!=""?int.parse(FlutterStars.SpUtil.getString(Constant.companyId)):"",
|
|
|
+ "position":position,
|
|
|
+ "userId":int.parse(FlutterStars.SpUtil.getString(Constant.userId))
|
|
|
+ }
|
|
|
+ ,onSuccess: (res) {
|
|
|
+
|
|
|
+ print("668-------------------////");
|
|
|
+
|
|
|
+ }, onError: (code, msg) {
|
|
|
+ toasts(msg);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
Future getBannerList() async {
|
|
|
await NewApiService().getBanner(1, 10, onSuccess: (BannerModel res) {
|
|
|
- print(jsonEncode(res));
|
|
|
+ // print(jsonEncode(res));
|
|
|
// print(JsonEncoder().convert(res.records));
|
|
|
bannerList = res.records;
|
|
|
bannerLastWidget = SwipeWidget(banners: bannerList,);
|
|
@@ -199,8 +245,8 @@ class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
|
|
|
Future getNotificaList() async {
|
|
|
display = true;
|
|
|
await NewApiService().myNotificaList(1, 10, onSuccess: (res) {
|
|
|
- print(jsonEncode(res));
|
|
|
- print(JsonEncoder().convert(res.records));
|
|
|
+ // print(jsonEncode(res));
|
|
|
+ // print(JsonEncoder().convert(res.records));
|
|
|
res.records.forEach((item){
|
|
|
if(item.viewFlag == 0){
|
|
|
setState(() {
|
|
@@ -209,7 +255,6 @@ class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
|
|
|
return;
|
|
|
}
|
|
|
});
|
|
|
- print("////////////////////////66666");
|
|
|
// print(bannerList.length);
|
|
|
setState(() {});
|
|
|
}, onError: (code, msg) {
|
|
@@ -220,7 +265,7 @@ class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
|
|
|
Future getNewsList() async {
|
|
|
await NewApiService().newsList(1, 3, 1, "", cityName, onSuccess: (res) {
|
|
|
newsList = res.topNews;
|
|
|
- print(JsonEncoder().convert(res.topNews));
|
|
|
+ // print(JsonEncoder().convert(res.topNews));
|
|
|
setState(() {});
|
|
|
}, onError: (code, msg) {
|
|
|
toasts(msg);
|
|
@@ -294,6 +339,7 @@ class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
|
|
|
_locationPlugin.destroy();
|
|
|
}
|
|
|
super.dispose();
|
|
|
+ cancelTimer();
|
|
|
}
|
|
|
|
|
|
static const diagnosisObj = [
|