wanghualei 2020-12-10 17:17:20 +08:00
commit 3f52ba9606
4 changed files with 70 additions and 16 deletions

View File

@ -91,5 +91,6 @@ kapt {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.finogeeks.lib:finapplet:2.12.31'
implementation 'com.finogeeks.lib:finapplet:2.13.13'
implementation 'com.finogeeks.mop:plugins:0.0.23'
}

View File

@ -4,6 +4,8 @@ import android.content.Context;
import android.util.Log;
import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.client.FinAppInfo;
import com.finogeeks.mop.api.BaseApi;
import com.finogeeks.mop.interfaces.ICallback;
@ -22,7 +24,6 @@ public class AppletModule extends BaseApi {
@Override
public void onCreate() {
super.onCreate();
}
@Override
@ -40,6 +41,7 @@ public class AppletModule extends BaseApi {
});
return;
}
Log.d("MopPlugin", "openApplet:params:" + param);
String appId = String.valueOf(param.get("appId"));
Integer sequence = (Integer) param.get("sequence");
Map<String, String> params = (Map) param.get("params");
@ -50,9 +52,43 @@ public class AppletModule extends BaseApi {
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, sequence, null);
}
} else {
Log.d("MopPlugin", "openApplet:params:" + param);
FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, params);
}
// String apiServer = (String) param.get("apiServer");
// String apiPrefix = (String) param.get("apiPrefix");
// if (apiServer == null || apiServer.isEmpty() || apiPrefix == null || apiPrefix.isEmpty()) {
// if (params == null) {
// if (sequence == null) {
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId);
// } else {
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, sequence, null);
// }
// } else {
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, appId, params);
// }
// } else {
// String fingerprint = (String) param.get("fingerprint");
// if (fingerprint == null) {
// fingerprint = "";
// }
// String cryptType = (String) param.get("cryptType");
// if (cryptType == null || cryptType.isEmpty()) {
// cryptType = FinAppConfig.ENCRYPTION_TYPE_MD5;
// }
// FinAppletStoreConfig finAppletStoreConfig = new FinAppletStoreConfig(apiServer, apiPrefix, fingerprint, cryptType);
// FinAppInfo.StartParams startParams = null;
// if (params != null) {
// String pageURL = params.get("path");
// String launchParams = params.get("query");
// String scene = params.get("scene");
// startParams = new FinAppInfo.StartParams(pageURL, launchParams, scene);
// }
// Log.d("MopPlugin", "openApplet:finAppletStoreConfig:" + finAppletStoreConfig.toString());
// Log.d("MopPlugin", "openApplet:appId:" + appId);
// Log.d("MopPlugin", "openApplet:sequence:" + sequence);
// Log.d("MopPlugin", "openApplet:startParams:" + startParams);
// FinAppClient.INSTANCE.getAppletApiManager().startApplet(mContext, finAppletStoreConfig, appId, sequence, startParams);
// }
callback.onSuccess(new HashMap());
}
}

View File

@ -1,14 +1,17 @@
package com.finogeeks.mop.api.mop;
import android.app.Application;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
import com.finogeeks.lib.applet.BuildConfig;
import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.interfaces.FinCallback;
import com.finogeeks.mop.api.BaseApi;
import com.finogeeks.mop.interfaces.ICallback;
import com.finogeeks.mop.plugins.client.FinPluginClient;
import com.finogeeks.mop.service.MopPluginService;
import java.util.HashMap;
@ -61,19 +64,22 @@ public class BaseModule extends BaseApi {
disablePermission = false;
}
FinAppConfig config = new FinAppConfig.Builder()
.setAppKey(appkey)
.setAppSecret(secret)
.setSdkKey(appkey)
.setSdkSecret(secret)
.setApiUrl(apiServer)
.setApiPrefix(apiPrefix)
.setGlideWithJWT(false)
.setEncryptionType(cryptType)
.setDebugMode(BuildConfig.DEBUG)
.setDisableRequestPermissions(disablePermission)
.build();
final Application application = MopPluginService.getInstance().getActivity().getApplication();
// SDKSDK
FinCallback<Object> cb = new FinCallback<Object>() {
@Override
public void onSuccess(Object result) {
// SDK
FinPluginClient.INSTANCE.getPluginManager().registerPlugins(application);
callback.onSuccess(null);
}
@ -89,8 +95,6 @@ public class BaseModule extends BaseApi {
}
};
FinAppClient.INSTANCE.init(MopPluginService.getInstance().getActivity().getApplication(), config, cb);
FinAppClient.INSTANCE.init(application, config, cb);
}
}

View File

@ -85,23 +85,36 @@ class Mop {
return ret;
}
///
///
/// open the miniprogram [appId] from the mop server.
///
/// [appId] is required.
/// [path] is miniprogram open path. example /pages/index/index
/// [query] is miniprogram query parameters. example key1=value1&key2=value2
///
///
Future<Map> openApplet(final String appId,
{final String path, final String query, final int sequence}) async {
/// [sequence] is miniprogram sequence. example 0,1.2.3,4,5...
/// [apiServer] is optional. the mop server address. default is https://mp.finogeek.com
/// [apiPrefix] is optional. the mop server prefix. default is /api/v1/mop
/// [fingerprint] is optional. the mop sdk fingerprint. is nullable
/// [cryptType] is optional. cryptType, should be MD5/SM
Future<Map> openApplet(
final String appId, {
final String path,
final String query,
final int sequence,
final String apiServer,
final String apiPrefix,
final String fingerprint,
final String cryptType,
}) async {
Map<String, Object> params = {'appId': appId};
Map param = {};
if (path != null) param["path"] = path;
if (query != null) param["query"] = query;
if (param.length > 0) params["params"] = param;
if (sequence != null) params["sequence"] = sequence;
if (apiServer != null) params["apiServer"] = apiServer;
if (apiPrefix != null) params["apiPrefix"] = apiPrefix;
if (fingerprint != null) params["fingerprint"] = fingerprint;
if (cryptType != null) params["cryptType"] = cryptType;
final Map ret = await _channel.invokeMethod('openApplet', params);
return ret;
}