From b9faef12a8742073f9919f0baa7e49e1dc25d04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=88=E5=93=88=E5=93=88?= Date: Sat, 7 Aug 2021 10:17:03 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/proguard-rules.pro | 10 ++++++++++ lib/address/address_map_page.dart | 5 +++-- lib/main_page.dart | 8 +++++++- 3 files changed, 20 insertions(+), 3 deletions(-) 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/lib/address/address_map_page.dart b/lib/address/address_map_page.dart index d2381ecf..5b9b153a 100644 --- a/lib/address/address_map_page.dart +++ b/lib/address/address_map_page.dart @@ -61,6 +61,7 @@ class _AddressMapPage extends State { 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/main_page.dart b/lib/main_page.dart index 9c783691..611fd619 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -63,7 +63,7 @@ class _MainPage extends State { queryUserInfo(); - /// @typed: 1文章 2活动 3店铺 4积分商品 + /// @typed: 1文章 2活动 3店铺 4积分商品 5订单 xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async { print("xgPushClickAction1: ${event.toString()}"); if (event["actionType"] == 2) return event; @@ -71,6 +71,12 @@ class _MainPage extends State { SharedPreferences.getInstance().then((value) { value.setString("pushData", event["customMessage"]); }); + print("ModalRoute: ${ModalRoute.of(context).isActive}"); + print("ModalRoute: ${ModalRoute.of(context).isCurrent}"); + print("ModalRoute: ${ModalRoute.of(context).isFirst}"); + if(ModalRoute.of(context).isActive && ModalRoute.of(context).isCurrent) { + pushRoute(); + } } return event; }, onReceiveNotificationResponse: (event) async { From 831c8be177dcf76e57f7d26cbf91564cc5c2508d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=88=E5=93=88=E5=93=88?= Date: Sat, 7 Aug 2021 10:37:00 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main_page.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/main_page.dart b/lib/main_page.dart index 611fd619..c57c0428 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -67,15 +67,17 @@ class _MainPage extends State { xgFlutterPlugin.addEventHandler(xgPushClickAction: (event) async { print("xgPushClickAction1: ${event.toString()}"); if (event["actionType"] == 2) return event; - if (event["actionType"] == 0 && event["customMessage"] != null) { + if (event["actionType"] == 0 && 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: ${ModalRoute.of(context).isActive}"); print("ModalRoute: ${ModalRoute.of(context).isCurrent}"); print("ModalRoute: ${ModalRoute.of(context).isFirst}"); if(ModalRoute.of(context).isActive && ModalRoute.of(context).isCurrent) { pushRoute(); + } else { + } } return event; From 4688239f66734a6b9df65dcf53a1b9f99029cd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=88=E5=93=88=E5=93=88?= Date: Sat, 7 Aug 2021 11:40:18 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main_page.dart | 34 ++++++++++++++++++++--------- lib/utils/native_event_handler.dart | 28 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 lib/utils/native_event_handler.dart diff --git a/lib/main_page.dart b/lib/main_page.dart index c57c0428..3912e689 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,21 +63,35 @@ class _MainPage extends State { queryUserInfo(); + 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[Platform.isAndroid ? "customMessage" : "custom"] != 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[Platform.isAndroid ? "customMessage" : "custom"]); + value.setString("pushData", + event[Platform.isAndroid ? "customMessage" : "custom"]); }); print("ModalRoute: ${ModalRoute.of(context).isActive}"); print("ModalRoute: ${ModalRoute.of(context).isCurrent}"); print("ModalRoute: ${ModalRoute.of(context).isFirst}"); - if(ModalRoute.of(context).isActive && ModalRoute.of(context).isCurrent) { + if (ModalRoute.of(context).isActive && + ModalRoute.of(context).isCurrent) { pushRoute(); - } else { - } } return event; @@ -88,7 +102,6 @@ class _MainPage extends State { print("onReceiveMessage: ${event.toString()}"); return event; }); - } pushRoute() async { @@ -99,7 +112,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"]; @@ -127,7 +140,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/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 From 4b0d2156fcd7e869f7f4b2e6b984dbce2786cd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=88=E5=93=88=E5=93=88?= Date: Sat, 7 Aug 2021 11:56:16 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/src/main/kotlin/com/zsw/huixiang/MainActivity.kt | 3 +++ lib/main_page.dart | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/kotlin/com/zsw/huixiang/MainActivity.kt b/android/app/src/main/kotlin/com/zsw/huixiang/MainActivity.kt index 2a13c235..1667e29d 100644 --- a/android/app/src/main/kotlin/com/zsw/huixiang/MainActivity.kt +++ b/android/app/src/main/kotlin/com/zsw/huixiang/MainActivity.kt @@ -1,6 +1,7 @@ package com.zsw.huixiang import android.os.Bundle +import android.util.Log import io.dcloud.feature.sdk.DCUniMPSDK import io.flutter.embedding.android.FlutterActivity @@ -11,6 +12,8 @@ class MainActivity: FlutterActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + Log.e("intentUrl:", "url: ${intent.data}" ) + flutterEngine?.plugins?.add(MinPlugin()) } diff --git a/lib/main_page.dart b/lib/main_page.dart index 3912e689..0eca8fee 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -86,9 +86,9 @@ class _MainPage extends State { value.setString("pushData", event[Platform.isAndroid ? "customMessage" : "custom"]); }); - print("ModalRoute: ${ModalRoute.of(context).isActive}"); - print("ModalRoute: ${ModalRoute.of(context).isCurrent}"); - print("ModalRoute: ${ModalRoute.of(context).isFirst}"); + 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(); From 3bf36b7e5dc4b5dd24a35b51a6db624984765016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=88=E5=93=88=E5=93=88?= Date: Sat, 7 Aug 2021 13:35:56 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 10 ++++++++++ lib/main_page.dart | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 65e66c38..812c6f2e 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -59,6 +59,16 @@ + + + + + + + { if (ModalRoute.of(context).isActive && ModalRoute.of(context).isCurrent) { pushRoute(); + } else { + Navigator.of(context).pushNamedAndRemoveUntil('/router/main_page', (route) => false); } } return event; @@ -129,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"); From 68cc9b4842ae3e010499fe9938d5c38ad9a1a65a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=93=88=E5=93=88=E5=93=88?= Date: Sat, 7 Aug 2021 15:13:25 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 5 ++--- lib/integral/integral_page.dart | 2 +- lib/login/login_page.dart | 6 +----- lib/retrofit/retrofit_api.dart | 9 ++++----- lib/union/union_page.dart | 2 +- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 812c6f2e..c548f123 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -65,9 +65,8 @@ + android:scheme="huixiang" + android:host="com.zsw.huixiang"/> { .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/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,