diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index a2053995..1ab628de 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -20,6 +20,16 @@ -keep class com.baidu.vi.** {*;} -dontwarn com.baidu.** +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep class com.tencent.android.tpush.** {*;} +-keep class com.tencent.tpns.baseapi.** {*;} +-keep class com.tencent.tpns.mqttchannel.** {*;} +-keep class com.tencent.tpns.dataacquisition.** {*;} + +-keep class com.tencent.bigdata.baseapi.** {*;} +-keep class com.tencent.bigdata.mqttchannel.** {*;} + #andResGuard { # whiteList = [ # "R.layout.mob_authorize_*", diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 65e66c38..c548f123 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -59,6 +59,15 @@ + + + + + + + { if (aMapFlutterLocation == null) { aMapFlutterLocation = LocationFlutterPlugin(); + aMapFlutterLocation.requestPermission(); aMapFlutterLocation.onResultCallback().listen((event) { print("event: ${jsonEncode(event)}"); if (event != null && @@ -144,7 +145,7 @@ class _AddressMapPage extends State { BMFPoiNearbySearch bmfPoiNearbySearch = BMFPoiNearbySearch(); bmfPoiNearbySearch.onGetPoiNearbySearchResult( callback: (BMFPoiSearchResult result, BMFSearchErrorCode errorCode) { - if ((DateTime.now().millisecondsSinceEpoch - time) > 2000) { + // if ((DateTime.now().millisecondsSinceEpoch - time) > 2000) { result.poiInfoList.map((e) => print("sssssssssss:${e.toMap()}")); poiList = result.poiInfoList .map((e) => Address.fromJson({ @@ -167,7 +168,7 @@ class _AddressMapPage extends State { setState(() { time = DateTime.now().millisecondsSinceEpoch; }); - } + // } }); bmfPoiNearbySearch.poiNearbySearch(BMFPoiNearbySearchOption( keywords: ["all"], diff --git a/lib/integral/integral_page.dart b/lib/integral/integral_page.dart index 6e6aaa60..98fc9740 100644 --- a/lib/integral/integral_page.dart +++ b/lib/integral/integral_page.dart @@ -67,7 +67,7 @@ class _IntegralPage extends State { .indexWhere((element) => element.id == userinfo.memberRankVo.id) + 1); } - SmartDialog.dismiss(); + SmartDialog.dismiss(closeType: 3); if (baseData != null && baseData.isSuccess) { signInfo = SignInfo.fromJson(baseData.data); setState(() {}); diff --git a/lib/login/login_page.dart b/lib/login/login_page.dart index 41bd1080..0a835d0e 100644 --- a/lib/login/login_page.dart +++ b/lib/login/login_page.dart @@ -289,11 +289,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { xgFlutterPlugin.bindWithIdentifier( identify: mobile, bindType: XGBindType.account); - if (widget.arguments != null) { - Navigator.of(context).pop(); - } else { - Navigator.of(context).popAndPushNamed('/router/main_page'); - } + Navigator.of(context).pushNamedAndRemoveUntil('/router/main_page', (route) => false); } else { SmartDialog.showToast("${value.msg}", alignment: Alignment.center); } diff --git a/lib/main_page.dart b/lib/main_page.dart index 9c783691..7805564b 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -12,6 +12,7 @@ import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/union/union_page.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/utils/event_type.dart'; +import 'package:huixiang/utils/native_event_handler.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -23,7 +24,6 @@ class MainPage extends StatefulWidget { } class _MainPage extends State { - List _widgetOptions; List icons; @@ -63,14 +63,38 @@ class _MainPage extends State { queryUserInfo(); - /// @typed: 1文章 2活动 3店铺 4积分商品 + if (Platform.isAndroid) { + xgFlutterPlugin.getXgAndroidApi().addNativeEventHandler( + MyNativeEventHandler((String title, String message, + String customContent, int type) { + print("xgPushClickAction2: $customContent"); + SharedPreferences.getInstance().then((value) { + value.setString("pushData", customContent); + }); + })); + } + + /// @typed: 1文章 2活动 3店铺 4积分商品 5订单 xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async { - print("xgPushClickAction1: ${event.toString()}"); + print("xgPushClickAction1: $event"); if (event["actionType"] == 2) return event; - if (event["actionType"] == 0 && event["customMessage"] != null) { + if (Platform.isAndroid + ? (event["actionType"] == 0) + : (event["xg"]["msgtype"] == 1) && + event[Platform.isAndroid ? "customMessage" : "custom"] != null) { SharedPreferences.getInstance().then((value) { - value.setString("pushData", event["customMessage"]); + value.setString("pushData", + event[Platform.isAndroid ? "customMessage" : "custom"]); }); + print("ModalRoute isActive: ${ModalRoute.of(context).isActive}"); + print("ModalRoute isCurrent: ${ModalRoute.of(context).isCurrent}"); + print("ModalRoute isFirst: ${ModalRoute.of(context).isFirst}"); + if (ModalRoute.of(context).isActive && + ModalRoute.of(context).isCurrent) { + pushRoute(); + } else { + Navigator.of(context).pushNamedAndRemoveUntil('/router/main_page', (route) => false); + } } return event; }, onReceiveNotificationResponse: (event) async { @@ -80,7 +104,6 @@ class _MainPage extends State { print("onReceiveMessage: ${event.toString()}"); return event; }); - } pushRoute() async { @@ -91,7 +114,7 @@ class _MainPage extends State { if (pushMap != null) { String routeName = ""; Map params = {}; - switch(pushMap["typed"]) { + switch (pushMap["typed"]) { case 1: routeName = "/router/store_detail_page"; params["articleId"] = pushMap["info"]; @@ -108,6 +131,10 @@ class _MainPage extends State { routeName = "/router/integral_store_page"; params["goodsId"] = pushMap["info"]; break; + case 5: + routeName = "/router/order_details"; + params["id"] = pushMap["info"]; + break; } sharedPreferences.setString("pushData", ""); print("xgPushClickAction: routeName: $routeName"); @@ -119,7 +146,8 @@ class _MainPage extends State { queryUserInfo() async { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); - if (sharedPreferences.getString("token") == null || sharedPreferences.getString("token") == "") return; + if (sharedPreferences.getString("token") == null || + sharedPreferences.getString("token") == "") return; BaseData baseDate = await ApiService(Dio(), context: context, token: sharedPreferences.getString('token')) .queryInfo(); diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 4b50c67c..700e9905 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -14,12 +14,11 @@ import 'package:shared_preferences/shared_preferences.dart'; part 'retrofit_api.g.dart'; -// const base_url = "http://platform.test.api.lotus-wallet.com/app/";/// 测试 -const base_url = "https://pos.platform.lotus-wallet.com/app/"; -// const baseUrl = "http://platform.test.api.lotus-wallet.com/app/";/// 测试 -const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; +const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 + +// const base_url = "http://192.168.10.236:8766/app/"; // const baseUrl = "http://192.168.10.236:8766/app/";/// 本地 -// const baseUrl = "http://192.168.10.129:8766/app/"; /// 本地 @RestApi(baseUrl: baseUrl) abstract class ApiService { diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index f600d5aa..74bd2220 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -269,7 +269,7 @@ class _UnionPage extends State PreferredSize( preferredSize: Size(double.infinity, 52.h), child: Container( - padding: EdgeInsets.only(top: 26.5.h), + padding: EdgeInsets.only(top: 20.h), color: Color(0xFFFAFAFA), child: ItemTitle( text: S.of(context).jingbilianmenghuiyuandian, diff --git a/lib/utils/native_event_handler.dart b/lib/utils/native_event_handler.dart new file mode 100644 index 00000000..03120c5e --- /dev/null +++ b/lib/utils/native_event_handler.dart @@ -0,0 +1,28 @@ + + + +import 'package:tpns_flutter_plugin/android/native_event_handler.dart'; + +class MyNativeEventHandler extends NativeEventHandler { + + final Function(String title, String message, String customContent, int type) notifyClick; + + MyNativeEventHandler(this.notifyClick); + + @override + void onRegisterPushFail(String message, int code) { + + } + + @override + void onRegisterPushSuccess(String token) { + + } + + @override + void onNotifactionClickedResult(String title, String message, String customContent, int type) { + super.onNotifactionClickedResult(title, message, customContent, type); + this.notifyClick(title, message, customContent, type); + } + +} \ No newline at end of file