From a0df048fc48f2e56a45adb038bea2b413969a580 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Fri, 7 May 2021 10:45:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=81=AB=E8=AD=A6=E6=8E=A8?= =?UTF-8?q?=E9=80=81=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=B7=A1=E6=9B=B4=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 3 +- lib/main.dart | 3 + .../inspection_point_detail_page.dart | 3 +- lib/utils/jpush_message_parse.dart | 59 +++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 lib/utils/jpush_message_parse.dart diff --git a/lib/const/api.dart b/lib/const/api.dart index f8daa80..b80cdfb 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -1,6 +1,6 @@ class API { ///HOST - static const String host = 'http://test.akuhotel.com:8804'; + static const String host = 'http://39.103.177.88:8804'; ///接口基础地址 static const String baseURL = '$host/IntelligentCommunity/butlerApp'; @@ -185,7 +185,6 @@ class _Manage { ///巡检管理:上传巡检定位信息(开始巡检后,每n秒上传一次) String get uploadLocation => '/user/inspection/uploadLocation'; - } class _Upload { diff --git a/lib/main.dart b/lib/main.dart index 9dd0dc4..cf4ff4c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,6 +11,7 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:jpush_flutter/jpush_flutter.dart'; +import 'package:power_logger/power_logger.dart'; import 'package:provider/provider.dart'; // Project imports: @@ -31,6 +32,7 @@ void main() async { // 接收通知回调方法。 onReceiveNotification: (Map message) async { print("flutter onReceiveNotification: $message"); + LoggerData.addData(message); }, // 点击通知回调方法。 onOpenNotification: (Map message) async { @@ -47,6 +49,7 @@ void main() async { production: false, debug: true, // 设置是否打印 debug 日志 ); + print(jpush.getRegistrationID()); runApp(MyApp()); } diff --git a/lib/ui/manage_pages/inspection_manage/inspection_point_detail_page.dart b/lib/ui/manage_pages/inspection_manage/inspection_point_detail_page.dart index 0b3a38e..9ea24ef 100644 --- a/lib/ui/manage_pages/inspection_manage/inspection_point_detail_page.dart +++ b/lib/ui/manage_pages/inspection_manage/inspection_point_detail_page.dart @@ -289,7 +289,8 @@ class _InspectionPointDetailPageState extends State { ), padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 24.w), - child: model.remakes.text + child: (model?.remakes ?? '') + .text .color(kTextPrimaryColor) .size(28.sp) .make(), diff --git a/lib/utils/jpush_message_parse.dart b/lib/utils/jpush_message_parse.dart new file mode 100644 index 0000000..b29d34c --- /dev/null +++ b/lib/utils/jpush_message_parse.dart @@ -0,0 +1,59 @@ +import 'dart:convert'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class JpushMessageParse { + final Map message; + String subTitle; + String type = '0'; + JpushMessageParse(Map rawMessage) + : message = Map.from(rawMessage); + + Future shot() async { + subTitle = message['alert']; + Map rawExtras = message['extras']; + String androidExtra = rawExtras['cn.jpush.android.EXTRA']; + if (androidExtra == null) { + return; + } else { + Map _innerMap = jsonDecode(androidExtra); + type = _innerMap['type'] ?? '0'; + switch (type) { + case '1': + await fireAlert(subTitle); + break; + default: + } + } + } + + Future fireAlert(String subTitle) async { + await Get.dialog( + CupertinoAlertDialog( + title: Text('发现火灾!请立刻组织疏散人群!'), + content: Column( + children: [ + Text(subTitle), + 10.w.heightBox, + Icon( + CupertinoIcons.bell_fill, + color: Colors.red, + size: 48.w, + ), + ], + ), + actions: [ + CupertinoDialogAction( + child: Text('确认'), + onPressed: () => Get.back(), + ), + ], + ), + barrierDismissible: false, + ); + } +}