From 6e75fe48e75e3c990689ae785c6354fc9c19634a Mon Sep 17 00:00:00 2001 From: gaoyunfei Date: Sun, 22 May 2022 17:37:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=87=E6=8D=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../finogeeks/mop/api/mop/AppletModule.java | 18 +++++++++++++++++- .../com/finogeeks/mop/api/mop/BaseModule.java | 4 ++-- lib/mop.dart | 6 ++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java index cfab8ad..0dc67cd 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java @@ -30,7 +30,7 @@ public class AppletModule extends BaseApi { @Override public String[] apis() { - return new String[]{"openApplet", "scanOpenApplet","qrcodeOpenApplet"}; + return new String[]{"openApplet", "scanOpenApplet","qrcodeOpenApplet", "changeUserId"}; } @Override @@ -41,6 +41,8 @@ public class AppletModule extends BaseApi { scanOpenApplet(param, callback); } else if ("qrcodeOpenApplet".equals(event)){ qrcodeOpenApplet(param,callback); + } else if ("changeUserId".equals(event)) { + changeUserId(param, callback); } } @@ -138,4 +140,18 @@ public class AppletModule extends BaseApi { } }); } + + private void changeUserId(Map param, ICallback callback) { + String userId = String.valueOf(param.get("userId")); + if (FinAppClient.INSTANCE.getFinAppConfig() != null) { + FinAppClient.INSTANCE.getFinAppConfig().setUserId(userId); + callback.onSuccess(new HashMap()); + } else { + callback.onFail(new HashMap(){ + { + put("info", "sdk not initilized"); + } + }); + } + } } diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java index 627a43d..8cb637f 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java @@ -121,8 +121,8 @@ public class BaseModule extends BaseApi { .setUserId(userId) .setDebugMode(debug) .setDisableRequestPermissions(disablePermission) - .setBindAppletWithMainProcess(bindAppletWithMainProcess) - .setPageCountLimit(pageCountLimit); + .setBindAppletWithMainProcess(bindAppletWithMainProcess); +// .setPageCountLimit(pageCountLimit); if (customWebViewUserAgent != null) builder.setCustomWebViewUserAgent(customWebViewUserAgent); diff --git a/lib/mop.dart b/lib/mop.dart index 9490270..014c290 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -387,6 +387,12 @@ class Mop { return Map.from(ret!); } + Future> changeUserId(String userId) async { + Map params = {'userId': userId}; + final ret = await _channel.invokeMapMethod("changeUserId", params); + return Map.from(ret!); + } + /// /// close all running applets /// 关闭当前打开的所有小程序