fix: applet url && upgrade

master
developer 2020-02-28 12:20:44 +08:00
parent e8be3294a0
commit 3c39836645
6 changed files with 80 additions and 57 deletions

View File

@ -1,14 +1,3 @@
# mop # 凡泰极客小程序 Flutter 插件
A new flutter plugin project. 本插件提供在 Flutter 运行环境中运行小程序能力。
## Getting Started
This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

View File

@ -13,10 +13,10 @@ buildscript {
google() google()
jcenter() jcenter()
maven { maven {
url "https://gradle.finogeeks.club/repository/finogeeks/" url "https://gradle.finogeeks.club/repository/applet/"
credentials { credentials {
username "xiaoyu" username "applet"
password "xy123456" password "123321"
} }
} }
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
@ -35,10 +35,10 @@ rootProject.allprojects {
google() google()
jcenter() jcenter()
maven { maven {
url "https://gradle.finogeeks.club/repository/finogeeks/" url "https://gradle.finogeeks.club/repository/applet/"
credentials { credentials {
username "xiaoyu" username "applet"
password "xy123456" password "123321"
} }
} }
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
@ -77,7 +77,6 @@ kapt {
} }
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.finogeeks.lib:finapplet:2.0.51' implementation 'com.finogeeks.lib:finapplet:2.0.75'
implementation 'org.greenrobot:greendao:3.2.2'
} }

View File

@ -29,7 +29,6 @@ public class AppletModule extends BaseApi {
@Override @Override
public void invoke(String event, Map param, ICallback callback) { public void invoke(String event, Map param, ICallback callback) {
System.out.println("AppletModule");
if (param.get("appId") == null) { if (param.get("appId") == null) {
callback.onFail(new HashMap(){ callback.onFail(new HashMap(){
{ {

View File

@ -46,6 +46,9 @@ public class BaseModule extends BaseApi {
} }
if (param.get("apiPrefix") != null) { if (param.get("apiPrefix") != null) {
apiPrefix = String.valueOf(param.get("apiPrefix")); apiPrefix = String.valueOf(param.get("apiPrefix"));
if (!apiPrefix.endsWith("/")) {
apiPrefix = apiPrefix + "/";
}
} }
FinAppConfig config = new FinAppConfig.Builder() FinAppConfig config = new FinAppConfig.Builder()
.setAppKey(appkey) .setAppKey(appkey)

View File

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:mop/mop.dart'; import 'package:mop/mop.dart';
void main() => runApp(MyApp()); void main() => runApp(MyApp());
@ -15,27 +14,22 @@ class _MyAppState extends State<MyApp> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
initPlatformState(); init();
} }
// Platform messages are asynchronous, so we initialize in an async method. // Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async { Future<void> init() async {
// String platformVersion; if (Platform.isIOS) {
// // Platform messages may fail, so we use a try/catch PlatformException. final res = await Mop.instance.initialize(
// try { '22LyZEib0gLTQdU3MUauARlLry7JL/2fRpscC9kpGZQA', '1c11d7252c53e0b6',
// platformVersion = await Mop.instance.platformVersion; apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/mop');
// print(platformVersion); print(res);
// } on PlatformException { } else if (Platform.isAndroid) {
// platformVersion = 'Failed to get platform version.';
// }
final res = await Mop.instance.initialize( final res = await Mop.instance.initialize(
'22LyZEib0gLTQdU3MUauARjmmp6QmYgjGb3uHueys1oA', '98c49f97a031b555', '22LyZEib0gLTQdU3MUauARjmmp6QmYgjGb3uHueys1oA', '98c49f97a031b555',
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/'); apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/mop');
print(res); print(res);
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return; if (!mounted) return;
} }
@ -44,20 +38,60 @@ class _MyAppState extends State<MyApp> {
return MaterialApp( return MaterialApp(
home: Scaffold( home: Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Plugin example app'), title: const Text('凡泰极客小程序 Flutter 插件'),
), ),
body: Center( body: Center(
child: Container(
padding: EdgeInsets.only(
top: 20,
),
child: Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
gradient: LinearGradient(
colors: const [Color(0xFF12767e), Color(0xFF0dabb8)],
stops: const [0.0, 1.0],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: FlatButton( child: FlatButton(
onPressed: () { onPressed: () {
// appId: '5e3c147a188211000141e9b1', Mop.instance.openApplet('5e3c147a188211000141e9b1');
// path: "/pages/index/index",
// query: "key1=value1&key2=value2",
// scene: "1001"
Mop.instance.openApplet('5e3c147a188211000141e9b1',
path: '/pages/index/index', query: 'key1=value1&key2=value2');
}, },
child: Text('打开小程序'), child: Text(
)), '打开示例小程序',
style: TextStyle(color: Colors.white),
),
),
),
SizedBox(height: 30),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
gradient: LinearGradient(
colors: const [Color(0xFF12767e), Color(0xFF0dabb8)],
stops: const [0.0, 1.0],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: FlatButton(
onPressed: () {
Mop.instance.openApplet('5e4d123647edd60001055df1');
},
child: Text(
'打开官方小程序',
style: TextStyle(color: Colors.white),
),
),
),
],
),
),
),
), ),
); );
} }

View File

@ -65,16 +65,15 @@ class Mop {
/// [appId] is required. /// [appId] is required.
/// [path] is miniprogram open path. example /pages/index/index /// [path] is miniprogram open path. example /pages/index/index
/// [query] is miniprogram query parameters. example key1=value1&key2=value2 /// [query] is miniprogram query parameters. example key1=value1&key2=value2
/// [scene] is miniprogram scene string. example 1100
/// ///
/// ///
Future<Map> openApplet(final String appId, Future<Map> openApplet(final String appId,
{final String path, final String query, final String scene}) async { {final String path, final String query}) async {
Map<String, Object> params; Map<String, Object> params;
if (path != '') { if (path != '') {
params = { params = {
'appId': appId, 'appId': appId,
'params': {'path': path, 'query': query, 'scene': scene} 'params': {'path': path, 'query': query}
}; };
} else { } else {
params = {'appId': appId}; params = {'appId': appId};