fix: applet url && upgrade
parent
e8be3294a0
commit
3c39836645
15
README.md
15
README.md
|
@ -1,14 +1,3 @@
|
|||
# mop
|
||||
# 凡泰极客小程序 Flutter 插件
|
||||
|
||||
A new flutter plugin project.
|
||||
|
||||
## 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.
|
||||
本插件提供在 Flutter 运行环境中运行小程序能力。
|
||||
|
|
|
@ -13,10 +13,10 @@ buildscript {
|
|||
google()
|
||||
jcenter()
|
||||
maven {
|
||||
url "https://gradle.finogeeks.club/repository/finogeeks/"
|
||||
url "https://gradle.finogeeks.club/repository/applet/"
|
||||
credentials {
|
||||
username "xiaoyu"
|
||||
password "xy123456"
|
||||
username "applet"
|
||||
password "123321"
|
||||
}
|
||||
}
|
||||
maven { url "https://jitpack.io" }
|
||||
|
@ -35,10 +35,10 @@ rootProject.allprojects {
|
|||
google()
|
||||
jcenter()
|
||||
maven {
|
||||
url "https://gradle.finogeeks.club/repository/finogeeks/"
|
||||
url "https://gradle.finogeeks.club/repository/applet/"
|
||||
credentials {
|
||||
username "xiaoyu"
|
||||
password "xy123456"
|
||||
username "applet"
|
||||
password "123321"
|
||||
}
|
||||
}
|
||||
maven { url "https://jitpack.io" }
|
||||
|
@ -77,7 +77,6 @@ kapt {
|
|||
}
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.finogeeks.lib:finapplet:2.0.51'
|
||||
implementation 'org.greenrobot:greendao:3.2.2'
|
||||
implementation 'com.finogeeks.lib:finapplet:2.0.75'
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ public class AppletModule extends BaseApi {
|
|||
|
||||
@Override
|
||||
public void invoke(String event, Map param, ICallback callback) {
|
||||
System.out.println("AppletModule");
|
||||
if (param.get("appId") == null) {
|
||||
callback.onFail(new HashMap(){
|
||||
{
|
||||
|
|
|
@ -46,6 +46,9 @@ public class BaseModule extends BaseApi {
|
|||
}
|
||||
if (param.get("apiPrefix") != null) {
|
||||
apiPrefix = String.valueOf(param.get("apiPrefix"));
|
||||
if (!apiPrefix.endsWith("/")) {
|
||||
apiPrefix = apiPrefix + "/";
|
||||
}
|
||||
}
|
||||
FinAppConfig config = new FinAppConfig.Builder()
|
||||
.setAppKey(appkey)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'dart:io';
|
||||
import 'package:mop/mop.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
@ -15,27 +14,22 @@ class _MyAppState extends State<MyApp> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initPlatformState();
|
||||
init();
|
||||
}
|
||||
|
||||
// Platform messages are asynchronous, so we initialize in an async method.
|
||||
Future<void> initPlatformState() async {
|
||||
// String platformVersion;
|
||||
// // Platform messages may fail, so we use a try/catch PlatformException.
|
||||
// try {
|
||||
// platformVersion = await Mop.instance.platformVersion;
|
||||
// print(platformVersion);
|
||||
// } on PlatformException {
|
||||
// platformVersion = 'Failed to get platform version.';
|
||||
// }
|
||||
Future<void> init() async {
|
||||
if (Platform.isIOS) {
|
||||
final res = await Mop.instance.initialize(
|
||||
'22LyZEib0gLTQdU3MUauARlLry7JL/2fRpscC9kpGZQA', '1c11d7252c53e0b6',
|
||||
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/mop');
|
||||
print(res);
|
||||
} else if (Platform.isAndroid) {
|
||||
final res = await Mop.instance.initialize(
|
||||
'22LyZEib0gLTQdU3MUauARjmmp6QmYgjGb3uHueys1oA', '98c49f97a031b555',
|
||||
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/');
|
||||
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/mop');
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -44,20 +38,60 @@ class _MyAppState extends State<MyApp> {
|
|||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Plugin example app'),
|
||||
title: const Text('凡泰极客小程序 Flutter 插件'),
|
||||
),
|
||||
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(
|
||||
onPressed: () {
|
||||
// appId: '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');
|
||||
Mop.instance.openApplet('5e3c147a188211000141e9b1');
|
||||
},
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -65,16 +65,15 @@ class Mop {
|
|||
/// [appId] is required.
|
||||
/// [path] is miniprogram open path. example /pages/index/index
|
||||
/// [query] is miniprogram query parameters. example key1=value1&key2=value2
|
||||
/// [scene] is miniprogram scene string. example 1100
|
||||
///
|
||||
///
|
||||
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;
|
||||
if (path != '') {
|
||||
params = {
|
||||
'appId': appId,
|
||||
'params': {'path': path, 'query': query, 'scene': scene}
|
||||
'params': {'path': path, 'query': query}
|
||||
};
|
||||
} else {
|
||||
params = {'appId': appId};
|
||||
|
|
Loading…
Reference in New Issue