From a7bbacbd47fc40a39e1e1c2db48cccc30bb7f29e Mon Sep 17 00:00:00 2001 From: zhongweiguang Date: Fri, 25 Jun 2021 13:30:34 +0800 Subject: [PATCH] =?UTF-8?q?android:=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1QrCode=E4=BF=A1=E6=81=AF=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=BF=A1=E6=81=AF=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 2 +- .../com/finogeeks/mop/api/ApisManager.java | 2 + .../finogeeks/mop/api/mop/WXQrCodeModule.java | 48 +++++++++++++++++++ lib/mop.dart | 3 ++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 android/src/main/java/com/finogeeks/mop/api/mop/WXQrCodeModule.java diff --git a/android/build.gradle b/android/build.gradle index 270a1b7..f18015d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.31.0-alpha20210625v01' + implementation 'com.finogeeks.lib:finapplet:2.31.0-alpha20210624v06' implementation 'com.finogeeks.mop:plugins:2.30.2' } \ No newline at end of file diff --git a/android/src/main/java/com/finogeeks/mop/api/ApisManager.java b/android/src/main/java/com/finogeeks/mop/api/ApisManager.java index 39bdfee..168793e 100644 --- a/android/src/main/java/com/finogeeks/mop/api/ApisManager.java +++ b/android/src/main/java/com/finogeeks/mop/api/ApisManager.java @@ -10,6 +10,7 @@ import com.finogeeks.mop.api.mop.BaseModule; import com.finogeeks.mop.api.mop.ExtensionApiModule; import com.finogeeks.mop.api.mop.VersionModule; import com.finogeeks.mop.api.mop.SmSignModule; +import com.finogeeks.mop.api.mop.WXQrCodeModule; import com.finogeeks.mop.interfaces.Event; import com.finogeeks.mop.interfaces.IApi; @@ -71,6 +72,7 @@ public class ApisManager { add(new ExtensionApiModule(activity)); add(new VersionModule(activity)); add(new SmSignModule(activity)); + add(new WXQrCodeModule(activity)); } private void add(IApi api) { diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/WXQrCodeModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/WXQrCodeModule.java new file mode 100644 index 0000000..2fc0174 --- /dev/null +++ b/android/src/main/java/com/finogeeks/mop/api/mop/WXQrCodeModule.java @@ -0,0 +1,48 @@ +package com.finogeeks.mop.api.mop; + +import android.content.Context; + +import com.finogeeks.lib.applet.client.FinAppClient; +import com.finogeeks.lib.applet.modules.callback.FinSimpleCallback; +import com.finogeeks.lib.applet.sdk.model.ParsedAppletInfo; +import com.finogeeks.mop.api.BaseApi; +import com.finogeeks.mop.interfaces.ICallback; + +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +public class WXQrCodeModule extends BaseApi { + + public WXQrCodeModule(Context context) { + super(context); + } + + @Override + public String[] apis() { + return new String[]{"parseAppletInfoFromWXQrCode"}; + } + + @Override + public void invoke(String event, Map param, ICallback callback) { + String qrCode = (String) param.get("qrCode"); + String apiServer = (String) param.get("apiServer"); + FinAppClient.INSTANCE.getAppletApiManager().parseAppletInfoFromWXQrCode( + qrCode, + apiServer, + new FinSimpleCallback() { + @Override + public void onSuccess(ParsedAppletInfo appletInfo) { + HashMap map = new HashMap<>(); + map.put("appId", appletInfo != null ? appletInfo.getAppId() : null); + callback.onSuccess(map); + } + + @Override + public void onError(int code, @Nullable String error) { + callback.onFail(code + ", " + error); + } + }); + } +} diff --git a/lib/mop.dart b/lib/mop.dart index 524639e..aa0f70f 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -165,6 +165,9 @@ class Mop { return await _channel.invokeMapMethod("scanOpenApplet", params); } + /// + /// 根据微信QrCode信息解析小程序信息 + /// Future> parseAppletInfoFromWXQrCode( String qrCode, String apiServer) async { final ret = await _channel.invokeMapMethod("parseAppletInfoFromWXQrCode",