From 5cc95b4affa187d47c9362f28fcea1906fd3481b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Sat, 10 Apr 2021 18:16:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96UDid?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flutter_alibc/FlutterAlibcHandle.java | 8 +++ .../flutter_alibc/FlutterAlibcPlugin.java | 2 + lib/flutter_alibc.dart | 60 ++++++++----------- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java b/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java index 332463e..cc5a797 100644 --- a/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java +++ b/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcHandle.java @@ -35,6 +35,7 @@ import com.baichuan.nb_trade.auth.TopAuth; import com.baichuan.nb_trade.callback.AlibcTradeInitCallback; import com.baichuan.nb_trade.callback.AuthCallback; import com.baichuan.nb_trade.core.AlibcTradeSDK; +import com.ut.device.UTDevice; import com.wxwx.flutter_alibc.web.WebViewActivity; import java.util.Map; @@ -489,5 +490,12 @@ public class FlutterAlibcHandle { // AlibcTradeSDK.setShouldUseAlipay(call.argument("isNeed")); } + public void getUdid(MethodCall call) { + String udid = UTDevice.getUtdid(register.activity().getApplicationContext()); + Map resMap = new HashMap(); + resMap.put("udid", udid); + result.success(resMap); + } + } \ No newline at end of file diff --git a/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java b/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java index 8173bae..eed04fe 100644 --- a/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java +++ b/android/src/main/java/com/wxwx/flutter_alibc/FlutterAlibcPlugin.java @@ -43,6 +43,8 @@ public class FlutterAlibcPlugin implements MethodCallHandler { handle.syncForTaoke(call); }else if (call.method.equals("useAlipayNative")){ handle.useAlipayNative(call); + }if (call.method.equals("getUdid")){ + handle.useAlipayNative(call); }else { result.notImplemented(); } diff --git a/lib/flutter_alibc.dart b/lib/flutter_alibc.dart index e872b53..9f83124 100644 --- a/lib/flutter_alibc.dart +++ b/lib/flutter_alibc.dart @@ -37,10 +37,8 @@ class FlutterAlibc { /// errorMessage, //message ///} static Future initAlibc({String version, String appName}) async { - Map result = await _channel - .invokeMethod("initAlibc", {"version": version, "appName": appName}); - return InitModel( - result[AlibcConstKey.errorCode], result[AlibcConstKey.errorMessage]); + Map result = await _channel.invokeMethod("initAlibc", {"version": version, "appName": appName}); + return InitModel(result[AlibcConstKey.errorCode], result[AlibcConstKey.errorMessage]); } /// @@ -57,15 +55,9 @@ class FlutterAlibc { result[AlibcConstKey.errorMessage], ); } - return LoginModel( - result[AlibcConstKey.errorCode], result[AlibcConstKey.errorMessage], - data: UserModel( - result[AlibcConstKey.data]["nick"], - result[AlibcConstKey.data]["avatarUrl"], - result[AlibcConstKey.data]["openId"], - result[AlibcConstKey.data]["openSid"], - result[AlibcConstKey.data]["topAccessToken"], - result[AlibcConstKey.data]["topAuthCode"])); + return LoginModel(result[AlibcConstKey.errorCode], result[AlibcConstKey.errorMessage], + data: UserModel(result[AlibcConstKey.data]["nick"], result[AlibcConstKey.data]["avatarUrl"], result[AlibcConstKey.data]["openId"], result[AlibcConstKey.data]["openSid"], + result[AlibcConstKey.data]["topAccessToken"], result[AlibcConstKey.data]["topAuthCode"])); } /// @@ -86,8 +78,7 @@ class FlutterAlibc { @required String url, AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, bool isNeedCustomNativeFailMode = false, - AlibcNativeFailMode nativeFailMode = - AlibcNativeFailMode.AlibcNativeFailModeNone, + AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTaoBao, TaokeParams taokeParams, String backUrl, @@ -111,10 +102,7 @@ class FlutterAlibc { /// name app名字 /// alibcAppKey 百川Key /// Map - static Future> taoKeLoginNew( - String name, - String alibcAppKey) async { - + static Future> taoKeLoginNew(String name, String alibcAppKey) async { Map result = await _channel.invokeMethod("taoKeLoginNew", { "name": name, "alibcAppKey": alibcAppKey, @@ -135,17 +123,15 @@ class FlutterAlibc { /// backUrl: 跳转回来的url /// @return: /// - static Future openByUrl({ - @required String url, - AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, - bool isNeedCustomNativeFailMode = false, - AlibcNativeFailMode nativeFailMode = - AlibcNativeFailMode.AlibcNativeFailModeNone, - AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, - TaokeParams taokeParams, - String backUrl, - bool isAuth = false - }) async { + static Future openByUrl( + {@required String url, + AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, + bool isNeedCustomNativeFailMode = false, + AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, + AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, + TaokeParams taokeParams, + String backUrl, + bool isAuth = false}) async { Map taoKe = AlibcTools.getTaokeMap(taokeParams); var result = await _channel.invokeMethod("openByUrl", { "url": url, @@ -188,8 +174,7 @@ class FlutterAlibc { // bool isNeedPush = false, AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, bool isNeedCustomNativeFailMode = false, - AlibcNativeFailMode nativeFailMode = - AlibcNativeFailMode.AlibcNativeFailModeNone, + AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, TaokeParams taokeParams, // 额外需要追踪的业务数据 @@ -224,8 +209,7 @@ class FlutterAlibc { // bool isNeedPush = false, AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, bool isNeedCustomNativeFailMode = false, - AlibcNativeFailMode nativeFailMode = - AlibcNativeFailMode.AlibcNativeFailModeNone, + AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, TaokeParams taokeParams, // 额外需要追踪的业务数据 @@ -259,8 +243,7 @@ class FlutterAlibc { // bool isNeedPush = false, AlibcOpenType openType = AlibcOpenType.AlibcOpenTypeAuto, bool isNeedCustomNativeFailMode = false, - AlibcNativeFailMode nativeFailMode = - AlibcNativeFailMode.AlibcNativeFailModeNone, + AlibcNativeFailMode nativeFailMode = AlibcNativeFailMode.AlibcNativeFailModeNone, AlibcSchemeType schemeType = AlibcSchemeType.AlibcSchemeTmall, TaokeParams taokeParams, // 额外需要追踪的业务数据 @@ -292,4 +275,9 @@ class FlutterAlibc { static useAlipayNative(bool isNeed) { _channel.invokeMethod("useAlipayNative", {"isNeed": isNeed}); } + + static Future getUdid(bool isNeed) async { + var map = await _channel.invokeMethod("getUdid"); + return map['udid']; + } }