1
0
Fork 0
phizclip-flutter-demo/README.md

330 lines
11 KiB
Dart
Raw Normal View History

2021-09-22 16:58:02 +08:00
<p align="center">
<a href="https://www.finclip.com?from=github">
<img width="auto" src="https://www.finclip.com/mop/document/images/logo.png">
</a>
</p>
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
<p align="center">
<strong>FinClip Flutter DEMO</strong></br>
<p>
<p align="center">
Flutter DEMO
<p>
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
<p align="center">
👉 <a href="https://www.finclip.com?from=github">https://www.finclip.com/</a> 👈
</p>
2020-03-08 17:09:34 +08:00
2021-11-14 23:11:51 +08:00
<div align="center">
<a href="#"><img src="https://img.shields.io/badge/%E4%B8%93%E5%B1%9E%E5%BC%80%E5%8F%91%E8%80%85-20000%2B-brightgreen"></a>
<a href="#"><img src="https://img.shields.io/badge/%E5%B7%B2%E4%B8%8A%E6%9E%B6%E5%B0%8F%E7%A8%8B%E5%BA%8F-6000%2B-blue"></a>
<a href="#"><img src="https://img.shields.io/badge/%E5%B7%B2%E9%9B%86%E6%88%90%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%BA%94%E7%94%A8-75%2B-yellow"></a>
<a href="#"><img src="https://img.shields.io/badge/%E5%AE%9E%E9%99%85%E8%A6%86%E7%9B%96%E7%94%A8%E6%88%B7-2500%20%E4%B8%87%2B-orange"></a>
<a href="https://www.zhihu.com/org/finchat"><img src="https://img.shields.io/badge/FinClip--lightgrey?logo=zhihu&style=social"></a>
<a href="https://www.finclip.com/blog/"><img src="https://img.shields.io/badge/FinClip%20Blog--lightgrey?logo=ghost&style=social"></a>
2021-11-14 23:15:46 +08:00
</div>
<p align="center">
<div align="center">
[](https://www.finclip.com/) | [示例小程序](https://www.finclip.com/#/market) | [开发文档](https://www.finclip.com/mop/document/) | [部署指南](https://www.finclip.com/mop/document/introduce/quickStart/cloud-server-deployment-guide.html) | [SDK 集成指南](https://www.finclip.com/mop/document/introduce/quickStart/intergration-guide.html) | [API 列表](https://www.finclip.com/mop/document/develop/api/overview.html) | [组件列表](https://www.finclip.com/mop/document/develop/component/overview.html) | [隐私承诺](https://www.finclip.com/mop/document/operate/safety.html)
2021-11-14 23:11:51 +08:00
</div>
2021-09-22 16:58:02 +08:00
-----
## 🤔 FinClip ?
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
**** APP
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
**** APP SDK
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
FinClip
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
## Flutter
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
`pubspec.yaml`
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
```yaml
mop: latest.version
```
## 🖥
```flutter
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';
import 'package:mop/mop.dart';
void main() => runApp(MyApp());
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
init();
}
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> init() async {
if (Platform.isiOS) {
//com.finogeeks.mopExample
final res = await Mop.instance.initialize(
'22LyZEib0gLTQdU3MUauARlLry7JL/2fRpscC9kpGZQA', '1c11d7252c53e0b6',
apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop');
print(res);
} else if (Platform.isAndroid) {
//com.finogeeks.mopexample
final res = await Mop.instance.initialize(
'22LyZEib0gLTQdU3MUauARjmmp6QmYgjGb3uHueys1oA', '98c49f97a031b555',
apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop');
print(res);
}
if (!mounted) return;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
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: () {
Mop.instance.openApplet('5e3c147a188211000141e9b1');
},
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',sequence: 1);
},
child: Text(
'打开官方小程序',
style: TextStyle(color: Colors.white),
),
),
),
],
),
),
),
),
);
}
}
2020-03-08 17:09:34 +08:00
```
2021-09-22 16:58:02 +08:00
## 📋
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
### 1.
使 SDK API SDK SDK
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
```
///
/// initialize mop miniprogram engine.
/// 初始化小程序
/// [appkey] is required. it can be getted from api.finclip.com
/// [secret] is required. it can be getted from api.finclip.com
/// [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
///
///
Future<Map> initialize(String appkey, String secret,
{String apiServer, String apiPrefix})
```
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
使
```
final res = await Mop.instance.initialize(
'22LyZEib0gLTQdU3MUauARlLry7JL/2fRpscC9kpGZQA', '1c11d7252c53e0b6',
apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop');
```
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
### 2.
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
```
///
/// 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})
2020-03-08 17:09:34 +08:00
```
2021-09-22 16:58:02 +08:00
### 3. 使
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
`appId`, `name`, `icon`, `description`, `version`, `thumbnail`
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
```
///
/// get current using applet
/// 获取当前正在使用的小程序信息
/// {appId,name,icon,description,version,thumbnail}
///
///
Future<Map<String, dynamic>> currentApplet()
```
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
### 4.
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
```
///
/// close all running applets
/// 关闭当前打开的所有小程序
///
Future closeAllApplets()
```
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
### 5.
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
```
///
/// clear applets cache
/// 清除缓存的小程序
///
Future clearApplets()
```
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
### 6.
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
使
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
```
///
/// register handler to provide custom info or behaviour
/// 注册小程序事件处理
///
void registerAppletHandler(AppletHandler handler)
```
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
```
abstract class AppletHandler {
///
/// 转发小程序
///
///
///
void forwardApplet(Map<String, dynamic> appletInfo);
///
///获取用户信息
/// "userId"
/// "nickName"
/// "avatarUrl"
/// "jwt"
/// "accessToken"
///
Future<Map<String, dynamic>> getUserInfo();
/// 获取自定义菜单
Future<List<CustomMenu>> getCustomMenus(String appId);
///自定义菜单点击处理
Future onCustomMenuClick(String appId, int menuId);
}
2020-03-08 17:09:34 +08:00
```
2021-11-14 23:04:24 +08:00
### 7. API
2021-09-22 16:58:02 +08:00
SDK API API API
```
///
/// register extension api
2021-11-14 23:04:24 +08:00
/// 注册扩展api
2021-09-22 16:58:02 +08:00
///
void registerExtensionApi(String name, ExtensionApiHandler handler)
```
iOS `FinChatConf.js`
```
module.exports = {
extApi:[
{ //普通交互API
name: 'onCustomEvent', //扩展api名 该api必须Native方实现了
params: { //扩展api 的参数格式,可以只列必须的属性
url: ''
}
}
]
}
```
## 🔗
FinClip
- [FinClip ](https://www.finclip.com/#/home)
- [](https://www.finclip.com/#/market)
- [](https://www.finclip.com/mop/document/)
- [SDK ](https://www.finclip.com/mop/document/introduce/quickStart/intergration-guide.html)
- [](https://www.finclip.com/mop/document/develop/guide/structure.html)
- [iOS ](https://www.finclip.com/mop/document/runtime-sdk/ios/ios-integrate.html)
- [Android ](https://www.finclip.com/mop/document/runtime-sdk/android/android-integrate.html)
- [Flutter ](https://www.finclip.com/mop/document/runtime-sdk/flutter/flutter-integrate.html)
##
****<br>
<img width="150px" src="https://www.finclip.com/mop/document/images/ic_qr.svg">
finclip <br>
<img width="150px" src="https://finclip-homeweb-1251849568.cos.ap-guangzhou.myqcloud.com/images/ldy111.jpg">
## Stargazers
[![Stargazers repo roster for @finogeeks/finclip-flutter-demo](https://reporoster.com/stars/finogeeks/finclip-flutter-demo)](https://github.com/finogeeks/finclip-flutter-demo/stargazers)
2020-03-08 17:09:34 +08:00
2021-09-22 16:58:02 +08:00
## Forkers
[![Forkers repo roster for @finogeeks/finclip-flutter-demo](https://reporoster.com/forks/finogeeks/finclip-flutter-demo)](https://github.com/finogeeks/finclip-flutter-demo/network/members)